Skip to content

Commit

Permalink
Show popover descriptions for scenarios with no modifications
Browse files Browse the repository at this point in the history
- Add a new popover view to show if a scenario can't or doesn't have
  modifications
 - Current Conditions and 100% Forest Cover explain what they are
 - Regular Scenarios without modifications, describe how to add modifications
  • Loading branch information
Alice Rottersman committed Aug 21, 2017
1 parent 45c1b0d commit 31925b9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/mmw/js/src/compare/templates/compareDescriptionPopover.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% if is_pre_columbian %}
<h3 class="compare-no-mod-title">{{name}}</h3>
<p>
Lorem ipsum this scenario shows the tr55 model results under pre columbian conditions...
</p>
{% elif is_current_conditions %}
<h3 class="compare-no-mod-title">{{name}}</h3>
<p>
Lorem ipsum this is the model run under current conditions
</p>
{% else %}
<h3 class="compare-no-mod-title">No modifications</h3>
<p>
To add modifications, close this modal and select "Land cover" or "Conservation practices" lorem ipsum dolor sit
</p>
{% endif %}
35 changes: 23 additions & 12 deletions src/mmw/js/src/compare/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var _ = require('lodash'),
compareScenarioTmpl = require('./templates/compareScenario.html'),
compareModelingTmpl = require('./templates/compareModeling.html'),
compareModificationsTmpl = require('./templates/compareModifications.html'),
compareModificationsPopoverTmpl = require('./templates/compareModificationsPopover.html');
compareModificationsPopoverTmpl = require('./templates/compareModificationsPopover.html'),
compareDescriptionPopoverTmpl = require('./templates/compareDescriptionPopover.html');

var CompareWindow2 = Marionette.LayoutView.extend({
template: compareWindow2Tmpl,
Expand Down Expand Up @@ -155,6 +156,7 @@ var InputsView = Marionette.LayoutView.extend({
});

var CompareModificationsPopoverView = Marionette.ItemView.extend({
// model: ModificationsCollection
template: compareModificationsPopoverTmpl,

templateHelpers: function() {
Expand All @@ -170,6 +172,12 @@ var CompareModificationsPopoverView = Marionette.ItemView.extend({
}
});

var CompareDescriptionPopoverView = Marionette.ItemView.extend({
// model: ScenarioModel
template: compareDescriptionPopoverTmpl,
className: 'compare-no-mods-popover'
});

var ScenarioItemView = Marionette.ItemView.extend({
className: 'compare-column',
template: compareScenarioItemTmpl,
Expand Down Expand Up @@ -200,17 +208,20 @@ var ScenarioItemView = Marionette.ItemView.extend({
},

onRender: function() {
var modifications = this.model.get('modifications');

if (modifications.length > 0) {
this.ui.mapContainer.popover({
placement: 'bottom',
trigger: 'hover focus',
content: new CompareModificationsPopoverView({
model: this.model.get('modifications')
}).render().el
});
}
var modifications = this.model.get('modifications'),
popOverView = modifications.length > 0 ?
new CompareModificationsPopoverView({
model: modifications
}) :
new CompareDescriptionPopoverView({
model: this.model
});

this.ui.mapContainer.popover({
placement: 'bottom',
trigger: 'hover focus',
content: popOverView.render().el
});
}
});

Expand Down
7 changes: 7 additions & 0 deletions src/mmw/sass/pages/_compare.scss
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,13 @@ $compare-chart-table-height: calc(100vh - #{$height-lg} - #{$compare-footer-heig
}
}

.compare-no-mods-popover {
width: 189px;
> .compare-no-mod-title {
margin-bottom: 2px;
}
}

.compare-inputs {
float: right;
margin-right: -5px;
Expand Down

0 comments on commit 31925b9

Please sign in to comment.