cms/app-client/app/components/notice-location-component.js
author ymh <ymh.work@gmail.com>
Mon, 19 Mar 2018 15:45:08 +0100
changeset 569 2815e71c65fb
parent 502 74fba571487e
permissions -rw-r--r--
corrcet https vs http for title image + avoid unused update route on api
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
import Ember from 'ember';
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
import * as commonUtils from 'corpus-common-addon/utils/utils';
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
     3
import * as commonConstants from 'corpus-common-addon/utils/constants';
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
export default Ember.Component.extend({
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
  classNames: ['notice-location-component'],
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
     7
  filter: Ember.inject.service(),
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
     8
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
  zoom: 6,
569
2815e71c65fb corrcet https vs http for title image + avoid unused update route on api
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
    10
  tilesUrl: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    11
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
  location: Ember.computed('geoInfo', function() {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
    return [this.get('geoInfo.latitude'), this.get('geoInfo.longitude')];
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
  }),
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    15
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
  hasCoordinates: Ember.computed('geoInfo', function() {
453
1059a7ae018a correct notice stand alone display
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    17
    return Boolean(this.get('geoInfo.longitude')) && Boolean(this.get('geoInfo.latitude'));
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
  }),
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    19
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
  geonamesLink: Ember.computed('geoInfo.ref-locs', function() {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    let link = null;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    this.get('geoInfo.ref-locs').forEach(l => {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
      if(commonUtils.isGeonamesLink(l)) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
        return link=l;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
      }
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
    });
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
    return link;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
  }),
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    29
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    30
  otherRefLinks: Ember.computed.filter('geoInfo.ref-locs', l => { return !commonUtils.isGeonamesLink(l); }),
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    31
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    32
  actions: {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    33
    addLocationFilter: function(id) {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    34
      this.get('filter').setFilter('location', commonConstants.GEONAMES_BASE_URL + id);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    35
    }
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 453
diff changeset
    36
  }
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
});