emit response and commit change in store

This commit is contained in:
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;
}
)
}