From 17509e414853d93106d05253630c6186ef4eaf97 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Fri, 11 Oct 2019 16:20:38 +0300 Subject: [PATCH] #463 --- .../resources/views/table/categories.twig | 18 +++++++-- .../Category/Command/GetCategoryDetail.php | 38 +++++++++++++++++++ .../cats-module/src/CatsModulePlugin.php | 11 ++++++ 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryDetail.php diff --git a/addons/default/visiosoft/cats-module/resources/views/table/categories.twig b/addons/default/visiosoft/cats-module/resources/views/table/categories.twig index 3bfbdc17c..702f2cba1 100644 --- a/addons/default/visiosoft/cats-module/resources/views/table/categories.twig +++ b/addons/default/visiosoft/cats-module/resources/views/table/categories.twig @@ -7,12 +7,24 @@ {% if table.options.sortable %} {{ asset_add("scripts.js", "streams::js/table/sortable.js") }} {% endif %} - +{% if app.request.get('cat') != null %} + {% set parent = category_detail(app.request.get('cat')) %} + {% if parent.parent_category is null %} + {% set parent_url = url('admin/cats') %} + {% else %} + {% set parent_url = url('admin/cats?cat='~parent.parent_category_id) %} + {% endif %} +
+ +
+{% endif %}
- {{ view("streams::table/partials/filters", {'table': table}) }} {{ view("streams::table/partials/views", {'table': table}) }} - {{ view(table.options.heading ?: "streams::table/partials/heading", {'table': table}) }} {% if not table.rows.empty() %} {% block card %} diff --git a/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryDetail.php b/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryDetail.php new file mode 100644 index 000000000..351142df5 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryDetail.php @@ -0,0 +1,38 @@ +id = $id; + } + + + /** + * @param CategoryRepositoryInterface $groups + * @return |null + */ + public function handle(CategoryRepositoryInterface $groups) + { + if ($this->id) { + $category = $groups->find($this->id); + if (!is_null($category)) + return $category; + else + return null; + } + return null; + } +} diff --git a/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php b/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php index a0d55f8f0..ed8df9a3e 100644 --- a/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php +++ b/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php @@ -2,6 +2,7 @@ use Anomaly\Streams\Platform\Addon\Plugin\Plugin; use Visiosoft\CatsModule\Category\Command\GetCategoryName; +use Visiosoft\CatsModule\Category\Command\GetCategoryDetail; class CatsModulePlugin extends Plugin { @@ -20,6 +21,16 @@ class CatsModulePlugin extends Plugin return null; } + return $ad; + } + ),new \Twig_SimpleFunction( + 'category_detail', + function ($id) { + + if (!$ad = $this->dispatch(new GetCategoryDetail($id))) { + return null; + } + return $ad; } )