Skip to content

Commit

Permalink
Merge pull request #630 from mrc-ide/mrc-2797
Browse files Browse the repository at this point in the history
mrc-2797 Remove calibration plot when user changes calibration options
  • Loading branch information
LekanAnni committed Nov 22, 2021
2 parents fb0251a + 83da765 commit b2c58f8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# hint 1.74.1

* Remove calibration plot when user changes calibration options

# hint 1.74.0

* Add navigation buttons to bottom of every page
Expand Down
34 changes: 18 additions & 16 deletions src/app/static/src/app/components/modelCalibrate/ModelCalibrate.vue
Expand Up @@ -23,7 +23,7 @@
>
{{ submitText }}
</button>
<p v-if="calibrationPlotGenerated" id="reviewResults" class="mb-0" v-translate="'reviewResults'"></p>
<p v-if="showCalibrateResults" id="reviewResults" class="mb-0" v-translate="'reviewResults'"></p>
</div>
<div v-if="calibrating" id="calibrating" class="mt-3">
<loading-spinner size="xs"></loading-spinner>
Expand All @@ -44,7 +44,7 @@
<span v-translate="'genCalibResults'"></span>
</div>
<calibration-results
v-if="calibrationPlotGenerated"
v-if="showCalibrateResults"
></calibration-results>
</div>
</template>
Expand All @@ -62,13 +62,11 @@
import {
mapActionByName,
mapGetterByName,
mapMutationByName,
mapStateProp,
mapStateProps,
} from "../../utils";
import { ModelCalibrateMutation } from "../../store/modelCalibrate/mutations";
import { StepDescription } from "../../store/stepper/stepper";
import { RootState } from "../../root";
import { Language } from "../../store/translations/locales";
import { ModelCalibrateState } from "../../store/modelCalibrate/modelCalibrate";
Expand Down Expand Up @@ -96,6 +94,7 @@
hasError: boolean;
error: Error;
progressMessage: string;
showCalibrateResults: boolean
}
interface Data {
Expand All @@ -113,26 +112,29 @@
},
computed: {
...mapStateProps<ModelCalibrateState, keyof Computed>(namespace, {
loading: (s) => s.fetching,
calibrating: (s) => s.calibrating,
generatingCalibrationPlot: (s) => s.generatingCalibrationPlot,
calibrationPlotGenerated: (s) => !!s.calibratePlotResult,
error: (s) => s.error,
progressMessage: (s) => {
loading: (state) => state.fetching,
calibrating: (state) => state.calibrating,
generatingCalibrationPlot: (state) => state.generatingCalibrationPlot,
calibrationPlotGenerated: (state) => !!state.calibratePlotResult,
error: (state) => state.error,
progressMessage: (state) => {
if (
s.status &&
s.status.progress &&
s.status.progress.length > 0
state.status &&
state.status.progress &&
state.status.progress.length > 0
) {
const p = s.status.progress[0]; //This may be either a string or ProgressPhase
const p = state.status.progress[0]; //This may be either a string or ProgressPhase
return typeof p == "string"
? p
: `${p.name}: ${p.helpText}`;
} else {
return null;
}
},
}
}),
showCalibrateResults() {
return this.calibrationPlotGenerated && this.complete
},
currentLanguage: mapStateProp<RootState, Language>(
null,
(state: RootState) => state.language
Expand Down Expand Up @@ -179,6 +181,6 @@
},
mounted() {
this.fetchOptions();
},
}
});
</script>
2 changes: 1 addition & 1 deletion src/app/static/src/app/hintVersion.ts
@@ -1 +1 @@
export const currentHintVersion = "1.74.0";
export const currentHintVersion = "1.74.1";
@@ -1,8 +1,8 @@
import Vuex, {ActionTree, MutationTree, Store} from "vuex";
import Vuex, {Store} from "vuex";
import {mockError, mockModelCalibrateState, mockRootState} from "../../mocks";
import registerTranslations from "../../../app/store/translations/registerTranslations";
import {RootState} from "../../../app/root";
import {ModelCalibrateState} from "../../../app/store/modelCalibrate/modelCalibrate";;
import {ModelCalibrateState} from "../../../app/store/modelCalibrate/modelCalibrate";
import {mount, shallowMount} from "@vue/test-utils";
import ModelCalibrate from "../../../app/components/modelCalibrate/ModelCalibrate.vue";
import CalibrationResults from "../../../app/components/modelCalibrate/CalibrationResults.vue";
Expand Down Expand Up @@ -74,7 +74,7 @@ describe("Model calibrate component", () => {
it("invokes fetch options action on mount", () => {
const mockFetch = jest.fn();
const store = getStore({}, mockFetch);
const wrapper = getWrapper(store);
getWrapper(store);
expect(mockFetch.mock.calls.length).toBe(1);
});

Expand Down Expand Up @@ -176,11 +176,18 @@ describe("Model calibrate component", () => {
"Générer des résultats d'étalonnage", "Gerando resultados de calibração", store);
});

it("renders calibration plot", () => {
it("renders calibration plot and label if calibration is complete", () => {
const store = getStore({complete: true, calibratePlotResult: {}});
const wrapper = getWrapper(store);
expect(wrapper.find(CalibrationResults).exists()).toBe(true);
expectTranslated(wrapper.find("#reviewResults"), "(Review results below)",
"(Consultez les résultats ci-dessous)", "(Analise os resultados abaixo)", store);
});

it("it does not render calibration plot and label if calibration is incomplete", () => {
const store = getStore({complete: false, calibratePlotResult: {}});
const wrapper = getWrapper(store);
expect(wrapper.find(CalibrationResults).exists()).toBe(false);
expect(wrapper.find("#reviewResults").exists()).toBe(false)
});
});

0 comments on commit b2c58f8

Please sign in to comment.