mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add document from activity
This commit is contained in:
parent
c6373a075d
commit
79b82e09e1
@ -201,12 +201,36 @@ final class ActivityController extends AbstractController
|
|||||||
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
||||||
'activityType' => $entity->getActivityType(),
|
'activityType' => $entity->getActivityType(),
|
||||||
'accompanyingPeriod' => $accompanyingPeriod,
|
'accompanyingPeriod' => $accompanyingPeriod,
|
||||||
])->handleRequest($request);
|
]);
|
||||||
|
|
||||||
|
if ($form->has('documents')) {
|
||||||
|
$form->add('gendocTemplateId', HiddenType::class, [
|
||||||
|
'mapped' => false,
|
||||||
|
'data' => null,
|
||||||
|
'attr' => [
|
||||||
|
// required for js
|
||||||
|
'data-template-id' => 'data-template-id',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$this->entityManager->persist($entity);
|
$this->entityManager->persist($entity);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
if ($form->has('gendocTemplateId') && '' !== $form['gendocTemplateId']) {
|
||||||
|
return $this->redirectToRoute(
|
||||||
|
'chill_docgenerator_generate_from_template',
|
||||||
|
[
|
||||||
|
'template' => $form->get('gendocTemplateId')->getData(),
|
||||||
|
'entityClassName' => Activity::class,
|
||||||
|
'entityId' => $entity->getId(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
|
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
|
||||||
|
|
||||||
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
@ -410,12 +434,20 @@ final class ActivityController extends AbstractController
|
|||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
if ($form->has('gendocTemplateId')) {
|
|
||||||
dd($form->get('gendocTemplateId')->getData());
|
|
||||||
}
|
|
||||||
$this->entityManager->persist($entity);
|
$this->entityManager->persist($entity);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
if ($form->has('gendocTemplateId') && '' !== $form['gendocTemplateId']) {
|
||||||
|
return $this->redirectToRoute(
|
||||||
|
'chill_docgenerator_generate_from_template',
|
||||||
|
[
|
||||||
|
'template' => $form->get('gendocTemplateId')->getData(),
|
||||||
|
'entityClassName' => Activity::class,
|
||||||
|
'entityId' => $entity->getId(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')->trans('Success : activity created!'));
|
$this->addFlash('success', $this->get('translator')->trans('Success : activity created!'));
|
||||||
|
|
||||||
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
|
@ -2,7 +2,7 @@ import { createApp } from 'vue';
|
|||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||||
import { activityMessages } from './i18n'
|
import { activityMessages } from './i18n'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
|
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplatePreventMoving.vue';
|
||||||
import {fetchTemplates} from 'ChillDocGeneratorAssets/api/pickTemplate.js';
|
import {fetchTemplates} from 'ChillDocGeneratorAssets/api/pickTemplate.js';
|
||||||
|
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
@ -41,9 +41,10 @@ const i18nGendoc = _createI18n({});
|
|||||||
|
|
||||||
document.querySelectorAll('div[data-docgen-template-picker]').forEach(el => {
|
document.querySelectorAll('div[data-docgen-template-picker]').forEach(el => {
|
||||||
fetchTemplates(el.dataset.entityClass).then(templates => {
|
fetchTemplates(el.dataset.entityClass).then(templates => {
|
||||||
let
|
const picker = {
|
||||||
picker = {
|
template:
|
||||||
template: '<pick-template :templates="this.templates" :entityId="this.entityId" @generate="generateDoc" :entityClass="faked"></pick-template>',
|
'<pick-template :templates="this.templates" :preventDefaultMoveToGenerate="true" ' +
|
||||||
|
':entityClass="faked" @go-to-generate-document="generateDoc"></pick-template>',
|
||||||
components: {
|
components: {
|
||||||
PickTemplate,
|
PickTemplate,
|
||||||
},
|
},
|
||||||
@ -59,7 +60,6 @@ document.querySelectorAll('div[data-docgen-template-picker]').forEach(el => {
|
|||||||
console.log('link', link);
|
console.log('link', link);
|
||||||
console.log('template', template);
|
console.log('template', template);
|
||||||
|
|
||||||
event.preventDefault();
|
|
||||||
let hiddenInput = document.querySelector("input[data-template-id]");
|
let hiddenInput = document.querySelector("input[data-template-id]");
|
||||||
|
|
||||||
if (hiddenInput === null) {
|
if (hiddenInput === null) {
|
||||||
@ -69,20 +69,17 @@ document.querySelectorAll('div[data-docgen-template-picker]').forEach(el => {
|
|||||||
|
|
||||||
hiddenInput.value = template;
|
hiddenInput.value = template;
|
||||||
|
|
||||||
let form = document.querySelect('form[name="chill_activitybundle_activity"');
|
let form = document.querySelector('form[name="chill_activitybundle_activity"');
|
||||||
|
|
||||||
if (form === null) {
|
if (form === null) {
|
||||||
console.error('form not found');
|
console.error('form not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('subbmitting formt');
|
|
||||||
|
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
;
|
|
||||||
createApp(picker).use(i18nGendoc).mount(el);
|
createApp(picker).use(i18nGendoc).mount(el);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -24,12 +24,10 @@
|
|||||||
window.activity = {{ activity_json|json_encode|raw }};
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -39,11 +39,9 @@
|
|||||||
window.activity = {{ activity_json|json_encode|raw }};
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -21,12 +21,10 @@
|
|||||||
{% if default_location is not null %}window.default_location_id = {{ default_location.id }}{% endif %};
|
{% if default_location is not null %}window.default_location_id = {{ default_location.id }}{% endif %};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -23,11 +23,9 @@
|
|||||||
window.activity = {{ activity_json|json_encode|raw }};
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -210,11 +210,8 @@ class ActivityContext implements
|
|||||||
*/
|
*/
|
||||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
||||||
{
|
{
|
||||||
$doc = new StoredObject();
|
$entity->addDocument($storedObject);
|
||||||
// TODO push document to remote
|
|
||||||
|
|
||||||
$this->em->persist($doc);
|
$this->em->persist($storedObject);
|
||||||
|
|
||||||
$entity->addDocument($doc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
|||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||||
* @Serializer\Groups({"read","read:accompanyingPeriodWork:light"})
|
* @Serializer\Groups({"read","read:accompanyingPeriodWork:light"})
|
||||||
|
* @Serializer\Context(normalizationContext={"groups"={"read"}}, groups={"read:accompanyingPeriodWork:light"})
|
||||||
*/
|
*/
|
||||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user