Refactor FormEvaluation.vue component

This commit is contained in:
Julie Lenaerts 2025-04-02 11:55:37 +02:00
parent 204fb20475
commit ab23a4efb5
6 changed files with 547 additions and 658 deletions

View File

@ -0,0 +1,25 @@
<template>
<div class="row mb-3">
<label class="col-sm-4 col-form-label visually-hidden">{{ trans(EVALUATION_PUBLIC_COMMENT) }}</label>
<div class="col-sm-12">
<ckeditor
:editor="ClassicEditor"
:config="classicEditorConfig"
:placeholder="trans(EVALUATION_COMMENT_PLACEHOLDER)"
:value="comment"
@input="$emit('update:comment', $event)"
tag-name="textarea"
></ckeditor>
</div>
</div>
</template>
<script setup>
import { Ckeditor } from '@ckeditor/ckeditor5-vue';
import { ClassicEditor } from 'ckeditor5';
import classicEditorConfig from 'ChillMainAssets/module/ckeditor5/editor_config';
import { EVALUATION_PUBLIC_COMMENT, EVALUATION_COMMENT_PLACEHOLDER, trans } from 'translator';
defineProps(['comment']);
defineEmits(['update:comment']);
</script>

View File

@ -0,0 +1,60 @@
<template>
<div class="row mb-3">
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
{{ trans(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"
:value="startDate"
@input="$emit('update:startDate', $event.target.value)"
/>
</div>
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
{{ trans(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"
:value="endDate"
@input="$emit('update:endDate', $event.target.value)"
/>
</div>
</div>
<div class="row mb-3">
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
{{ trans(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"
:value="maxDate"
@input="$emit('update:maxDate', $event.target.value)"
/>
</div>
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
{{ trans(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"
:value="warningInterval"
@input="$emit('update:warningInterval', $event.target.value)"
/>
</div>
</div>
</template>
<script setup>
import { EVALUATION_STARTDATE, EVALUATION_ENDDATE, EVALUATION_MAXDATE, EVALUATION_WARNING_INTERVAL, trans } from 'translator';
defineProps(['startDate', 'endDate', 'maxDate', 'warningInterval']);
defineEmits(['update:startDate', 'update:endDate', 'update:maxDate', 'update:warningInterval']);
</script>

View File

@ -0,0 +1,40 @@
<template>
<div class="row mb-3">
<h6>{{ trans(EVALUATION_DOCUMENT_ADD) }} :</h6>
<pick-template
entityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation"
:id="evaluation.id"
:templates="templates"
:preventDefaultMoveToGenerate="true"
@go-to-generate-document="$emit('submitBeforeGenerate', $event)"
>
<template v-slot:title>
<label class="col-form-label">{{ trans(EVALUATION_GENERATE_A_DOCUMENT) }}</label>
</template>
</pick-template>
<div>
<label class="col-form-label">{{ trans(EVALUATION_DOCUMENT_UPLOAD) }}</label>
<ul class="record_actions document-upload">
<li>
<drop-file-modal :allow-remove="false" @add-document="$emit('addDocument', $event)"></drop-file-modal>
</li>
</ul>
</div>
</div>
</template>
<script setup>
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
import DropFileModal from 'ChillDocStoreAssets/vuejs/DropFileWidget/DropFileModal.vue';
import { EVALUATION_DOCUMENT_ADD,
EVALUATION_DOCUMENT_UPLOAD, EVALUATION_GENERATE_A_DOCUMENT, trans } from 'translator';
defineProps(['evaluation', 'templates']);
defineEmits(['addDocument', 'submitBeforeGenerate']);
</script>
<style scoped>
ul.document-upload {
justify-content: flex-start;
}
</style>

View File

@ -0,0 +1,157 @@
<template>
<div class="row mb-3">
<h5>{{ trans(EVALUATION_DOCUMENTS) }} :</h5>
<div class="flex-table">
<div
class="item-bloc"
v-for="(d, i) in documents"
:key="d.id"
:class="[parseInt(docAnchorId) === d.id ? 'bg-blink' : 'nothing']"
>
<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>
<div class="col-sm-9">
<input
class="form-control document-title"
type="text"
:value="d.title"
:id="d.id"
:data-key="i"
@input="$emit('inputDocumentTitle', $event)"
/>
</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>
</div>
</div>
<div class="item-row">
<div class="item-col">
<ul class="record_actions">
<li v-if="d.workflows_availables.length > 0 || d.workflows.length > 0">
<list-workflow-modal
:workflows="d.workflows"
:allowCreate="true"
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument"
:relatedEntityId="d.id"
:workflowsAvailables="d.workflows_availables"
:preventDefaultMoveToGenerate="true"
:goToGenerateWorkflowPayload="{ doc: d }"
@go-to-generate-workflow="$emit('goToGenerateWorkflow', $event)"
></list-workflow-modal>
</li>
<li>
<button
v-if="AmIRefferer"
class="btn btn-notify"
@click="$emit('goToGenerateNotification', d, false)"
></button>
<template v-else>
<button
id="btnGroupNotifyButtons"
type="button"
class="btn btn-notify dropdown-toggle"
:title="trans(EVALUATION_NOTIFICATION_SEND)"
data-bs-toggle="dropdown"
aria-expanded="false"
>
&nbsp;
</button>
<ul class="dropdown-menu" aria-labelledby="btnGroupNotifyButtons">
<li>
<a class="dropdown-item" @click="$emit('goToGenerateNotification', d, true)">
{{ trans(EVALUATION_NOTIFICATION_NOTIFY_REFERRER) }}
</a>
</li>
<li>
<a class="dropdown-item" @click="$emit('goToGenerateNotification', d, false)">
{{ trans(EVALUATION_NOTIFICATION_NOTIFY_ANY) }}
</a>
</li>
</ul>
</template>
</li>
<li>
<document-action-buttons-group
:stored-object="d.storedObject"
:filename="d.title"
:can-edit="true"
:execute-before-leave="submitBeforeLeaveToEditor"
:davLink="d.storedObject._links?.dav_link.href"
:davLinkExpiration="d.storedObject._links?.dav_link.expiration"
@on-stored-object-status-change="$emit('statusDocumentChanged', $event)"
></document-action-buttons-group>
</li>
<li v-if="d.storedObject._permissions.canEdit">
<drop-file-modal
:existing-doc="d.storedObject"
:allow-remove="false"
@add-document="(arg) => $emit('replaceDocument', d, arg.stored_object, arg.stored_object_version)"
></drop-file-modal>
</li>
<li v-if="d.workflows.length === 0">
<a class="btn btn-delete" @click="$emit('removeDocument', d)"> </a>
</li>
<li v-if="Number.isInteger(d.id)">
<div class="duplicate-dropdown">
<button class="btn btn-duplicate dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Dupliquer
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" @click="$emit('duplicateDocument', d)">Dupliquer ici</a>
</li>
<li>
<a class="dropdown-item" @click="showAccompanyingPeriodSelector = true">Dupliquer vers un autre actions d'accompagnement</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<AccompanyingPeriodWorkSelectorModal
v-if="showAccompanyingPeriodSelector"
v-model:selectedAcpw="selectedAcpw"
:accompanying-period-id="accompanyingPeriodId"
@close-modal="showAccompanyingPeriodSelector = false"
@update:selectedAcpw="selectedAcpw = $event"
/>
</template>
<script setup>
import { ISOToDatetime } from 'ChillMainAssets/chill/js/date';
import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue';
import DocumentActionButtonsGroup from 'ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue';
import DropFileModal from 'ChillDocStoreAssets/vuejs/DropFileWidget/DropFileModal.vue';
import {
EVALUATION_NOTIFICATION_NOTIFY_REFERRER,
EVALUATION_NOTIFICATION_NOTIFY_ANY,
EVALUATION_NOTIFICATION_SEND,
EVALUATION_DOCUMENTS,
trans
} from 'translator';
import {ref, watch} from "vue";
import AccompanyingPeriodWorkSelectorModal
from "ChillPersonAssets/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkSelectorModal.vue";
defineProps(['documents', 'docAnchorId', 'accompanyingPeriodId']);
defineEmits(['inputDocumentTitle', 'removeDocument', 'duplicateDocument', 'statusDocumentChanged', 'goToGenerateWorkflow', 'goToGenerateNotification']);
const showAccompanyingPeriodSelector = ref(false);
const selectedAcpw = ref(null);
/*watch(selectedAcpw, (val) => {
console.log("selected acpw changed:", val);
});*/
</script>

View File

@ -1,678 +1,262 @@
<template> <template>
<div> <div>
<div class="m-md-3"> <div class="m-md-3">
<div class="row mb-3"> <DateInputs
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label"> :startDate="startDate"
{{ $t("evaluation_startdate") }} :endDate="endDate"
</label> :maxDate="maxDate"
<div class="col-8 col-sm-4 col-md-8 col-lg-4"> :warningInterval="warningInterval"
<input @update:startDate="updateStartDate"
class="form-control form-control-sm" @update:endDate="updateEndDate"
type="date" @update:maxDate="updateMaxDate"
v-model="startDate" @update:warningInterval="updateWarningInterval"
/> />
</div>
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label"> <TimeSpentInput
{{ $t("evaluation_enddate") }} :timeSpent="timeSpent"
</label> :timeSpentChoices="timeSpentChoices"
<div class="col-8 col-sm-4 col-md-8 col-lg-4"> @update:timeSpent="updateTimeSpent"
<input />
class="form-control form-control-sm"
type="date"
v-model="endDate"
/>
</div>
</div>
<div class="row mb-3"> <CommentInput
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label"> :comment="comment"
{{ $t("evaluation_maxdate") }} @update:comment="updateComment"
</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"> <DocumentsList
{{ $t("evaluation_warning_interval") }} v-if="evaluation.documents.length > 0"
</label> :documents="evaluation.documents"
<div class="col-8 col-sm-4 col-md-8 col-lg-4"> :docAnchorId="docAnchorId"
<input :accompanyingPeriodId="store.state.work.accompanyingPeriod.id"
class="form-control form-control-sm" @inputDocumentTitle="onInputDocumentTitle"
type="number" @removeDocument="removeDocument"
v-model.number="warningInterval" @duplicateDocument="duplicateDocument"
/> @statusDocumentChanged="onStatusDocumentChanged"
</div> @goToGenerateWorkflow="goToGenerateWorkflowEvaluationDocument"
</div> @goToGenerateNotification="goToGenerateDocumentNotification"
/>
<div class="row mb-3"> <DocumentActions
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label"> :evaluation="evaluation"
{{ $t("evaluation_time_spent") }}
</label>
<div class="col-8 col-sm-4 col-md-8 col-lg-4">
<select
class="form-control form-control-sm"
type="time"
v-model="timeSpent"
>
<option disabled value="">{{ $t("select_time_spent") }}</option>
<option v-for="time in timeSpentChoices" :value="time.value">
{{ time.text }}
</option>
</select>
</div>
</div>
<div class="row mb-3">
<label class="col-sm-4 col-form-label visually-hidden">{{
$t("evaluation_public_comment")
}}</label>
<div class="col-sm-12">
<ckeditor
:editor="classicEditor"
:config="editorConfig"
:placeholder="$t('evaluation_comment_placeholder')"
v-model="comment"
tag-name="textarea"
></ckeditor>
</div>
</div>
<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',
]"
>
<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
>
<div class="col-sm-9">
<input
class="form-control document-title"
type="text"
:value="d.title"
: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>
</div>
</div>
<div class="item-row">
<div class="item-col">
<ul class="record_actions">
<li
v-if="
d.workflows_availables.length > 0 ||
d.workflows.length > 0
"
>
<list-workflow-modal
:workflows="d.workflows"
:allowCreate="true"
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument"
:relatedEntityId="d.id"
:workflowsAvailables="d.workflows_availables"
:preventDefaultMoveToGenerate="true"
:goToGenerateWorkflowPayload="{ doc: d }"
@go-to-generate-workflow="
goToGenerateWorkflowEvaluationDocument
"
></list-workflow-modal>
</li>
<li>
<button
v-if="AmIRefferer"
class="btn btn-notify"
@click="goToGenerateDocumentNotification(d, false)"
></button>
<template v-else>
<button
id="btnGroupNotifyButtons"
type="button"
class="btn btn-notify dropdown-toggle"
:title="$t('notification_send')"
data-bs-toggle="dropdown"
aria-expanded="false"
>
&nbsp;
</button>
<ul
class="dropdown-menu"
aria-labelledby="btnGroupNotifyButtons"
>
<li>
<a
class="dropdown-item"
@click="goToGenerateDocumentNotification(d, true)"
>{{ $t("notification_notify_referrer") }}</a
>
</li>
<li>
<a
class="dropdown-item"
@click="goToGenerateDocumentNotification(d, false)"
>{{ $t("notification_notify_any") }}</a
>
</li>
</ul>
</template>
</li>
<li>
<document-action-buttons-group
:stored-object="d.storedObject"
:filename="d.title"
:can-edit="true"
:execute-before-leave="submitBeforeLeaveToEditor"
:davLink="d.storedObject._links?.dav_link.href"
:davLinkExpiration="
d.storedObject._links?.dav_link.expiration
"
@on-stored-object-status-change="onStatusDocumentChanged"
></document-action-buttons-group>
</li>
<li v-if="d.storedObject._permissions.canEdit">
<drop-file-modal
:existing-doc="d.storedObject"
:allow-remove="false"
@add-document="
(arg) =>
replaceDocument(
d,
arg.stored_object,
arg.stored_object_version,
)
"
></drop-file-modal>
</li>
<li v-if="d.workflows.length === 0">
<a class="btn btn-delete" @click="removeDocument(d)"> </a>
</li>
<li v-if="Number.isInteger(d.id)">
<div class="duplicate-dropdown">
<button class="btn btn-duplicate dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false">
<!-- todo use translations -->
Dupliquer
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" @click="duplicateDocument(d)">Dupliquer ici</a>
</li>
<li>
<a class="dropdown-item" @click="openModal">Dupliquer vers un autre actions d'accompagnement</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="row mb-3">
<h6>{{ $t("document_add") }} :</h6>
<pick-template
entityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation"
:id="evaluation.id"
:templates="getTemplatesAvailables" :templates="getTemplatesAvailables"
:preventDefaultMoveToGenerate="true" @addDocument="addDocument"
@go-to-generate-document="submitBeforeGenerate" @submitBeforeGenerate="submitBeforeGenerate"
> />
<template v-slot:title>
<label class="col-form-label">{{
$t("evaluation_generate_a_document")
}}</label>
</template>
</pick-template>
<div>
<label class="col-form-label">{{ $t("document_upload") }}</label>
<ul class="record_actions document-upload">
<li>
<drop-file-modal
:allow-remove="false"
@add-document="addDocument"
></drop-file-modal>
</li>
</ul>
</div>
</div>
</div> </div>
</div> </div>
<teleport to="body">
<modal v-if="showModal" @close="closeModal" modal-dialog-class="modal-dialog-scrollable modal-xl">
<template #header>
<h3>{{ trans(ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK) }}</h3>
</template>
<template #body>
<accompanying-period-work-list
:accompanying-period-works="accompanyingPeriodWorks"
v-model:selectedAcpw="selectedAcpw"
/>
</template>
<template #footer>
<button type="button" class="btn btn-save" @click="confirmSelection">
{{ trans(CONFIRM) }}
</button>
</template>
</modal>
</teleport>
</template> </template>
<script> <script setup>
import { ISOToDatetime } from "ChillMainAssets/chill/js/date"; import { computed } from 'vue';
import { Ckeditor } from "@ckeditor/ckeditor5-vue"; import { useStore } from 'vuex';
import { ClassicEditor } from "ckeditor5"; import DateInputs from './DateInputs.vue';
import classicEditorConfig from "ChillMainAssets/module/ckeditor5/editor_config"; import TimeSpentInput from './TimeSpentInput.vue';
import { mapState } from "vuex"; import CommentInput from './CommentInput.vue';
import PickTemplate from "ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue"; import DocumentsList from './DocumentsList.vue';
import { buildLink } from "ChillDocGeneratorAssets/lib/document-generator"; import DocumentActions from './DocumentActions.vue';
import ListWorkflowModal from "ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue";
import { buildLinkCreate } from "ChillMainAssets/lib/entity-workflow/api";
import { buildLinkCreate as buildLinkCreateNotification } from "ChillMainAssets/lib/entity-notification/api";
import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue";
import DropFileModal from "ChillDocStoreAssets/vuejs/DropFileWidget/DropFileModal.vue";
import {
trans,
ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK,
CONFIRM,
} from "translator";
import AccompanyingPeriodWorkList from "../../_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkList.vue";
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
const i18n = { const props = defineProps(['evaluation', 'docAnchorId']);
messages: { const store = useStore();
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 { const timeSpentChoices = [
name: "FormEvaluation", { text: '1 minute', value: 60 },
props: ["evaluation", "docAnchorId"], { text: '2 minutes', value: 120 },
components: { { text: '3 minutes', value: 180 },
DropFileModal, { text: '4 minutes', value: 240 },
ckeditor: Ckeditor, { text: '5 minutes', value: 300 },
PickTemplate, { text: '10 minutes', value: 600 },
ListWorkflowModal, { text: '15 minutes', value: 900 },
DocumentActionButtonsGroup, { text: '20 minutes', value: 1200 },
AccompanyingPeriodWorkList, { text: '25 minutes', value: 1500 },
Modal, { text: '30 minutes', value: 1800 },
trans, { text: '45 minutes', value: 2700 },
ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK, { text: '1 hour', value: 3600 },
CONFIRM, { text: '1 hour 15 minutes', value: 4500 },
}, { text: '1 hour 30 minutes', value: 5400 },
i18n, { text: '1 hour 45 minutes', value: 6300 },
data() { { text: '2 hours', value: 7200 },
return { { text: '2 hours 30 minutes', value: 9000 },
template: null, { text: '3 hours', value: 10800 },
asyncUploadOptions: { { text: '3 hours 30 minutes', value: 12600 },
maxFiles: 1, { text: '4 hours', value: 14400 },
maxPostSize: 15000000, { text: '4 hours 30 minutes', value: 16200 },
required: false, { text: '5 hours', value: 18000 },
}, { text: '5 hours 30 minutes', value: 19800 },
timeSpentChoices: [ { text: '6 hours', value: 21600 },
{ text: "1 minute", value: 60 }, { text: '6 hours 30 minutes', value: 23400 },
{ text: "2 minutes", value: 120 }, { text: '7 hours', value: 25200 },
{ text: "3 minutes", value: 180 }, { text: '7 hours 30 minutes', value: 27000 },
{ text: "4 minutes", value: 240 }, { text: '8 hours', value: 28800 },
{ 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"]),
classicEditor: () => ClassicEditor,
editorConfig: () => classicEditorConfig,
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( const startDate = computed({
buildLink( get() {
template, return props.evaluation.startDate;
evaluationId, },
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation", set(v) {
), store.commit('setEvaluationStartDate', { key: props.evaluation.key, date: v });
); },
}; });
return this.$store.dispatch("submit", callback).catch((e) => { const endDate = computed({
console.log(e); get() {
throw e; return props.evaluation.endDate;
}); },
}, set(v) {
onInputDocumentTitle(event) { store.commit('setEvaluationEndDate', { key: props.evaluation.key, date: v });
const id = Number(event.target.id); },
const key = Number(event.target.dataset.key) + 1; });
const title = event.target.value;
this.$store.commit("updateDocumentTitle", { const maxDate = computed({
id: id, get() {
key: key, return props.evaluation.maxDate;
evaluationKey: this.evaluation.key, },
title: title, set(v) {
}); store.commit('setEvaluationMaxDate', { key: props.evaluation.key, date: v });
}, },
addDocument({ stored_object, stored_object_version }) { });
let document = {
type: "accompanying_period_work_evaluation_document", const warningInterval = computed({
storedObject: stored_object, get() {
title: "Nouveau document", return props.evaluation.warningInterval;
}; },
this.$store.commit("addDocument", { set(v) {
key: this.evaluation.key, store.commit('setEvaluationWarningInterval', { key: props.evaluation.key, days: v });
document, },
stored_object_version, });
});
}, const timeSpent = computed({
/** get() {
* Replaces a document in the store with a new document. return props.evaluation.timeSpent;
* },
* @param {Object} oldDocument - The document to be replaced. set(v) {
* @param {StoredObject} storedObject - The stored object of the new document. store.commit('setEvaluationTimeSpent', { key: props.evaluation.key, time: v });
* @param {StoredObjectVersion} storedObjectVersion - The new version of the document },
* @return {void} });
*/
replaceDocument(oldDocument, storedObject, storedObjectVersion) { const comment = computed({
let document = { get() {
type: "accompanying_period_work_evaluation_document", return props.evaluation.comment;
storedObject: storedObject, },
title: oldDocument.title, set(v) {
}; store.commit('setEvaluationComment', { key: props.evaluation.key, comment: v });
this.$store.commit("replaceDocument", { },
key: this.evaluation.key, });
document,
oldDocument: oldDocument, const getTemplatesAvailables = computed(() => {
stored_object_version: storedObjectVersion, return store.getters.getTemplatesAvailablesForEvaluation(props.evaluation.evaluation);
}); });
},
removeDocument(document) { // const getAccompanyingPeriod = computed(() => store.work)
if ( function updateStartDate(value) {
window.confirm( startDate.value = value;
'Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre "' + }
document.title +
'" ?', function updateEndDate(value) {
) endDate.value = value;
) { }
this.$store.commit("removeDocument", {
key: this.evaluation.key, function updateMaxDate(value) {
document: document, maxDate.value = value;
}); }
}
}, function updateWarningInterval(value) {
duplicateDocument(document) { warningInterval.value = value;
this.$store.dispatch("duplicateDocument", { }
evaluation_key: this.evaluation.key,
document: document, function updateTimeSpent(value) {
}); timeSpent.value = value;
}, }
onStatusDocumentChanged(newStatus) {
console.log("onStatusDocumentChanged", newStatus); function updateComment(value) {
this.$store.commit("statusDocumentChanged", { comment.value = value;
key: this.evaluation.key, }
newStatus: newStatus,
}); function onInputDocumentTitle(event) {
}, const id = Number(event.target.id);
goToGenerateWorkflowEvaluationDocument({ workflowName, payload }) { const key = Number(event.target.dataset.key) + 1;
const callback = (data) => { const title = event.target.value;
let evaluation = data.accompanyingPeriodWorkEvaluations.find( store.commit('updateDocumentTitle', {
(e) => e.key === this.evaluation.key, id: id,
); key: key,
let updatedDocument = evaluation.documents.find( evaluationKey: props.evaluation.key,
(d) => d.key === payload.doc.key, title: title,
); });
window.location.assign( }
buildLinkCreate(
function addDocument({ stored_object, stored_object_version }) {
let document = {
type: 'accompanying_period_work_evaluation_document',
storedObject: stored_object,
title: 'Nouveau document',
};
store.commit('addDocument', {
key: props.evaluation.key,
document,
stored_object_version,
});
}
function removeDocument(document) {
if (window.confirm('Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre "' + document.title + '" ?')) {
store.commit('removeDocument', {
key: props.evaluation.key,
document: document,
});
}
}
function duplicateDocument(document) {
store.dispatch('duplicateDocument', {
evaluation_key: props.evaluation.key,
document: document,
});
}
function onStatusDocumentChanged(newStatus) {
store.commit('statusDocumentChanged', {
key: props.evaluation.key,
newStatus: newStatus,
});
}
function goToGenerateWorkflowEvaluationDocument({ workflowName, payload }) {
const callback = (data) => {
let evaluation = data.accompanyingPeriodWorkEvaluations.find((e) => e.key === props.evaluation.key);
let updatedDocument = evaluation.documents.find((d) => d.key === payload.doc.key);
window.location.assign(
buildLinkCreate(
workflowName, workflowName,
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument", 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument',
updatedDocument.id, updatedDocument.id,
), ),
); );
}; };
return this.$store.dispatch("submit", callback).catch((e) => { store.dispatch('submit', callback).catch((e) => {
console.log(e); console.log(e);
throw e; throw e;
}); });
}, }
goToGenerateDocumentNotification(document, tos) {
const callback = (data) => { function goToGenerateDocumentNotification(document, tos) {
let evaluation = data.accompanyingPeriodWorkEvaluations.find( const callback = (data) => {
(e) => e.key === this.evaluation.key, let evaluation = data.accompanyingPeriodWorkEvaluations.find((e) => e.key === props.evaluation.key);
); let updatedDocument = evaluation.documents.find((d) => d.key === document.key);
let updatedDocument = evaluation.documents.find( window.location.assign(
(d) => d.key === document.key, buildLinkCreateNotification(
); 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument',
window.location.assign(
buildLinkCreateNotification(
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument",
updatedDocument.id, updatedDocument.id,
tos === true tos === true ? store.state.work.accompanyingPeriod.user.id : null,
? this.$store.state.work.accompanyingPeriod.user.id window.location.pathname + window.location.search + window.location.hash,
: null, ),
window.location.pathname + );
window.location.search + };
window.location.hash, store.dispatch('submit', callback).catch((e) => {
), console.log(e);
); throw e;
}; });
return this.$store.dispatch("submit", callback).catch((e) => { }
console.log(e);
throw e;
});
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -680,9 +264,6 @@ input.document-title {
font-weight: bold; font-weight: bold;
font-size: 1rem; font-size: 1rem;
} }
ul.document-upload {
justify-content: flex-start;
}
.bg-blink { .bg-blink {
color: #050000; color: #050000;

View File

@ -0,0 +1,26 @@
<template>
<div class="row mb-3">
<label class="col-4 col-sm-2 col-md-4 col-lg-2 col-form-label">
{{ trans(EVALUATION_TIME_SPENT) }}
</label>
<div class="col-8 col-sm-4 col-md-8 col-lg-4">
<select
class="form-control form-control-sm"
:value="timeSpent"
@input="$emit('update:timeSpent', $event.target.value)"
>
<option disabled value="">{{ trans(EVALUATION_TIME_SPENT) }}</option>
<option v-for="time in timeSpentChoices" :value="time.value" :key="time.value">
{{ time.text }}
</option>
</select>
</div>
</div>
</template>
<script setup>
import { EVALUATION_TIME_SPENT, trans } from 'translator';
defineProps(['timeSpent', 'timeSpentChoices']);
defineEmits(['update:timeSpent']);
</script>