Commit b113a1ff authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout du namespace au template

parent 7eb39694
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ create table unicaen_renderer_template
    id serial not null constraint unicaen_document_template_pk primary key,
    code varchar(256) not null,
    description text,
    namespace varchar(1024),
    document_type varchar(256) not null,
    document_sujet text not null,
    document_corps text not null,
+20 −22
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ return [
                                'order'    => 10000,
                                'dropdown-header' => true,
                            ],
                            'pages' => [
                            'macro' => [
                                'label' => 'Macros',
                                'route' => 'contenu/macro',
@@ -51,5 +50,4 @@ return [
            ],
        ],
    ],
    ],
];
 No newline at end of file
+13 −0
Original line number Diff line number Diff line
@@ -25,6 +25,19 @@ Privilèges associés au module
Dépendances
===========

CHANGELOG
---------

**5.0.5**  - Ajout de la notion de namespace au template pour facilitité l'exploitation

Modification du schéma
----------------------

avec la 5.0.5
```sql
alter table unicaen_renderer_template add namespace varchar(1024);
```

Dépendance à **UnicaenPrivilege**
----------------------------------
1. Dans **vendor/unicaen/renderer/config/merged/index.config.php**, **vendor/unicaen/renderer/config/merged/macro.config.php**, **vendor/unicaen/renderer/config/merged/rendu.config.php**, **vendor/unicaen/renderer/config/merged/template.config.php** : `UnicaenPrivilege\Guard\PrivilegeController` pour les gardes liées aux actions.
+28 −2
Original line number Diff line number Diff line
@@ -15,13 +15,39 @@ class TemplateController extends AbstractActionController {
    use MacroServiceAwareTrait;
    use TemplateFormAwareTrait;

    public function indexAction()
    const SANS_NAMESPACE = "Sans namespace";

    public function indexAction() : ViewModel
    {
        $templates = $this->getTemplateService()->getTemplates();
        $selected = $this->params()->fromQuery('namespace');

        /** @var Template[] $allTemplates */
        $allTemplates = $this->getTemplateService()->getTemplates();

        $namespaces = [];
        foreach ($allTemplates as $template) {
            $namespace = $template->getNamespace();
            $namespaces[$namespace][] = $template;
        }

        $templates = [];
        foreach ($allTemplates as $template) {
            if ($selected === null or $selected === "") {
                $templates[] = $template;
            } else {
                if ($selected === TemplateController::SANS_NAMESPACE) {
                    if ($template->getNamespace() === null) $templates[] = $template;
                }  else {
                    if ($template->getNamespace() === $selected) $templates[] = $template;
                }
            }
        }

        return new ViewModel([
            'title' => 'Gestion des templates',
            'templates' => $templates,
            'namespaces' => $namespaces,
            'selected' => $selected,
        ]);
    }

+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

        <field name="code"              column="code"                   type="string"    length="256"     nullable="false" />
        <field name="description"       column="description"            type="string"    length="4096"    nullable="false" />
        <field name="namespace"         column="namespace"              type="string"    length="1024"    nullable="false" />
        <field name="type"              column="document_type"          type="string"    length="256"     nullable="false" />
        <field name="sujet"             column="document_sujet"         type="string"    length="4096"    nullable="false" />
        <field name="corps"             column="document_corps"         type="string"    length="4096"    nullable="false" />
Loading