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