mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
merge master into branch
This commit is contained in:
@@ -14,24 +14,27 @@
|
||||
|
||||
<ckeditor
|
||||
name="content"
|
||||
v-bind:placeholder="$t('comment.content')"
|
||||
:placeholder="$t('comment.content')"
|
||||
:editor="editor"
|
||||
v-model="content"
|
||||
tag-name="textarea">
|
||||
</ckeditor>
|
||||
|
||||
<div v-if="pinnedComment" class="metadata">
|
||||
{{ $t('comment.created_by', [
|
||||
pinnedComment.creator.text,
|
||||
$d(pinnedComment.createdAt.datetime, 'long')
|
||||
]) }}
|
||||
<div class="sub-comment">
|
||||
<div v-if="pinnedComment !== null && typeof pinnedComment.creator !== 'undefined'" class="metadata">
|
||||
{{ $t('comment.created_by', [
|
||||
pinnedComment.creator.text,
|
||||
$d(pinnedComment.updatedAt.datetime, 'long')
|
||||
])
|
||||
}}
|
||||
</div>
|
||||
<div class="loading">
|
||||
<i v-if="loading" class="fa fa-circle-o-notch fa-spin" :title="$t('loading')"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<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">
|
||||
@@ -50,6 +53,7 @@
|
||||
<script>
|
||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||
import ClassicEditor from "ChillMainAssets/module/ckeditor5";
|
||||
import { mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "Comment",
|
||||
@@ -59,22 +63,58 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
formdata: {
|
||||
type: "accompanying_period_comment",
|
||||
content: ''
|
||||
}
|
||||
loading: false,
|
||||
lastRecordedContent: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
pinnedComment() {
|
||||
return this.$store.state.accompanyingCourse.pinnedComment;
|
||||
},
|
||||
...mapState({
|
||||
pinnedComment: state => state.accompanyingCourse.pinnedComment,
|
||||
}),
|
||||
content: {
|
||||
set(value) {
|
||||
this.formdata.content = value;
|
||||
console.log('new comment value', value);
|
||||
console.log('previous value', this.lastRecordedContent);
|
||||
this.lastRecordedContent = value;
|
||||
|
||||
setTimeout(() => {
|
||||
console.log('performing test on ', value);
|
||||
if (this.lastRecordedContent === value) {
|
||||
this.loading = true;
|
||||
if (value !== '') {
|
||||
this.$store.dispatch('updatePinnedComment', value)
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
})
|
||||
.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 {
|
||||
if (this.$store.state.accompanyingCourse.pinnedComment !== null) {
|
||||
this.$store.dispatch('removePinnedComment', {id: this.pinnedComment.id})
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
this.lastRecoredContent = null;
|
||||
})
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
},
|
||||
get() {
|
||||
return (this.pinnedComment)? this.pinnedComment.content : {};
|
||||
get() {
|
||||
return this.pinnedComment ? this.pinnedComment.content : '';
|
||||
}
|
||||
},
|
||||
errors() {
|
||||
@@ -82,18 +122,11 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitform() {
|
||||
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'})
|
||||
}
|
||||
});
|
||||
onContentChange() {
|
||||
let lastRecordedContent = this.formData.content;
|
||||
},
|
||||
removeComment() {
|
||||
this.$store.dispatch('postFirstComment', {})
|
||||
this.$store.dispatch('removePinnedComment', {id: this.pinnedComment.id})
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
@@ -104,15 +137,18 @@ 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">
|
||||
div.ck-editor.ck-reset {
|
||||
margin: 0.6em 0;
|
||||
}
|
||||
div.sub-comment {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
div.loading {
|
||||
margin-right: 6px;
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<input type="checkbox" v-model="requestorIsAnonymous" class="me-2" />
|
||||
{{ $t('requestor.is_anonymous') }}
|
||||
</label>
|
||||
<confidential :positionBtn="false" v-if="accompanyingCourse.requestor.type === 'thirdparty'">
|
||||
<confidential v-if="accompanyingCourse.requestor.type === 'thirdparty'">
|
||||
<template v-slot:confidential-content>
|
||||
<third-party-render-box
|
||||
:thirdparty="accompanyingCourse.requestor"
|
||||
@@ -33,7 +33,7 @@
|
||||
</template>
|
||||
</confidential>
|
||||
|
||||
<confidential :positionBtnFar="false" v-else-if="accompanyingCourse.requestor.type === 'person'">
|
||||
<confidential v-else-if="accompanyingCourse.requestor.type === 'person'">
|
||||
<template v-slot:confidential-content>
|
||||
<person-render-box render="bloc"
|
||||
:person="accompanyingCourse.requestor"
|
||||
@@ -339,5 +339,6 @@ div.flex-table {
|
||||
|
||||
.confidential {
|
||||
display: block;
|
||||
margin-right: 0px !important;
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user