From 61cad7c5f1680e3c91da16f2d5deb38ceb73fffb Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 21 Jul 2018 21:48:53 +0200 Subject: no 200 item limit on drop-down lists, index : better codegen --- app-from-scratch.sh | 7 +++++++ .../src/Template/Bake/Element/Controller/_empty.twig | 2 -- .../src/Template/Bake/Element/Controller/add.twig | 2 +- .../src/Template/Bake/Element/Controller/edit.twig | 2 +- .../src/Template/Bake/Element/Controller/index.twig | 12 ++++++++---- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app-from-scratch.sh b/app-from-scratch.sh index 519c68b..e06be6c 100644 --- a/app-from-scratch.sh +++ b/app-from-scratch.sh @@ -344,3 +344,10 @@ git add src/Template/Layout/default.ctp .gitignore cake bake all --everything --force --quiet git add ../app-from-scratch.sh git commit -m "rename ippubliques -> ip_publiques, .gitignore autogenerated code for now" +# 51f0aacb4d4f2514433139552ac6ab8ab5506653 + +# no 200 item limit on drop-down lists, index : better codegen +editor plugins/CustomTheme/src/Template/Bake/Element/Controller/* +git add plugins/CustomTheme/src/Template/Bake/Element/Controller/* +git add ../app-from-scratch.sh +git commit -m "no 200 item limit on drop-down lists, index : better codegen" diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/_empty.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/_empty.twig index 8175902..3e0a08b 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/_empty.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/_empty.twig @@ -20,8 +20,6 @@ * */ #} -{% set compact = ["'#{singularName}'"] %} - /** * _empty method * Generated when no other actions requested diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.twig index 1c67f5e..ec3f031 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/add.twig @@ -38,7 +38,7 @@ {%- for assoc in associations %} {%- set otherName = Bake.getAssociatedTableAlias(modelObj, assoc) %} {%- set otherPlural = otherName|variable %} - ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', ['limit' => 200]); + ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list'); {{- "\n" }} {%- set compact = compact|merge(["'#{otherPlural}'"]) %} {% endfor %} diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig index d06cb9c..c99b6a2 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/edit.twig @@ -41,7 +41,7 @@ {% for assoc in belongsTo|merge(belongsToMany) %} {%- set otherName = Bake.getAssociatedTableAlias(modelObj, assoc) %} {%- set otherPlural = otherName|variable %} - ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list', ['limit' => 200]); + ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list'); {{- "\n" }} {%- set compact = compact|merge(["'#{otherPlural}'"]) %} {% endfor %} diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig index 8938f6a..78183f6 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Element/Controller/index.twig @@ -13,6 +13,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ #} +{% set compact = ["'#{pluralName}'"] %} /** * Index method @@ -34,10 +35,13 @@ {% else %} ${{ pluralName }} = $this->paginate($this->{{ currentModelName }}); {% endif %} - $this->set('{{ pluralName }}', ${{ pluralName }}); -{% for model in BakeExtra.getFiltersExtraModels(name, modelObj) %} - $this->loadModel('{{ model.getAlias }}'); - $this->set('{{ model.getAlias|variable }}', $this->{{ model.getAlias }}->find('list')->toArray()); +{% for model in BakeExtra.getFiltersExtraModels(name, modelObj) %} + {%- set otherName = model.getAlias %} + {%- set otherPlural = otherName|variable %} + ${{ otherPlural }} = $this->{{ currentModelName }}->{{ otherName }}->find('list'); + {{- "\n" }} + {%- set compact = compact|merge(["'#{otherPlural}'"]) %} {% endfor %} + $this->set(compact({{ compact|join(', ')|raw }})); } -- cgit v1.1