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

Create hydrology tables #2924

Merged
merged 1 commit into from Aug 17, 2018
Merged

Create hydrology tables #2924

merged 1 commit into from Aug 17, 2018

Conversation

kellyi
Copy link
Contributor

@kellyi kellyi commented Aug 15, 2018

Overview

This PR implements the hydrology tables as depicted below. Was able to reuse the the table view from TR55, with the data adjusted to reformat it for GWLFE.

The bulk of the change here is a reduce function to transform the GWLFE data into a shape for display in the tables.

Connects #2915

Demo

hydrologytable

Testing Instructions

  • serve this branch, then visit a MapShed project and open the compare view
  • toggle the hydrology table and then verify that you see data and can toggle through the attributes using the selection box

@kellyi kellyi force-pushed the ki/hydrology-tables branch 2 times, most recently from 74ad1c8 to f3c004f Compare August 16, 2018 16:23
@rajadain rajadain added Compare View Revamp CitSci Funding Source: Citizen Science Initiative labels Aug 16, 2018
@kellyi kellyi force-pushed the ki/hydrology-tables branch 3 times, most recently from 94cae83 to 888c129 Compare August 17, 2018 17:57
@kellyi kellyi changed the title WIP Ki/hydrology tables Create hydrology tables Aug 17, 2018
@kellyi kellyi requested a review from rajadain August 17, 2018 18:00
} else {
window.console.warn('TODO: Implement GWLFE Table');
window.console.log('TODO Implement GWLFE Water Quality table & chart');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Committed this by mistake but I guess it'll be removed semi-immediately anyway.

@@ -201,10 +205,21 @@ var CompareWindow2 = modalViews.ModalBaseView.extend({
var selected =
activeTab.get('selections').findWhere({ active: true });


Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also committed by mistake, but this function's going to get removed when the water quality work is in.

@rajadain
Copy link
Member

This looks really good! I noticed that the pagination wasn't working out of the box as I expected, so I looked into the code, and found that extending the existing TableRowView and TableView works just as well, makes pagination work, and is more compact:

diff --git a/src/mmw/js/src/compare/views.js b/src/mmw/js/src/compare/views.js
index 780a7634..79195ba4 100644
--- a/src/mmw/js/src/compare/views.js
+++ b/src/mmw/js/src/compare/views.js
@@ -747,32 +747,6 @@ var GWLFEHydrologyChartView = Marionette.CollectionView.extend({
     childView: LineChartRowView,
 });
 
-var GWLFEHydrologyTableRowView = Marionette.ItemView.extend({
-    models: models.MonthlyTableRowModel,
-    className: 'compare-table-row -hydrology',
-    template: compareTableRowTmpl,
-
-    modelEvents: {
-        'change': 'render',
-    },
-
-    templateHelpers: function() {
-        var selectedAttribute = this.model.get('selectedAttribute');
-
-        return {
-            values: this.model
-                .get('values')
-                .map(function(v) {
-                    return v[selectedAttribute];
-                }),
-        };
-    },
-});
-
-var GWLFEHydrologyTableView = Marionette.CollectionView.extend({
-    childView: GWLFEHydrologyTableRowView,
-});
-
 var TR55ChartView = Marionette.CollectionView.extend({
     childView: BarChartRowView,
 
@@ -856,6 +830,22 @@ var TableView = Marionette.CollectionView.extend({
     }
 });
 
+var GWLFEHydrologyTableRowView = TableRowView.extend({
+    className: 'compare-table-row -hydrology',
+
+    templateHelpers: function() {
+        var selectedAttribute = this.model.get('selectedAttribute');
+
+        return {
+            values: this.model.get('values').pluck(selectedAttribute)
+        };
+    },
+});
+
+var GWLFEHydrologyTableView = TableView.extend({
+    childView: GWLFEHydrologyTableRowView,
+});
+
 var CompareWindow = Marionette.LayoutView.extend({
     //model: modelingModels.ProjectModel,
 

I would recommend adding that change and this will be good to merge! Will take care of the other demo stuff in this PR in upcoming Water Quality PRs.

@kellyi
Copy link
Contributor Author

kellyi commented Aug 17, 2018

Sounds good to me. I'm making that change & will amend the existing commit to include it.

For whatever reason I've not been able to get .pluck to work, so I'll keep the .map op instead.

- use map & reduce to create reformatted GWLFE Hydrology data in a shape
to use in the compare view table: each month has its own row, displaying
that data from the scenario
- conditionally adjust Sass rules to set column opacity to 1.0 in order
to circumvent a bug whereby opening the compare view kicks off polling
- use `text-align: right` to right-align Current Conditions column
header until it's remedied in additional design work
- toggle attributes with selection component
@kellyi
Copy link
Contributor Author

kellyi commented Aug 17, 2018

Here's the table view with the column toggles:

screen shot 2018-08-17 at 5 02 55 pm

Copy link
Member

@rajadain rajadain left a comment

Choose a reason for hiding this comment

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

+1 tested. Working well. Great job!

@rajadain rajadain assigned kellyi and unassigned rajadain Aug 17, 2018
@kellyi
Copy link
Contributor Author

kellyi commented Aug 17, 2018

Great! Thanks for your help with this!

@kellyi kellyi merged commit 19bb76c into develop Aug 17, 2018
@kellyi kellyi deleted the ki/hydrology-tables branch August 17, 2018 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CitSci Funding Source: Citizen Science Initiative Compare View Revamp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants