mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-08 14:29:42 +00:00
Apply prettier rules
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,15 @@
|
||||
<template>
|
||||
<div>
|
||||
<a id="evaluations" />
|
||||
<div
|
||||
class="item-title"
|
||||
:title="evaluation.id || 'no id yet'"
|
||||
>
|
||||
<div class="item-title" :title="evaluation.id || 'no id yet'">
|
||||
<span>{{ evaluation.evaluation.title.fr }}</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="item-url mt-3 mb-4"
|
||||
v-if="evaluation.evaluation.url"
|
||||
>
|
||||
<div class="item-url mt-3 mb-4" v-if="evaluation.evaluation.url">
|
||||
<i class="fa fa-link fa-lg" />
|
||||
<a
|
||||
:href="evaluation.evaluation.url"
|
||||
target="_blank"
|
||||
>{{ evaluation.evaluation.url }}</a>
|
||||
<a :href="evaluation.evaluation.url" target="_blank">{{
|
||||
evaluation.evaluation.url
|
||||
}}</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -43,7 +36,8 @@
|
||||
class="btn btn-delete"
|
||||
@click="modal.showModal = true"
|
||||
:title="$t('action.delete')"
|
||||
>{{ $t('delete_evaluation') }}</a>
|
||||
>{{ $t("delete_evaluation") }}</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -56,18 +50,15 @@
|
||||
>
|
||||
<template #header>
|
||||
<h2 class="modal-title">
|
||||
{{ $t('delete.sure') }}
|
||||
{{ $t("delete.sure") }}
|
||||
</h2>
|
||||
</template>
|
||||
<template #body>
|
||||
<p>{{ $t('delete.sure_description') }}</p>
|
||||
<p>{{ $t("delete.sure_description") }}</p>
|
||||
</template>
|
||||
<template #footer>
|
||||
<button
|
||||
class="btn btn-danger"
|
||||
@click="removeEvaluation(evaluation)"
|
||||
>
|
||||
{{ $t('delete.ok') }}
|
||||
<button class="btn btn-danger" @click="removeEvaluation(evaluation)">
|
||||
{{ $t("delete.ok") }}
|
||||
</button>
|
||||
</template>
|
||||
</modal>
|
||||
@@ -76,107 +67,117 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FormEvaluation from './FormEvaluation.vue';
|
||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
|
||||
import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue';
|
||||
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
|
||||
import FormEvaluation from "./FormEvaluation.vue";
|
||||
import Modal from "ChillMainAssets/vuejs/_components/Modal";
|
||||
import ListWorkflowModal from "ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue";
|
||||
import { buildLinkCreate } from "ChillMainAssets/lib/entity-workflow/api.js";
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
fr: {
|
||||
no_evaluation_associated: "Aucune évaluation associée",
|
||||
add_an_evaluation: "Évaluations disponibles",
|
||||
evaluation_has_no_evaluation: "Aucune évaluation disponible",
|
||||
startDate: "Date d'ouverture",
|
||||
endDate: "Date de fin",
|
||||
maxDate: "Date d'échéance",
|
||||
warningInterval: "Rappel (jours)",
|
||||
comment: "Note publique",
|
||||
documents: "Documents",
|
||||
delete: {
|
||||
sure: "Êtes-vous sûr?",
|
||||
sure_description: "Cette évaluation sera supprimée de cette action d'accompagnement",
|
||||
ok: "Supprimer"
|
||||
},
|
||||
delete_evaluation: "Supprimer l'évaluation",
|
||||
}
|
||||
}
|
||||
messages: {
|
||||
fr: {
|
||||
no_evaluation_associated: "Aucune évaluation associée",
|
||||
add_an_evaluation: "Évaluations disponibles",
|
||||
evaluation_has_no_evaluation: "Aucune évaluation disponible",
|
||||
startDate: "Date d'ouverture",
|
||||
endDate: "Date de fin",
|
||||
maxDate: "Date d'échéance",
|
||||
warningInterval: "Rappel (jours)",
|
||||
comment: "Note publique",
|
||||
documents: "Documents",
|
||||
delete: {
|
||||
sure: "Êtes-vous sûr?",
|
||||
sure_description:
|
||||
"Cette évaluation sera supprimée de cette action d'accompagnement",
|
||||
ok: "Supprimer",
|
||||
},
|
||||
delete_evaluation: "Supprimer l'évaluation",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "AddEvaluation",
|
||||
components: {
|
||||
FormEvaluation,
|
||||
Modal,
|
||||
ListWorkflowModal,
|
||||
},
|
||||
props: ['evaluation', 'docAnchorId'],
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
modal: {
|
||||
showModal: false,
|
||||
modalDialogClass: "modal-dialog-centered modal-md"
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
pickedEvaluations() {
|
||||
return this.$store.state.evaluationsPicked;
|
||||
name: "AddEvaluation",
|
||||
components: {
|
||||
FormEvaluation,
|
||||
Modal,
|
||||
ListWorkflowModal,
|
||||
},
|
||||
props: ["evaluation", "docAnchorId"],
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
modal: {
|
||||
showModal: false,
|
||||
modalDialogClass: "modal-dialog-centered modal-md",
|
||||
},
|
||||
canDelete() {
|
||||
if (this.evaluation.workflows.length > 0) {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
pickedEvaluations() {
|
||||
return this.$store.state.evaluationsPicked;
|
||||
},
|
||||
canDelete() {
|
||||
if (this.evaluation.workflows.length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let doc of this.evaluation.documents) {
|
||||
if (doc.workflows.length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let doc of this.evaluation.documents) {
|
||||
if (doc.workflows.length > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
removeEvaluation(e) {
|
||||
this.$store.commit('removeEvaluation', e);
|
||||
return;
|
||||
},
|
||||
toggleEditEvaluation() {
|
||||
this.$store.commit('toggleEvaluationEdit', { key: this.evaluation.key });
|
||||
},
|
||||
submitForm() {
|
||||
this.toggleEditEvaluation();
|
||||
},
|
||||
goToGenerateWorkflow({workflowName}) {
|
||||
const callback = (data) => {
|
||||
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id;
|
||||
window.location.assign(buildLinkCreate(workflowName,
|
||||
'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation', evaluationId));
|
||||
};
|
||||
|
||||
return this.$store.dispatch('submit', callback)
|
||||
.catch(e => { console.log(e); throw e; });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
removeEvaluation(e) {
|
||||
this.$store.commit("removeEvaluation", e);
|
||||
return;
|
||||
},
|
||||
toggleEditEvaluation() {
|
||||
this.$store.commit("toggleEvaluationEdit", { key: this.evaluation.key });
|
||||
},
|
||||
submitForm() {
|
||||
this.toggleEditEvaluation();
|
||||
},
|
||||
goToGenerateWorkflow({ workflowName }) {
|
||||
const callback = (data) => {
|
||||
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(
|
||||
(e) => e.key === this.evaluation.key,
|
||||
).id;
|
||||
window.location.assign(
|
||||
buildLinkCreate(
|
||||
workflowName,
|
||||
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation",
|
||||
evaluationId,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
return this.$store.dispatch("submit", callback).catch((e) => {
|
||||
console.log(e);
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
div.item-title{
|
||||
.evaluation-title{
|
||||
cursor: default;
|
||||
&::before{
|
||||
content: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
div.item-url {
|
||||
i {
|
||||
color: unset!important;
|
||||
margin-left: 1rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
}
|
||||
div.item-title {
|
||||
.evaluation-title {
|
||||
cursor: default;
|
||||
&::before {
|
||||
content: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
div.item-url {
|
||||
i {
|
||||
color: unset !important;
|
||||
margin-left: 1rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,36 +1,20 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="hasResult"
|
||||
class="addResult"
|
||||
>
|
||||
<p
|
||||
v-if="pickedResults.length ===0"
|
||||
class="chill-no-data-statement"
|
||||
>
|
||||
<div v-if="hasResult" class="addResult">
|
||||
<p v-if="pickedResults.length === 0" class="chill-no-data-statement">
|
||||
Aucun résultat associé
|
||||
</p>
|
||||
|
||||
<ul class="list-suggest remove-items">
|
||||
<li
|
||||
v-for="r in pickedResults"
|
||||
@click="removeResult(r)"
|
||||
:key="r.id"
|
||||
>
|
||||
<li v-for="r in pickedResults" @click="removeResult(r)" :key="r.id">
|
||||
<span>
|
||||
{{ r.title.fr }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div
|
||||
class="accordion"
|
||||
id="expandedSuggestions"
|
||||
>
|
||||
<div class="accordion" id="expandedSuggestions">
|
||||
<div class="accordion-item">
|
||||
<h2
|
||||
class="accordion-header"
|
||||
id="heading_expanded_suggestions"
|
||||
>
|
||||
<h2 class="accordion-header" id="heading_expanded_suggestions">
|
||||
<button
|
||||
v-if="isExpanded"
|
||||
class="accordion-button"
|
||||
@@ -74,105 +58,107 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="!hasResult"
|
||||
class="noResult"
|
||||
>
|
||||
<div v-if="!hasResult" class="noResult">
|
||||
<div class="chill-no-data-statement">
|
||||
{{ $t('goal_has_no_result') }}
|
||||
{{ $t("goal_has_no_result") }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
fr: {
|
||||
add_a_result: "Résultat - orientation disponibles",
|
||||
goal_has_no_result: "Aucun résultat - orientation disponible",
|
||||
}
|
||||
}
|
||||
messages: {
|
||||
fr: {
|
||||
add_a_result: "Résultat - orientation disponibles",
|
||||
goal_has_no_result: "Aucun résultat - orientation disponible",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "AddResult",
|
||||
props: ['destination', 'goal', 'availableResults'],
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
isExpanded: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
hasResult() {
|
||||
if (this.destination === 'action') {
|
||||
return this.$store.state.resultsForAction.length > 0;
|
||||
} else if (this.destination === 'goal') {
|
||||
return this.$store.getters.resultsForGoal(this.goal).length > 0;
|
||||
}
|
||||
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
pickedResults() {
|
||||
if (this.destination === 'action') {
|
||||
return this.$store.state.resultsPicked;
|
||||
} else if (this.destination === 'goal') {
|
||||
return this.$store.getters.resultsPickedForGoal(this.goal);
|
||||
}
|
||||
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
availableForCheckResults() {
|
||||
if (this.destination === 'action') {
|
||||
let pickedIds = this.$store.state.resultsPicked.map(r => r.id);
|
||||
|
||||
return this.$store.state.resultsForAction.filter(r => !pickedIds.includes(r.id));
|
||||
} else if (this.destination === 'goal') {
|
||||
let pickedIds = this.$store.getters.resultsPickedForGoal(this.goal).map(r => r.id);
|
||||
|
||||
return this.$store.getters.resultsForGoal(this.goal).filter(r => !pickedIds.includes(r.id));
|
||||
}
|
||||
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
name: "AddResult",
|
||||
props: ["destination", "goal", "availableResults"],
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
isExpanded: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
hasResult() {
|
||||
if (this.destination === "action") {
|
||||
return this.$store.state.resultsForAction.length > 0;
|
||||
} else if (this.destination === "goal") {
|
||||
return this.$store.getters.resultsForGoal(this.goal).length > 0;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toggleSelect() {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
},
|
||||
addResult(r) {
|
||||
|
||||
if (this.destination === 'action') {
|
||||
this.$store.commit('addResultPicked', r);
|
||||
return;
|
||||
} else if (this.destination === 'goal') {
|
||||
this.$store.commit('addResultForGoalPicked', {goal: this.goal, result: r});
|
||||
return;
|
||||
}
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
removeResult(r) {
|
||||
|
||||
if (this.destination === 'action') {
|
||||
this.$store.commit('removeResultPicked', r);
|
||||
return;
|
||||
} else if (this.destination === 'goal') {
|
||||
this.$store.commit('removeResultForGoalPicked', {goal: this.goal, result: r});
|
||||
return;
|
||||
}
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
pickedResults() {
|
||||
if (this.destination === "action") {
|
||||
return this.$store.state.resultsPicked;
|
||||
} else if (this.destination === "goal") {
|
||||
return this.$store.getters.resultsPickedForGoal(this.goal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
availableForCheckResults() {
|
||||
if (this.destination === "action") {
|
||||
let pickedIds = this.$store.state.resultsPicked.map((r) => r.id);
|
||||
|
||||
return this.$store.state.resultsForAction.filter(
|
||||
(r) => !pickedIds.includes(r.id),
|
||||
);
|
||||
} else if (this.destination === "goal") {
|
||||
let pickedIds = this.$store.getters
|
||||
.resultsPickedForGoal(this.goal)
|
||||
.map((r) => r.id);
|
||||
|
||||
return this.$store.getters
|
||||
.resultsForGoal(this.goal)
|
||||
.filter((r) => !pickedIds.includes(r.id));
|
||||
}
|
||||
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
toggleSelect() {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
},
|
||||
addResult(r) {
|
||||
if (this.destination === "action") {
|
||||
this.$store.commit("addResultPicked", r);
|
||||
return;
|
||||
} else if (this.destination === "goal") {
|
||||
this.$store.commit("addResultForGoalPicked", {
|
||||
goal: this.goal,
|
||||
result: r,
|
||||
});
|
||||
return;
|
||||
}
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
removeResult(r) {
|
||||
if (this.destination === "action") {
|
||||
this.$store.commit("removeResultPicked", r);
|
||||
return;
|
||||
} else if (this.destination === "goal") {
|
||||
this.$store.commit("removeResultForGoalPicked", {
|
||||
goal: this.goal,
|
||||
result: r,
|
||||
});
|
||||
return;
|
||||
}
|
||||
throw Error(`this.destination is not implemented: ${this.destination}`);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.accordion-button {
|
||||
padding: .25rem;
|
||||
padding: 0.25rem;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
@@ -19,55 +19,55 @@
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
|
||||
{{ $t('evaluation_startdate') }}
|
||||
{{ $t("evaluation_startdate") }}
|
||||
</label>
|
||||
<div class="col-8 col-sm-4 col-md-8 col-lg-4">
|
||||
<input
|
||||
class="form-control form-control-sm"
|
||||
type="date"
|
||||
v-model="startDate"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
|
||||
{{ $t('evaluation_enddate') }}
|
||||
{{ $t("evaluation_enddate") }}
|
||||
</label>
|
||||
<div class="col-8 col-sm-4 col-md-8 col-lg-4">
|
||||
<input
|
||||
class="form-control form-control-sm"
|
||||
type="date"
|
||||
v-model="endDate"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
|
||||
{{ $t('evaluation_maxdate') }}
|
||||
{{ $t("evaluation_maxdate") }}
|
||||
</label>
|
||||
<div class="col-8 col-sm-4 col-md-8 col-lg-4">
|
||||
<input
|
||||
class="form-control form-control-sm"
|
||||
type="date"
|
||||
v-model="maxDate"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
|
||||
{{ $t('evaluation_warning_interval') }}
|
||||
{{ $t("evaluation_warning_interval") }}
|
||||
</label>
|
||||
<div class="col-8 col-sm-4 col-md-8 col-lg-4">
|
||||
<input
|
||||
class="form-control form-control-sm"
|
||||
type="number"
|
||||
v-model.number="warningInterval"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
|
||||
{{ $t('evaluation_time_spent') }}
|
||||
{{ $t("evaluation_time_spent") }}
|
||||
</label>
|
||||
<div class="col-8 col-sm-4 col-md-8 col-lg-4">
|
||||
<select
|
||||
@@ -75,11 +75,8 @@
|
||||
type="time"
|
||||
v-model="timeSpent"
|
||||
>
|
||||
<option
|
||||
disabled
|
||||
value=""
|
||||
>
|
||||
{{ $t('select_time_spent') }}
|
||||
<option disabled value="">
|
||||
{{ $t("select_time_spent") }}
|
||||
</option>
|
||||
<option
|
||||
v-for="(time, index) in timeSpentChoices"
|
||||
@@ -93,7 +90,9 @@
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-4 col-form-label visually-hidden">{{ $t('evaluation_public_comment') }}</label>
|
||||
<label class="col-sm-4 col-form-label visually-hidden">{{
|
||||
$t("evaluation_public_comment")
|
||||
}}</label>
|
||||
<div class="col-sm-12">
|
||||
<ckeditor
|
||||
:editor="editor"
|
||||
@@ -104,25 +103,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="evaluation.documents.length > 0"
|
||||
class="row mb-3"
|
||||
>
|
||||
<h5>{{ $t('Documents') }} :</h5>
|
||||
<div v-if="evaluation.documents.length > 0" class="row mb-3">
|
||||
<h5>{{ $t("Documents") }} :</h5>
|
||||
|
||||
<div class="flex-table">
|
||||
<div
|
||||
class="item-bloc"
|
||||
v-for="(d, i) in evaluation.documents"
|
||||
:key="d.id"
|
||||
:class="[parseInt(this.docAnchorId) === d.id ? 'bg-blink' : 'nothing']"
|
||||
:class="[
|
||||
parseInt(this.docAnchorId) === d.id ? 'bg-blink' : 'nothing',
|
||||
]"
|
||||
>
|
||||
<div
|
||||
:id="`document_${d.id}`"
|
||||
class="item-row"
|
||||
>
|
||||
<div :id="`document_${d.id}`" class="item-row">
|
||||
<div class="input-group input-group-lg mb-3 row">
|
||||
<label class="col-sm-3 col-form-label">Titre du document:</label>
|
||||
<label class="col-sm-3 col-form-label"
|
||||
>Titre du document:</label
|
||||
>
|
||||
<div class="col-sm-9">
|
||||
<input
|
||||
class="form-control document-title"
|
||||
@@ -131,18 +128,15 @@
|
||||
:id="d.id"
|
||||
:data-key="i"
|
||||
@input="onInputDocumentTitle"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-row">
|
||||
<div class="item-col item-meta">
|
||||
<p
|
||||
v-if="d.createdBy"
|
||||
class="createdBy"
|
||||
>
|
||||
Créé par {{ d.createdBy.text }}<br>
|
||||
Le {{ $d(ISOToDatetime(d.createdAt.datetime), 'long') }}
|
||||
<p v-if="d.createdBy" class="createdBy">
|
||||
Créé par {{ d.createdBy.text }}<br />
|
||||
Le {{ $d(ISOToDatetime(d.createdAt.datetime), "long") }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -157,8 +151,10 @@
|
||||
:related-entity-id="d.id"
|
||||
:workflows-availables="d.workflows_availables"
|
||||
:prevent-default-move-to-generate="true"
|
||||
:go-to-generate-workflow-payload="{doc: d}"
|
||||
@go-to-generate-workflow="goToGenerateWorkflowEvaluationDocument"
|
||||
:go-to-generate-workflow-payload="{ doc: d }"
|
||||
@go-to-generate-workflow="
|
||||
goToGenerateWorkflowEvaluationDocument
|
||||
"
|
||||
/>
|
||||
</li>
|
||||
<li>
|
||||
@@ -176,7 +172,7 @@
|
||||
data-bs-toggle="dropdown"
|
||||
aria-expanded="false"
|
||||
>
|
||||
|
||||
|
||||
</button>
|
||||
<ul
|
||||
class="dropdown-menu"
|
||||
@@ -186,13 +182,15 @@
|
||||
<a
|
||||
class="dropdown-item"
|
||||
@click="goToGenerateDocumentNotification(d, true)"
|
||||
>{{ $t('notification_notify_referrer') }}</a>
|
||||
>{{ $t("notification_notify_referrer") }}</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
class="dropdown-item"
|
||||
@click="goToGenerateDocumentNotification(d, false)"
|
||||
>{{ $t('notification_notify_any') }}</a>
|
||||
>{{ $t("notification_notify_any") }}</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@@ -204,7 +202,9 @@
|
||||
:can-edit="true"
|
||||
:execute-before-leave="submitBeforeLeaveToEditor"
|
||||
:dav-link="d.storedObject._links?.dav_link.href"
|
||||
:dav-link-expiration="d.storedObject._links?.dav_link.expiration"
|
||||
:dav-link-expiration="
|
||||
d.storedObject._links?.dav_link.expiration
|
||||
"
|
||||
@on-stored-object-status-change="onStatusDocumentChanged"
|
||||
/>
|
||||
</li>
|
||||
@@ -212,15 +212,12 @@
|
||||
<add-async-upload
|
||||
:button-title="$t('replace')"
|
||||
:options="asyncUploadOptions"
|
||||
:btn-classes="{'btn': true, 'btn-edit': true}"
|
||||
:btn-classes="{ btn: true, 'btn-edit': true }"
|
||||
@add-document="(arg) => replaceDocument(d, arg)"
|
||||
/>
|
||||
</li>
|
||||
<li v-if="d.workflows.length === 0">
|
||||
<a
|
||||
class="btn btn-delete"
|
||||
@click="removeDocument(d)"
|
||||
/>
|
||||
<a class="btn btn-delete" @click="removeDocument(d)" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -230,7 +227,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<h6>{{ $t('document_add') }} :</h6>
|
||||
<h6>{{ $t("document_add") }} :</h6>
|
||||
<pick-template
|
||||
entity-class="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation"
|
||||
:id="evaluation.id"
|
||||
@@ -239,11 +236,13 @@
|
||||
@go-to-generate-document="submitBeforeGenerate"
|
||||
>
|
||||
<template #title>
|
||||
<label class="col-form-label">{{ $t('evaluation_generate_a_document') }}</label>
|
||||
<label class="col-form-label">{{
|
||||
$t("evaluation_generate_a_document")
|
||||
}}</label>
|
||||
</template>
|
||||
</pick-template>
|
||||
<div>
|
||||
<label class="col-form-label">{{ $t('document_upload') }}</label>
|
||||
<label class="col-form-label">{{ $t("document_upload") }}</label>
|
||||
<ul class="record_actions document-upload">
|
||||
<li>
|
||||
<add-async-upload
|
||||
@@ -260,266 +259,395 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {ISOToDatetime} from 'ChillMainAssets/chill/js/date';
|
||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/editor_config';
|
||||
import { mapState } from 'vuex';
|
||||
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
|
||||
import {buildLink} from 'ChillDocGeneratorAssets/lib/document-generator';
|
||||
import AddAsyncUpload from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUpload.vue';
|
||||
import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue';
|
||||
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
|
||||
import {buildLinkCreate as buildLinkCreateNotification} from 'ChillMainAssets/lib/entity-notification/api';
|
||||
import { ISOToDatetime } from "ChillMainAssets/chill/js/date";
|
||||
import CKEditor from "@ckeditor/ckeditor5-vue";
|
||||
import ClassicEditor from "ChillMainAssets/module/ckeditor5/editor_config";
|
||||
import { mapState } from "vuex";
|
||||
import PickTemplate from "ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue";
|
||||
import { buildLink } from "ChillDocGeneratorAssets/lib/document-generator";
|
||||
import AddAsyncUpload from "ChillDocStoreAssets/vuejs/_components/AddAsyncUpload.vue";
|
||||
import ListWorkflowModal from "ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue";
|
||||
import { buildLinkCreate } from "ChillMainAssets/lib/entity-workflow/api.js";
|
||||
import { buildLinkCreate as buildLinkCreateNotification } from "ChillMainAssets/lib/entity-notification/api";
|
||||
import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue";
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
fr: {
|
||||
evaluation_title: "Ecrire une évaluation",
|
||||
evaluation_status: "Statut",
|
||||
evaluation_choose_a_status: "Choisir un statut",
|
||||
evaluation_startdate: "Date d'ouverture",
|
||||
evaluation_enddate: "Date de fin",
|
||||
evaluation_maxdate: "Date d'échéance",
|
||||
evaluation_warning_interval: "Rappel (jours)",
|
||||
evaluation_public_comment: "Note publique",
|
||||
evaluation_comment_placeholder: "Commencez à écrire ...",
|
||||
evaluation_generate_a_document: "Générer un document",
|
||||
evaluation_choose_a_template: "Choisir un modèle",
|
||||
evaluation_add_a_document: "Ajouter un document",
|
||||
evaluation_add: "Ajouter une évaluation",
|
||||
evaluation_time_spent: "Temps de rédaction",
|
||||
select_time_spent: "Indiquez le temps de rédaction",
|
||||
Documents: "Documents",
|
||||
document_add: "Générer ou téléverser un document",
|
||||
document_upload: "Téléverser un document",
|
||||
document_title: "Titre du document",
|
||||
template_title: "Nom du template",
|
||||
browse: "Ajouter un document",
|
||||
replace: "Remplacer",
|
||||
download: "Télécharger le fichier existant",
|
||||
notification_notify_referrer: "Notifier le référent",
|
||||
notification_notify_any: "Notifier d'autres utilisateurs",
|
||||
notification_send: "Envoyer une notification",
|
||||
}
|
||||
}
|
||||
messages: {
|
||||
fr: {
|
||||
evaluation_title: "Ecrire une évaluation",
|
||||
evaluation_status: "Statut",
|
||||
evaluation_choose_a_status: "Choisir un statut",
|
||||
evaluation_startdate: "Date d'ouverture",
|
||||
evaluation_enddate: "Date de fin",
|
||||
evaluation_maxdate: "Date d'échéance",
|
||||
evaluation_warning_interval: "Rappel (jours)",
|
||||
evaluation_public_comment: "Note publique",
|
||||
evaluation_comment_placeholder: "Commencez à écrire ...",
|
||||
evaluation_generate_a_document: "Générer un document",
|
||||
evaluation_choose_a_template: "Choisir un modèle",
|
||||
evaluation_add_a_document: "Ajouter un document",
|
||||
evaluation_add: "Ajouter une évaluation",
|
||||
evaluation_time_spent: "Temps de rédaction",
|
||||
select_time_spent: "Indiquez le temps de rédaction",
|
||||
Documents: "Documents",
|
||||
document_add: "Générer ou téléverser un document",
|
||||
document_upload: "Téléverser un document",
|
||||
document_title: "Titre du document",
|
||||
template_title: "Nom du template",
|
||||
browse: "Ajouter un document",
|
||||
replace: "Remplacer",
|
||||
download: "Télécharger le fichier existant",
|
||||
notification_notify_referrer: "Notifier le référent",
|
||||
notification_notify_any: "Notifier d'autres utilisateurs",
|
||||
notification_send: "Envoyer une notification",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "FormEvaluation",
|
||||
props: ['evaluation', 'docAnchorId'],
|
||||
components: {
|
||||
ckeditor: CKEditor.component,
|
||||
PickTemplate,
|
||||
AddAsyncUpload,
|
||||
ListWorkflowModal,
|
||||
DocumentActionButtonsGroup,
|
||||
},
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
template: null,
|
||||
asyncUploadOptions: {
|
||||
maxFiles: 1,
|
||||
maxPostSize: 15000000,
|
||||
required: false,
|
||||
},
|
||||
timeSpentChoices: [
|
||||
{ text: '1 minute', value: 60 }, { text: '2 minutes', value: 120 },
|
||||
{ text: '3 minutes', value: 180 }, { text: '4 minutes', value: 240 },
|
||||
{ text: '5 minutes', value: 300 }, { text: '10 minutes', value: 600 },
|
||||
{ text: '15 minutes', value: 900 },{ text: '20 minutes', value: 1200 },
|
||||
{ text: '25 minutes', value: 1500 }, { text: '30 minutes', value: 1800 },
|
||||
{ text: '45 minutes', value: 2700 },{ text: '1 hour', value: 3600 },
|
||||
{ text: '1 hour 15 minutes', value: 4500 }, { text: '1 hour 30 minutes', value: 5400 },
|
||||
{ text: '1 hour 45 minutes', value: 6300 }, { text: '2 hours', value: 7200 },
|
||||
{ text: '2 hours 30 minutes', value: 9000 }, { text: '3 hours', value: 10800 },
|
||||
{ text: '3 hours 30 minutes', value: 12600 },{ text: '4 hours', value: 14400 },
|
||||
{ text: '4 hours 30 minutes', value: 16200 },{ text: '5 hours', value: 18000 },
|
||||
{ text: '5 hours 30 minutes', value: 19800 },{ text: '6 hours', value: 21600 },
|
||||
{ text: '6 hours 30 minutes', value: 23400 },{ text: '7 hours', value: 25200 },
|
||||
{ text: '7 hours 30 minutes', value: 27000 },{ text: '8 hours', value: 28800 },
|
||||
]
|
||||
name: "FormEvaluation",
|
||||
props: ["evaluation", "docAnchorId"],
|
||||
components: {
|
||||
ckeditor: CKEditor.component,
|
||||
PickTemplate,
|
||||
AddAsyncUpload,
|
||||
ListWorkflowModal,
|
||||
DocumentActionButtonsGroup,
|
||||
},
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
template: null,
|
||||
asyncUploadOptions: {
|
||||
maxFiles: 1,
|
||||
maxPostSize: 15000000,
|
||||
required: false,
|
||||
},
|
||||
timeSpentChoices: [
|
||||
{ text: "1 minute", value: 60 },
|
||||
{ text: "2 minutes", value: 120 },
|
||||
{ text: "3 minutes", value: 180 },
|
||||
{ text: "4 minutes", value: 240 },
|
||||
{ text: "5 minutes", value: 300 },
|
||||
{ text: "10 minutes", value: 600 },
|
||||
{ text: "15 minutes", value: 900 },
|
||||
{ text: "20 minutes", value: 1200 },
|
||||
{ text: "25 minutes", value: 1500 },
|
||||
{ text: "30 minutes", value: 1800 },
|
||||
{ text: "45 minutes", value: 2700 },
|
||||
{ text: "1 hour", value: 3600 },
|
||||
{ text: "1 hour 15 minutes", value: 4500 },
|
||||
{ text: "1 hour 30 minutes", value: 5400 },
|
||||
{ text: "1 hour 45 minutes", value: 6300 },
|
||||
{ text: "2 hours", value: 7200 },
|
||||
{ text: "2 hours 30 minutes", value: 9000 },
|
||||
{ text: "3 hours", value: 10800 },
|
||||
{ text: "3 hours 30 minutes", value: 12600 },
|
||||
{ text: "4 hours", value: 14400 },
|
||||
{ text: "4 hours 30 minutes", value: 16200 },
|
||||
{ text: "5 hours", value: 18000 },
|
||||
{ text: "5 hours 30 minutes", value: 19800 },
|
||||
{ text: "6 hours", value: 21600 },
|
||||
{ text: "6 hours 30 minutes", value: 23400 },
|
||||
{ text: "7 hours", value: 25200 },
|
||||
{ text: "7 hours 30 minutes", value: 27000 },
|
||||
{ text: "8 hours", value: 28800 },
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["isPosting", "work", "me"]),
|
||||
AmIRefferer() {
|
||||
return !(
|
||||
this.$store.state.work.accompanyingPeriod.user &&
|
||||
this.$store.state.me &&
|
||||
this.$store.state.work.accompanyingPeriod.user.id !==
|
||||
this.$store.state.me.id
|
||||
);
|
||||
},
|
||||
getTemplatesAvailables() {
|
||||
return this.$store.getters.getTemplatesAvailablesForEvaluation(
|
||||
this.evaluation.evaluation,
|
||||
);
|
||||
},
|
||||
canGenerate() {
|
||||
return !this.$store.state.isPosting && this.template !== null;
|
||||
},
|
||||
startDate: {
|
||||
get() {
|
||||
console.log("evaluation", this.evaluation);
|
||||
return this.evaluation.startDate;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit("setEvaluationStartDate", {
|
||||
key: this.evaluation.key,
|
||||
date: v,
|
||||
});
|
||||
},
|
||||
},
|
||||
endDate: {
|
||||
get() {
|
||||
return this.evaluation.endDate;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit("setEvaluationEndDate", {
|
||||
key: this.evaluation.key,
|
||||
date: v,
|
||||
});
|
||||
},
|
||||
},
|
||||
maxDate: {
|
||||
get() {
|
||||
return this.evaluation.maxDate;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit("setEvaluationMaxDate", {
|
||||
key: this.evaluation.key,
|
||||
date: v,
|
||||
});
|
||||
},
|
||||
},
|
||||
warningInterval: {
|
||||
get() {
|
||||
return this.evaluation.warningInterval;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit("setEvaluationWarningInterval", {
|
||||
key: this.evaluation.key,
|
||||
days: v,
|
||||
});
|
||||
},
|
||||
},
|
||||
timeSpent: {
|
||||
get() {
|
||||
return this.evaluation.timeSpent;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit("setEvaluationTimeSpent", {
|
||||
key: this.evaluation.key,
|
||||
time: v,
|
||||
});
|
||||
},
|
||||
},
|
||||
comment: {
|
||||
get() {
|
||||
return this.evaluation.comment;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit("setEvaluationComment", {
|
||||
key: this.evaluation.key,
|
||||
comment: v,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
ISOToDatetime,
|
||||
listAllStatus() {
|
||||
console.log("load all status");
|
||||
let url = `/api/`;
|
||||
fetch(url).then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
throw { m: "yeeah", s: response.status, b: response.body };
|
||||
});
|
||||
},
|
||||
buildEditLink(document) {
|
||||
return (
|
||||
`/chill/wopi/edit/${document.storedObject.uuid}?returnPath=` +
|
||||
encodeURIComponent(
|
||||
window.location.pathname +
|
||||
window.location.search +
|
||||
window.location.hash,
|
||||
)
|
||||
);
|
||||
},
|
||||
submitBeforeLeaveToEditor() {
|
||||
console.log("submit beore edit 2");
|
||||
// empty callback
|
||||
const callback = () => null;
|
||||
return this.$store.dispatch("submit", callback).catch((e) => {
|
||||
console.log(e);
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
submitBeforeEdit(storedObject) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(
|
||||
(e) => e.key === this.evaluation.key,
|
||||
);
|
||||
let document = evaluation.documents.find(
|
||||
(d) => d.storedObject.id === storedObject.id,
|
||||
);
|
||||
//console.log('=> document', document);
|
||||
window.location.assign(this.buildEditLink(document));
|
||||
};
|
||||
return this.$store.dispatch("submit", callback).catch((e) => {
|
||||
console.log(e);
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
submitBeforeGenerate({ template }) {
|
||||
const callback = (data) => {
|
||||
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(
|
||||
(e) => e.key === this.evaluation.key,
|
||||
).id;
|
||||
|
||||
window.location.assign(
|
||||
buildLink(
|
||||
template,
|
||||
evaluationId,
|
||||
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation",
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
return this.$store.dispatch("submit", callback).catch((e) => {
|
||||
console.log(e);
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
onInputDocumentTitle(event) {
|
||||
const id = Number(event.target.id);
|
||||
const key = Number(event.target.dataset.key) + 1;
|
||||
const title = event.target.value;
|
||||
this.$store.commit("updateDocumentTitle", {
|
||||
id: id,
|
||||
key: key,
|
||||
evaluationKey: this.evaluation.key,
|
||||
title: title,
|
||||
});
|
||||
},
|
||||
addDocument(storedObject) {
|
||||
let document = {
|
||||
type: "accompanying_period_work_evaluation_document",
|
||||
storedObject: storedObject,
|
||||
title: "Nouveau document",
|
||||
};
|
||||
this.$store.commit("addDocument", {
|
||||
key: this.evaluation.key,
|
||||
document: document,
|
||||
});
|
||||
},
|
||||
replaceDocument(oldDocument, storedObject) {
|
||||
let document = {
|
||||
type: "accompanying_period_work_evaluation_document",
|
||||
storedObject: storedObject,
|
||||
title: oldDocument.title,
|
||||
};
|
||||
this.$store.commit("replaceDocument", {
|
||||
key: this.evaluation.key,
|
||||
document: document,
|
||||
oldDocument: oldDocument,
|
||||
});
|
||||
},
|
||||
removeDocument(document) {
|
||||
if (
|
||||
window.confirm(
|
||||
'Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre "' +
|
||||
document.title +
|
||||
'" ?',
|
||||
)
|
||||
) {
|
||||
this.$store.commit("removeDocument", {
|
||||
key: this.evaluation.key,
|
||||
document: document,
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState([
|
||||
'isPosting',
|
||||
'work',
|
||||
'me',
|
||||
]),
|
||||
AmIRefferer() {
|
||||
return (!(this.$store.state.work.accompanyingPeriod.user && this.$store.state.me
|
||||
&& (this.$store.state.work.accompanyingPeriod.user.id !== this.$store.state.me.id)));
|
||||
},
|
||||
getTemplatesAvailables() {
|
||||
return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation);
|
||||
},
|
||||
canGenerate() {
|
||||
return !this.$store.state.isPosting && this.template !== null;
|
||||
},
|
||||
startDate: {
|
||||
get() {
|
||||
console.log('evaluation', this.evaluation);
|
||||
return this.evaluation.startDate;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: v });
|
||||
}
|
||||
},
|
||||
endDate: {
|
||||
get() {
|
||||
return this.evaluation.endDate;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: v });
|
||||
}
|
||||
},
|
||||
maxDate: {
|
||||
get() {
|
||||
return this.evaluation.maxDate;
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: v });
|
||||
}
|
||||
},
|
||||
warningInterval: {
|
||||
get() { return this.evaluation.warningInterval; },
|
||||
set(v) { this.$store.commit('setEvaluationWarningInterval', { key: this.evaluation.key, days: v }); }
|
||||
},
|
||||
timeSpent: {
|
||||
get() { return this.evaluation.timeSpent },
|
||||
set(v) { this.$store.commit('setEvaluationTimeSpent', { key: this.evaluation.key, time: v}) }
|
||||
},
|
||||
comment: {
|
||||
get() { return this.evaluation.comment; },
|
||||
set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); }
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
ISOToDatetime,
|
||||
listAllStatus() {
|
||||
console.log('load all status');
|
||||
let url = `/api/`;
|
||||
fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
throw { m: 'yeeah', s: response.status, b: response.body };
|
||||
})
|
||||
;
|
||||
},
|
||||
buildEditLink(document) {
|
||||
return `/chill/wopi/edit/${document.storedObject.uuid}?returnPath=` + encodeURIComponent(
|
||||
window.location.pathname + window.location.search + window.location.hash);
|
||||
},
|
||||
submitBeforeLeaveToEditor() {
|
||||
console.log('submit beore edit 2');
|
||||
// empty callback
|
||||
const callback = () => null;
|
||||
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
|
||||
},
|
||||
submitBeforeEdit(storedObject) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
|
||||
let document = evaluation.documents.find(d => d.storedObject.id === storedObject.id);
|
||||
//console.log('=> document', document);
|
||||
window.location.assign(this.buildEditLink(document));
|
||||
};
|
||||
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
|
||||
},
|
||||
submitBeforeGenerate({template}) {
|
||||
const callback = (data) => {
|
||||
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id;
|
||||
},
|
||||
onStatusDocumentChanged(newStatus) {
|
||||
console.log("onStatusDocumentChanged", newStatus);
|
||||
this.$store.commit("statusDocumentChanged", {
|
||||
key: this.evaluation.key,
|
||||
newStatus: newStatus,
|
||||
});
|
||||
},
|
||||
goToGenerateWorkflowEvaluationDocument({
|
||||
event,
|
||||
link,
|
||||
workflowName,
|
||||
payload,
|
||||
}) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(
|
||||
(e) => e.key === this.evaluation.key,
|
||||
);
|
||||
let updatedDocument = evaluation.documents.find(
|
||||
(d) => d.key === payload.doc.key,
|
||||
);
|
||||
window.location.assign(
|
||||
buildLinkCreate(
|
||||
workflowName,
|
||||
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument",
|
||||
updatedDocument.id,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
window.location.assign(buildLink(template, evaluationId, 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation'));
|
||||
};
|
||||
|
||||
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
|
||||
},
|
||||
onInputDocumentTitle(event) {
|
||||
const id = Number(event.target.id);
|
||||
const key = Number(event.target.dataset.key) + 1;
|
||||
const title = event.target.value;
|
||||
this.$store.commit('updateDocumentTitle', {id: id, key: key, evaluationKey: this.evaluation.key, title: title});
|
||||
},
|
||||
addDocument(storedObject) {
|
||||
let document = {
|
||||
type: 'accompanying_period_work_evaluation_document',
|
||||
storedObject: storedObject,
|
||||
title: 'Nouveau document',
|
||||
};
|
||||
this.$store.commit('addDocument', {key: this.evaluation.key, document: document});
|
||||
},
|
||||
replaceDocument(oldDocument, storedObject) {
|
||||
let document = {
|
||||
type: 'accompanying_period_work_evaluation_document',
|
||||
storedObject: storedObject,
|
||||
title: oldDocument.title
|
||||
};
|
||||
this.$store.commit('replaceDocument', {key: this.evaluation.key, document: document, oldDocument: oldDocument});
|
||||
},
|
||||
removeDocument(document) {
|
||||
if (window.confirm("Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre \"" + document.title +"\" ?")) {
|
||||
this.$store.commit('removeDocument', {key: this.evaluation.key, document: document});
|
||||
}
|
||||
},
|
||||
onStatusDocumentChanged(newStatus) {
|
||||
console.log('onStatusDocumentChanged', newStatus);
|
||||
this.$store.commit('statusDocumentChanged', {key: this.evaluation.key, newStatus: newStatus});
|
||||
},
|
||||
goToGenerateWorkflowEvaluationDocument({event, link, workflowName, payload}) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
|
||||
let updatedDocument = evaluation.documents.find(d => d.key === payload.doc.key);
|
||||
window.location.assign(buildLinkCreate(workflowName,
|
||||
'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', updatedDocument.id));
|
||||
};
|
||||
|
||||
return this.$store.dispatch('submit', callback)
|
||||
.catch(e => { console.log(e); throw e; });
|
||||
},
|
||||
goToGenerateDocumentNotification(document, tos) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
|
||||
let updatedDocument = evaluation.documents.find(d => d.key === document.key);
|
||||
window.location.assign(buildLinkCreateNotification(
|
||||
'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument',
|
||||
updatedDocument.id,
|
||||
tos === true ? this.$store.state.work.accompanyingPeriod.user.id : null,
|
||||
window.location.pathname + window.location.search + window.location.hash
|
||||
));
|
||||
};
|
||||
return this.$store.dispatch('submit', callback)
|
||||
.catch(e => {console.log(e); throw e});
|
||||
}
|
||||
},
|
||||
}
|
||||
return this.$store.dispatch("submit", callback).catch((e) => {
|
||||
console.log(e);
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
goToGenerateDocumentNotification(document, tos) {
|
||||
const callback = (data) => {
|
||||
let evaluation = data.accompanyingPeriodWorkEvaluations.find(
|
||||
(e) => e.key === this.evaluation.key,
|
||||
);
|
||||
let updatedDocument = evaluation.documents.find(
|
||||
(d) => d.key === document.key,
|
||||
);
|
||||
window.location.assign(
|
||||
buildLinkCreateNotification(
|
||||
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument",
|
||||
updatedDocument.id,
|
||||
tos === true
|
||||
? this.$store.state.work.accompanyingPeriod.user.id
|
||||
: null,
|
||||
window.location.pathname +
|
||||
window.location.search +
|
||||
window.location.hash,
|
||||
),
|
||||
);
|
||||
};
|
||||
return this.$store.dispatch("submit", callback).catch((e) => {
|
||||
console.log(e);
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
input.document-title {
|
||||
font-weight: bold;
|
||||
font-size: 1rem;
|
||||
}
|
||||
ul.document-upload {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
input.document-title {
|
||||
font-weight: bold;
|
||||
font-size: 1rem;
|
||||
}
|
||||
ul.document-upload {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.bg-blink{
|
||||
color: #050000;
|
||||
padding: 10px;
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
animation: blinkingBackground 2.2s infinite;
|
||||
animation-iteration-count: 2;
|
||||
}
|
||||
.bg-blink {
|
||||
color: #050000;
|
||||
padding: 10px;
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
animation: blinkingBackground 2.2s infinite;
|
||||
animation-iteration-count: 2;
|
||||
}
|
||||
|
||||
@keyframes blinkingBackground{
|
||||
0% { background-color: #ed776d;}
|
||||
50% { background-color: #ffffff;}
|
||||
100% { background-color: #ed776d;}
|
||||
}
|
||||
@keyframes blinkingBackground {
|
||||
0% {
|
||||
background-color: #ed776d;
|
||||
}
|
||||
50% {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
100% {
|
||||
background-color: #ed776d;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,24 +1,24 @@
|
||||
import { createApp } from 'vue';
|
||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
import { store } from './store';
|
||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
|
||||
import 'vue-toast-notification/dist/theme-sugar.css';
|
||||
import App from './App.vue';
|
||||
import { createApp } from "vue";
|
||||
import { _createI18n } from "ChillMainAssets/vuejs/_js/i18n";
|
||||
import { store } from "./store";
|
||||
import { personMessages } from "ChillPersonAssets/vuejs/_js/i18n";
|
||||
import "vue-toast-notification/dist/theme-sugar.css";
|
||||
import App from "./App.vue";
|
||||
import ToastPlugin from "vue-toast-notification";
|
||||
|
||||
const i18n = _createI18n(personMessages);
|
||||
|
||||
/* exported app */
|
||||
const app = createApp({
|
||||
template: `<app></app>`,
|
||||
template: `<app></app>`,
|
||||
})
|
||||
.use(store)
|
||||
.use(ToastPlugin, {
|
||||
position: "bottom-right",
|
||||
type: "error",
|
||||
duration: 10000,
|
||||
dismissible: true
|
||||
})
|
||||
.use(i18n)
|
||||
.component('app', App)
|
||||
.mount('#accompanying_course_work_edit');
|
||||
.use(store)
|
||||
.use(ToastPlugin, {
|
||||
position: "bottom-right",
|
||||
type: "error",
|
||||
duration: 10000,
|
||||
dismissible: true,
|
||||
})
|
||||
.use(i18n)
|
||||
.component("app", App)
|
||||
.mount("#accompanying_course_work_edit");
|
||||
|
@@ -1,18 +1,28 @@
|
||||
import { createStore } from 'vuex';
|
||||
import { dateToISO, ISOToDate, datetimeToISO, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date';
|
||||
import { fetchResults, makeFetch } from 'ChillMainAssets/lib/api/apiMethods.ts';
|
||||
import { fetchTemplates } from 'ChillDocGeneratorAssets/api/pickTemplate.js';
|
||||
import { createStore } from "vuex";
|
||||
import {
|
||||
dateToISO,
|
||||
ISOToDate,
|
||||
datetimeToISO,
|
||||
intervalDaysToISO,
|
||||
intervalISOToDays,
|
||||
} from "ChillMainAssets/chill/js/date";
|
||||
import { fetchResults, makeFetch } from "ChillMainAssets/lib/api/apiMethods.ts";
|
||||
import { fetchTemplates } from "ChillDocGeneratorAssets/api/pickTemplate.js";
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const debug = process.env.NODE_ENV !== "production";
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state: {
|
||||
work: window.accompanyingCourseWork,
|
||||
startDate: window.accompanyingCourseWork.startDate !== null ?
|
||||
dateToISO(new Date(window.accompanyingCourseWork.startDate.datetime)) : null,
|
||||
endDate: window.accompanyingCourseWork.endDate !== null ?
|
||||
dateToISO(new Date(window.accompanyingCourseWork.endDate.datetime)) : null,
|
||||
startDate:
|
||||
window.accompanyingCourseWork.startDate !== null
|
||||
? dateToISO(new Date(window.accompanyingCourseWork.startDate.datetime))
|
||||
: null,
|
||||
endDate:
|
||||
window.accompanyingCourseWork.endDate !== null
|
||||
? dateToISO(new Date(window.accompanyingCourseWork.endDate.datetime))
|
||||
: null,
|
||||
note: window.accompanyingCourseWork.note,
|
||||
privateComment: window.accompanyingCourseWork.privateComment,
|
||||
goalsPicked: window.accompanyingCourseWork.goals,
|
||||
@@ -25,15 +35,17 @@ const store = createStore({
|
||||
templatesAvailablesForAction: [],
|
||||
templatesAvailablesForEvaluation: new Map([]),
|
||||
personsPicked: window.accompanyingCourseWork.persons,
|
||||
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
|
||||
.map(p => p.person),
|
||||
personsReachables:
|
||||
window.accompanyingCourseWork.accompanyingPeriod.participations
|
||||
.filter((p) => p.endDate == null)
|
||||
.map((p) => p.person),
|
||||
handlingThirdParty: window.accompanyingCourseWork.handlingThierParty,
|
||||
thirdParties: window.accompanyingCourseWork.thirdParties,
|
||||
referrers: window.accompanyingCourseWork.referrers,
|
||||
isPosting: false,
|
||||
errors: [],
|
||||
me: null,
|
||||
version: window.accompanyingCourseWork.version
|
||||
version: window.accompanyingCourseWork.version,
|
||||
},
|
||||
getters: {
|
||||
socialAction(state) {
|
||||
@@ -43,12 +55,12 @@ const store = createStore({
|
||||
return state.resultsForAction.length > 0;
|
||||
},
|
||||
resultsForGoal: (state) => (goal) => {
|
||||
let founds = state.resultsForGoal.filter(r => r.goalId === goal.id);
|
||||
let founds = state.resultsForGoal.filter((r) => r.goalId === goal.id);
|
||||
|
||||
return founds === undefined ? [] : founds;
|
||||
},
|
||||
resultsPickedForGoal: (state) => (goal) => {
|
||||
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
||||
let found = state.goalsPicked.find((g) => g.goal.id === goal.id);
|
||||
|
||||
return found === undefined ? [] : found.results;
|
||||
},
|
||||
@@ -70,26 +82,38 @@ const store = createStore({
|
||||
},
|
||||
buildPayload(state) {
|
||||
return {
|
||||
type: 'accompanying_period_work',
|
||||
type: "accompanying_period_work",
|
||||
id: state.work.id,
|
||||
version: state.version,
|
||||
startDate: state.startDate === null || state.startDate === '' ? null : {
|
||||
datetime: datetimeToISO(ISOToDate(state.startDate))
|
||||
},
|
||||
endDate: state.endDate === null || state.endDate === '' ? null : {
|
||||
datetime: datetimeToISO(ISOToDate(state.endDate))
|
||||
},
|
||||
startDate:
|
||||
state.startDate === null || state.startDate === ""
|
||||
? null
|
||||
: {
|
||||
datetime: datetimeToISO(ISOToDate(state.startDate)),
|
||||
},
|
||||
endDate:
|
||||
state.endDate === null || state.endDate === ""
|
||||
? null
|
||||
: {
|
||||
datetime: datetimeToISO(ISOToDate(state.endDate)),
|
||||
},
|
||||
note: state.note,
|
||||
privateComment: state.privateComment,
|
||||
persons: state.personsPicked.map(p => ({id: p.id, type: p.type})),
|
||||
handlingThierParty: state.handlingThirdParty === null ? null : {
|
||||
id: state.handlingThirdParty.id,
|
||||
type: state.handlingThirdParty.type
|
||||
},
|
||||
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 => {
|
||||
persons: state.personsPicked.map((p) => ({ id: p.id, type: p.type })),
|
||||
handlingThierParty:
|
||||
state.handlingThirdParty === null
|
||||
? null
|
||||
: {
|
||||
id: state.handlingThirdParty.id,
|
||||
type: state.handlingThirdParty.type,
|
||||
},
|
||||
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,
|
||||
note: g.note,
|
||||
@@ -97,55 +121,72 @@ const store = createStore({
|
||||
type: g.goal.type,
|
||||
id: g.goal.id,
|
||||
},
|
||||
results: g.results.map(r => ({id: r.id, type: r.type})),
|
||||
results: g.results.map((r) => ({ id: r.id, type: r.type })),
|
||||
};
|
||||
if (g.id !== undefined) {
|
||||
o.id = g.id;
|
||||
}
|
||||
return o;
|
||||
}),
|
||||
accompanyingPeriodWorkEvaluations: state.evaluationsPicked.map(e => {
|
||||
accompanyingPeriodWorkEvaluations: state.evaluationsPicked.map((e) => {
|
||||
let o = {
|
||||
type: e.type,
|
||||
key: e.key,
|
||||
evaluation: {
|
||||
id: e.evaluation.id,
|
||||
type: e.evaluation.type
|
||||
type: e.evaluation.type,
|
||||
},
|
||||
startDate: e.startDate === null || e.startDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.startDate)) },
|
||||
endDate: e.endDate === null || e.endDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.endDate)) },
|
||||
maxDate: e.maxDate === null || e.maxDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.maxDate)) },
|
||||
startDate:
|
||||
e.startDate === null || e.startDate === ""
|
||||
? null
|
||||
: { datetime: datetimeToISO(ISOToDate(e.startDate)) },
|
||||
endDate:
|
||||
e.endDate === null || e.endDate === ""
|
||||
? null
|
||||
: { datetime: datetimeToISO(ISOToDate(e.endDate)) },
|
||||
maxDate:
|
||||
e.maxDate === null || e.maxDate === ""
|
||||
? null
|
||||
: { datetime: datetimeToISO(ISOToDate(e.maxDate)) },
|
||||
warningInterval: intervalDaysToISO(e.warningInterval),
|
||||
timeSpent: e.timeSpent,
|
||||
comment: e.comment,
|
||||
documents: e.documents
|
||||
documents: e.documents,
|
||||
};
|
||||
if (e.id !== undefined) {
|
||||
o.id = e.id;
|
||||
}
|
||||
|
||||
return o;
|
||||
})
|
||||
}),
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
setWhoAmiI(state, me) {
|
||||
state.me = me;
|
||||
state.me = me;
|
||||
},
|
||||
setEvaluationsPicked(state, evaluations) {
|
||||
state.evaluationsPicked = evaluations.map((e, index) => {
|
||||
var k = Object.assign(e, {
|
||||
key: index,
|
||||
editEvaluation: false,
|
||||
startDate: e.startDate !== null ? dateToISO(new Date(e.startDate.datetime)) : null,
|
||||
endDate: e.endDate !== null ? dateToISO(new Date(e.endDate.datetime)) : null,
|
||||
maxDate: e.maxDate !== null ? dateToISO(new Date(e.maxDate.datetime)) : null,
|
||||
warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null,
|
||||
startDate:
|
||||
e.startDate !== null
|
||||
? dateToISO(new Date(e.startDate.datetime))
|
||||
: null,
|
||||
endDate:
|
||||
e.endDate !== null ? dateToISO(new Date(e.endDate.datetime)) : null,
|
||||
maxDate:
|
||||
e.maxDate !== null ? dateToISO(new Date(e.maxDate.datetime)) : null,
|
||||
warningInterval:
|
||||
e.warningInterval !== null
|
||||
? intervalISOToDays(e.warningInterval)
|
||||
: null,
|
||||
timeSpent: e.timeSpent !== null ? e.timeSpent : null,
|
||||
documents: e.documents.map((d, docIndex) => {
|
||||
return Object.assign(d, {
|
||||
key: docIndex
|
||||
key: docIndex,
|
||||
});
|
||||
}),
|
||||
});
|
||||
@@ -177,28 +218,30 @@ const store = createStore({
|
||||
state.resultsPicked.push(result);
|
||||
},
|
||||
removeResultPicked(state, result) {
|
||||
state.resultsPicked = state.resultsPicked.filter(r => r.id !== result.id);
|
||||
state.resultsPicked = state.resultsPicked.filter(
|
||||
(r) => r.id !== result.id,
|
||||
);
|
||||
},
|
||||
addGoal(state, goal) {
|
||||
let g = {
|
||||
type: "accompanying_period_work_goal",
|
||||
goal: goal,
|
||||
note: '',
|
||||
results: []
|
||||
}
|
||||
const tmpIndex = () => {
|
||||
let ar = state.goalsPicked.map(g => g.id),
|
||||
s = Math.min(...ar);
|
||||
return (s < 0) ? s : 0
|
||||
note: "",
|
||||
results: [],
|
||||
};
|
||||
g.id = tmpIndex() -1
|
||||
const tmpIndex = () => {
|
||||
let ar = state.goalsPicked.map((g) => g.id),
|
||||
s = Math.min(...ar);
|
||||
return s < 0 ? s : 0;
|
||||
};
|
||||
g.id = tmpIndex() - 1;
|
||||
state.goalsPicked.push(g);
|
||||
},
|
||||
removeGoal(state, goal) {
|
||||
state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id);
|
||||
state.goalsPicked = state.goalsPicked.filter((g) => g.id !== goal.id);
|
||||
},
|
||||
addResultForGoalPicked(state, { goal, result}) {
|
||||
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
||||
addResultForGoalPicked(state, { goal, result }) {
|
||||
let found = state.goalsPicked.find((g) => g.goal.id === goal.id);
|
||||
|
||||
if (found === undefined) {
|
||||
return;
|
||||
@@ -207,52 +250,63 @@ const store = createStore({
|
||||
found.results.push(result);
|
||||
},
|
||||
removeResultForGoalPicked(state, { goal, result }) {
|
||||
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
||||
let found = state.goalsPicked.find((g) => g.goal.id === goal.id);
|
||||
|
||||
if (found === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
found.results = found.results.filter(r => r.id !== result.id);
|
||||
found.results = found.results.filter((r) => r.id !== result.id);
|
||||
},
|
||||
addDocument(state, payload) {
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === payload.key);
|
||||
evaluation.documents.push(Object.assign(
|
||||
payload.document, {
|
||||
let evaluation = state.evaluationsPicked.find(
|
||||
(e) => e.key === payload.key,
|
||||
);
|
||||
evaluation.documents.push(
|
||||
Object.assign(payload.document, {
|
||||
key: evaluation.documents.length + 1,
|
||||
workflows_availables: state.work.workflows_availables_evaluation_documents,
|
||||
workflows_availables:
|
||||
state.work.workflows_availables_evaluation_documents,
|
||||
workflows: [],
|
||||
}));
|
||||
}),
|
||||
);
|
||||
},
|
||||
removeDocument(state, {key, document}) {
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
||||
removeDocument(state, { key, document }) {
|
||||
let evaluation = state.evaluationsPicked.find((e) => e.key === key);
|
||||
if (evaluation === undefined) {
|
||||
return;
|
||||
}
|
||||
evaluation.documents = evaluation.documents.filter(d => d.key !== document.key);
|
||||
evaluation.documents = evaluation.documents.filter(
|
||||
(d) => d.key !== document.key,
|
||||
);
|
||||
},
|
||||
replaceDocument(state, payload) {
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === payload.key);
|
||||
let evaluation = state.evaluationsPicked.find(
|
||||
(e) => e.key === payload.key,
|
||||
);
|
||||
if (evaluation === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
let doc = evaluation.documents.find(d => d.key === payload.oldDocument.key);
|
||||
let doc = evaluation.documents.find(
|
||||
(d) => d.key === payload.oldDocument.key,
|
||||
);
|
||||
|
||||
if (typeof doc === 'undefined') {
|
||||
console.error('doc not found');
|
||||
if (typeof doc === "undefined") {
|
||||
console.error("doc not found");
|
||||
}
|
||||
|
||||
doc.storedObject = payload.document.storedObject;
|
||||
return;
|
||||
let newDocument = Object.assign(
|
||||
payload.document, {
|
||||
key: evaluation.documents.length + 1,
|
||||
workflows_availables: state.work.workflows_availables_evaluation_documents,
|
||||
workflows: [],
|
||||
}
|
||||
let newDocument = Object.assign(payload.document, {
|
||||
key: evaluation.documents.length + 1,
|
||||
workflows_availables:
|
||||
state.work.workflows_availables_evaluation_documents,
|
||||
workflows: [],
|
||||
});
|
||||
evaluation.documents = evaluation.documents.map((d) =>
|
||||
d.id === payload.oldDocument.id ? newDocument : d,
|
||||
);
|
||||
evaluation.documents = evaluation.documents.map(d => d.id === payload.oldDocument.id ? newDocument : d);
|
||||
},
|
||||
addEvaluation(state, evaluation) {
|
||||
let e = {
|
||||
@@ -260,8 +314,8 @@ const store = createStore({
|
||||
key: state.evaluationsPicked.length + 1,
|
||||
evaluation: evaluation,
|
||||
startDate: dateToISO(new Date()),
|
||||
endDate: null,
|
||||
maxDate: null,
|
||||
endDate: null,
|
||||
maxDate: null,
|
||||
warningInterval: null,
|
||||
timeSpent: null,
|
||||
comment: "",
|
||||
@@ -273,46 +327,43 @@ const store = createStore({
|
||||
state.evaluationsPicked.push(e);
|
||||
},
|
||||
removeEvaluation(state, evaluation) {
|
||||
state.evaluationsPicked = state.evaluationsPicked.filter(e => e.key !== evaluation.key);
|
||||
state.evaluationsPicked = state.evaluationsPicked.filter(
|
||||
(e) => e.key !== evaluation.key,
|
||||
);
|
||||
},
|
||||
setEvaluationStartDate(state, {key, date}) {
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.startDate = date;
|
||||
setEvaluationStartDate(state, { key, date }) {
|
||||
state.evaluationsPicked.find((e) => e.key === key).startDate = date;
|
||||
},
|
||||
setEvaluationEndDate(state, {key, date}) {
|
||||
console.log('commit date', date)
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.endDate = date;
|
||||
setEvaluationEndDate(state, { key, date }) {
|
||||
console.log("commit date", date);
|
||||
state.evaluationsPicked.find((e) => e.key === key).endDate = date;
|
||||
},
|
||||
setEvaluationMaxDate(state, {key, date}) {
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.maxDate = date;
|
||||
setEvaluationMaxDate(state, { key, date }) {
|
||||
state.evaluationsPicked.find((e) => e.key === key).maxDate = date;
|
||||
},
|
||||
setEvaluationWarningInterval(state, {key, days}) {
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.warningInterval = days;
|
||||
setEvaluationWarningInterval(state, { key, days }) {
|
||||
state.evaluationsPicked.find((e) => e.key === key).warningInterval = days;
|
||||
},
|
||||
setEvaluationTimeSpent(state, {key, time}) {
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.timeSpent = time;
|
||||
setEvaluationTimeSpent(state, { key, time }) {
|
||||
state.evaluationsPicked.find((e) => e.key === key).timeSpent = time;
|
||||
},
|
||||
setEvaluationComment(state, {key, comment}) {
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.comment = comment;
|
||||
setEvaluationComment(state, { key, comment }) {
|
||||
state.evaluationsPicked.find((e) => e.key === key).comment = comment;
|
||||
},
|
||||
toggleEvaluationEdit(state, {key}) {
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
||||
toggleEvaluationEdit(state, { key }) {
|
||||
let evaluation = state.evaluationsPicked.find((e) => e.key === key);
|
||||
evaluation.editEvaluation = !evaluation.editEvaluation;
|
||||
},
|
||||
setTemplatesForEvaluation(state, {templates, evaluation}) {
|
||||
setTemplatesForEvaluation(state, { templates, evaluation }) {
|
||||
state.templatesAvailablesForEvaluation.set(evaluation.id, templates);
|
||||
},
|
||||
setTemplatesAvailablesForAction(state, templates) {
|
||||
state.templatesAvailablesForAction = templates;
|
||||
},
|
||||
setPersonsPickedIds(state, ids) {
|
||||
state.personsPicked = state.personsReachables
|
||||
.filter(p => ids.includes(p.id))
|
||||
state.personsPicked = state.personsReachables.filter((p) =>
|
||||
ids.includes(p.id),
|
||||
);
|
||||
},
|
||||
setNote(state, note) {
|
||||
state.note = note;
|
||||
@@ -325,8 +376,8 @@ const store = createStore({
|
||||
},
|
||||
addThirdParties(state, thirdParties) {
|
||||
// filter to remove existing thirdparties
|
||||
let ids = state.thirdParties.map(t => t.id);
|
||||
let unexistings = thirdParties.filter(t => !ids.includes(t.id));
|
||||
let ids = state.thirdParties.map((t) => t.id);
|
||||
let unexistings = thirdParties.filter((t) => !ids.includes(t.id));
|
||||
|
||||
for (let i in unexistings) {
|
||||
state.thirdParties.push(unexistings[i]);
|
||||
@@ -334,27 +385,29 @@ const store = createStore({
|
||||
},
|
||||
updateThirdParty(state, thirdParty) {
|
||||
for (let t of state.thirdParties) {
|
||||
if (t.id === thirdParty.id){
|
||||
state.thirdParties = state.thirdParties.filter(t => t.id !== thirdParty.id);
|
||||
if (t.id === thirdParty.id) {
|
||||
state.thirdParties = state.thirdParties.filter(
|
||||
(t) => t.id !== thirdParty.id,
|
||||
);
|
||||
state.thirdParties.push(thirdParty);
|
||||
}
|
||||
}
|
||||
},
|
||||
removeThirdParty(state, thirdParty) {
|
||||
state.thirdParties = state.thirdParties
|
||||
.filter(t => t.id !== thirdParty.id);
|
||||
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));
|
||||
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);
|
||||
state.referrers = state.referrers.filter((u) => u.id !== user.id);
|
||||
},
|
||||
setErrors(state, errors) {
|
||||
state.errors = errors;
|
||||
@@ -364,22 +417,24 @@ const store = createStore({
|
||||
},
|
||||
updateDocumentTitle(state, payload) {
|
||||
if (payload.id === 0) {
|
||||
state.evaluationsPicked.find(e => e.key === payload.evaluationKey)
|
||||
.documents.find(d => d.key === payload.key).title = payload.title;
|
||||
state.evaluationsPicked
|
||||
.find((e) => e.key === payload.evaluationKey)
|
||||
.documents.find((d) => d.key === payload.key).title = payload.title;
|
||||
} else {
|
||||
state.evaluationsPicked.find(e => e.key === payload.evaluationKey)
|
||||
.documents.find(d => d.id === payload.id).title = payload.title;
|
||||
state.evaluationsPicked
|
||||
.find((e) => e.key === payload.evaluationKey)
|
||||
.documents.find((d) => d.id === payload.id).title = payload.title;
|
||||
}
|
||||
},
|
||||
statusDocumentChanged(state, {newStatus, key}) {
|
||||
const e = state.evaluationsPicked.find(e => e.key === key);
|
||||
if (typeof e === 'undefined') {
|
||||
console.error('evaluation not found for given key', {key});
|
||||
statusDocumentChanged(state, { newStatus, key }) {
|
||||
const e = state.evaluationsPicked.find((e) => e.key === key);
|
||||
if (typeof e === "undefined") {
|
||||
console.error("evaluation not found for given key", { key });
|
||||
}
|
||||
|
||||
const doc = e.documents.find(d => d.storedObject?.id === newStatus.id);
|
||||
if (typeof doc === 'undefined') {
|
||||
console.error('document not found', {newStatus});
|
||||
const doc = e.documents.find((d) => d.storedObject?.id === newStatus.id);
|
||||
if (typeof doc === "undefined") {
|
||||
console.error("document not found", { newStatus });
|
||||
}
|
||||
|
||||
doc.storedObject.status = newStatus.status;
|
||||
@@ -389,160 +444,184 @@ const store = createStore({
|
||||
},
|
||||
actions: {
|
||||
getWhoAmI({ commit }) {
|
||||
let url = `/api/1.0/main/whoami.json`;
|
||||
window.fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
throw { m: 'Error while retriving results for goal', s: response.status, b: response.body };
|
||||
})
|
||||
.then(data => {
|
||||
commit('setWhoAmiI', data);
|
||||
});
|
||||
},
|
||||
updateThirdParty({ commit }, payload) {
|
||||
commit('updateThirdParty', payload);
|
||||
},
|
||||
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
||||
let
|
||||
socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/goal/by-social-action/${socialActionId}.json`
|
||||
;
|
||||
let url = `/api/1.0/main/whoami.json`;
|
||||
window
|
||||
.fetch(
|
||||
url
|
||||
).then( response => {
|
||||
.fetch(url)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
throw { m: 'Error while retriving goal for social action', s: response.status, b: response.body };
|
||||
}).then( data => {
|
||||
for (let i in data.results) {
|
||||
dispatch('getReachablesResultsForGoal', data.results[i]);
|
||||
}
|
||||
}).catch( errors => {
|
||||
commit('addErrors', errors);
|
||||
throw {
|
||||
m: "Error while retriving results for goal",
|
||||
s: response.status,
|
||||
b: response.body,
|
||||
};
|
||||
})
|
||||
.then((data) => {
|
||||
commit("setWhoAmiI", data);
|
||||
});
|
||||
},
|
||||
updateThirdParty({ commit }, payload) {
|
||||
commit("updateThirdParty", payload);
|
||||
},
|
||||
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
||||
let socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/goal/by-social-action/${socialActionId}.json`;
|
||||
window
|
||||
.fetch(url)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
throw {
|
||||
m: "Error while retriving goal for social action",
|
||||
s: response.status,
|
||||
b: response.body,
|
||||
};
|
||||
})
|
||||
.then((data) => {
|
||||
for (let i in data.results) {
|
||||
dispatch("getReachablesResultsForGoal", data.results[i]);
|
||||
}
|
||||
})
|
||||
.catch((errors) => {
|
||||
commit("addErrors", errors);
|
||||
});
|
||||
},
|
||||
getReachablesResultsForGoal({ commit }, goal) {
|
||||
let
|
||||
url = `/api/1.0/person/social-work/result/by-goal/${goal.id}.json`
|
||||
;
|
||||
window.fetch(url)
|
||||
.then(response => {
|
||||
let url = `/api/1.0/person/social-work/result/by-goal/${goal.id}.json`;
|
||||
window
|
||||
.fetch(url)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
throw { m: 'Error while retriving results for goal', s: response.status, b: response.body };
|
||||
throw {
|
||||
m: "Error while retriving results for goal",
|
||||
s: response.status,
|
||||
b: response.body,
|
||||
};
|
||||
})
|
||||
.then(data => {
|
||||
commit('setResultsForGoal', { goal, results: data.results });
|
||||
.then((data) => {
|
||||
commit("setResultsForGoal", { goal, results: data.results });
|
||||
});
|
||||
},
|
||||
getReachablesResultsForAction({ getters, commit }) {
|
||||
let
|
||||
socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/result/by-social-action/${socialActionId}.json`
|
||||
;
|
||||
window.fetch(url)
|
||||
.then(response => {
|
||||
let socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/result/by-social-action/${socialActionId}.json`;
|
||||
window
|
||||
.fetch(url)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
throw { m: 'Error while retriving results for social action', s: response.status, b: response.body };
|
||||
throw {
|
||||
m: "Error while retriving results for social action",
|
||||
s: response.status,
|
||||
b: response.body,
|
||||
};
|
||||
})
|
||||
.then(data => {
|
||||
commit('setResultsForAction', data.results);
|
||||
.then((data) => {
|
||||
commit("setResultsForAction", data.results);
|
||||
});
|
||||
},
|
||||
getReachablesEvaluationsForAction({ getters, commit }) {
|
||||
let
|
||||
socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/evaluation/by-social-action/${socialActionId}.json`
|
||||
;
|
||||
window.fetch(url)
|
||||
.then(response => {
|
||||
let socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/evaluation/by-social-action/${socialActionId}.json`;
|
||||
window
|
||||
.fetch(url)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
throw { m: 'Error while retriving evaluations for social action', s: response.status, b: response.body };
|
||||
throw {
|
||||
m: "Error while retriving evaluations for social action",
|
||||
s: response.status,
|
||||
b: response.body,
|
||||
};
|
||||
})
|
||||
.then(data => {
|
||||
commit('setEvaluationsForAction', data.results);
|
||||
.then((data) => {
|
||||
commit("setEvaluationsForAction", data.results);
|
||||
});
|
||||
},
|
||||
addEvaluation({commit, dispatch}, evaluation) {
|
||||
commit('addEvaluation', evaluation);
|
||||
dispatch('fetchTemplatesAvailablesForEvaluation', evaluation);
|
||||
addEvaluation({ commit, dispatch }, evaluation) {
|
||||
commit("addEvaluation", evaluation);
|
||||
dispatch("fetchTemplatesAvailablesForEvaluation", evaluation);
|
||||
},
|
||||
fetchTemplatesAvailablesForEvaluation({commit, state}, evaluation) {
|
||||
fetchTemplatesAvailablesForEvaluation({ commit, state }, evaluation) {
|
||||
if (!state.templatesAvailablesForEvaluation.has(evaluation.id)) {
|
||||
// commit an empty array to avoid parallel fetching for same evaluation id
|
||||
commit('setTemplatesForEvaluation', {templates: [], evaluation});
|
||||
fetchResults(`/api/1.0/person/docgen/template/by-evaluation/${evaluation.id}.json`)
|
||||
.then(templates => {
|
||||
commit('setTemplatesForEvaluation', {templates, evaluation});
|
||||
});
|
||||
commit("setTemplatesForEvaluation", { templates: [], evaluation });
|
||||
fetchResults(
|
||||
`/api/1.0/person/docgen/template/by-evaluation/${evaluation.id}.json`,
|
||||
).then((templates) => {
|
||||
commit("setTemplatesForEvaluation", { templates, evaluation });
|
||||
});
|
||||
}
|
||||
},
|
||||
addDocument({commit}, payload) {
|
||||
commit('addDocument', payload);
|
||||
addDocument({ commit }, payload) {
|
||||
commit("addDocument", payload);
|
||||
},
|
||||
removeDocument({commit}, payload) {
|
||||
commit('removeDocument', payload);
|
||||
removeDocument({ commit }, payload) {
|
||||
commit("removeDocument", payload);
|
||||
},
|
||||
replaceDocument({commit}, payload) {
|
||||
commit('replaceDocument', payload);
|
||||
replaceDocument({ commit }, payload) {
|
||||
commit("replaceDocument", payload);
|
||||
},
|
||||
submit({ getters, state, commit }, callback) {
|
||||
let
|
||||
payload = getters.buildPayload,
|
||||
params = new URLSearchParams({'entity_version': state.version}),
|
||||
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json?${params}`
|
||||
;
|
||||
|
||||
commit('setIsPosting', true);
|
||||
let payload = getters.buildPayload,
|
||||
params = new URLSearchParams({ entity_version: state.version }),
|
||||
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json?${params}`;
|
||||
commit("setIsPosting", true);
|
||||
|
||||
// console.log('the social action', payload);
|
||||
|
||||
return makeFetch('PUT', url, payload)
|
||||
.then(data => {
|
||||
if (typeof(callback) !== 'undefined') {
|
||||
return makeFetch("PUT", url, payload)
|
||||
.then((data) => {
|
||||
if (typeof callback !== "undefined") {
|
||||
return callback(data);
|
||||
} else {
|
||||
// console.log('payload', payload.privateComment)
|
||||
// console.info('nothing to do here, bye bye');
|
||||
window.location.assign(`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`);
|
||||
window.location.assign(
|
||||
`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`,
|
||||
);
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log('error', error)
|
||||
commit('setIsPosting', false);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("error", error);
|
||||
commit("setIsPosting", false);
|
||||
throw error;
|
||||
});
|
||||
},
|
||||
updateDocumentTitle({commit}, payload) {
|
||||
commit('updateDocumentTitle', payload)
|
||||
}
|
||||
}
|
||||
updateDocumentTitle({ commit }, payload) {
|
||||
commit("updateDocumentTitle", payload);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
store.commit('setEvaluationsPicked', window.accompanyingCourseWork.accompanyingPeriodWorkEvaluations);
|
||||
store.dispatch('getReachablesResultsForAction');
|
||||
store.dispatch('getReachablesGoalsForAction');
|
||||
store.dispatch('getReachablesEvaluationsForAction');
|
||||
store.dispatch('getWhoAmI');
|
||||
store.commit(
|
||||
"setEvaluationsPicked",
|
||||
window.accompanyingCourseWork.accompanyingPeriodWorkEvaluations,
|
||||
);
|
||||
store.dispatch("getReachablesResultsForAction");
|
||||
store.dispatch("getReachablesGoalsForAction");
|
||||
store.dispatch("getReachablesEvaluationsForAction");
|
||||
store.dispatch("getWhoAmI");
|
||||
|
||||
store.state.evaluationsPicked.forEach(evaluation => {
|
||||
store.dispatch('fetchTemplatesAvailablesForEvaluation', evaluation.evaluation)
|
||||
store.state.evaluationsPicked.forEach((evaluation) => {
|
||||
store.dispatch(
|
||||
"fetchTemplatesAvailablesForEvaluation",
|
||||
evaluation.evaluation,
|
||||
);
|
||||
});
|
||||
|
||||
fetchTemplates('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork')
|
||||
.then(templates => {
|
||||
store.commit('setTemplatesAvailablesForAction', templates);
|
||||
}
|
||||
)
|
||||
fetchTemplates(
|
||||
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork",
|
||||
).then((templates) => {
|
||||
store.commit("setTemplatesAvailablesForAction", templates);
|
||||
});
|
||||
|
||||
export { store };
|
||||
|
Reference in New Issue
Block a user