mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	Fix document generation and workflow generation do not work on accompanying period work documents
This commit is contained in:
		
							
								
								
									
										6
									
								
								.changes/unreleased/Fixed-20250912-123656.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.changes/unreleased/Fixed-20250912-123656.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| kind: Fixed | ||||
| body: Fix document generation and workflow generation do not work on accompanying period work documents | ||||
| time: 2025-09-12T12:36:56.444183161+02:00 | ||||
| custom: | ||||
|     Issue: "" | ||||
|     SchemaChange: No schema change | ||||
| @@ -4,7 +4,7 @@ import { StoredObject, StoredObjectVersion } from "../../types"; | ||||
| import DropFileWidget from "ChillDocStoreAssets/vuejs/DropFileWidget/DropFileWidget.vue"; | ||||
| import { computed, reactive } from "vue"; | ||||
| import { useToast } from "vue-toast-notification"; | ||||
| import { DOCUMENT_REPLACE, DOCUMENT_ADD, trans } from "translator"; | ||||
| import { DOCUMENT_ADD, trans } from "translator"; | ||||
|  | ||||
| interface DropFileConfig { | ||||
|     allowRemove: boolean; | ||||
| @@ -78,9 +78,7 @@ function closeModal(): void { | ||||
|     > | ||||
|         {{ trans(DOCUMENT_ADD) }} | ||||
|     </button> | ||||
|     <button v-else @click="openModal" class="dropdown-item"> | ||||
|         {{ trans(DOCUMENT_REPLACE) }} | ||||
|     </button> | ||||
|     <button v-else @click="openModal" class="btn btn-edit"></button> | ||||
|     <modal | ||||
|         v-if="state.showModal" | ||||
|         :modal-dialog-class="modalClasses" | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
|         role="button" | ||||
|         data-bs-toggle="dropdown" | ||||
|         aria-expanded="false"> | ||||
|         <i class="fa fa-flash"></i> | ||||
|         <i class="bi bi-lightning-fill"></i> | ||||
|     </a> | ||||
|     <div class="dropdown-menu"> | ||||
|         {% for menu in menus %} | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|             :id="evaluation.id" | ||||
|             :templates="templates" | ||||
|             :preventDefaultMoveToGenerate="true" | ||||
|             @go-to-generate-document="$emit('submitBeforeGenerate', $event)" | ||||
|             @go-to-generate-document="submitBeforeGenerate" | ||||
|         > | ||||
|             <template v-slot:title> | ||||
|                 <label class="col-form-label">{{ | ||||
| @@ -22,7 +22,7 @@ | ||||
|                 <li> | ||||
|                     <drop-file-modal | ||||
|                         :allow-remove="false" | ||||
|                         @add-document="$emit('addDocument', $event)" | ||||
|                         @add-document="emit('addDocument', $event)" | ||||
|                     ></drop-file-modal> | ||||
|                 </li> | ||||
|             </ul> | ||||
| @@ -39,9 +39,34 @@ import { | ||||
|     EVALUATION_GENERATE_A_DOCUMENT, | ||||
|     trans, | ||||
| } from "translator"; | ||||
| import { buildLink } from "ChillDocGeneratorAssets/lib/document-generator"; | ||||
| import { useStore } from "vuex"; | ||||
|  | ||||
| defineProps(["evaluation", "templates"]); | ||||
| defineEmits(["addDocument", "submitBeforeGenerate"]); | ||||
| const store = useStore(); | ||||
|  | ||||
| const props = defineProps(["evaluation", "templates"]); | ||||
| const emit = defineEmits(["addDocument"]); | ||||
|  | ||||
| async function submitBeforeGenerate({ template }) { | ||||
|     const callback = (data) => { | ||||
|         let evaluationId = data.accompanyingPeriodWorkEvaluations.find( | ||||
|             (e) => e.key === props.evaluation.key, | ||||
|         ).id; | ||||
|  | ||||
|         window.location.assign( | ||||
|             buildLink( | ||||
|                 template, | ||||
|                 evaluationId, | ||||
|                 "Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation", | ||||
|             ), | ||||
|         ); | ||||
|     }; | ||||
|  | ||||
|     return store.dispatch("submit", callback).catch((e) => { | ||||
|         console.log(e); | ||||
|         throw e; | ||||
|     }); | ||||
| } | ||||
| </script> | ||||
|  | ||||
| <style scoped> | ||||
|   | ||||
| @@ -58,7 +58,7 @@ | ||||
|                                     :preventDefaultMoveToGenerate="true" | ||||
|                                     :goToGenerateWorkflowPayload="{ doc: d }" | ||||
|                                     @go-to-generate-workflow=" | ||||
|                                         $emit('goToGenerateWorkflow', $event) | ||||
|                                         goToGenerateWorkflowEvaluationDocument | ||||
|                                     " | ||||
|                                 ></list-workflow-modal> | ||||
|                             </li> | ||||
| @@ -95,10 +95,9 @@ | ||||
|                                             <a | ||||
|                                                 class="dropdown-item" | ||||
|                                                 @click=" | ||||
|                                                     $emit( | ||||
|                                                         'goToGenerateNotification', | ||||
|                                                     goToGenerateDocumentNotification( | ||||
|                                                         d, | ||||
|                                                         true, | ||||
|                                                         false, | ||||
|                                                     ) | ||||
|                                                 " | ||||
|                                             > | ||||
| @@ -113,8 +112,7 @@ | ||||
|                                             <a | ||||
|                                                 class="dropdown-item" | ||||
|                                                 @click=" | ||||
|                                                     $emit( | ||||
|                                                         'goToGenerateNotification', | ||||
|                                                     goToGenerateDocumentNotification( | ||||
|                                                         d, | ||||
|                                                         false, | ||||
|                                                     ) | ||||
| @@ -150,15 +148,35 @@ | ||||
|                                     " | ||||
|                                 ></document-action-buttons-group> | ||||
|                             </li> | ||||
|                             <!--replace document--> | ||||
|                             <li | ||||
|                                 v-if=" | ||||
|                                     Number.isInteger(d.id) && | ||||
|                                     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="Number.isInteger(d.id)"> | ||||
|                                 <div class="duplicate-dropdown"> | ||||
|                                     <button | ||||
|                                         class="btn btn-edit dropdown-toggle" | ||||
|                                         class="btn btn-outline-primary dropdown-toggle" | ||||
|                                         type="button" | ||||
|                                         data-bs-toggle="dropdown" | ||||
|                                         aria-expanded="false" | ||||
|                                     > | ||||
|                                         {{ trans(EVALUATION_DOCUMENT_EDIT) }} | ||||
|                                         <i class="bi bi-lightning-fill"></i> | ||||
|                                     </button> | ||||
|                                     <ul class="dropdown-menu"> | ||||
|                                         <!--delete--> | ||||
| @@ -180,27 +198,6 @@ | ||||
|                                                 }} | ||||
|                                             </a> | ||||
|                                         </li> | ||||
|                                         <!--replace document--> | ||||
|                                         <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> | ||||
|                                         <!--duplicate document--> | ||||
|                                         <li> | ||||
|                                             <a | ||||
| @@ -300,35 +297,45 @@ import { | ||||
|     EVALUATION_DOCUMENTS, | ||||
|     EVALUATION_DOCUMENT_MOVE, | ||||
|     EVALUATION_DOCUMENT_DELETE, | ||||
|     EVALUATION_DOCUMENT_EDIT, | ||||
|     EVALUATION_DOCUMENT_DUPLICATE_HERE, | ||||
|     EVALUATION_DOCUMENT_DUPLICATE_TO_OTHER_EVALUATION, | ||||
|     trans, | ||||
| } from "translator"; | ||||
| import { ref, watch } from "vue"; | ||||
| import { computed, ref, watch } from "vue"; | ||||
| import AccompanyingPeriodWorkSelectorModal from "ChillPersonAssets/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkSelectorModal.vue"; | ||||
| import { buildLinkCreate } from "ChillMainAssets/lib/entity-workflow/api"; | ||||
| import { buildLinkCreate as buildLinkCreateNotification } from "ChillMainAssets/lib/entity-notification/api"; | ||||
| import { useStore } from "vuex"; | ||||
|  | ||||
| defineProps([ | ||||
| const props = defineProps([ | ||||
|     "documents", | ||||
|     "docAnchorId", | ||||
|     "accompanyingPeriodId", | ||||
|     "accompanyingPeriodWorkId", | ||||
|     "evaluation", | ||||
| ]); | ||||
| const emit = defineEmits([ | ||||
|     "inputDocumentTitle", | ||||
|     "removeDocument", | ||||
|     "duplicateDocument", | ||||
|     "statusDocumentChanged", | ||||
|     "goToGenerateWorkflow", | ||||
|     "goToGenerateNotification", | ||||
|     "duplicateDocumentToWork", | ||||
| ]); | ||||
|  | ||||
| const store = useStore(); | ||||
|  | ||||
| const showAccompanyingPeriodSelector = ref(false); | ||||
| const selectedEvaluation = ref(null); | ||||
| const selectedDocumentToDuplicate = ref(null); | ||||
| const selectedDocumentToMove = ref(null); | ||||
|  | ||||
| const AmIRefferer = computed(() => { | ||||
|     return !( | ||||
|         store.state.work.accompanyingPeriod.user && | ||||
|         store.state.me && | ||||
|         store.state.work.accompanyingPeriod.user.id !== store.state.me.id | ||||
|     ); | ||||
| }); | ||||
|  | ||||
| const prepareDocumentDuplicationToWork = (d) => { | ||||
|     selectedDocumentToDuplicate.value = d; | ||||
|     /** ensure selectedDocumentToMove is null */ | ||||
| @@ -358,4 +365,91 @@ watch(selectedEvaluation, (val) => { | ||||
|         }); | ||||
|     } | ||||
| }); | ||||
|  | ||||
| async 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, | ||||
|                 "Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument", | ||||
|                 updatedDocument.id, | ||||
|             ), | ||||
|         ); | ||||
|     }; | ||||
|  | ||||
|     return store.dispatch("submit", callback).catch((e) => { | ||||
|         console.log(e); | ||||
|         throw e; | ||||
|     }); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Replaces a document in the store with a new document. | ||||
|  * | ||||
|  * @param {Object} oldDocument - The document to be replaced. | ||||
|  * @param {StoredObject} storedObject - The stored object of the new document. | ||||
|  * @param {StoredObjectVersion} storedObjectVersion - The new version of the document | ||||
|  * @return {void} | ||||
|  */ | ||||
| async function replaceDocument(oldDocument, storedObject, storedObjectVersion) { | ||||
|     let document = { | ||||
|         type: "accompanying_period_work_evaluation_document", | ||||
|         storedObject: storedObject, | ||||
|         title: oldDocument.title, | ||||
|     }; | ||||
|  | ||||
|     return store.commit("replaceDocument", { | ||||
|         key: props.evaluation.key, | ||||
|         document, | ||||
|         oldDocument: oldDocument, | ||||
|         stored_object_version: storedObjectVersion, | ||||
|     }); | ||||
| } | ||||
|  | ||||
| async function goToGenerateDocumentNotification(document, tos) { | ||||
|     const callback = (data) => { | ||||
|         let evaluation = data.accompanyingPeriodWorkEvaluations.find( | ||||
|             (e) => e.key === props.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 | ||||
|                     ? store.state.work.accompanyingPeriod.user?.id | ||||
|                     : null, | ||||
|                 window.location.pathname + | ||||
|                     window.location.search + | ||||
|                     window.location.hash, | ||||
|             ), | ||||
|         ); | ||||
|     }; | ||||
|  | ||||
|     return store.dispatch("submit", callback).catch((e) => { | ||||
|         console.log(e); | ||||
|         throw e; | ||||
|     }); | ||||
| } | ||||
|  | ||||
| async function submitBeforeLeaveToEditor() { | ||||
|     console.log("submit beore edit 2"); | ||||
|     // empty callback | ||||
|     const callback = () => null; | ||||
|     return store.dispatch("submit", callback).catch((e) => { | ||||
|         console.log(e); | ||||
|         throw e; | ||||
|     }); | ||||
| } | ||||
| </script> | ||||
|   | ||||
| @@ -24,8 +24,8 @@ | ||||
|                 v-if="evaluation.documents.length > 0" | ||||
|                 :documents="evaluation.documents" | ||||
|                 :docAnchorId="docAnchorId" | ||||
|                 :evaluation="evaluation" | ||||
|                 :accompanyingPeriodId="store.state.work.accompanyingPeriod.id" | ||||
|                 :accompanying-period-work-id="store.state.work.id" | ||||
|                 @inputDocumentTitle="onInputDocumentTitle" | ||||
|                 @removeDocument="removeDocument" | ||||
|                 @duplicateDocument="duplicateDocument" | ||||
| @@ -34,7 +34,6 @@ | ||||
|                 " | ||||
|                 @move-document-to-evaluation="moveDocumentToEvaluation" | ||||
|                 @statusDocumentChanged="onStatusDocumentChanged" | ||||
|                 @goToGenerateWorkflow="goToGenerateWorkflowEvaluationDocument" | ||||
|                 @goToGenerateNotification="goToGenerateDocumentNotification" | ||||
|             /> | ||||
|  | ||||
| @@ -42,7 +41,6 @@ | ||||
|                 :evaluation="evaluation" | ||||
|                 :templates="getTemplatesAvailables" | ||||
|                 @addDocument="addDocument" | ||||
|                 @submitBeforeGenerate="submitBeforeGenerate" | ||||
|             /> | ||||
|         </div> | ||||
|     </div> | ||||
| @@ -290,29 +288,6 @@ function onStatusDocumentChanged(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, | ||||
|                 "Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument", | ||||
|                 updatedDocument.id, | ||||
|             ), | ||||
|         ); | ||||
|     }; | ||||
|  | ||||
|     store.dispatch("submit", callback).catch((e) => { | ||||
|         console.log(e); | ||||
|         throw e; | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function goToGenerateDocumentNotification(document, tos) { | ||||
|     const callback = (data) => { | ||||
|         let evaluation = data.accompanyingPeriodWorkEvaluations.find( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user