diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 8d2f08f..fa98a42 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -142,6 +142,9 @@ class CRUDComponent extends Component $data[$i] = $this->attachMetaTemplatesIfNeeded($row, $metaTemplates); } $this->Controller->set('meta_templates', $metaTemplates); + $this->Controller->set('meta_templates_enabled', array_filter($metaTemplates, function($template) { + return $template['enabled']; + })); } if (true) { // check if stats are requested $modelStatistics = []; diff --git a/src/View/Helper/BootstrapHelper.php b/src/View/Helper/BootstrapHelper.php index 5b487c6..e452bb0 100644 --- a/src/View/Helper/BootstrapHelper.php +++ b/src/View/Helper/BootstrapHelper.php @@ -2008,6 +2008,12 @@ class BoostrapDropdownMenu extends BootstrapGeneric } $classes = ['dropdown-item']; + if (!empty($entry['class'])) { + if (!is_array($entry['class'])) { + $entry['class'] = [$entry['class']]; + } + $classes = array_merge($classes, $entry['class']); + } $params = ['href' => '#']; if (!empty($entry['menu'])) { diff --git a/templates/element/genericElements/ListTopBar/group_table_action.php b/templates/element/genericElements/ListTopBar/group_table_action.php index fe538b2..d239d82 100644 --- a/templates/element/genericElements/ListTopBar/group_table_action.php +++ b/templates/element/genericElements/ListTopBar/group_table_action.php @@ -19,27 +19,31 @@ $availableColumnsHtml = $this->element('/genericElements/ListTopBar/group_table_ $metaTemplateColumnMenu = []; if (!empty($meta_templates)) { $metaTemplateColumnMenu[] = ['header' => true, 'text' => __('Meta Templates'), 'icon' => 'object-group',]; - foreach ($meta_templates as $meta_template) { - $numberActiveMetaField = !empty($tableSettings['visible_meta_column'][$meta_template->id]) ? count($tableSettings['visible_meta_column'][$meta_template->id]) : 0; - $metaTemplateColumnMenu[] = [ - 'text' => $meta_template->name, - 'sup' => $meta_template->version, - 'badge' => [ - 'text' => $numberActiveMetaField, - 'variant' => 'secondary', - 'title' => __n('{0} meta-field active for this meta-template', '{0} meta-fields active for this meta-template', $numberActiveMetaField, $numberActiveMetaField), - ], - 'keepOpen' => true, - 'menu' => [ - [ - 'html' => $this->element('/genericElements/ListTopBar/group_table_action/hiddenMetaColumns', [ - 'tableSettings' => $tableSettings, - 'table_setting_id' => $data['table_setting_id'], - 'meta_template' => $meta_template, - ]) - ] - ], - ]; + if (empty($meta_templates_enabled)) { + $metaTemplateColumnMenu[] = ['header' => false, 'text' => __('- No enabled Meta Templates found -'), 'class' => ['disabled', 'muted']]; + } else { + foreach ($meta_templates_enabled as $meta_template) { + $numberActiveMetaField = !empty($tableSettings['visible_meta_column'][$meta_template->id]) ? count($tableSettings['visible_meta_column'][$meta_template->id]) : 0; + $metaTemplateColumnMenu[] = [ + 'text' => $meta_template->name, + 'sup' => $meta_template->version, + 'badge' => [ + 'text' => $numberActiveMetaField, + 'variant' => 'secondary', + 'title' => __n('{0} meta-field active for this meta-template', '{0} meta-fields active for this meta-template', $numberActiveMetaField, $numberActiveMetaField), + ], + 'keepOpen' => true, + 'menu' => [ + [ + 'html' => $this->element('/genericElements/ListTopBar/group_table_action/hiddenMetaColumns', [ + 'tableSettings' => $tableSettings, + 'table_setting_id' => $data['table_setting_id'], + 'meta_template' => $meta_template, + ]) + ] + ], + ]; + } } } $indexColumnMenu = array_merge(