From cc7cbddc74ee9076f960a54e05c36fffa536962a Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 3 Nov 2023 11:23:43 +0800 Subject: [PATCH] * zin: if the checkbox is enabled in the moduleMenu widget, the item corresponding to activeKey is set to the selected state. --- lib/zin/wg/modulemenu/v1.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/zin/wg/modulemenu/v1.php b/lib/zin/wg/modulemenu/v1.php index 65b9671103..cc17bae243 100644 --- a/lib/zin/wg/modulemenu/v1.php +++ b/lib/zin/wg/modulemenu/v1.php @@ -10,7 +10,7 @@ class moduleMenu extends wg protected static array $defineProps = array( 'modules: array', - 'activeKey?: int', + 'activeKey?: int|string', 'settingLink?: string', 'closeLink: string', 'showDisplay?: bool=true', @@ -49,8 +49,25 @@ class moduleMenu extends wg 'contentClass' => 'overflow-x-hidden' ); $items = $this->buildMenuTree($child->id); - if(count($items) !== 0) $item['items'] = $items; - if($child->id == $activeKey) $item['active'] = true; + if($items) $item['items'] = $items; + if($child->id == $activeKey) + { + $itemKey = $this->prop('checkbox') ? 'checked' : 'active'; + $item[$itemKey] = true; + } + if($this->prop('checkbox') && empty($item['checked']) && $items) + { + $checked = true; + foreach($items as $child) + { + if(empty($child['checked'])) + { + $checked = false; + break; + } + } + if($checked) $item['checked'] = true; + } $treeItems[] = $item; }