added clearer validation error message for overlapping interventions of the same type
@@ -196,16 +196,22 @@ var vm = new Vue({
this.$set(this.intervention_pars, key, []);
}
// validate intervention
- const notValid = !intervention.end || !intervention.start || intervention.end <= intervention.start || this.intervention_pars[key].some(({start, end}) => {
+ const notValid = !intervention.end || !intervention.start || intervention.end <= intervention.start
+ if (notValid) {
+ this.$set(this.scenarioError, scenarioKey, `Please enter a valid day range`);
+ return;
+ }
+
+ const overlaps = this.intervention_pars[key].some(({start, end}) => {
return start <= intervention.start && end >= intervention.start ||
start <= intervention.end && end >= intervention.end ||
intervention.start <= start && intervention.end >= end;
- });
- if (notValid) {
- this.$set(this.scenarioError, scenarioKey, `Please enter a valid day range`);
+ })
+ if (overlaps){
+ this.$set(this.scenarioError, scenarioKey, `Intervention day ranges cannot overlap.`)
return ;
}
- // Check that
+
const outOfBounds = intervention.start > this.sim_length.best || intervention.end > this.sim_length.best || this.intervention_pars[key].some(({start, end}) => {
return start > self.sim_length.best || end > self.sim_length.best
})
