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"
@goToGenerateWorkflow="goToGenerateWorkflowEvaluationDocument"
@goToGenerateNotification="goToGenerateDocumentNotification"
/> />
</div>
</div>
<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>
<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"
/> />
</div>
</div>
</template> </template>
<template #footer> <script setup>
<button type="button" class="btn btn-save" @click="confirmSelection"> import { computed } from 'vue';
{{ trans(CONFIRM) }} import { useStore } from 'vuex';
</button> import DateInputs from './DateInputs.vue';
</template> import TimeSpentInput from './TimeSpentInput.vue';
</modal> import CommentInput from './CommentInput.vue';
</teleport> import DocumentsList from './DocumentsList.vue';
</template> import DocumentActions from './DocumentActions.vue';
<script> const props = defineProps(['evaluation', 'docAnchorId']);
import { ISOToDatetime } from "ChillMainAssets/chill/js/date"; const store = useStore();
import { Ckeditor } from "@ckeditor/ckeditor5-vue";
import { ClassicEditor } from "ckeditor5";
import classicEditorConfig 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 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 timeSpentChoices = [
messages: { { text: '1 minute', value: 60 },
fr: { { text: '2 minutes', value: 120 },
evaluation_title: "Ecrire une évaluation", { text: '3 minutes', value: 180 },
evaluation_status: "Statut", { text: '4 minutes', value: 240 },
evaluation_choose_a_status: "Choisir un statut", { text: '5 minutes', value: 300 },
evaluation_startdate: "Date d'ouverture", { text: '10 minutes', value: 600 },
evaluation_enddate: "Date de fin", { text: '15 minutes', value: 900 },
evaluation_maxdate: "Date d'échéance", { text: '20 minutes', value: 1200 },
evaluation_warning_interval: "Rappel (jours)", { text: '25 minutes', value: 1500 },
evaluation_public_comment: "Note publique", { text: '30 minutes', value: 1800 },
evaluation_comment_placeholder: "Commencez à écrire ...", { text: '45 minutes', value: 2700 },
evaluation_generate_a_document: "Générer un document", { text: '1 hour', value: 3600 },
evaluation_choose_a_template: "Choisir un modèle", { text: '1 hour 15 minutes', value: 4500 },
evaluation_add_a_document: "Ajouter un document", { text: '1 hour 30 minutes', value: 5400 },
evaluation_add: "Ajouter une évaluation", { text: '1 hour 45 minutes', value: 6300 },
evaluation_time_spent: "Temps de rédaction", { text: '2 hours', value: 7200 },
select_time_spent: "Indiquez le temps de rédaction", { text: '2 hours 30 minutes', value: 9000 },
Documents: "Documents", { text: '3 hours', value: 10800 },
document_add: "Générer ou téléverser un document", { text: '3 hours 30 minutes', value: 12600 },
document_upload: "Téléverser un document", { text: '4 hours', value: 14400 },
document_title: "Titre du document", { text: '4 hours 30 minutes', value: 16200 },
template_title: "Nom du template", { text: '5 hours', value: 18000 },
browse: "Ajouter un document", { text: '5 hours 30 minutes', value: 19800 },
replace: "Remplacer", { text: '6 hours', value: 21600 },
download: "Télécharger le fichier existant", { text: '6 hours 30 minutes', value: 23400 },
notification_notify_referrer: "Notifier le référent", { text: '7 hours', value: 25200 },
notification_notify_any: "Notifier d'autres utilisateurs", { text: '7 hours 30 minutes', value: 27000 },
notification_send: "Envoyer une notification", { text: '8 hours', value: 28800 },
}, ];
},
};
export default { const startDate = computed({
name: "FormEvaluation",
props: ["evaluation", "docAnchorId"],
components: {
DropFileModal,
ckeditor: Ckeditor,
PickTemplate,
ListWorkflowModal,
DocumentActionButtonsGroup,
AccompanyingPeriodWorkList,
Modal,
trans,
ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK,
CONFIRM,
},
i18n,
data() {
return {
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"]),
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() { get() {
console.log("evaluation", this.evaluation); return props.evaluation.startDate;
return this.evaluation.startDate;
}, },
set(v) { set(v) {
this.$store.commit("setEvaluationStartDate", { store.commit('setEvaluationStartDate', { key: props.evaluation.key, date: v });
key: this.evaluation.key, },
date: v,
}); });
},
}, const endDate = computed({
endDate: {
get() { get() {
return this.evaluation.endDate; return props.evaluation.endDate;
}, },
set(v) { set(v) {
this.$store.commit("setEvaluationEndDate", { store.commit('setEvaluationEndDate', { key: props.evaluation.key, date: v });
key: this.evaluation.key, },
date: v,
}); });
},
}, const maxDate = computed({
maxDate: {
get() { get() {
return this.evaluation.maxDate; return props.evaluation.maxDate;
}, },
set(v) { set(v) {
this.$store.commit("setEvaluationMaxDate", { store.commit('setEvaluationMaxDate', { key: props.evaluation.key, date: v });
key: this.evaluation.key, },
date: v,
}); });
},
}, const warningInterval = computed({
warningInterval: {
get() { get() {
return this.evaluation.warningInterval; return props.evaluation.warningInterval;
}, },
set(v) { set(v) {
this.$store.commit("setEvaluationWarningInterval", { store.commit('setEvaluationWarningInterval', { key: props.evaluation.key, days: v });
key: this.evaluation.key, },
days: v,
}); });
},
}, const timeSpent = computed({
timeSpent: {
get() { get() {
return this.evaluation.timeSpent; return props.evaluation.timeSpent;
}, },
set(v) { set(v) {
this.$store.commit("setEvaluationTimeSpent", { store.commit('setEvaluationTimeSpent', { key: props.evaluation.key, time: v });
key: this.evaluation.key, },
time: v,
}); });
},
}, const comment = computed({
comment: {
get() { get() {
return this.evaluation.comment; return props.evaluation.comment;
}, },
set(v) { set(v) {
this.$store.commit("setEvaluationComment", { store.commit('setEvaluationComment', { key: props.evaluation.key, comment: v });
key: this.evaluation.key, },
comment: v,
}); });
},
}, const getTemplatesAvailables = computed(() => {
}, return store.getters.getTemplatesAvailablesForEvaluation(props.evaluation.evaluation);
methods: { });
ISOToDatetime,
listAllStatus() { // const getAccompanyingPeriod = computed(() => store.work)
console.log("load all status"); function updateStartDate(value) {
let url = `/api/`; startDate.value = value;
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( function updateEndDate(value) {
buildLink( endDate.value = value;
template, }
evaluationId,
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation",
),
);
};
return this.$store.dispatch("submit", callback).catch((e) => { function updateMaxDate(value) {
console.log(e); maxDate.value = value;
throw e; }
});
}, function updateWarningInterval(value) {
onInputDocumentTitle(event) { warningInterval.value = value;
}
function updateTimeSpent(value) {
timeSpent.value = value;
}
function updateComment(value) {
comment.value = value;
}
function onInputDocumentTitle(event) {
const id = Number(event.target.id); const id = Number(event.target.id);
const key = Number(event.target.dataset.key) + 1; const key = Number(event.target.dataset.key) + 1;
const title = event.target.value; const title = event.target.value;
this.$store.commit("updateDocumentTitle", { store.commit('updateDocumentTitle', {
id: id, id: id,
key: key, key: key,
evaluationKey: this.evaluation.key, evaluationKey: props.evaluation.key,
title: title, title: title,
}); });
}, }
addDocument({ stored_object, stored_object_version }) {
function addDocument({ stored_object, stored_object_version }) {
let document = { let document = {
type: "accompanying_period_work_evaluation_document", type: 'accompanying_period_work_evaluation_document',
storedObject: stored_object, storedObject: stored_object,
title: "Nouveau document", title: 'Nouveau document',
}; };
this.$store.commit("addDocument", { store.commit('addDocument', {
key: this.evaluation.key, key: props.evaluation.key,
document, document,
stored_object_version, stored_object_version,
}); });
}, }
/**
* Replaces a document in the store with a new document. function removeDocument(document) {
* if (window.confirm('Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre "' + document.title + '" ?')) {
* @param {Object} oldDocument - The document to be replaced. store.commit('removeDocument', {
* @param {StoredObject} storedObject - The stored object of the new document. key: props.evaluation.key,
* @param {StoredObjectVersion} storedObjectVersion - The new version of the document
* @return {void}
*/
replaceDocument(oldDocument, storedObject, storedObjectVersion) {
let document = {
type: "accompanying_period_work_evaluation_document",
storedObject: storedObject,
title: oldDocument.title,
};
this.$store.commit("replaceDocument", {
key: this.evaluation.key,
document,
oldDocument: oldDocument,
stored_object_version: storedObjectVersion,
});
},
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, document: document,
}); });
} }
}, }
duplicateDocument(document) {
this.$store.dispatch("duplicateDocument", { function duplicateDocument(document) {
evaluation_key: this.evaluation.key, store.dispatch('duplicateDocument', {
evaluation_key: props.evaluation.key,
document: document, document: document,
}); });
}, }
onStatusDocumentChanged(newStatus) {
console.log("onStatusDocumentChanged", newStatus); function onStatusDocumentChanged(newStatus) {
this.$store.commit("statusDocumentChanged", { store.commit('statusDocumentChanged', {
key: this.evaluation.key, key: props.evaluation.key,
newStatus: newStatus, newStatus: newStatus,
}); });
}, }
goToGenerateWorkflowEvaluationDocument({ workflowName, payload }) {
function goToGenerateWorkflowEvaluationDocument({ workflowName, payload }) {
const callback = (data) => { const callback = (data) => {
let evaluation = data.accompanyingPeriodWorkEvaluations.find( let evaluation = data.accompanyingPeriodWorkEvaluations.find((e) => e.key === props.evaluation.key);
(e) => e.key === this.evaluation.key, let updatedDocument = evaluation.documents.find((d) => d.key === payload.doc.key);
);
let updatedDocument = evaluation.documents.find(
(d) => d.key === payload.doc.key,
);
window.location.assign( window.location.assign(
buildLinkCreate( 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) {
function goToGenerateDocumentNotification(document, tos) {
const callback = (data) => { const callback = (data) => {
let evaluation = data.accompanyingPeriodWorkEvaluations.find( let evaluation = data.accompanyingPeriodWorkEvaluations.find((e) => e.key === props.evaluation.key);
(e) => e.key === this.evaluation.key, let updatedDocument = evaluation.documents.find((d) => d.key === document.key);
);
let updatedDocument = evaluation.documents.find(
(d) => d.key === document.key,
);
window.location.assign( window.location.assign(
buildLinkCreateNotification( buildLinkCreateNotification(
"Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument", '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,
), ),
); );
}; };
return this.$store.dispatch("submit", callback).catch((e) => { store.dispatch('submit', callback).catch((e) => {
console.log(e); console.log(e);
throw 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>