mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
accompanying course comment: tentative to delete the comment
This commit is contained in:
parent
cde6e8f368
commit
f04118218d
@ -14,7 +14,7 @@
|
||||
|
||||
<ckeditor
|
||||
name="content"
|
||||
v-bind:placeholder="$t('comment.content')"
|
||||
:placeholder="$t('comment.content')"
|
||||
:editor="editor"
|
||||
v-model="content"
|
||||
@input="onContentChange"
|
||||
@ -23,16 +23,14 @@
|
||||
|
||||
<div v-if="pinnedComment" class="metadata">
|
||||
{{ $t('comment.created_by', [
|
||||
pinnedComment.creator.text,
|
||||
$d(pinnedComment.createdAt.datetime, 'long')
|
||||
]) }}
|
||||
pinnedComment.creator.text,
|
||||
$d(pinnedComment.createdAt.datetime, 'long')
|
||||
])
|
||||
}}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<!-- <div> //DOES NOT WORk
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<button type="submit" class="btn btn-save">{{ $t('action.save') }}</button>
|
||||
</li>
|
||||
<li v-if="pinnedComment !== null">
|
||||
<a class="btn btn-delete"
|
||||
@click="removeComment">
|
||||
@ -40,7 +38,7 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</form>
|
||||
</div>
|
||||
@ -60,7 +58,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
formdata: {
|
||||
formData: {
|
||||
type: "accompanying_period_comment",
|
||||
content: ''
|
||||
}
|
||||
@ -72,7 +70,7 @@ export default {
|
||||
},
|
||||
content: {
|
||||
set(value) {
|
||||
this.formdata.content = value;
|
||||
this.formData.content = value;
|
||||
},
|
||||
get() {
|
||||
return (this.pinnedComment)? this.pinnedComment.content : {};
|
||||
@ -87,7 +85,7 @@ export default {
|
||||
console.log('content changed');
|
||||
console.log(this.pinnedComment)
|
||||
if (this.pinnedComment) {
|
||||
let body = this.formdata;
|
||||
let body = this.formData;
|
||||
Object.assign(body, {id: this.pinnedComment.id})
|
||||
this.$store.dispatch('updatePinnedComment', body)
|
||||
.catch(({name, violations}) => {
|
||||
@ -98,7 +96,7 @@ export default {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$store.dispatch('addPinnedComment', this.formdata)
|
||||
this.$store.dispatch('addPinnedComment', this.formData)
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
@ -108,27 +106,8 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
submitform() { //TODO deprecated, to remove
|
||||
console.log(this.formdata)
|
||||
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'})
|
||||
}
|
||||
});
|
||||
// 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() {
|
||||
this.$store.dispatch('postFirstComment', {})
|
||||
this.$store.dispatch('removePinnedComment', {})
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
@ -139,11 +118,6 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TODO
|
||||
* - [x] delete button in ul record_actions, but not in form
|
||||
* - [ ] display updatedAt => pinnedComment fetch PATCH content changes MUST NOT change object id !!
|
||||
*/
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -342,8 +342,8 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
||||
/**
|
||||
* Add/remove pinnedComment
|
||||
*/
|
||||
removePinnedComment({ commit, dispatch }) {
|
||||
const body = {};
|
||||
removePinnedComment({ commit }) { //DOES NOT WORK
|
||||
const body = {type: "accompanying_period_comment"};
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/comment.json`;
|
||||
|
||||
return makeFetch('DELETE', url, body)
|
||||
@ -381,7 +381,6 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
|
||||
},
|
||||
/**
|
||||
* Add/remove/display anonymous requestor
|
||||
|
Loading…
x
Reference in New Issue
Block a user