File tree 5 files changed +75
-9
lines changed
app/assets/javascripts/map
5 files changed +75
-9
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ define([
36
36
country : null ,
37
37
regions : null ,
38
38
region : null ,
39
+ layers : [ ] ,
39
40
40
41
overlay_stroke_weight : 2
41
42
}
@@ -53,6 +54,8 @@ define([
53
54
54
55
this . status . on ( 'change:regions' , this . changeRegions . bind ( this ) ) ;
55
56
57
+ this . status . on ( 'change:layers' , this . changeLayers . bind ( this ) ) ;
58
+
56
59
this . status . on ( 'change:enabled' , this . changeEnabled . bind ( this ) ) ;
57
60
this . status . on ( 'change:enabledSubscription' , this . changeEnabledSubscription . bind ( this ) ) ;
58
61
} ,
@@ -74,8 +77,18 @@ define([
74
77
region : params . iso . region
75
78
} ,
76
79
isoDisabled : ( ! ! params . dont_analyze ) || ! ( ! ! params . iso . country && params . iso . country != 'ALL' ) ,
80
+ fit_to_geom : ! ! params . fit_to_geom ,
81
+ layers : params . baselayers
77
82
78
- fit_to_geom : ! ! params . fit_to_geom
83
+ } ) ;
84
+ }
85
+ } ,
86
+ // Temp: to disable the regions selector
87
+ // for GLAD and terra-i
88
+ {
89
+ 'LayerNav/change' : function ( layerSpec ) {
90
+ this . status . set ( {
91
+ layers : _ . clone ( layerSpec . attributes )
79
92
} ) ;
80
93
}
81
94
} ,
@@ -158,6 +171,10 @@ define([
158
171
this . view . setSelects ( ) ;
159
172
} ,
160
173
174
+ changeLayers : function ( ) {
175
+ this . view . render ( ) ;
176
+ } ,
177
+
161
178
162
179
/**
163
180
* ACTIONS
Original file line number Diff line number Diff line change 5
5
<option value =" {{ this.iso }} " >{{ this.name }} </option >
6
6
{{ /each }}
7
7
</select >
8
- <select data-placeholder =" Select jurisdiction (optional)" disabled =" true" class =" chosen-select default notranslate" id =" analysis-region-select" >
9
- <option ></option >
10
- </select >
8
+ {{ #if showRegions }}
9
+ <select data-placeholder =" Select jurisdiction (optional)" disabled =" true" class =" chosen-select default notranslate" id =" analysis-region-select" >
10
+ <option ></option >
11
+ </select >
12
+ {{ /if }}
11
13
</div >
12
14
<ul id =" country-button-container" class =" button-container one" >
13
15
<li ><button id =" analysis-country-button" class =" btn green uppercase disabled" >Analyze</button ></li >
Original file line number Diff line number Diff line change 6
6
<option value =" {{ iso }} " >{{ name }} </option >
7
7
{{ /each }}
8
8
</select >
9
- <select data-placeholder =" Select jurisdiction (optional)" disabled =" true" class =" chosen-select default notranslate" id =" analysis-region-select" >
10
- <option ></option >
11
- </select >
9
+ {{ #if showRegions }}
10
+ <select data-placeholder =" Select jurisdiction (optional)" disabled =" true" class =" chosen-select default notranslate" id =" analysis-region-select" >
11
+ <option ></option >
12
+ </select >
13
+ {{ /if }}
12
14
</div >
13
15
{{ /if }}
14
16
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ define([
42
42
43
43
render : function ( ) {
44
44
this . $el . removeClass ( '-results' ) . html ( this . template ( {
45
- countries : this . countries
45
+ countries : this . countries ,
46
+ showRegions : this . _showRegions ( )
46
47
} ) ) ;
47
48
48
49
this . cache ( ) ;
@@ -72,7 +73,33 @@ define([
72
73
} ) ;
73
74
} ,
74
75
76
+ // TEMP: To disable regions for GLAD & Terra-i
77
+ _showRegions : function ( ) {
78
+ var layers = this . presenter . status . attributes . layers ;
79
+ var layersSlugs = [ ] ;
80
+ var showRegions = true ;
81
+
82
+ _ . each ( layers , function ( layer ) {
83
+ if ( layer . slug ) {
84
+ layersSlugs . push ( layer . slug ) ;
85
+ } else {
86
+ _ . each ( layer , function ( sublayer ) {
87
+ layersSlugs . push ( sublayer . slug ) ;
88
+ } ) ;
89
+ }
90
+ } ) ;
75
91
92
+ if ( layersSlugs . indexOf ( 'umd_as_it_happens' ) !== - 1 ||
93
+ layersSlugs . indexOf ( 'terrailoss' ) !== - 1 ) {
94
+ showRegions = false ;
95
+ this . presenter . status . set ( {
96
+ iso : _ . extend ( { } , this . presenter . status . attributes . iso , {
97
+ region : null
98
+ } )
99
+ } ) ;
100
+ }
101
+ return showRegions ;
102
+ } ,
76
103
77
104
78
105
Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ define([
71
71
72
72
this . $el . addClass ( '-results' ) . html ( this . templates . success ( {
73
73
resource : this . presenter . status . get ( 'resource' ) ,
74
- countries : ( ! ! country && country != 'ALL' ) ? this . countries : null
74
+ countries : ( ! ! country && country != 'ALL' ) ? this . countries : null ,
75
+ showRegions : this . _showRegions ( )
75
76
} ) ) ;
76
77
77
78
this . cache ( ) ;
@@ -149,6 +150,23 @@ define([
149
150
} ) ;
150
151
} ,
151
152
153
+ // Temp to disable GLAD and terra-i
154
+ _showRegions : function ( ) {
155
+ var layers = this . presenter . status . attributes . baselayers_full ;
156
+ var layersSlugs = [ ] ;
157
+ var showRegions = true ;
158
+
159
+ _ . each ( layers , function ( val , key ) {
160
+ layersSlugs . push ( key ) ;
161
+ } ) ;
162
+
163
+ if ( layersSlugs . indexOf ( 'umd_as_it_happens' ) !== - 1 ||
164
+ layersSlugs . indexOf ( 'terrailoss' ) !== - 1 ) {
165
+ showRegions = false ;
166
+ }
167
+ return showRegions ;
168
+ }
169
+
152
170
153
171
} ) ;
154
172
You can’t perform that action at this time.
0 commit comments