<commit_before>// Discourse.MapControllerMixin = Em.Mixin.create({
Discourse.MapFromOneParamController = Discourse.ObjectController.extend({
  needs: ['composer'],

  // selectedTopicPost: function(){
  //   if (this.get('selectedTopic')) {
  //     var selectedTopicPost = this.get('selectedTopic.post_stream.posts').findBy('post_number', 1);
  //     debugger;
  //     return selectedTopicPost;
  //   } else{
  //     return false;
  //   };
  // }.property('selectedTopic'),

  actions: {
    // had meant to show topic details next to index map - might come back to this
    // showPost: function(){

    //   var detailedTopic = Discourse.Topic.find(this.get('model.topics.firstObject.id'),{});
    //   var that = this;
    //   detailedTopic.then(function (result) {
    //     that.set('selectedTopic',result);
    //     debugger;
    //   });
    // },
    // can be triggered by clicking on infowindow after either doubleclicking map
    // use hovering over marker from places search
    startLocationTopic: function(locationType, locationDetails, city, title) {
      if (locationType === "placeSearch") {
        var locationObject = Discourse.Location.locationFromPlaceSearch(locationDetails, city);
      } else if (locationType === "gmapLocation") {
        var locationObject = Discourse.Location.locationFromGmap(locationDetails);
        locationObject.title = title;
      }
      // this.set('locationObject', locationObject);
      if (Discourse.User.current()) {
        var composerController = this.get('controllers.composer');
        var self = this;
        composerController.open({
          action: Discourse.Composer.CREATE_TOPIC,
          draftKey: "new_topic"
        }).then(function() {
          composerController.content.set('locationObject', locationObject);
        });
      } else {
        this.send('showLogin');
      }
      //return true to bubble up to route...
      return false;
    },
    initiateAddLocationToTopic: function() {
      if (Ember.isEmpty(this.get('locationObject.title'))) {
        return;
      };
      if (this.get('locationObject')) {
        this.set('model.locationObject', this.get('locationObject'));

      };
      this.send('closeModal');
    },
    topicSelected: function(topic) {
      // this.transitionToRoute('topic.fromParams', topic);
      // above doesn't work
      // https://meta.discourse.org/t/why-does-discourse-use-a-bunch-of-tags-with-unbound-in-the-basic-topic-list-template/10541/4
      this.transitionToRoute('topic.fromParams', Discourse.Topic.create({
        id: topic.id
      }));
    }
  },
  markers: function() {
    var topics = this.get('content.topics');
    var currentMarkerValues = [];
    debugger;
    // chapuzo to ensure I maximise no of markers on index page
    topics.forEach(function(t) {
      var markerInfo = {
        context: 'index_view',
        topic: t,
        location: t.get('location')
          // latitude: t.get('latitude'),
          // // venueAddress: t.get('excerpt'),
          // venueName: t.get('location_title')

      };
      currentMarkerValues.push(markerInfo);
      // p.user = users[p.user_id];
    });
    return currentMarkerValues;
  }.property('content')
});

// not using object controller as I won't be setting its content..
Discourse.MapController = Discourse.Controller.extend({
  // went back to objectcontroller at some point when I was worried it might be needed
  // to ensure observers triggered - that wasn't necessary though
  // Discourse.MapController = Discourse.ObjectController.extend({<commit_msg>Fix navigating to topic from map index<commit_after>// Discourse.MapControllerMixin = Em.Mixin.create({
Discourse.MapFromOneParamController = Discourse.ObjectController.extend({
  needs: ['composer'],

  // selectedTopicPost: function(){
  //   if (this.get('selectedTopic')) {
  //     var selectedTopicPost = this.get('selectedTopic.post_stream.posts').findBy('post_number', 1);
  //     debugger;
  //     return selectedTopicPost;
  //   } else{
  //     return false;
  //   };
  // }.property('selectedTopic'),

  actions: {
    // had meant to show topic details next to index map - might come back to this
    // showPost: function(){

    //   var detailedTopic = Discourse.Topic.find(this.get('model.topics.firstObject.id'),{});
    //   var that = this;
    //   detailedTopic.then(function (result) {
    //     that.set('selectedTopic',result);
    //     debugger;
    //   });
    // },
    // can be triggered by clicking on infowindow after either doubleclicking map
    // use hovering over marker from places search
    startLocationTopic: function(locationType, locationDetails, city, title) {
      if (locationType === "placeSearch") {
        var locationObject = Discourse.Location.locationFromPlaceSearch(locationDetails, city);
      } else if (locationType === "gmapLocation") {
        var locationObject = Discourse.Location.locationFromGmap(locationDetails);
        locationObject.title = title;
      }
      // this.set('locationObject', locationObject);
      if (Discourse.User.current()) {
        var composerController = this.get('controllers.composer');
        var self = this;
        composerController.open({
          action: Discourse.Composer.CREATE_TOPIC,
          draftKey: "new_topic"
        }).then(function() {
          composerController.content.set('locationObject', locationObject);
        });
      } else {
        this.send('showLogin');
      }
      //return true to bubble up to route...
      return false;
    },
    initiateAddLocationToTopic: function() {
      if (Ember.isEmpty(this.get('locationObject.title'))) {
        return;
      };
      if (this.get('locationObject')) {
        this.set('model.locationObject', this.get('locationObject'));

      };
      this.send('closeModal');
    },
    topicSelected: function(detailsForMarker) {
      debugger;
      // this.transitionToRoute('topic.fromParams', topic);
      // above doesn't work
      // https://meta.discourse.org/t/why-does-discourse-use-a-bunch-of-tags-with-unbound-in-the-basic-topic-list-template/10541/4
      this.transitionToRoute('topic.fromParams', Discourse.Topic.create({
        id: detailsForMarker.topic.id
      }));
    }
  },
  markers: function() {
    var topics = this.get('content.topics');
    var currentMarkerValues = [];
    // debugger;
    // chapuzo to ensure I maximise no of markers on index page
    topics.forEach(function(t) {
      var markerInfo = {
        context: 'index_view',
        topic: t,
        location: t.get('location')
          // latitude: t.get('latitude'),
          // // venueAddress: t.get('excerpt'),
          // venueName: t.get('location_title')

      };
      currentMarkerValues.push(markerInfo);
      // p.user = users[p.user_id];
    });
    return currentMarkerValues;
  }.property('content')
});

// not using object controller as I won't be setting its content..
Discourse.MapController = Discourse.Controller.extend({
  // went back to objectcontroller at some point when I was worried it might be needed
  // to ensure observers triggered - that wasn't necessary though
  // Discourse.MapController = Discourse.ObjectController.extend({
{'fraction_non_alphanumeric': 0.13609958506224065, 'fraction_numerical': 0.0019363762102351315, 'mean_word_length': 2.6930541368743617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5509561', 'n_tokens_mistral': 2056, 'n_tokens_neox': 2028, 'n_words': 442}