diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d6fabce9f7dd49de3ccea2e3c1036c4fb96630..00c4f8fbe67ac5b08f1706f435be118d75665400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - The monitoring location map component now implemented in Vue. - The jest test framework was replaced with vitest. - The statistics table now uses the USWDS table component from the wdfn-vue-components npm package. +- All radio buttons and radio button sets now use the wdfn-vue-components npm package. ### Fixed - If the data reports that a parameter has a period of record, yet the observations service returns no data, the application will no longer hang. diff --git a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.test.js b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.test.js index f7e4c5c36834acd274e528619613e80d3e5c9620..b1c52b0e19d6e537891ad8a867d86f660d92b34f 100644 --- a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.test.js +++ b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.test.js @@ -1,4 +1,3 @@ - import {bindActionCreators} from 'redux'; import ReduxConnectVue from 'redux-connect-vue'; import {createStructuredSelector} from 'reselect'; @@ -9,6 +8,8 @@ import {configureStore} from 'ml/store'; import {Actions} from 'ml/store/daily-value-time-series'; +import {USWDSRadioButton, USWDSRadioButtonSet} from '@wma/wdfn-vue-components'; + import DvGraphControls from './DvGraphControls.vue'; describe('monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.vue', () => { @@ -136,7 +137,6 @@ describe('monitoring-location/components/daily-value-hydrograph/vue-components/D }); describe('Creating the graph controls with data', () => { - let store; let retrieveDVTimeSeriesSpy; @@ -171,20 +171,30 @@ describe('monitoring-location/components/daily-value-hydrograph/vue-components/D }); it('Should render the radio buttons', () => { - const radioButtons = wrapper.findAll('input[type="radio"]'); - const firstRadioButton = wrapper.find('#code-72019-radio'); + expect(wrapper.findAllComponents(USWDSRadioButtonSet)).toHaveLength(1); + const radioButtons = wrapper.findAllComponents(USWDSRadioButton); expect(radioButtons).toHaveLength(2); - expect(firstRadioButton.element.checked).toBe(true); + expect(radioButtons[0].props('isButtonChecked')).toBe(true); + expect(radioButtons[0].props('radioButtonId')).toBe('code-72019-radio'); + expect(radioButtons[0].props('radioButtonLabel')).toBe('72019'); + expect(radioButtons[0].props('radioButtonName')).toBe('dv-parameter-code-selector-radio-button-set'); + expect(radioButtons[0].props('radioButtonValue')).toBe('72019'); + + expect(radioButtons[1].props('isButtonChecked')).toBe(false); + expect(radioButtons[1].props('radioButtonId')).toBe('code-62610-radio'); + expect(radioButtons[1].props('radioButtonLabel')).toBe('62610'); + expect(radioButtons[1].props('radioButtonName')).toBe('dv-parameter-code-selector-radio-button-set'); + expect(radioButtons[1].props('radioButtonValue')).toBe('62610'); }); it('Should update the selected parameter code', async() => { - const radioButtons = wrapper.findAll('input[type="radio"]'); + const radioButtons = wrapper.findAllComponents(USWDSRadioButton); expect(store.getState().dailyValueTimeSeriesState.currentDVTimeSeriesId.max).toBe('1123'); - await radioButtons[1].trigger('click'); + await radioButtons[1].find('input').trigger('click'); const dvState = store.getState().dailyValueTimeSeriesState; - expect(radioButtons[1].element.checked).toBe(true); - expect(radioButtons[0].element.checked).toBe(false); + expect(radioButtons[1].props('isButtonChecked')).toBe(true); + expect(radioButtons[0].props('isButtonChecked')).toBe(false); expect(retrieveDVTimeSeriesSpy.mock.calls).toHaveLength(3); expect(dvState.currentDVTimeSeriesId.max).toBe('1124'); expect(dvState.dvGraphBrushOffset).toEqual({ diff --git a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.vue b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.vue index 692da0b2ad237b584e72625c017bf53ba4091851..8f5463eb3267831fb84b0267c898476bf5bbd5cb 100644 --- a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.vue +++ b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/vue-components/DvGraphControls.vue @@ -18,11 +18,11 @@ - \ No newline at end of file + const retrieveAndSetTimeSeries = function(parameterCode) { + const timeSeries = getAvailableGWDVTimeSeriesIdsForParameterCode(parameterCode)(store.getState()); + actions.retrieveDVTimeSeries(monitoringLocationId, timeSeries.min); + actions.retrieveDVTimeSeries(monitoringLocationId, timeSeries.mean); + actions.retrieveDVTimeSeries(monitoringLocationId, timeSeries.max); + actions.clearDVGraphBrushOffset(); + actions.setCurrentDVTimeSeriesIds(timeSeries.min, timeSeries.mean, timeSeries.max); + }; + diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue index 01d6b5fd1a9ef003ba7925ba672b0b2c6ac351e9..928eb43b6c2c1cb686f54b2bcdeb8dc3ad394b00 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue @@ -1,112 +1,19 @@ - diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.test.js index 3844634f86c124939d03a6b32ebe992a06730a67..03a27c1b165617e97227a2f9f5c3bb8ac857b123 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.test.js @@ -8,7 +8,7 @@ import {USWDSCheckbox} from '@wma/wdfn-vue-components'; import config from 'ui/config'; -import USWDSRadioButtonSet from 'ui/vue-components/radio-button-set.vue'; +import {USWDSRadioButtonSet} from '@wma/wdfn-vue-components'; import {configureStore} from 'ml/store'; import * as hydrographData from 'ml/store/hydrograph-data'; diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.vue b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.vue index eb46c63939c3e968d9af1b056bda2fc4f1003c75..792410300bf52f863bd7ff46ede851a7bc16ac47 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.vue +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/secondary-parameter-controls.vue @@ -27,7 +27,7 @@ import {USWDSCheckbox} from '@wma/wdfn-vue-components'; import config from 'ui/config'; -import USWDSRadioButtonSet from 'ui/vue-components/radio-button-set.vue'; +import {USWDSRadioButtonSet} from '@wma/wdfn-vue-components'; import {setSelectedSecondaryParameterCode, setCompareDataVisibility, setShowLoadingIndicator, setMedianDataVisibility, setSelectedSecondaryIVMethodID} from 'ml/store/hydrograph-state'; diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.test.js index cb26953140f7a98e7c9ba457b1b23eddbfcc7e7b..e01348bf76ca526d24a70f4d25c30fbcfde318a9 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.test.js @@ -4,6 +4,8 @@ import {createStructuredSelector} from 'reselect'; import createFetchMock from 'vitest-fetch-mock'; import {mount} from '@vue/test-utils'; +import {USWDSRadioButton, USWDSRadioButtonSet} from '@wma/wdfn-vue-components'; + import config from 'ui/config'; import {getSelectedTimeSpan, getGraphBrushOffset} from 'ml/selectors/hydrograph-state-selector'; @@ -108,8 +110,8 @@ describe('monitoring-location/components/hydrograph/components/graph-controls', const radio1Year = wrapper.find('#P365D-input'); const labels = wrapper.findAll('.usa-radio__label'); - expect(wrapper.findAll('.iv-button-container')).toHaveLength(1); - expect(wrapper.findAll('.gw-button-container')).toHaveLength(0); + expect(wrapper.findAllComponents(USWDSRadioButtonSet)).toHaveLength(1); + expect(wrapper.findAllComponents(USWDSRadioButton)).toHaveLength(3); expect(radio7Day.attributes('value')).toBe('P7D'); expect(radio7Day.element.checked).toBe(true); @@ -160,8 +162,8 @@ describe('monitoring-location/components/hydrograph/components/graph-controls', const radio1Year = wrapper.find('#P365D-input'); const labels = wrapper.findAll('.usa-radio__label'); - expect(wrapper.findAll('.iv-button-container')).toHaveLength(1); - expect(wrapper.findAll('.gw-button-container')).toHaveLength(0); + expect(wrapper.findAllComponents(USWDSRadioButtonSet)).toHaveLength(1); + expect(wrapper.findAllComponents(USWDSRadioButton)).toHaveLength(3); expect(radio7Day.attributes('value')).toBe('P7D'); expect(radio7Day.element.checked).toBe(true); @@ -179,7 +181,7 @@ describe('monitoring-location/components/hydrograph/components/graph-controls', it('Expects that if the selectedTimeSpan is changed to a days before that is not a shortcut, they are all unset', async() => { store.dispatch(setSelectedTimeSpan('P45D')); await wrapper.vm.$nextTick(); - + const radio7Day = wrapper.find('#P7D-input'); const radio30Day = wrapper.find('#P30D-input'); const radio1Year = wrapper.find('#P365D-input'); @@ -192,7 +194,7 @@ describe('monitoring-location/components/hydrograph/components/graph-controls', it('Expects that if the selectedTimeSpan is changed to a date range, the shortcut radio buttons are not checked', async() => { store.dispatch(setSelectedTimeSpan({start: '2020-01-03', end: '2020-05-01'})); await wrapper.vm.$nextTick(); - + const radio7Day = wrapper.find('#P7D-input'); const radio30Day = wrapper.find('#P30D-input'); const radio1Year = wrapper.find('#P365D-input'); @@ -285,8 +287,8 @@ describe('monitoring-location/components/hydrograph/components/graph-controls', const radioAll = wrapper.find('#periodOfRecord-input'); const labels = wrapper.findAll('.usa-radio__label'); - expect(wrapper.findAll('.iv-button-container')).toHaveLength(0); - expect(wrapper.findAll('.gw-button-container')).toHaveLength(1); + expect(wrapper.findAllComponents(USWDSRadioButtonSet)).toHaveLength(1); + expect(wrapper.findAllComponents(USWDSRadioButton)).toHaveLength(3); expect(radio1Year.attributes('value')).toBe('P1Y'); expect(radio1Year.element.checked).toBe(true); diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.vue b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.vue index 132a5d7ea71e10e670b27b94a8bfd8f2607d8720..55ac15b386453e0238b33c38676dc883c5d90916 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.vue +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/time-span-shortcuts.vue @@ -1,66 +1,20 @@ -