mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-15 19:24:57 +00:00
enable moving documents between evaluations
- Add Vuex action and mutation for moving documents between evaluations - Implement `moveDocumentToEvaluation` API method - Update `DocumentsList.vue` and `FormEvaluation.vue` to handle move actions
This commit is contained in:
@@ -6,15 +6,11 @@
|
|||||||
class="item-bloc"
|
class="item-bloc"
|
||||||
v-for="(d, i) in documents"
|
v-for="(d, i) in documents"
|
||||||
:key="d.id"
|
:key="d.id"
|
||||||
:class="[
|
:class="[parseInt(docAnchorId) === d.id ? 'bg-blink' : 'nothing']"
|
||||||
parseInt(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">
|
<div class="input-group input-group-lg mb-3 row">
|
||||||
<label class="col-sm-3 col-form-label"
|
<label class="col-sm-3 col-form-label">Titre du document:</label>
|
||||||
>Titre du document:</label
|
|
||||||
>
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input
|
<input
|
||||||
class="form-control document-title"
|
class="form-control document-title"
|
||||||
@@ -31,10 +27,7 @@
|
|||||||
<div class="item-col item-meta">
|
<div class="item-col item-meta">
|
||||||
<p v-if="d.createdBy" class="createdBy">
|
<p v-if="d.createdBy" class="createdBy">
|
||||||
Créé par {{ d.createdBy.text }}<br />
|
Créé par {{ d.createdBy.text }}<br />
|
||||||
Le
|
Le {{ $d(ISOToDatetime(d.createdAt.datetime), "long") }}
|
||||||
{{
|
|
||||||
$d(ISOToDatetime(d.createdAt.datetime), "long")
|
|
||||||
}}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,8 +36,7 @@
|
|||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li
|
<li
|
||||||
v-if="
|
v-if="
|
||||||
d.workflows_availables.length > 0 ||
|
d.workflows_availables.length > 0 || d.workflows.length > 0
|
||||||
d.workflows.length > 0
|
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<list-workflow-modal
|
<list-workflow-modal
|
||||||
@@ -52,9 +44,7 @@
|
|||||||
:allowCreate="true"
|
:allowCreate="true"
|
||||||
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument"
|
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument"
|
||||||
:relatedEntityId="d.id"
|
:relatedEntityId="d.id"
|
||||||
:workflowsAvailables="
|
:workflowsAvailables="d.workflows_availables"
|
||||||
d.workflows_availables
|
|
||||||
"
|
|
||||||
:preventDefaultMoveToGenerate="true"
|
:preventDefaultMoveToGenerate="true"
|
||||||
:goToGenerateWorkflowPayload="{ doc: d }"
|
:goToGenerateWorkflowPayload="{ doc: d }"
|
||||||
@go-to-generate-workflow="
|
@go-to-generate-workflow="
|
||||||
@@ -66,22 +56,14 @@
|
|||||||
<button
|
<button
|
||||||
v-if="AmIRefferer"
|
v-if="AmIRefferer"
|
||||||
class="btn btn-notify"
|
class="btn btn-notify"
|
||||||
@click="
|
@click="$emit('goToGenerateNotification', d, false)"
|
||||||
$emit(
|
|
||||||
'goToGenerateNotification',
|
|
||||||
d,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
"
|
|
||||||
></button>
|
></button>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<button
|
<button
|
||||||
id="btnGroupNotifyButtons"
|
id="btnGroupNotifyButtons"
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-notify dropdown-toggle"
|
class="btn btn-notify dropdown-toggle"
|
||||||
:title="
|
:title="trans(EVALUATION_NOTIFICATION_SEND)"
|
||||||
trans(EVALUATION_NOTIFICATION_SEND)
|
|
||||||
"
|
|
||||||
data-bs-toggle="dropdown"
|
data-bs-toggle="dropdown"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
>
|
>
|
||||||
@@ -94,37 +76,17 @@
|
|||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
@click="
|
@click="$emit('goToGenerateNotification', d, true)"
|
||||||
$emit(
|
|
||||||
'goToGenerateNotification',
|
|
||||||
d,
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
{{
|
{{ trans(EVALUATION_NOTIFICATION_NOTIFY_REFERRER) }}
|
||||||
trans(
|
|
||||||
EVALUATION_NOTIFICATION_NOTIFY_REFERRER,
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
@click="
|
@click="$emit('goToGenerateNotification', d, false)"
|
||||||
$emit(
|
|
||||||
'goToGenerateNotification',
|
|
||||||
d,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
{{
|
{{ trans(EVALUATION_NOTIFICATION_NOTIFY_ANY) }}
|
||||||
trans(
|
|
||||||
EVALUATION_NOTIFICATION_NOTIFY_ANY,
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -135,15 +97,10 @@
|
|||||||
:stored-object="d.storedObject"
|
:stored-object="d.storedObject"
|
||||||
:filename="d.title"
|
:filename="d.title"
|
||||||
:can-edit="true"
|
:can-edit="true"
|
||||||
:execute-before-leave="
|
:execute-before-leave="submitBeforeLeaveToEditor"
|
||||||
submitBeforeLeaveToEditor
|
:davLink="d.storedObject._links?.dav_link.href"
|
||||||
"
|
|
||||||
:davLink="
|
|
||||||
d.storedObject._links?.dav_link.href
|
|
||||||
"
|
|
||||||
:davLinkExpiration="
|
:davLinkExpiration="
|
||||||
d.storedObject._links?.dav_link
|
d.storedObject._links?.dav_link.expiration
|
||||||
.expiration
|
|
||||||
"
|
"
|
||||||
@on-stored-object-status-change="
|
@on-stored-object-status-change="
|
||||||
$emit('statusDocumentChanged', $event)
|
$emit('statusDocumentChanged', $event)
|
||||||
@@ -158,35 +115,20 @@
|
|||||||
data-bs-toggle="dropdown"
|
data-bs-toggle="dropdown"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
>
|
>
|
||||||
{{
|
{{ trans(EVALUATION_DOCUMENT_DUPLICATE) }}
|
||||||
trans(EVALUATION_DOCUMENT_DUPLICATE)
|
|
||||||
}}
|
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
@click="
|
@click="$emit('duplicateDocument', d)"
|
||||||
$emit(
|
>{{ trans(EVALUATION_DOCUMENT_DUPLICATE_HERE) }}</a
|
||||||
'duplicateDocument',
|
|
||||||
d,
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>{{
|
|
||||||
trans(
|
|
||||||
EVALUATION_DOCUMENT_DUPLICATE_HERE,
|
|
||||||
)
|
|
||||||
}}</a
|
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
@click="
|
@click="prepareDocumentDuplicationToWork(d)"
|
||||||
prepareDocumentDuplicationToWork(
|
|
||||||
d,
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>{{
|
>{{
|
||||||
trans(
|
trans(
|
||||||
EVALUATION_DOCUMENT_DUPLICATE_TO_OTHER_EVALUATION,
|
EVALUATION_DOCUMENT_DUPLICATE_TO_OTHER_EVALUATION,
|
||||||
@@ -197,6 +139,11 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li v-if="d.storedObject._permissions.canEdit">
|
||||||
|
<a class="btn btn-choose" @click="prepareDocumentMoveToWork(d)"
|
||||||
|
>EVALUATION_DOCUMENT_MOVE</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
<li v-if="d.storedObject._permissions.canEdit">
|
<li v-if="d.storedObject._permissions.canEdit">
|
||||||
<drop-file-modal
|
<drop-file-modal
|
||||||
:existing-doc="d.storedObject"
|
:existing-doc="d.storedObject"
|
||||||
@@ -213,10 +160,7 @@
|
|||||||
></drop-file-modal>
|
></drop-file-modal>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="d.workflows.length === 0">
|
<li v-if="d.workflows.length === 0">
|
||||||
<a
|
<a class="btn btn-delete" @click="$emit('removeDocument', d)">
|
||||||
class="btn btn-delete"
|
|
||||||
@click="$emit('removeDocument', d)"
|
|
||||||
>
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -294,7 +238,7 @@ watch(selectedEvaluation, (val) => {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
emit("moveDocumentToEvaluation", {
|
emit("moveDocumentToEvaluation", {
|
||||||
evaluation: val,
|
evaluationDest: val,
|
||||||
document: selectedDocumentToMove.value,
|
document: selectedDocumentToMove.value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -258,17 +258,12 @@ function duplicateDocumentToEvaluation({ evaluation, document }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveDocumentToEvaluation({ evaluation, document }) {
|
function moveDocumentToEvaluation({ evaluationDest, document }) {
|
||||||
const url = `/api/1.0/person/accompanying-course-work-evaluation-document/${document.id}/evaluation/${evaluation.id}/move`;
|
console.log("dest eval in formEvaluation", evaluationDest);
|
||||||
// console.log('document id', document.id, 'evaluation id', evaluation.id)
|
store.dispatch("moveDocumentToEvaluation", {
|
||||||
|
evaluationInitial: props.evaluation,
|
||||||
makeFetch("POST", url)
|
evaluationDest: evaluationDest,
|
||||||
.then((response) => {
|
document: document,
|
||||||
console.log("document", response);
|
|
||||||
toast.open({ message: trans(DOCUMENT_DUPLICATE_TO_EVALUATION_SUCCESS) });
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log(error);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@ import { fetchTemplates } from "ChillDocGeneratorAssets/api/pickTemplate.js";
|
|||||||
import {
|
import {
|
||||||
duplicate,
|
duplicate,
|
||||||
duplicateDocumentToEvaluation,
|
duplicateDocumentToEvaluation,
|
||||||
|
moveDocumentToEvaluation,
|
||||||
} from "../_api/accompanyingCourseWorkEvaluationDocument";
|
} from "../_api/accompanyingCourseWorkEvaluationDocument";
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== "production";
|
const debug = process.env.NODE_ENV !== "production";
|
||||||
@@ -314,6 +315,29 @@ const store = createStore({
|
|||||||
evaluationDest.documents.splice(0, 0, document);
|
evaluationDest.documents.splice(0, 0, document);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
moveDocumentToEvaluation(
|
||||||
|
state,
|
||||||
|
{ evaluationInitial, evaluationDest, document },
|
||||||
|
) {
|
||||||
|
let evaluationA = state.evaluationsPicked.find(
|
||||||
|
(e) => e.id === evaluationInitial.id,
|
||||||
|
);
|
||||||
|
let evaluationB = state.evaluationsPicked.find(
|
||||||
|
(e) => e.id === evaluationDest.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
// add document to chosen evaluation
|
||||||
|
document.key = evaluationB.documents.length + 1;
|
||||||
|
evaluationB.documents.splice(0, 0, document);
|
||||||
|
|
||||||
|
// remove document from original evaluation
|
||||||
|
const indexToRemove = evaluationA.documents.findIndex(
|
||||||
|
(doc) => doc.id === document.id,
|
||||||
|
);
|
||||||
|
if (indexToRemove !== -1) {
|
||||||
|
evaluationA.documents.splice(indexToRemove, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Replaces a document in the state with a new document.
|
* Replaces a document in the state with a new document.
|
||||||
*
|
*
|
||||||
@@ -627,6 +651,18 @@ const store = createStore({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async moveDocumentToEvaluation(
|
||||||
|
{ commit },
|
||||||
|
{ evaluationInitial, evaluationDest, document },
|
||||||
|
) {
|
||||||
|
commit("moveDocumentToEvaluation", {
|
||||||
|
evaluationInitial,
|
||||||
|
evaluationDest,
|
||||||
|
document,
|
||||||
|
});
|
||||||
|
|
||||||
|
await moveDocumentToEvaluation(document.id, evaluationDest.id);
|
||||||
|
},
|
||||||
removeDocument({ commit }, payload) {
|
removeDocument({ commit }, payload) {
|
||||||
commit("removeDocument", payload);
|
commit("removeDocument", payload);
|
||||||
},
|
},
|
||||||
|
@@ -19,3 +19,13 @@ export const duplicateDocumentToEvaluation = async (
|
|||||||
`/api/1.0/person/accompanying-course-work-evaluation-document/${document_id}/evaluation/${evaluation_id}/duplicate`,
|
`/api/1.0/person/accompanying-course-work-evaluation-document/${document_id}/evaluation/${evaluation_id}/duplicate`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const moveDocumentToEvaluation = async (
|
||||||
|
document_id: number,
|
||||||
|
evaluation_id: number,
|
||||||
|
): Promise<AccompanyingPeriodWorkEvaluationDocument> => {
|
||||||
|
return makeFetch<null, AccompanyingPeriodWorkEvaluationDocument>(
|
||||||
|
"POST",
|
||||||
|
`/api/1.0/person/accompanying-course-work-evaluation-document/${document_id}/evaluation/${evaluation_id}/move`,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user