fix bug in saving evaluation dates

This commit is contained in:
Julien Fastré 2021-08-18 22:30:32 +02:00
parent 9a1f56a820
commit 9447516694
4 changed files with 43 additions and 47 deletions

View File

@ -87,7 +87,7 @@
<!-- list evaluations -->
<add-evaluation
v-for="e in pickedEvaluations"
v-bind:key="e.id"
v-bind:key="e.key"
v-bind:evaluation="e">
</add-evaluation>

View File

@ -8,13 +8,13 @@
<dl class="item-details definition-inline">
<dt v-if="evaluation.startDate">{{ $t('startDate') }} :</dt>
<dd v-if="evaluation.startDate">{{ $d(evaluation.startDate.datetime, 'short') }}</dd>
<dd v-if="evaluation.startDate">{{ $d(evaluation.startDate, 'short') }}</dd>
<dt v-if="evaluation.endDate">{{ $t('endDate') }} :</dt>
<dd v-if="evaluation.endDate">{{ $d(evaluation.endDate.datetime, 'short') }}</dd>
<dd v-if="evaluation.endDate">{{ $d(evaluation.endDate, 'short') }}</dd>
<dt v-if="evaluation.maxDate">{{ $t('maxDate') }} :</dt>
<dd v-if="evaluation.maxDate">{{ $d(evaluation.maxDate.datetime, 'short') }}</dd>
<dd v-if="evaluation.maxDate">{{ $d(evaluation.maxDate, 'short') }}</dd>
<dt v-if="evaluation.warningInterval">{{ $t('warningInterval') }} :</dt>
<dd v-if="evaluation.warningInterval">{{ evaluation.warningInterval }}</dd>
@ -70,7 +70,7 @@ export default {
components: {
FormEvaluation
},
props: ['evaluation'],
props: ['evaluation', 'editEvaluation'],
i18n,
data() {
return {
@ -91,7 +91,6 @@ export default {
this.editEvaluation = !this.editEvaluation;
},
submitForm() {
this.$refs.FormEvaluation.saveEvaluation();
this.toggleEditEvaluation();
}
}

View File

@ -139,37 +139,28 @@ export default {
},
*/
startDate: {
get() {
if (this.evaluation.startDate) {
return this.evaluation.startDate.datetime.split('T')[0];
}
return null;
},
set(v) {
this.evaluation.startDate.datetime = `${v}T00:00:00+0100`;
}
get() {
return dateToISO(this.evaluation.startDate);
},
set(v) {
this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) });
}
},
endDate: {
get() {
if (this.evaluation.endDate) {
return this.evaluation.endDate.datetime.split('T')[0];
}
return null;
},
set(v) {
this.evaluation.endDate.datetime = `${v}T00:00:00+0100`;
}
get() {
return dateToISO(this.evaluation.endDate);
},
set(v) {
this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: ISOToDate(v) });
}
},
maxDate: {
get() {
if (this.evaluation.maxDate) {
return this.evaluation.maxDate.datetime.split('T')[0];
}
return null;
},
set(v) {
this.evaluation.maxDate.datetime = `${v}T00:00:00+0100`;
}
get() {
return dateToISO(this.evaluation.maxDate);
},
set(v) {
this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: ISOToDate(v) });
}
},
warningInterval: {
get() { return this.evaluation.warningInterval; },
@ -203,12 +194,6 @@ export default {
})
;
},
saveEvaluation() {
console.log('save evaluation');
console.log('dispatch action: post/patch/put evaluation');
console.log('commit mutation: update state.mutation');
}
},
mounted() {
//this.listAllStatus();

View File

@ -165,7 +165,7 @@ const store = createStore({
found.results.push(result);
},
removeResultForGoalPicked(state, { goal, result}) {
removeResultForGoalPicked(state, { goal, result }) {
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
if (found === undefined) {
@ -177,14 +177,14 @@ const store = createStore({
addEvaluation(state, evaluation) {
let e = {
type: "accompanying_period_work_evaluation",
key: state.evaluationsPicked.length + 1,
evaluation: evaluation,
//startDate,
//endDate,
//maxDate,
//warningInterval
//comment,
//documents,
}
"startDate": null,
"endDate": null,
"maxDate": null,
"warningInterval": null,
"comment": "",
};
state.evaluationsPicked.push(e);
console.log('ep', state.evaluationsPicked);
},
@ -192,6 +192,18 @@ const store = createStore({
state.evaluationsPicked = state.evaluationsPicked.filter(e => e.id !== evaluation.id);
console.log('ep', state.evaluationsPicked);
},
setEvaluationStartDate(state, {key, date}) {
state.evaluationsPicked.find(e => e.key == key)
.startDate = date;
},
setEvaluationEndDate(state, {key, date}) {
state.evaluationsPicked.find(e => e.key == key)
.endDate = date;
},
setEvaluationMaxDate(state, {key, date}) {
state.evaluationsPicked.find(e => e.key == key)
.maxDate = date;
},
setPersonsPickedIds(state, ids) {
//console.log('persons ids', ids);
state.personsPicked = state.personsReachables