Skip to content
Snippets Groups Projects
Commit 428fd818 authored by Williams, Darius Shamar's avatar Williams, Darius Shamar
Browse files

Restricting multiple parameter codes

parent 3da14af4
No related branches found
No related tags found
1 merge request!385WDFN-762 - Restricting multiple parameter codes to IV data codes only
......@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Parameter selection list now has the option to graph a second parameter.
- Reworked the USWDSDatePicker to initialize itself and to handle changes to properties appropriately.
- Hydrograph Graph Brush is now implemented with a Vue component.
- Multiple parameter codes can only be selected for parameter codes with IV data available.
### Fixed
- Parameter codes with multiple methods will now show statistical data for each method available.
......
......@@ -77,6 +77,34 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel
let wrapper;
beforeEach(() => {
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'
}
};
retrieveHydrographDataSpy = jest.spyOn(hydrographData, 'retrieveHydrographData');
showDataIndicatorSpy = jest.spyOn(dataIndicator, 'showDataIndicators');
store = configureStore(TEST_STATE);
......@@ -246,14 +274,6 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel
'id': 'second-parameter-radio-button-00060',
'label': 'Discharge, cubic feet per second'
},
{
'actionValue': {
'secondaryParameterCode': '62610'
},
'checked': false,
'id': 'second-parameter-radio-button-62610',
'label': 'Groundwater level above NGVD 1929, feet'
},
{
'actionValue': {
'secondaryParameterCode': '00010'
......@@ -297,6 +317,61 @@ describe('monitoring-location/components/hydrograph/vue-components/parameter-sel
expect(rowForParameter72019.html()).not.toContain('secondary-parameter-controls-stub');
});
it('Expects that selecting a new parameter row without IV data will not show the second parameter selection component', async() => {
fetch.mockResponse(JSON.stringify({}));
const rowContainers = wrapper.findAll('.parameter-row-container');
expect(rowContainers).toHaveLength(5);
const rowForParameter62610 = rowContainers[2];
const rowForParameter72019 = rowContainers[1];
expect(rowForParameter62610.classes()).not.toContain('selected');
expect(rowForParameter62610.html()).not.toContain('secondary-parameter-controls-stub');
expect(rowForParameter72019.classes()).toContain('selected');
expect(rowForParameter72019.html()).toContain('secondary-parameter-controls-stub');
await rowForParameter62610.find('.parameter-row-info-container').trigger('click');
expect(rowForParameter62610.classes()).toContain('selected');
expect(rowForParameter62610.html()).not.toContain('secondary-parameter-controls-stub');
expect(rowForParameter72019.classes()).not.toContain('selected');
expect(rowForParameter72019.html()).not.toContain('secondary-parameter-controls-stub');
});
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() => {
fetch.mockResponse(JSON.stringify({}));
config.ivPeriodOfRecord = {
'72019': {
begin_date: '1980-04-01',
end_date: '2020-04-01'
}
};
wrapper = shallowMount(ParameterSelection, {
global: {
plugins: [
[ReduxConnectVue, {
store,
mapDispatchToPropsFactory: (actionCreators) => (dispatch) => bindActionCreators(actionCreators, dispatch),
mapStateToPropsFactory: createStructuredSelector
}]
],
provide: {
store: store,
siteno: '12345678',
agencyCode: 'USGS'
}
}
});
const rowContainers = wrapper.findAll('.parameter-row-container');
expect(rowContainers).toHaveLength(5);
const rowForParameter72019 = rowContainers[1];
expect(rowForParameter72019.classes()).toContain('selected');
expect(rowForParameter72019.html()).not.toContain('secondary-parameter-controls-stub');
});
it('Expects events emitted from secondary parameter controls will change the secondary parameter code in the state', async() => {
const TEST_STATE = {
hydrographData: {
......
......@@ -69,7 +69,7 @@
/>
<SecondaryParameterControls
v-if="parameter.parameterCode === expandedParameterCode"
v-if="enabledForSecondaryParameter(parameter.parameterCode)"
:parameter-list="secondaryParameterButtonList"
:is-second-parameter-options-checked="isSecondParameterOptionsChecked"
@setCheckBoxStatus="setCheckBoxStatus"
......@@ -159,7 +159,8 @@ export default {
const secondaryParameterButtonList = computed(() => {
const radioButtonList = [];
state.parameters.value.forEach((parameter) => {
if (parameter.parameterCode !== expandedParameterCode.value) {
if (parameter.parameterCode !== expandedParameterCode.value &&
parameter.parameterCode.replace(config.CALCULATED_TEMPERATURE_VARIABLE_CODE, '') in config.ivPeriodOfRecord) {
const buttonDetail = {
id: `second-parameter-radio-button-${parameter.parameterCode}`,
label: parameter.description,
......@@ -202,6 +203,22 @@ export default {
actions.setSelectedIVMethodID(methodId);
}
function enabledForSecondaryParameter(rowParameterCode) {
const selected = rowParameterCode === expandedParameterCode.value;
if (!selected) {
return selected;
}
let otherCodesHaveIVData = false;
let hasIVData = false;
state.parameters.value.forEach((parameter) => {
if (parameter.parameterCode.replace(config.CALCULATED_TEMPERATURE_VARIABLE_CODE, '') in config.ivPeriodOfRecord) {
otherCodesHaveIVData = otherCodesHaveIVData ? otherCodesHaveIVData : rowParameterCode !== parameter.parameterCode;
hasIVData = hasIVData ? hasIVData : rowParameterCode === parameter.parameterCode;
}
});
return selected && otherCodesHaveIVData && hasIVData;
}
return {
...state,
expandedParameterCode,
......@@ -210,7 +227,8 @@ export default {
selectParameter,
setCheckBoxStatus,
toggleExpansionRow,
updateSelectedMethod
updateSelectedMethod,
enabledForSecondaryParameter
};
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment