Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NLCD code to analyze land results csv #2176

Merged
merged 2 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/mmw/js/src/analyze/templates/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<thead>
<tr>
<th data-sortable="true">Type</th>
{% if isLandTable %}
<th class="hidden-analyze-table-column" data-tableexport-display="always">NLCD Code</th>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider dropping this class and using the HTML hidden attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this out & it seemed like there's some quirk getting the hidden attribute to take hold via the Nunjucks template.

Going to leave this as is for now, but we should try it again if we end up adjusting these to include more hidden columns.

{% endif %}
<th class="text-right" data-sortable="true" data-sorter="window.numericSort">Area ({{ headerUnits }})</th>
<th class="text-right" data-sortable="true" data-sorter="window.numericSort">Coverage (%)</th>
</tr>
Expand Down
3 changes: 3 additions & 0 deletions src/mmw/js/src/analyze/templates/tableRow.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<td>{{ type }}</td>
{% if isLandTable %}
<td class="hidden-analyze-table-column" data-tableexport-display="always">{{ code }}</td>
{% endif %}
<td class="strong text-right">{{ scaledArea|round(2)|toLocaleString(2) }}</td>
<td class="strong text-right">{{ coveragePct|toFixed(1) }}</td>
14 changes: 10 additions & 4 deletions src/mmw/js/src/analyze/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ function testAnalysisType(type) {
resultView.listenTo(resultView, 'show', function() {
var expectedTableHeaders = tableHeaders[type],
expectedTableRows = tableRows(type, result),
actualTableHeaders = $('table thead th').map(function() {
actualTableHeaders = _.compact($('table thead th').map(function() {
if ($(this).hasClass('hidden-analyze-table-column')) {
return null;
}
return $(this).text().trim();
}).toArray(),
actualTableRows = $('table tbody td').map(function() {
}).toArray()),
actualTableRows = _.compact($('table tbody td').map(function() {
if ($(this).hasClass('hidden-analyze-table-column')) {
return null;
}
return $(this).text().trim();
}).toArray();
}).toArray());

assert.deepEqual(expectedTableHeaders, actualTableHeaders);
assert.deepEqual(expectedTableRows, actualTableRows);
Expand Down
17 changes: 12 additions & 5 deletions src/mmw/js/src/analyze/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,17 @@ var TableRowView = Marionette.ItemView.extend({
template: tableRowTmpl,
templateHelpers: function() {
var area = this.model.get('area'),
units = this.options.units;
units = this.options.units,
isLandTable = this.options.isLandTable,
code = isLandTable ? this.model.get('nlcd') : null;

return {
// Convert coverage to percentage for display.
coveragePct: (this.model.get('coverage') * 100),
// Scale the area to display units.
scaledArea: utils.changeOfAreaUnits(area, 'm<sup>2</sup>', units)
scaledArea: utils.changeOfAreaUnits(area, 'm<sup>2</sup>', units),
code: code,
isLandTable: isLandTable
};
}
});
Expand All @@ -545,12 +549,14 @@ var TableView = Marionette.CompositeView.extend({
childView: TableRowView,
childViewOptions: function() {
return {
units: this.options.units
units: this.options.units,
isLandTable: this.options.modelName === 'land'
};
},
templateHelpers: function() {
return {
headerUnits: this.options.units
headerUnits: this.options.units,
isLandTable: this.options.modelName === 'land'
};
},
childViewContainer: 'tbody',
Expand Down Expand Up @@ -1027,7 +1033,8 @@ var AnalyzeResultView = Marionette.LayoutView.extend({

this.tableRegion.show(new AnalyzeTableView({
units: units,
collection: census
collection: census,
modelName: this.model.get('name')
}));

if (AnalyzeChartView) {
Expand Down
4 changes: 4 additions & 0 deletions src/mmw/sass/pages/_analyze.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,7 @@
max-width: 650px !important;
height: 100%;
}

.hidden-analyze-table-column {
display: none;
}