diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-07-22 15:03:12 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-07-22 15:03:12 +0200 |
commit | a86c0db98c3b5f12b0f47532c5136234a5161f5d (patch) | |
tree | 499bf61ef2d5520489a4e15c7e0b67ae577e2d11 /fai_gestion/plugins | |
parent | bee10297dea652f0c22207ae53836fc318067a60 (diff) | |
download | chd_gestion-a86c0db98c3b5f12b0f47532c5136234a5161f5d.zip chd_gestion-a86c0db98c3b5f12b0f47532c5136234a5161f5d.tar.gz chd_gestion-a86c0db98c3b5f12b0f47532c5136234a5161f5d.tar.bz2 |
bake : limit action links to defined controller methods
Diffstat (limited to 'fai_gestion/plugins')
3 files changed, 51 insertions, 3 deletions
diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig index 2ed5249..e48d107 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/form.twig @@ -13,6 +13,29 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ #} +<?php +/** + * Copyright 2016-2018 Ludovic Pouzenc <ludovic@pouzenc.fr> + * Copyright 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr> + * + * This file is part of FAI Gestion forked from CHD Gestion. + * + * FAI Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FAI Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FAI Gestion. If not, see <http://www.gnu.org/licenses/>. + * + * Auto-generated code with CakePHP(tm) bake derived code. +**/ +?> {% set fields = Bake.filterFields(fields, schema, modelObject) %} <nav class="large-2 medium-3 columns" id="actions-sidebar"> <ul class="side-nav"> @@ -31,8 +54,12 @@ {% for type, data in associations %} {%- for alias, details in data %} {%- if details.controller is not same as(_view.name) and details.controller not in done %} +{% if BakeExtra.hasAction('index', details.controller) %} <li><?= $this->Html->link(__('List {{ alias|underscore|humanize }}'), ['controller' => '{{ details.controller }}', 'action' => 'index']) ?></li> +{% endif %} +{% if BakeExtra.hasAction('add', details.controller) %} <li><?= $this->Html->link(__('New {{ alias|singularize|underscore|humanize }}'), ['controller' => '{{ details.controller }}', 'action' => 'add']) ?></li> +{% endif %} {{- "\n" }} {%- set done = done|merge([details.controller]) %} {%- endif %} diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig index f057d35..10a8754 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/index.twig @@ -47,13 +47,16 @@ $this->Form->setTemplates(['label' => '']); <nav class="large-2 medium-3 columns" id="actions-sidebar"> <ul class="side-nav"> <li class="heading"><?= __('Actions') ?></li> - <li><?= $this->Html->link(__('New {{ singularHumanName }}'), ['action' => 'add']) ?></li> +{% if BakeExtra.hasAction('add', modelClass) %} +<li><?= $this->Html->link(__('New {{ singularHumanName }}'), ['action' => 'add']) ?></li> +{% endif %} {% set done = [] %} {% for type, data in associations %} {% for alias, details in data %} {% if details.navLink and details.controller is not same as(_view.name) and details.controller not in done %} +{% if BakeExtra.hasAction('index', details.controller) %} <li><?= $this->Html->link(__('List {{ alias|underscore|humanize }}'), ['controller' => '{{ details.controller }}', 'action' => 'index']) ?></li> - <li><?= $this->Html->link(__('New {{ alias|singularize|underscore|humanize }}'), ['controller' => '{{ details.controller }}', 'action' => 'add']) ?></li> +{% endif %} {% set done = done|merge([details.controller]) %} {% endif %} {% endfor %} @@ -118,9 +121,15 @@ $this->Form->setTemplates(['label' => '']); {% endfor %} {% set pk = '$' ~ singularVar ~ '->' ~ primaryKey[0] %} <td class="actions"> +{% if BakeExtra.hasAction('view', modelClass) %} <?= $this->Html->link(__('View'), ['action' => 'view', {{ pk|raw }}]) ?> +{% endif %} +{% if BakeExtra.hasAction('edit', modelClass) %} <?= $this->Html->link(__('Edit'), ['action' => 'edit', {{ pk|raw }}]) ?> +{% endif %} +{% if BakeExtra.hasAction('delete', modelClass) %} <?= $this->Form->postLink(__('Delete'), ['action' => 'delete', {{ pk|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ pk|raw }})]) ?> +{% endif %} </td> </tr> <?php endforeach; ?> diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig index 69abdd2..354ec12 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig @@ -48,16 +48,28 @@ <nav class="large-2 medium-3 columns" id="actions-sidebar"> <ul class="side-nav"> <li class="heading"><?= __('Actions') ?></li> +{% if BakeExtra.hasAction('edit', modelClass) %} <li><?= $this->Html->link(__('Edit {{ singularHumanName }}'), ['action' => 'edit', {{ pK|raw }}]) ?> </li> +{% endif %} +{% if BakeExtra.hasAction('delete', modelClass) %} <li><?= $this->Form->postLink(__('Delete {{ singularHumanName }}'), ['action' => 'delete', {{ pK|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ pK|raw }})]) ?> </li> +{% endif %} +{% if BakeExtra.hasAction('index', modelClass) %} <li><?= $this->Html->link(__('List {{ pluralHumanName }}'), ['action' => 'index']) ?> </li> - <li><?= $this->Html->link(__('New {{ singularHumanName }}'), ['action' => 'add']) ?> </li> +{% endif %} {% set done = [] %} {% for type, data in associations %} {% for alias, details in data %} +{% if false %} +// Bug here _view.name is NULL +{% endif %} {% if details.controller is not same as(_view.name) and details.controller not in done %} +{% if BakeExtra.hasAction('index', details.controller) %} <li><?= $this->Html->link(__('List {{ alias|underscore|humanize }}'), ['controller' => '{{ details.controller }}', 'action' => 'index']) ?> </li> +{% endif %} +{% if BakeExtra.hasAction('add', details.controller) %} <li><?= $this->Html->link(__('New {{ alias|underscore|singularize|humanize }}'), ['controller' => '{{ details.controller }}', 'action' => 'add']) ?> </li> +{% endif %} {% set done = done|merge(['controller']) %} {% endif %} {% endfor %} |