1 import Ember from 'ember'; |
1 import Ember from 'ember'; |
2 import * as commonUtils from 'corpus-common-addon/utils/utils'; |
2 import * as commonUtils from 'corpus-common-addon/utils/utils'; |
|
3 import * as commonConstants from 'corpus-common-addon/utils/constants'; |
3 |
4 |
4 export default Ember.Component.extend({ |
5 export default Ember.Component.extend({ |
5 classNames: ['notice-location-component'], |
6 classNames: ['notice-location-component'], |
|
7 filter: Ember.inject.service(), |
|
8 |
6 zoom: 6, |
9 zoom: 6, |
7 tilesUrl: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", |
10 tilesUrl: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", |
|
11 |
8 location: Ember.computed('geoInfo', function() { |
12 location: Ember.computed('geoInfo', function() { |
9 return [this.get('geoInfo.latitude'), this.get('geoInfo.longitude')]; |
13 return [this.get('geoInfo.latitude'), this.get('geoInfo.longitude')]; |
10 }), |
14 }), |
|
15 |
11 hasCoordinates: Ember.computed('geoInfo', function() { |
16 hasCoordinates: Ember.computed('geoInfo', function() { |
12 return Boolean(this.get('geoInfo.longitude')) && Boolean(this.get('geoInfo.latitude')); |
17 return Boolean(this.get('geoInfo.longitude')) && Boolean(this.get('geoInfo.latitude')); |
13 }), |
18 }), |
|
19 |
14 geonamesLink: Ember.computed('geoInfo.ref-locs', function() { |
20 geonamesLink: Ember.computed('geoInfo.ref-locs', function() { |
15 let link = null; |
21 let link = null; |
16 this.get('geoInfo.ref-locs').forEach(l => { |
22 this.get('geoInfo.ref-locs').forEach(l => { |
17 if(commonUtils.isGeonamesLink(l)) { |
23 if(commonUtils.isGeonamesLink(l)) { |
18 return link=l; |
24 return link=l; |
19 } |
25 } |
20 }); |
26 }); |
21 return link; |
27 return link; |
22 }), |
28 }), |
23 otherRefLinks: Ember.computed.filter('geoInfo.ref-locs', l => { return !commonUtils.isGeonamesLink(l); }) |
29 |
|
30 otherRefLinks: Ember.computed.filter('geoInfo.ref-locs', l => { return !commonUtils.isGeonamesLink(l); }), |
|
31 |
|
32 actions: { |
|
33 addLocationFilter: function(id) { |
|
34 this.get('filter').setFilter('location', commonConstants.GEONAMES_BASE_URL + id); |
|
35 } |
|
36 } |
24 |
37 |
25 }); |
38 }); |