WIP enable moving documents to evaluations

- Add new button and logic in `DocumentsList.vue` for moving documents
- Implement `moveDocumentToEvaluation` method in `FormEvaluation.vue`
- Ensure duplication and moving actions are mutually exclusive
- Add event for moving documents to evaluations
This commit is contained in:
2025-08-13 10:56:53 +02:00
parent 9d58904969
commit 7dc7e77c62
2 changed files with 49 additions and 20 deletions

View File

@@ -267,17 +267,33 @@ const emit = defineEmits([
const showAccompanyingPeriodSelector = ref(false); const showAccompanyingPeriodSelector = ref(false);
const selectedEvaluation = ref(null); const selectedEvaluation = ref(null);
const selectedDocument = ref(null); const selectedDocumentToDuplicate = ref(null);
const selectedDocumentToMove = ref(null);
const prepareDocumentDuplicationToWork = (d) => { const prepareDocumentDuplicationToWork = (d) => {
selectedDocument.value = d; selectedDocumentToDuplicate.value = d;
showAccompanyingPeriodSelector.value = true; /** ensure selectedDocumentToMove is null */
selectedDocumentToMove.value = null;
showAccompanyingPeriodSelector.value = true;
};
const prepareDocumentMoveToWork = (d) => {
selectedDocumentToMove.value = d;
/** ensure selectedDocumentToDuplicate is null */
selectedDocumentToDuplicate.value = null;
showAccompanyingPeriodSelector.value = true;
}; };
watch(selectedEvaluation, (val) => { watch(selectedEvaluation, (val) => {
if (selectedDocumentToDuplicate.value) {
emit("duplicateDocumentToEvaluation", { emit("duplicateDocumentToEvaluation", {
evaluation: val, evaluation: val,
document: selectedDocument.value, document: selectedDocumentToDuplicate.value,
}); });
} else {
console.log('this is the document to move', selectedDocumentToMove.value);
}
}); });
</script> </script>

View File

@@ -20,21 +20,20 @@
<CommentInput :comment="comment" @update:comment="updateComment" /> <CommentInput :comment="comment" @update:comment="updateComment" />
<DocumentsList <DocumentsList
v-if="evaluation.documents.length > 0" v-if="evaluation.documents.length > 0"
:documents="evaluation.documents" :documents="evaluation.documents"
:docAnchorId="docAnchorId" :docAnchorId="docAnchorId"
:accompanyingPeriodId="store.state.work.accompanyingPeriod.id" :accompanyingPeriodId="store.state.work.accompanyingPeriod.id"
@inputDocumentTitle="onInputDocumentTitle" @inputDocumentTitle="onInputDocumentTitle"
@removeDocument="removeDocument" @removeDocument="removeDocument"
@duplicateDocument="duplicateDocument" @duplicateDocument="duplicateDocument"
@duplicate-document-to-evaluation=" @duplicate-document-to-evaluation="duplicateDocumentToEvaluation"
duplicateDocumentToEvaluation @move-document-to-evaluation="moveDocumentToEvaluation"
" @statusDocumentChanged="onStatusDocumentChanged"
@statusDocumentChanged="onStatusDocumentChanged" @goToGenerateWorkflow="goToGenerateWorkflowEvaluationDocument"
@goToGenerateWorkflow="goToGenerateWorkflowEvaluationDocument" @goToGenerateNotification="goToGenerateDocumentNotification"
@goToGenerateNotification="goToGenerateDocumentNotification" />
/>
<DocumentActions <DocumentActions
:evaluation="evaluation" :evaluation="evaluation"
@@ -259,6 +258,20 @@ function duplicateDocumentToEvaluation({ evaluation, document }) {
}); });
} }
function moveDocumentToEvaluation({ evaluation, document }) {
const url = `/api/1.0/person/accompanying-course-work-evaluation-document/${document.id}/evaluation/${evaluation.id}/duplicate`;
// console.log('document id', document.id, 'evaluation id', evaluation.id)
makeFetch("POST", url)
.then((response) => {
console.log("new document", response);
toast.open({ message: trans(DOCUMENT_DUPLICATE_TO_EVALUATION_SUCCESS) });
})
.catch((error) => {
console.log(error);
});
}
function onStatusDocumentChanged(newStatus) { function onStatusDocumentChanged(newStatus) {
store.commit("statusDocumentChanged", { store.commit("statusDocumentChanged", {
key: props.evaluation.key, key: props.evaluation.key,