Skip to content

Commit

Permalink
Merge pull request #2662 from Vizzuality/disposable/disable-subnation…
Browse files Browse the repository at this point in the history
…al-analysis

Release: Disable subnational analysis
  • Loading branch information
geriux authored Dec 1, 2016
2 parents 989e02a + 4a3c703 commit 7d04d35
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ define([
country: null,
regions: null,
region: null,
layers: [],

overlay_stroke_weight: 2
}
Expand All @@ -53,6 +54,8 @@ define([

this.status.on('change:regions', this.changeRegions.bind(this));

this.status.on('change:layers', this.changeLayers.bind(this));

this.status.on('change:enabled', this.changeEnabled.bind(this));
this.status.on('change:enabledSubscription', this.changeEnabledSubscription.bind(this));
},
Expand All @@ -74,8 +77,18 @@ define([
region: params.iso.region
},
isoDisabled: (!!params.dont_analyze) || !(!!params.iso.country && params.iso.country != 'ALL'),
fit_to_geom: !!params.fit_to_geom,
layers: params.baselayers

fit_to_geom: !!params.fit_to_geom
});
}
},
// Temp: to disable the regions selector
// for GLAD and terra-i
{
'LayerNav/change': function(layerSpec) {
this.status.set({
layers: _.clone(layerSpec.attributes)
});
}
},
Expand Down Expand Up @@ -158,6 +171,10 @@ define([
this.view.setSelects();
},

changeLayers: function() {
this.view.render();
},


/**
* ACTIONS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
<option value="{{this.iso}}">{{this.name}}</option>
{{/each}}
</select>
<select data-placeholder="Select jurisdiction (optional)" disabled="true" class="chosen-select default notranslate" id="analysis-region-select">
<option></option>
</select>
{{#if showRegions}}
<select data-placeholder="Select jurisdiction (optional)" disabled="true" class="chosen-select default notranslate" id="analysis-region-select">
<option></option>
</select>
{{/if}}
</div>
<ul id="country-button-container" class="button-container one">
<li><button id="analysis-country-button" class="btn green uppercase disabled">Analyze</button></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
<option value="{{iso}}">{{name}}</option>
{{/each}}
</select>
<select data-placeholder="Select jurisdiction (optional)" disabled="true" class="chosen-select default notranslate" id="analysis-region-select">
<option></option>
</select>
{{#if showRegions}}
<select data-placeholder="Select jurisdiction (optional)" disabled="true" class="chosen-select default notranslate" id="analysis-region-select">
<option></option>
</select>
{{/if}}
</div>
{{/if}}

Expand Down
29 changes: 28 additions & 1 deletion app/assets/javascripts/map/views/analysis/AnalysisCountryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ define([

render: function(){
this.$el.removeClass('-results').html(this.template({
countries: this.countries
countries: this.countries,
showRegions: this._showRegions()
}));

this.cache();
Expand Down Expand Up @@ -72,7 +73,33 @@ define([
});
},

// TEMP: To disable regions for GLAD & Terra-i
_showRegions: function() {
var layers = this.presenter.status.attributes.layers;
var layersSlugs = [];
var showRegions = true;

_.each(layers, function(layer) {
if (layer.slug) {
layersSlugs.push(layer.slug);
} else {
_.each(layer, function(sublayer) {
layersSlugs.push(sublayer.slug);
});
}
});

if (layersSlugs.indexOf('umd_as_it_happens') !== -1 ||
layersSlugs.indexOf('terrailoss') !== -1) {
showRegions = false;
this.presenter.status.set({
iso: _.extend({}, this.presenter.status.attributes.iso, {
region: null
})
});
}
return showRegions;
},



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ define([

this.$el.addClass('-results').html(this.templates.success({
resource: this.presenter.status.get('resource'),
countries: (!!country && country != 'ALL') ? this.countries : null
countries: (!!country && country != 'ALL') ? this.countries : null,
showRegions: this._showRegions()
}));

this.cache();
Expand Down Expand Up @@ -149,6 +150,23 @@ define([
});
},

// Temp to disable GLAD and terra-i
_showRegions: function() {
var layers = this.presenter.status.attributes.baselayers_full;
var layersSlugs = [];
var showRegions = true;

_.each(layers, function(val, key) {
layersSlugs.push(key);
});

if (layersSlugs.indexOf('umd_as_it_happens') !== -1 ||
layersSlugs.indexOf('terrailoss') !== -1) {
showRegions = false;
}
return showRegions;
}


});

Expand Down

0 comments on commit 7d04d35

Please sign in to comment.