mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DocGeneratorTemplate use StoredObject for storign the template
This commit is contained in:
parent
a3da9c538c
commit
7fe2172f05
@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
@ -46,9 +47,9 @@ class DocGeneratorTemplate
|
||||
private array $entities = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"}).)
|
||||
*/
|
||||
private string $file;
|
||||
private ?StoredObject $file = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
@ -58,6 +59,7 @@ class DocGeneratorTemplate
|
||||
*/
|
||||
private int $id;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
@ -79,7 +81,7 @@ class DocGeneratorTemplate
|
||||
return $this->entities;
|
||||
}
|
||||
|
||||
public function getFile(): ?string
|
||||
public function getFile(): ?StoredObject
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
@ -94,6 +96,7 @@ class DocGeneratorTemplate
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
public function setContext(string $context): self
|
||||
{
|
||||
$this->context = $context;
|
||||
@ -115,7 +118,7 @@ class DocGeneratorTemplate
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFile(string $file): self
|
||||
public function setFile(StoredObject $file): self
|
||||
{
|
||||
$this->file = $file;
|
||||
|
||||
|
@ -14,8 +14,10 @@ namespace Chill\DocGeneratorBundle\Form;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\DocStoreBundle\Form\StoredObjectType;
|
||||
|
||||
class DocGeneratorTemplateType extends AbstractType
|
||||
{
|
||||
@ -25,8 +27,18 @@ class DocGeneratorTemplateType extends AbstractType
|
||||
->add('name', TranslatableStringFormType::class, [
|
||||
'label' => 'Nom',
|
||||
])
|
||||
->add('context')
|
||||
->add('entities', ChoiceType::class, [
|
||||
'multiple' => true,
|
||||
'choices' => [
|
||||
'AccompanyingPeriod' => 'Chill\PersonBundle\Entity\AccompanyingPeriod',
|
||||
'SocialWork\SocialAction' => 'Chill\PersonBundle\Entity\SocialWork\SocialAction'
|
||||
]])
|
||||
->add('description')
|
||||
->add('file');
|
||||
->add('file', StoredObjectType::class, [
|
||||
'error_bubbling' => true
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
|
@ -10,3 +10,12 @@
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||
{% endblock %}
|
||||
|
@ -5,7 +5,7 @@
|
||||
{% block table_entities_thead_tr %}
|
||||
<th></th>
|
||||
<th>{{ 'Title'|trans }}</th>
|
||||
<th>{{ 'File'|trans }}</th>
|
||||
<th>{{ 'Edit'|trans }}</th>
|
||||
{% endblock %}
|
||||
|
||||
{% block table_entities_tbody %}
|
||||
@ -13,7 +13,11 @@
|
||||
<tr>
|
||||
<td>{{ entity.id }}</td>
|
||||
<td>{{ entity.name | localize_translatable_string }}</td>
|
||||
<td>{{ entity.file }}</td>
|
||||
<td>
|
||||
<a href="{{ chill_path_add_return_path('chill_crud_docgen_template_edit', { 'id': entity.id }) }}" class="btn btn-edit">
|
||||
{{ 'Edit'|trans }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
@ -9,3 +9,12 @@
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||
{% endblock %}
|
||||
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\DocGenerator;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Using DocStore objects inside the DocGenTemplate
|
||||
*/
|
||||
final class Version20211103111010 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Using DocStore objects inside the DocGenTemplate';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ADD file_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP file');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ALTER entities SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ALTER context SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ADD CONSTRAINT FK_49A347E893CB796C FOREIGN KEY (file_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_49A347E893CB796C ON chill_docgen_template (file_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP CONSTRAINT FK_49A347E893CB796C');
|
||||
$this->addSql('DROP INDEX IDX_49A347E893CB796C');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ADD file VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP file_id');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ALTER entities DROP NOT NULL');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ALTER context DROP NOT NULL');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user