* zin: if the checkbox is enabled in the moduleMenu widget, the item corresponding to activeKey is set to the selected state.

This commit is contained in:
liugang
2023-11-03 11:23:43 +08:00
parent 87f568622f
commit cc7cbddc74
+20 -3
View File
@@ -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;
}