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 --> <!-- list evaluations -->
<add-evaluation <add-evaluation
v-for="e in pickedEvaluations" v-for="e in pickedEvaluations"
v-bind:key="e.id" v-bind:key="e.key"
v-bind:evaluation="e"> v-bind:evaluation="e">
</add-evaluation> </add-evaluation>

View File

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

View File

@ -139,37 +139,28 @@ export default {
}, },
*/ */
startDate: { startDate: {
get() { get() {
if (this.evaluation.startDate) { return dateToISO(this.evaluation.startDate);
return this.evaluation.startDate.datetime.split('T')[0]; },
} set(v) {
return null; this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) });
}, }
set(v) {
this.evaluation.startDate.datetime = `${v}T00:00:00+0100`;
}
}, },
endDate: { endDate: {
get() { get() {
if (this.evaluation.endDate) { return dateToISO(this.evaluation.endDate);
return this.evaluation.endDate.datetime.split('T')[0]; },
} set(v) {
return null; this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: ISOToDate(v) });
}, }
set(v) {
this.evaluation.endDate.datetime = `${v}T00:00:00+0100`;
}
}, },
maxDate: { maxDate: {
get() { get() {
if (this.evaluation.maxDate) { return dateToISO(this.evaluation.maxDate);
return this.evaluation.maxDate.datetime.split('T')[0]; },
} set(v) {
return null; this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: ISOToDate(v) });
}, }
set(v) {
this.evaluation.maxDate.datetime = `${v}T00:00:00+0100`;
}
}, },
warningInterval: { warningInterval: {
get() { return this.evaluation.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() { mounted() {
//this.listAllStatus(); //this.listAllStatus();

View File

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