Merge pull request #1187 from shreesh-webkul/tree-update-fix

Added: Feature in tree to select all children node when parent node is selected and fixed some text issue
This commit is contained in:
Rohit Jain
2024-08-27 13:31:08 +05:30
committed by GitHub
5 changed files with 32 additions and 44 deletions

View File

@@ -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 <support@webkul.com>
* @copyright Since 2010 Webkul IN
* @license https://store.webkul.com/license.html
*}
{extends file="helpers/tree/tree.tpl"}
<script>
{block name="script" append}
$(document).ready(function () {
$('#{$id|escape:'html':'UTF-8'}').find('[name="hotel_box[]"]').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');
});
}
});
});
{/block}
</script>

View File

@@ -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');

View File

@@ -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(

View File

@@ -3507,6 +3507,7 @@ class AdminNormalProductsControllerCore extends AdminController
'selectedElements' => $selectedElements
]))
->setUseCheckBox(true)
->setAutoSelectChildren(true)
->setUseBulkActions(true)
->setUseSearch(true);
$data->assign('hotel_tree', $tree->render());

View File

@@ -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 {