diff --git a/CHANGELOG.md b/CHANGELOG.md index f3b26daee89041192e3eca75149303389dace86b..14f29288bcc97b39d03fcf47b4c1f5371a3a5f62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased](https://code.usgs.gov/wma/iow/waterdataui/~/compare/waterdataui-1.3.0...main) +### Fixed +- Sites with GW levels now correctly renders the Select Data to Graph section. ## [1.3.0](https://code.usgs.gov/wma/iow/waterdataui/~/compare/waterdataui-1.3.0...waterdataui-1.2.0) - 2022-07-20 ### Added diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.test.js index 40920a89db8ff95836562f7ba94a019b7c6de527..59c3321b77df6153ca191d0778d22d904076adaf 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.test.js @@ -22,32 +22,6 @@ import SecondaryParameterControls from './secondary-parameter-controls.vue'; describe('monitoring-location/components/hydrograph/vue-components/parameter-selection', () => { utils.mediaQuery = jest.fn().mockReturnValue(true); - config.ivPeriodOfRecord = { - '00060': { - begin_date: '1980-01-01', - end_date: '2020-01-01' - }, - '72019': { - begin_date: '1980-04-01', - end_date: '2020-04-01' - }, - '00010': { - begin_date: '1981-04-01', - end_date: '2019-04-01' - } - - }; - config.gwPeriodOfRecord = { - '72019': { - begin_date: '1980-03-31', - end_date: '2020-03-31' - }, - '62610': { - begin_date: '1980-05-01', - end_date: '2020-05-01' - } - }; - config.SENSOR_THINGS_ENDPOINT = 'https://fake-sensor-things-endpoint'; config.IV_DATA_ENDPOINT = 'https://fake-iv-data-endpoint'; @@ -249,7 +223,6 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel expect(parameterRows[1].classes()).toContain('selected'); }); - it('Expects that clicking the expansion toggle in the selected row hides the expansion container', async() => { const selectedExpansionToggle = wrapper.find('.selected').findComponent(ParameterSelectionExpansionControl); await selectedExpansionToggle.vm.$emit('toggleExpansionRow', '72019', false); @@ -306,15 +279,15 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel const rowForParameter72019 = rowContainers[1]; expect(rowForParameter00060.classes()).not.toContain('selected'); - expect(rowForParameter00060.html()).not.toContain('secondary-parameter-controls-stub'); + expect(rowForParameter00060.findComponent(SecondaryParameterControls).exists()).toBe(false); expect(rowForParameter72019.classes()).toContain('selected'); - expect(rowForParameter72019.html()).toContain('secondary-parameter-controls-stub'); + expect(rowForParameter72019.findComponent(SecondaryParameterControls).exists()).toBe(true); await rowForParameter00060.find('.parameter-row-info-container').trigger('click'); expect(rowForParameter00060.classes()).toContain('selected'); - expect(rowForParameter00060.html()).toContain('secondary-parameter-controls-stub'); + expect(rowForParameter00060.findComponent(SecondaryParameterControls).exists()).toBe(true); expect(rowForParameter72019.classes()).not.toContain('selected'); - expect(rowForParameter72019.html()).not.toContain('secondary-parameter-controls-stub'); + expect(rowForParameter72019.findComponent(SecondaryParameterControls).exists()).toBe(false); }); it('Expects that selecting a new parameter row without IV data will not show the second parameter selection component', async() => { @@ -326,15 +299,15 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel const rowForParameter72019 = rowContainers[1]; expect(rowForParameter62610.classes()).not.toContain('selected'); - expect(rowForParameter62610.html()).not.toContain('secondary-parameter-controls-stub'); + expect(rowForParameter62610.findComponent(SecondaryParameterControls).exists()).toBe(false); expect(rowForParameter72019.classes()).toContain('selected'); - expect(rowForParameter72019.html()).toContain('secondary-parameter-controls-stub'); + expect(rowForParameter72019.findComponent(SecondaryParameterControls).exists()).toBe(true); await rowForParameter62610.find('.parameter-row-info-container').trigger('click'); expect(rowForParameter62610.classes()).toContain('selected'); - expect(rowForParameter62610.html()).not.toContain('secondary-parameter-controls-stub'); + expect(rowForParameter62610.findComponent(SecondaryParameterControls).exists()).toBe(false); expect(rowForParameter72019.classes()).not.toContain('selected'); - expect(rowForParameter72019.html()).not.toContain('secondary-parameter-controls-stub'); + expect(rowForParameter72019.findComponent(SecondaryParameterControls).exists()).toBe(false); }); it('Expects that selecting a parameter row with IV data without any other IV data parameters available will not show the second parameter selection component', async() => { @@ -347,6 +320,18 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel } }; + const TEST_STATE = { + hydrographParameters: TEST_HYDROGRAPH_PARAMETERS, + hydrographState: { + selectedTimeSpan: 'P7D', + selectedParameterCode: '72019', + selectedIVMethodID: '', + selectedSecondaryParameterCode: '' + } + }; + + store = configureStore(TEST_STATE); + wrapper = shallowMount(ParameterSelection, { global: { plugins: [ @@ -369,7 +354,41 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel const rowForParameter72019 = rowContainers[1]; expect(rowForParameter72019.classes()).toContain('selected'); - expect(rowForParameter72019.html()).not.toContain('secondary-parameter-controls-stub'); + expect(rowForParameter72019.findComponent(SecondaryParameterControls).exists()).toBe(false); + }); + + it('Expects that if no IV data is available the secondary parameter controls is not rendered for any row', () => { + config.ivPeriodOfRecord = undefined; + const TEST_STATE = { + hydrographParameters: TEST_HYDROGRAPH_PARAMETERS, + hydrographState: { + selectedTimeSpan: 'P7D', + selectedParameterCode: '72019', + selectedIVMethodID: '', + selectedSecondaryParameterCode: '' + } + }; + + store = configureStore(TEST_STATE); + + wrapper = shallowMount(ParameterSelection, { + global: { + plugins: [ + [ReduxConnectVue, { + store, + mapDispatchToPropsFactory: (actionCreators) => (dispatch) => bindActionCreators(actionCreators, dispatch), + mapStateToPropsFactory: createStructuredSelector + }] + ], + provide: { + store: store, + siteno: '12345678', + agencyCode: 'USGS' + } + } + }); + + expect(wrapper.findComponent(SecondaryParameterControls).exists()).toBe(false); }); it('Expects events emitted from secondary parameter controls will change the secondary parameter code in the state', async() => { diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.vue b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.vue index 2a710fa7acdbb34547bcd9a808d97a5fb41afc61..6818a2a5fc2f6109f36d5ad64365074278bba809 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.vue +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/parameter-selection.vue @@ -204,17 +204,16 @@ export default { } function enabledForSecondaryParameter(rowParameterCode) { - const selected = rowParameterCode === expandedParameterCode.value; - if (!selected) { - return selected; + if (!config.ivPeriodOfRecord || + rowParameterCode !== expandedParameterCode.value || + !(rowParameterCode.replace(config.CALCULATED_TEMPERATURE_VARIABLE_CODE, '') in config.ivPeriodOfRecord)) { + return false; } - const hasIVData = rowParameterCode.replace(config.CALCULATED_TEMPERATURE_VARIABLE_CODE, '') in config.ivPeriodOfRecord; - const otherCodesHaveIVData = state.parameters.value.find((parameter) => { - return parameter.parameterCode !== rowParameterCode && - parameter.parameterCode.replace(config.CALCULATED_TEMPERATURE_VARIABLE_CODE) in config.ivPeriodOfRecord; - }) ? true : false; - return selected && otherCodesHaveIVData && hasIVData; + return state.parameters.value + .filter(parameter => parameter.parameterCode !== rowParameterCode) + .find(parameter => + parameter.parameterCode.replace(config.CALCULATED_TEMPERATURE_VARIABLE_CODE) in config.ivPeriodOfRecord); } return { diff --git a/wdfn-server/waterdata/templates/index.html b/wdfn-server/waterdata/templates/index.html index 0432d94cf5ccc54ede75ce4d59aa82d05e8acfd8..b02d8378daacbe35e36756b3a5a9ac27c314aaaa 100644 --- a/wdfn-server/waterdata/templates/index.html +++ b/wdfn-server/waterdata/templates/index.html @@ -8,17 +8,33 @@ <li><a class="usa-link" href="{{ url_for('states_counties') }}">By States</a></li> <li><a class="usa-link" href="{{ url_for('networks') }}">By Networks</a></li> </ul> - <h4>Example monitoring location pages</h4> + <h4>Sites with different characteristics. These are helpful to test sites with a wide variety of characteristics</h4> + <ul class="usa-list"> + <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='05428500') }}"> + 05428500 - Yahara River (site with camera and IV data but no GW data or logos) + </a></li> + <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='05427948') }}"> + 05427948 - Pheasant Branch at Middleton WI (site with camera, IV data with total precipitation, cameras, but no logos) + </a></li> + <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='03341500') }}"> + 03341500 - Wabash River at Terre Haute, IN (site IV data, flood levels, FIM map, and logos but no cameras) + </a></li> + <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='07144100') }}"> + 07144100 - L Arkansas R NR Sedgwick, KS(super gage with IV data with methods, flood levels, FIM map, and logos but no cameras) + </a></li> + <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='354133082042203') }}"> + 354133082042203 - MC-109 Near Pleasant Gardens, NC(BEDROCK)(one code with IV, three with GW) + </a></li> + <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='345224116525704') }}"> + 345224116525704 - 009N001E16F004S(no IV data, three with GW) + </a></li> + </ul> + <h4>Other favorite monitoring location pages</h4> <ul class="usa-list"> - <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='05428500') }}">05428500 - Yahara River (site with camera)</a></li> <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='05370000') }}">05370000 - Eau Galle River at Spring Valley, WI</a></li> - <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='05427948') }}">05427948 - Pheasant Branch at Middleton, WI (has total precipitation which is accumulated</a></li> - <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='03341500') }}">03341500 - Wabash River at Terre Haute, IN (has SIFTA logos)</a></li> <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='01646500') }}">01646500 - Potomac River Near Wash, DC Little Falls Pump Sta (has SIFTA logos)</a></li> <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='414240072033201') }}">414240072033201 - CT-SC 22 SCOTLAND (has DV data)</a></li> - <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='354133082042203') }}">354133082042203 - Has DV min, mean, and max and masks (and SIFTA logos)</a></li> <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='08279500') }}">08279500 - Rio Grande at Embudo, NM</a></li> - <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='07144100') }}">07144100 - Little Arkansas River Near Sedgwick, KS</a></li> <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='16103000') }}">16103000 - Hanalei River nr Hanalei, Kauai, HI - has two active gage heights</a></li> <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='08470400', agency_cd='USIBW') }}">08470400 - USIBW Arroyo Colorado at Harlingen, TX</a></li> <li><a class="usa-link" href="{{ url_for('monitoring_location', site_no='08470400', agency_cd='USGS') }}">08470400 - Arroyo Colorado at Harlingen, TX</a></li>