mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Emit duplication of document to an evaluation and add backend logic
This commit is contained in:
parent
3f91c65b30
commit
445e093a28
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\ChillUrlGeneratorInterface;
|
use Chill\MainBundle\Routing\ChillUrlGeneratorInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
|
||||||
use Chill\PersonBundle\Service\AccompanyingPeriodWorkEvaluationDocument\AccompanyingPeriodWorkEvaluationDocumentDuplicator;
|
use Chill\PersonBundle\Service\AccompanyingPeriodWorkEvaluationDocument\AccompanyingPeriodWorkEvaluationDocumentDuplicator;
|
||||||
@ -24,6 +25,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
|
|
||||||
class AccompanyingPeriodWorkEvaluationDocumentDuplicateController
|
class AccompanyingPeriodWorkEvaluationDocumentDuplicateController
|
||||||
{
|
{
|
||||||
@ -56,6 +58,34 @@ class AccompanyingPeriodWorkEvaluationDocumentDuplicateController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ParamConverter("document", options={"id": "document_id"})
|
||||||
|
* @ParamConverter("evaluation", options={"id": "evaluation_id"})
|
||||||
|
*/
|
||||||
|
#[Route('/api/1.0/person/accompanying-course-work-evaluation-document/{document_id}/evaluation/{evaluation_id}/duplicate', methods: ['POST'])]
|
||||||
|
public function duplicateToEvaluationApi(AccompanyingPeriodWorkEvaluationDocument $document, AccompanyingPeriodWorkEvaluation $evaluation): Response
|
||||||
|
{
|
||||||
|
$work = $evaluation->getAccompanyingPeriodWork();
|
||||||
|
|
||||||
|
if (!$this->security->isGranted(AccompanyingPeriodWorkVoter::UPDATE, $work)) {
|
||||||
|
throw new AccessDeniedHttpException('not allowed to edit this accompanying period work');
|
||||||
|
}
|
||||||
|
|
||||||
|
$duplicatedDocument = $this->duplicator->duplicateToEvaluation($document, $evaluation);
|
||||||
|
|
||||||
|
$this->entityManager->persist($duplicatedDocument);
|
||||||
|
$this->entityManager->persist($duplicatedDocument->getStoredObject());
|
||||||
|
$this->entityManager->persist($evaluation);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
dump($duplicatedDocument);
|
||||||
|
|
||||||
|
return new JsonResponse(
|
||||||
|
$this->serializer->serialize($duplicatedDocument, 'json', [AbstractNormalizer::GROUPS => ['read']]),
|
||||||
|
json: true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[Route('/{_locale}/person/accompanying-course-work-evaluation-document/{id}/duplicate', name: 'chill_person_accompanying_period_work_evaluation_document_duplicate', methods: ['POST'])]
|
#[Route('/{_locale}/person/accompanying-course-work-evaluation-document/{id}/duplicate', name: 'chill_person_accompanying_period_work_evaluation_document_duplicate', methods: ['POST'])]
|
||||||
public function duplicate(AccompanyingPeriodWorkEvaluationDocument $document): Response
|
public function duplicate(AccompanyingPeriodWorkEvaluationDocument $document): Response
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@
|
|||||||
<a class="dropdown-item" @click="$emit('duplicateDocument', d)">Dupliquer ici</a>
|
<a class="dropdown-item" @click="$emit('duplicateDocument', d)">Dupliquer ici</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item" @click="showAccompanyingPeriodSelector = true">Dupliquer vers un autre actions d'accompagnement</a>
|
<a class="dropdown-item" @click="prepareDocumentDuplicationToWork(d)">Dupliquer vers un autre actions d'accompagnement</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -147,13 +147,19 @@ import AccompanyingPeriodWorkSelectorModal
|
|||||||
from "ChillPersonAssets/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkSelectorModal.vue";
|
from "ChillPersonAssets/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkSelectorModal.vue";
|
||||||
|
|
||||||
defineProps(['documents', 'docAnchorId', 'accompanyingPeriodId']);
|
defineProps(['documents', 'docAnchorId', 'accompanyingPeriodId']);
|
||||||
defineEmits(['inputDocumentTitle', 'removeDocument', 'duplicateDocument', 'statusDocumentChanged', 'goToGenerateWorkflow', 'goToGenerateNotification']);
|
const emit = defineEmits(['inputDocumentTitle', 'removeDocument', 'duplicateDocument', 'statusDocumentChanged', 'goToGenerateWorkflow', 'goToGenerateNotification', 'duplicateDocumentToWork']);
|
||||||
|
|
||||||
const showAccompanyingPeriodSelector = ref(false);
|
const showAccompanyingPeriodSelector = ref(false);
|
||||||
const selectedEvaluation = ref(null);
|
const selectedEvaluation = ref(null);
|
||||||
|
const selectedDocument = ref(null);
|
||||||
|
|
||||||
|
const prepareDocumentDuplicationToWork = (d) => {
|
||||||
|
selectedDocument.value = d
|
||||||
|
showAccompanyingPeriodSelector.value = true
|
||||||
|
}
|
||||||
|
|
||||||
watch(selectedEvaluation, (val) => {
|
watch(selectedEvaluation, (val) => {
|
||||||
console.log("selected evaluation changed:", val);
|
emit('duplicateDocumentToEvaluation', {'evaluation': val, 'document': selectedDocument.value})
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
@inputDocumentTitle="onInputDocumentTitle"
|
@inputDocumentTitle="onInputDocumentTitle"
|
||||||
@removeDocument="removeDocument"
|
@removeDocument="removeDocument"
|
||||||
@duplicateDocument="duplicateDocument"
|
@duplicateDocument="duplicateDocument"
|
||||||
|
@duplicate-document-to-evaluation="duplicateDocumentToEvaluation"
|
||||||
@statusDocumentChanged="onStatusDocumentChanged"
|
@statusDocumentChanged="onStatusDocumentChanged"
|
||||||
@goToGenerateWorkflow="goToGenerateWorkflowEvaluationDocument"
|
@goToGenerateWorkflow="goToGenerateWorkflowEvaluationDocument"
|
||||||
@goToGenerateNotification="goToGenerateDocumentNotification"
|
@goToGenerateNotification="goToGenerateDocumentNotification"
|
||||||
@ -54,6 +55,7 @@ import TimeSpentInput from './TimeSpentInput.vue';
|
|||||||
import CommentInput from './CommentInput.vue';
|
import CommentInput from './CommentInput.vue';
|
||||||
import DocumentsList from './DocumentsList.vue';
|
import DocumentsList from './DocumentsList.vue';
|
||||||
import DocumentActions from './DocumentActions.vue';
|
import DocumentActions from './DocumentActions.vue';
|
||||||
|
import {makeFetch} from "ChillMainAssets/lib/api/apiMethods";
|
||||||
|
|
||||||
const props = defineProps(['evaluation', 'docAnchorId']);
|
const props = defineProps(['evaluation', 'docAnchorId']);
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
@ -213,6 +215,21 @@ function duplicateDocument(document) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function duplicateDocumentToEvaluation({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)
|
||||||
|
this.$toast.open({ message: 'Le document a été dupliquer' });
|
||||||
|
})
|
||||||
|
.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,
|
||||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Service\AccompanyingPeriodWorkEvaluationDocument;
|
namespace Chill\PersonBundle\Service\AccompanyingPeriodWorkEvaluationDocument;
|
||||||
|
|
||||||
use Chill\DocStoreBundle\Service\StoredObjectDuplicate;
|
use Chill\DocStoreBundle\Service\StoredObjectDuplicate;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||||
use Symfony\Component\Clock\ClockInterface;
|
use Symfony\Component\Clock\ClockInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
@ -36,4 +37,17 @@ class AccompanyingPeriodWorkEvaluationDocumentDuplicator
|
|||||||
|
|
||||||
return $newDocument;
|
return $newDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function duplicateToEvaluation(AccompanyingPeriodWorkEvaluationDocument $document, AccompanyingPeriodWorkEvaluation $evaluation): AccompanyingPeriodWorkEvaluationDocument
|
||||||
|
{
|
||||||
|
$newDocument = new AccompanyingPeriodWorkEvaluationDocument();
|
||||||
|
$newDocument
|
||||||
|
->setTitle($document->getTitle().' ('.$this->translator->trans('accompanying_course_evaluation_document.duplicated_at', ['at' => $this->clock->now()]).')')
|
||||||
|
->setStoredObject($this->storedObjectDuplicate->duplicate($document->getStoredObject()))
|
||||||
|
;
|
||||||
|
|
||||||
|
$evaluation->addDocument($newDocument);
|
||||||
|
|
||||||
|
return $newDocument;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1993,3 +1993,33 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
|
|
||||||
|
/1.0/person/accompanying-course-work-evaluation-document/{document_id}/evaluation/{evaluation_id}/duplicate:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- accompanying-course-work-evaluation-document
|
||||||
|
summary: Dupliate an an accompanying period work evaluation document to another evaluation
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: document_id
|
||||||
|
required: true
|
||||||
|
description: The document's id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: integer
|
||||||
|
minimum: 1
|
||||||
|
- in: path
|
||||||
|
name: evaluation_id
|
||||||
|
required: true
|
||||||
|
description: The evaluation's id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: integer
|
||||||
|
minimum: 1
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
@ -746,6 +746,33 @@ evaluation:
|
|||||||
delay: Délai
|
delay: Délai
|
||||||
notificationDelay: Délai de notification
|
notificationDelay: Délai de notification
|
||||||
url: Lien internet
|
url: Lien internet
|
||||||
|
title: Ecrire une évaluation
|
||||||
|
status: Statut
|
||||||
|
choose_a_status: Choisir un statut
|
||||||
|
startdate: Date d'ouverture
|
||||||
|
enddate: Date de fin
|
||||||
|
maxdate: Date d'échéance
|
||||||
|
warning_interval: Rappel (jours)
|
||||||
|
public_comment: Note publique
|
||||||
|
comment_placeholder: Commencez à écrire ...
|
||||||
|
generate_a_document: Générer un document
|
||||||
|
choose_a_template: Choisir un modèle
|
||||||
|
add_a_document: Ajouter un document
|
||||||
|
add: Ajouter une évaluation
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
goal:
|
goal:
|
||||||
desactivationDate: Date de désactivation
|
desactivationDate: Date de désactivation
|
||||||
@ -770,7 +797,6 @@ relation:
|
|||||||
reverseTitle: Deuxième membre
|
reverseTitle: Deuxième membre
|
||||||
|
|
||||||
days: jours
|
days: jours
|
||||||
months: mois
|
|
||||||
years: années
|
years: années
|
||||||
|
|
||||||
# specific to closing motive
|
# specific to closing motive
|
||||||
@ -1505,3 +1531,6 @@ acpw_duplicate:
|
|||||||
Accompanying period work to keep: Action d'accompagnement à conserver
|
Accompanying period work to keep: Action d'accompagnement à conserver
|
||||||
to keep: Action d'accompagnement à conserver
|
to keep: Action d'accompagnement à conserver
|
||||||
to delete: Action d'accompagnement à supprimer
|
to delete: Action d'accompagnement à supprimer
|
||||||
|
|
||||||
|
document_duplicate:
|
||||||
|
to_evaluation_success: "Le document a été dupliquer"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user