emit response and commit change in store

This commit is contained in:
Mathieu Jaumotte 2022-01-12 16:56:21 +01:00
parent abcc8557ce
commit 34ff91979b
3 changed files with 21 additions and 2 deletions

View File

@ -17,6 +17,7 @@
<li>
<write-comment
:resource="resource"
@updateComment="updateComment"
></write-comment>
</li>
<li>
@ -60,6 +61,7 @@
<li>
<write-comment
:resource="resource"
@updateComment="updateComment"
></write-comment>
</li>
<li>
@ -127,6 +129,10 @@ export default {
this.$toast.open({message: 'An error occurred'})
}
});
},
updateComment(resource) {
console.log('updateComment', resource);
this.$store.commit('updateResource', resource);
}
}
}

View File

@ -45,11 +45,12 @@ import ClassicEditor from "ChillMainAssets/module/ckeditor5";
export default {
name: "WriteComment",
props: ['resource'],
components: {
Modal,
ckeditor: CKEditor.component,
},
props: ['resource'],
emits: ['updateComment'],
data() {
return {
modal: {
@ -99,7 +100,14 @@ export default {
;
makeFetch('PATCH', url, body)
.then(r => {
this.modal.showModal = false
let resource = {
'type': 'accompanying_period_resource',
'id': r.id,
'comment': r.comment,
'resource': r.resource
}
this.$emit('updateComment', resource);
this.modal.showModal = false;
}
)
}

View File

@ -124,6 +124,11 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
//console.log('### mutation: addResource', resource);
state.accompanyingCourse.resources.push(resource);
},
updateResource(state, payload) {
console.log('### mutation: updateResource', payload);
let i = state.accompanyingCourse.resources.findIndex(r => r.id === payload.id);
state.accompanyingCourse.resources[i] = payload;
},
updatePerson(state, payload) {
console.log('### mutation: updatePerson', payload);
let i = null;