mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Merge remote-tracking branch 'origin/master' into issue511_document_evaluations
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>
|
||||
|
@@ -122,7 +122,7 @@ const appMessages = {
|
||||
title: "Observations",
|
||||
label: "Ajout d'une 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: {
|
||||
title: "Confirmation",
|
||||
|
@@ -42,7 +42,11 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
||||
referrersSuggested: [],
|
||||
// all the users available
|
||||
users: [],
|
||||
permissions: {}
|
||||
permissions: {},
|
||||
// controller for updating comment
|
||||
updateCommentAbortController: null,
|
||||
// waiting response for inserting first comment
|
||||
postFirstPinnedCommentResponse: null,
|
||||
},
|
||||
getters: {
|
||||
isParticipationValid(state) {
|
||||
@@ -203,9 +207,35 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
||||
//console.log('### mutation: toggleConfidential');
|
||||
state.accompanyingCourse.confidential = value;
|
||||
},
|
||||
postFirstComment(state, comment) {
|
||||
//console.log('### mutation: postFirstComment', comment);
|
||||
state.accompanyingCourse.pinnedComment = comment;
|
||||
setPinnedComment(state, content) {
|
||||
if (null === state.accompanyingCourse.pinnedComment) {
|
||||
state.accompanyingCourse.pinnedComment = {
|
||||
id: -1,
|
||||
content,
|
||||
type: "accompanying_period_comment",
|
||||
};
|
||||
} else {
|
||||
state.accompanyingCourse.pinnedComment.content = content;
|
||||
}
|
||||
},
|
||||
setPinnedCommentDetails(state, value) {
|
||||
state.accompanyingCourse.pinnedComment.id = value.id;
|
||||
if (typeof value.creator !== 'undefined') {
|
||||
state.accompanyingCourse.pinnedComment.creator = value.creator;
|
||||
state.accompanyingCourse.pinnedComment.updatedBy = value.updatedBy;
|
||||
state.accompanyingCourse.pinnedComment.updatedAt = value.updatedAt;
|
||||
state.accompanyingCourse.pinnedComment.createdAt = value.createdAt;
|
||||
|
||||
}
|
||||
},
|
||||
removePinnedComment(state, value) {
|
||||
state.accompanyingCourse.pinnedComment = null;
|
||||
},
|
||||
setPinCommentAbortController(state, value) {
|
||||
state.updateCommentAbortController = value;
|
||||
},
|
||||
setPostFirstPinnedCommentResponse(state, value) {
|
||||
state.postFirstPinnedCommentResponse = value;
|
||||
},
|
||||
updateSocialIssues(state, value) {
|
||||
console.log('updateSocialIssues', value);
|
||||
@@ -337,6 +367,87 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
/**
|
||||
* Add/remove pinnedComment
|
||||
*/
|
||||
removePinnedComment({ commit }, payload) {
|
||||
const body = {type: "accompanying_period_comment", id: payload.id};
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/comment.json`;
|
||||
|
||||
return makeFetch('DELETE', url, body)
|
||||
.then((response) => {
|
||||
commit('removePinnedComment');
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
/**
|
||||
* internal method to insert a new comment
|
||||
*
|
||||
* @param commit
|
||||
* @param dispatch
|
||||
* @param content
|
||||
* @returns {*}
|
||||
*/
|
||||
addPinnedComment({ commit, dispatch }, content) {
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/comment.json`;
|
||||
|
||||
return makeFetch('POST', url, {type: "accompanying_period_comment", content})
|
||||
.then((response) => {
|
||||
commit('setPinnedCommentDetails', response);
|
||||
return dispatch('patchFirstComment', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
updatePinnedComment({ commit, state, dispatch }, content) {
|
||||
commit('setPinnedComment', content);
|
||||
if (state.accompanyingCourse.pinnedComment.id === -1 && state.postFirstPinnedCommentResponse === null) {
|
||||
let r = dispatch('addPinnedComment', content).then(() => {
|
||||
commit('setPostFirstPinnedCommentResponse', null);
|
||||
});
|
||||
commit('setPostFirstPinnedCommentResponse', r);
|
||||
} else {
|
||||
(state.postFirstPinnedCommentResponse === null ? Promise.resolve() : state.postFirstPinnedCommentResponse).then(() => {
|
||||
dispatch('updateExistingPinnedComment', content);
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* internal method to patch an existing comment
|
||||
*
|
||||
* @param commit
|
||||
* @param state
|
||||
* @param comment
|
||||
* @returns {*}
|
||||
*/
|
||||
updateExistingPinnedComment({ commit, state }, content) {
|
||||
const payload = {type: "accompanying_period_comment", content, id: state.accompanyingCourse.pinnedComment.id};
|
||||
const url = `/api/1.0/person/accompanying-period/comment/${payload.id}.json`;
|
||||
|
||||
if (state.updateCommentAbortController !== null) {
|
||||
state.updateCommentAbortController.abort();
|
||||
commit('setPinCommentAbortController', null);
|
||||
}
|
||||
|
||||
let controller = new AbortController();
|
||||
commit('setPinCommentAbortController', controller);
|
||||
|
||||
return makeFetch('PATCH', url, payload, { signal: controller.signal })
|
||||
.then((response) => {
|
||||
commit('setPinCommentAbortController', null);
|
||||
commit('setPinnedCommentDetails', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
commit('setPinCommentAbortController', null);
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
/**
|
||||
* Add/remove/display anonymous requestor
|
||||
*/
|
||||
@@ -606,18 +717,20 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
|
||||
|
||||
return Promise.all(promises);
|
||||
},
|
||||
postFirstComment({ commit }, payload) {
|
||||
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
||||
const body = { type: "accompanying_period", pinnedComment: payload }
|
||||
|
||||
patchFirstComment({ commit }, payload) {
|
||||
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||
const body = {
|
||||
type: "accompanying_period",
|
||||
pinnedComment: {
|
||||
type: "accompanying_period_comment",
|
||||
id: payload.id
|
||||
}
|
||||
};
|
||||
return makeFetch('PATCH', url, body)
|
||||
.then((response) => {
|
||||
commit('postFirstComment', response.pinnedComment);
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
});
|
||||
},
|
||||
updateSocialIssues({ state, commit, dispatch }, { payload, body, method }) {
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/socialissue.json`;
|
||||
|
@@ -151,6 +151,37 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="referrers" class="action-row">
|
||||
<h3>{{ $t('referrers') }}</h3>
|
||||
|
||||
<div v-if="!hasReferrers">
|
||||
<p class="chill-no-data-statement">{{ $t('no_referrers') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<ul class="list-suggest remove-items inline">
|
||||
<li v-for="u in referrers" :key="u.id" :title="$t('remove_referrer')" @click="removeReferrer(u)">
|
||||
<span>
|
||||
{{ u.text }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li class="add-persons">
|
||||
<add-persons
|
||||
ref="referrerPicker"
|
||||
:key="referrerPicker.key"
|
||||
:buttonTitle="$t('add_referrers')"
|
||||
:modalTitle="$t('choose_referrers')"
|
||||
:options="referrerPicker.options"
|
||||
@addNewPersons="addReferrers">
|
||||
</add-persons>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="handlingThirdParty" class="action-row">
|
||||
<h3>{{ $t('handling_thirdparty') }}</h3>
|
||||
|
||||
@@ -289,7 +320,6 @@ import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vu
|
||||
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
fr: {
|
||||
@@ -319,9 +349,13 @@ const i18n = {
|
||||
add_thirdparties: "Ajouter des tiers",
|
||||
choose_thirdparties: "Choisir des tiers",
|
||||
fix_these_errors: "Veuillez corriger les erreurs suivantes :",
|
||||
available_evaluations_text: "Évaluations disponibles pour ajout :",
|
||||
available_evaluations_text: "Documents disponibles pour ajout :",
|
||||
no_evaluations_available: "Aucune évaluation disponible",
|
||||
no_goals_available: "Aucun objectif disponible",
|
||||
referrers: "Agents traitants",
|
||||
no_referrers: "Aucun agent traitant",
|
||||
choose_referrers: "Choisir des agents traitants",
|
||||
remove_referrer: "Enlever l'agent"
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -370,6 +404,17 @@ export default {
|
||||
}
|
||||
},
|
||||
},
|
||||
referrerPicker: {
|
||||
key: 'referrer',
|
||||
options: {
|
||||
type: ['user'],
|
||||
priority: null,
|
||||
uniq: false,
|
||||
button: {
|
||||
display: false
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -381,6 +426,7 @@ export default {
|
||||
'personsReachables',
|
||||
'handlingThirdParty',
|
||||
'thirdParties',
|
||||
'referrers',
|
||||
'isPosting',
|
||||
'errors',
|
||||
'templatesAvailablesForAction',
|
||||
@@ -389,6 +435,7 @@ export default {
|
||||
'hasResultsForAction',
|
||||
'hasHandlingThirdParty',
|
||||
'hasThirdParties',
|
||||
'hasReferrers'
|
||||
]),
|
||||
startDate: {
|
||||
get() {
|
||||
@@ -465,6 +512,14 @@ export default {
|
||||
removeThirdParty(t) {
|
||||
this.$store.commit('removeThirdParty', t);
|
||||
},
|
||||
addReferrers({selected, modal}) {
|
||||
this.$store.commit('addReferrers', selected.map(r => r.result));
|
||||
this.$refs.referrerPicker.resetSearch();
|
||||
modal.showModal = false;
|
||||
},
|
||||
removeReferrer(u) {
|
||||
this.$store.commit('removeReferrer', u);
|
||||
},
|
||||
goToGenerateWorkflow({link}) {
|
||||
console.log('save before leave to generate workflow')
|
||||
const callback = (data) => {
|
||||
@@ -521,6 +576,7 @@ div#workEditor {
|
||||
"objectives objectives"
|
||||
"evaluations evaluations"
|
||||
"persons persons"
|
||||
"referrers referrers"
|
||||
"handling handling"
|
||||
"tparties tparties"
|
||||
"errors errors";
|
||||
@@ -543,6 +599,8 @@ div#workEditor {
|
||||
grid-area: handling; }
|
||||
#thirdParties {
|
||||
grid-area: tparties; }
|
||||
#referrers {
|
||||
grid-area: referrers; }
|
||||
#errors {
|
||||
grid-area: errors; }
|
||||
|
||||
@@ -657,5 +715,4 @@ div#workEditor {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
@@ -70,7 +70,7 @@
|
||||
<div class="input-group input-group-lg mb-3">
|
||||
<div>
|
||||
<input
|
||||
class="form-control form-control-lg"
|
||||
class="form-control"
|
||||
style="font-weight: bold;"
|
||||
type="text"
|
||||
:value="d.title"
|
||||
|
@@ -31,6 +31,7 @@ const store = createStore({
|
||||
.map(p => p.person),
|
||||
handlingThirdParty: window.accompanyingCourseWork.handlingThierParty,
|
||||
thirdParties: window.accompanyingCourseWork.thirdParties,
|
||||
referrers: window.accompanyingCourseWork.referrers,
|
||||
isPosting: false,
|
||||
errors: [],
|
||||
},
|
||||
@@ -54,6 +55,9 @@ const store = createStore({
|
||||
hasHandlingThirdParty(state) {
|
||||
return state.handlingThirdParty !== null;
|
||||
},
|
||||
hasReferrers(state) {
|
||||
return state.referrers.length > 0;
|
||||
},
|
||||
hasThirdParties(state) {
|
||||
return state.thirdParties.length > 0;
|
||||
},
|
||||
@@ -82,6 +86,7 @@ const store = createStore({
|
||||
},
|
||||
results: state.resultsPicked.map(r => ({id: r.id, type: r.type})),
|
||||
thirdParties: state.thirdParties.map(t => ({id: t.id, type: t.type})),
|
||||
referrers: state.referrers.map(t => ({id: t.id, type: t.type})),
|
||||
goals: state.goalsPicked.map(g => {
|
||||
let o = {
|
||||
type: g.type,
|
||||
@@ -315,6 +320,18 @@ const store = createStore({
|
||||
state.thirdParties = state.thirdParties
|
||||
.filter(t => t.id !== thirdParty.id);
|
||||
},
|
||||
addReferrers(state, referrers) {
|
||||
let ids = state.referrers.map(t => t.id);
|
||||
let unexistings = referrers.filter(t => !ids.includes(t.id));
|
||||
|
||||
for (let i in unexistings) {
|
||||
state.referrers.push(unexistings[i]);
|
||||
}
|
||||
},
|
||||
removeReferrer(state, user) {
|
||||
state.referrers = state.referrers
|
||||
.filter(u => u.id !== user.id);
|
||||
},
|
||||
setErrors(state, errors) {
|
||||
state.errors = errors;
|
||||
},
|
||||
@@ -333,7 +350,6 @@ const store = createStore({
|
||||
},
|
||||
actions: {
|
||||
updateThirdParty({ commit }, payload) {
|
||||
console.log(payload);
|
||||
commit('updateThirdParty', payload);
|
||||
},
|
||||
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
||||
|
@@ -87,10 +87,14 @@ export default {
|
||||
currentMembers() {
|
||||
let members = this.household.members.filter(m => this.household.current_members_id.includes(m.id))
|
||||
.sort((a, b) => {
|
||||
if (a.position.ordering < b.position.ordering) {
|
||||
|
||||
const orderA = a.position ? a.position.ordering : 0;
|
||||
const orderB = b.position ? b.position.ordering : 0;
|
||||
|
||||
if (orderA < orderB) {
|
||||
return -1;
|
||||
}
|
||||
if (a.position.ordering > b.position.ordering) {
|
||||
if (orderA > orderB) {
|
||||
return 1;
|
||||
}
|
||||
if (a.holder && !b.holder) {
|
||||
|
Reference in New Issue
Block a user