mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
accompanying course comment: autosave the comment
This commit is contained in:
parent
6472c554ed
commit
4b692edd7d
@ -24,7 +24,7 @@
|
|||||||
<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.updatedAt.datetime, 'long')
|
||||||
])
|
])
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
@ -82,29 +82,34 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onContentChange() {
|
onContentChange() {
|
||||||
console.log('content changed');
|
let lastRecordedContent = this.formData.content;
|
||||||
console.log(this.pinnedComment)
|
setTimeout(() => {
|
||||||
if (this.pinnedComment) {
|
if (lastRecordedContent === this.formData.content) {
|
||||||
let body = this.formData;
|
if (this.pinnedComment) {
|
||||||
Object.assign(body, {id: this.pinnedComment.id})
|
let body = this.formData;
|
||||||
this.$store.dispatch('updatePinnedComment', body)
|
Object.assign(body, {id: this.pinnedComment.id});
|
||||||
.catch(({name, violations}) => {
|
|
||||||
if (name === 'ValidationException' || name === 'AccessException') {
|
this.$store.dispatch('updatePinnedComment', body)
|
||||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
.catch(({name, violations}) => {
|
||||||
} else {
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
this.$toast.open({message: 'An error occurred'})
|
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}) => {
|
} else {
|
||||||
if (name === 'ValidationException' || name === 'AccessException') {
|
this.$store.dispatch('addPinnedComment', this.formData)
|
||||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
.catch(({name, violations}) => {
|
||||||
} else {
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
this.$toast.open({message: 'An error occurred'})
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
}
|
} else {
|
||||||
});
|
this.$toast.open({message: 'An error occurred'})
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
lastRecordedContent = null;
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
},
|
},
|
||||||
removeComment() {
|
removeComment() {
|
||||||
this.$store.dispatch('removePinnedComment', {id: this.pinnedComment.id})
|
this.$store.dispatch('removePinnedComment', {id: this.pinnedComment.id})
|
||||||
|
@ -122,7 +122,7 @@ const appMessages = {
|
|||||||
title: "Observations",
|
title: "Observations",
|
||||||
label: "Ajout d'une note",
|
label: "Ajout d'une note",
|
||||||
content: "Rédigez une première note…",
|
content: "Rédigez une première note…",
|
||||||
created_by: "créé par {0}, le {1}"
|
created_by: "créé par {0}, mis à jour le {1}"
|
||||||
},
|
},
|
||||||
confirm: {
|
confirm: {
|
||||||
title: "Confirmation",
|
title: "Confirmation",
|
||||||
|
@ -370,12 +370,10 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
updatePinnedComment({ commit }, payload) {
|
updatePinnedComment({ commit }, payload) {
|
||||||
console.log(payload)
|
|
||||||
const url = `/api/1.0/person/accompanying-period/comment/${payload.id}.json`;
|
const url = `/api/1.0/person/accompanying-period/comment/${payload.id}.json`;
|
||||||
|
|
||||||
return makeFetch('PATCH', url, payload)
|
return makeFetch('PATCH', url, payload)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(response)
|
|
||||||
commit('addPinnedComment', response);
|
commit('addPinnedComment', response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user