mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
accompanying course: allow PATCH on a comment entity
This commit is contained in:
parent
6d46efa610
commit
cde6e8f368
@ -415,6 +415,22 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Comment::class,
|
||||||
|
'name' => 'accompanying_period_comment',
|
||||||
|
'base_path' => '/api/1.0/person/accompanying-period/comment',
|
||||||
|
'base_role' => 'ROLE_USER',
|
||||||
|
'actions' => [
|
||||||
|
'_entity' => [
|
||||||
|
'methods' => [
|
||||||
|
Request::METHOD_GET => false,
|
||||||
|
Request::METHOD_PATCH => true,
|
||||||
|
Request::METHOD_HEAD => false,
|
||||||
|
Request::METHOD_DELETE => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Resource::class,
|
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Resource::class,
|
||||||
'name' => 'accompanying_period_resource',
|
'name' => 'accompanying_period_resource',
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
v-bind:placeholder="$t('comment.content')"
|
v-bind:placeholder="$t('comment.content')"
|
||||||
:editor="editor"
|
:editor="editor"
|
||||||
v-model="content"
|
v-model="content"
|
||||||
|
@input="onContentChange"
|
||||||
tag-name="textarea">
|
tag-name="textarea">
|
||||||
</ckeditor>
|
</ckeditor>
|
||||||
|
|
||||||
@ -82,8 +83,34 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submitform() {
|
onContentChange() {
|
||||||
this.$store.dispatch('postFirstComment', this.formdata)
|
console.log('content changed');
|
||||||
|
console.log(this.pinnedComment)
|
||||||
|
if (this.pinnedComment) {
|
||||||
|
let body = this.formdata;
|
||||||
|
Object.assign(body, {id: this.pinnedComment.id})
|
||||||
|
this.$store.dispatch('updatePinnedComment', body)
|
||||||
|
.catch(({name, violations}) => {
|
||||||
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
|
} else {
|
||||||
|
this.$toast.open({message: 'An error occurred'})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch('addPinnedComment', this.formdata)
|
||||||
|
.catch(({name, violations}) => {
|
||||||
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
|
} else {
|
||||||
|
this.$toast.open({message: 'An error occurred'})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
submitform() { //TODO deprecated, to remove
|
||||||
|
console.log(this.formdata)
|
||||||
|
this.$store.dispatch('addPinnedComment', this.formdata)
|
||||||
.catch(({name, violations}) => {
|
.catch(({name, violations}) => {
|
||||||
if (name === 'ValidationException' || name === 'AccessException') {
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
@ -91,6 +118,14 @@ export default {
|
|||||||
this.$toast.open({message: 'An error occurred'})
|
this.$toast.open({message: 'An error occurred'})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// this.$store.dispatch('postFirstComment', this.formdata)
|
||||||
|
// .catch(({name, violations}) => {
|
||||||
|
// if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
|
// violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
|
// } else {
|
||||||
|
// this.$toast.open({message: 'An error occurred'})
|
||||||
|
// }
|
||||||
|
// });
|
||||||
},
|
},
|
||||||
removeComment() {
|
removeComment() {
|
||||||
this.$store.dispatch('postFirstComment', {})
|
this.$store.dispatch('postFirstComment', {})
|
||||||
|
@ -348,7 +348,7 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
|||||||
|
|
||||||
return makeFetch('DELETE', url, body)
|
return makeFetch('DELETE', url, body)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
commit('removePinnedComment');
|
commit('removePinnedComment');
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
commit('catchError', error);
|
commit('catchError', error);
|
||||||
@ -368,6 +368,21 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
|||||||
throw error;
|
throw error;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
updatePinnedComment({ commit }, payload) {
|
||||||
|
console.log(payload)
|
||||||
|
const url = `/api/1.0/person/accompanying-period/comment/${payload.id}.json`;
|
||||||
|
|
||||||
|
return makeFetch('PATCH', url, payload)
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response)
|
||||||
|
commit('addPinnedComment', response);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
commit('catchError', error);
|
||||||
|
throw error;
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Add/remove/display anonymous requestor
|
* Add/remove/display anonymous requestor
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user