From 0c95a3273936033947eb2049e8c11ec2a11bc257 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 23 Aug 2024 11:55:36 +0530 Subject: [PATCH] Added: Feature in tree select all children node when parent node is selected --- .../normal_products/helpers/tree/tree.tpl | 39 ------------------- .../default/template/helpers/tree/tree.tpl | 16 ++++++++ classes/helper/HelperTree.php | 14 +++++++ .../admin/AdminNormalProductsController.php | 1 + .../classes/HotelHelper.php | 6 +-- 5 files changed, 32 insertions(+), 44 deletions(-) delete mode 100644 admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl diff --git a/admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl b/admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl deleted file mode 100644 index ce2479919..000000000 --- a/admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{* -* Since 2010 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright Since 2010 Webkul IN -* @license https://store.webkul.com/license.html -*} -{extends file="helpers/tree/tree.tpl"} - \ No newline at end of file diff --git a/admin/themes/default/template/helpers/tree/tree.tpl b/admin/themes/default/template/helpers/tree/tree.tpl index c4ecff65f..30c4283c6 100644 --- a/admin/themes/default/template/helpers/tree/tree.tpl +++ b/admin/themes/default/template/helpers/tree/tree.tpl @@ -84,6 +84,22 @@ }); {/if} + {if isset($auto_select_children) && $auto_select_children == true} + $('#{$id|escape:'html':'UTF-8'}').find(':input[type=checkbox]').on('click', function(){ + if ($(this).is(":checked")) { + $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){ + $(this).prop('checked', true); + $(this).parent().addClass('tree-selected'); + }); + } else { + $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){ + $(this).prop('checked', false); + $(this).parent().removeClass('tree-selected'); + }); + } + }); + {/if} + $(document).ready(function () { var tree = $("#{$id|escape:'html':'UTF-8'}").tree('collapseAll'); diff --git a/classes/helper/HelperTree.php b/classes/helper/HelperTree.php index 0a3824205..d79bea095 100644 --- a/classes/helper/HelperTree.php +++ b/classes/helper/HelperTree.php @@ -29,6 +29,7 @@ class HelperTreeCore extends TreeCore private $_use_bulk_actions; private $_use_checkbox; private $_show_collapse_expand_button = true; + private $_auto_select_children = false; private $_max_height = 350; @@ -43,6 +44,18 @@ class HelperTreeCore extends TreeCore return (isset($this->_use_search) && $this->_use_search); } + public function setAutoSelectChildren($value) + { + $this->_auto_select_children = (bool)$value; + return $this; + } + + public function autoSelectChildren() + { + return (isset($this->_auto_select_children) && $this->_auto_select_children); + } + + public function setUseBulkActions($value) { $this->_use_bulk_actions = (bool)$value; @@ -119,6 +132,7 @@ class HelperTreeCore extends TreeCore ); $this->setAttribute('use_search', $this->useSearch()); } + $this->setAttribute('auto_select_children', $this->autoSelectChildren()); if ($this->showCollapseExpandButton()) { $collapse_all = new TreeToolbarLink( diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 0e52ca53f..c584a46b6 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -3507,6 +3507,7 @@ class AdminNormalProductsControllerCore extends AdminController 'selectedElements' => $selectedElements ])) ->setUseCheckBox(true) + ->setAutoSelectChildren(true) ->setUseBulkActions(true) ->setUseSearch(true); $data->assign('hotel_tree', $tree->render()); diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index d44240626..dc442e32d 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2730,11 +2730,7 @@ class HotelHelper if (isset($rooms[$roomType['value']])) { $roomType['children'] = $rooms[$roomType['value']]; } - $roomType['hint'] = 'This is Room type hint'; - $roomType['badge'] = array( - 'class' => 'badge-danger', - 'title' => 'Disabled' - ); + if ($previousElements) { $return[$roomType['id_hotel']][] = $roomType; } else {