chg: [ui:generic_index] Only show enabled meta-templates in table options

develop-unstable
Sami Mokaddem 2023-01-17 09:17:49 +01:00
parent 9506142de5
commit 715ba1d75b
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 34 additions and 21 deletions

View File

@ -142,6 +142,9 @@ class CRUDComponent extends Component
$data[$i] = $this->attachMetaTemplatesIfNeeded($row, $metaTemplates); $data[$i] = $this->attachMetaTemplatesIfNeeded($row, $metaTemplates);
} }
$this->Controller->set('meta_templates', $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 if (true) { // check if stats are requested
$modelStatistics = []; $modelStatistics = [];

View File

@ -2008,6 +2008,12 @@ class BoostrapDropdownMenu extends BootstrapGeneric
} }
$classes = ['dropdown-item']; $classes = ['dropdown-item'];
if (!empty($entry['class'])) {
if (!is_array($entry['class'])) {
$entry['class'] = [$entry['class']];
}
$classes = array_merge($classes, $entry['class']);
}
$params = ['href' => '#']; $params = ['href' => '#'];
if (!empty($entry['menu'])) { if (!empty($entry['menu'])) {

View File

@ -19,27 +19,31 @@ $availableColumnsHtml = $this->element('/genericElements/ListTopBar/group_table_
$metaTemplateColumnMenu = []; $metaTemplateColumnMenu = [];
if (!empty($meta_templates)) { if (!empty($meta_templates)) {
$metaTemplateColumnMenu[] = ['header' => true, 'text' => __('Meta Templates'), 'icon' => 'object-group',]; $metaTemplateColumnMenu[] = ['header' => true, 'text' => __('Meta Templates'), 'icon' => 'object-group',];
foreach ($meta_templates as $meta_template) { if (empty($meta_templates_enabled)) {
$numberActiveMetaField = !empty($tableSettings['visible_meta_column'][$meta_template->id]) ? count($tableSettings['visible_meta_column'][$meta_template->id]) : 0; $metaTemplateColumnMenu[] = ['header' => false, 'text' => __('- No enabled Meta Templates found -'), 'class' => ['disabled', 'muted']];
$metaTemplateColumnMenu[] = [ } else {
'text' => $meta_template->name, foreach ($meta_templates_enabled as $meta_template) {
'sup' => $meta_template->version, $numberActiveMetaField = !empty($tableSettings['visible_meta_column'][$meta_template->id]) ? count($tableSettings['visible_meta_column'][$meta_template->id]) : 0;
'badge' => [ $metaTemplateColumnMenu[] = [
'text' => $numberActiveMetaField, 'text' => $meta_template->name,
'variant' => 'secondary', 'sup' => $meta_template->version,
'title' => __n('{0} meta-field active for this meta-template', '{0} meta-fields active for this meta-template', $numberActiveMetaField, $numberActiveMetaField), 'badge' => [
], 'text' => $numberActiveMetaField,
'keepOpen' => true, 'variant' => 'secondary',
'menu' => [ 'title' => __n('{0} meta-field active for this meta-template', '{0} meta-fields active for this meta-template', $numberActiveMetaField, $numberActiveMetaField),
[ ],
'html' => $this->element('/genericElements/ListTopBar/group_table_action/hiddenMetaColumns', [ 'keepOpen' => true,
'tableSettings' => $tableSettings, 'menu' => [
'table_setting_id' => $data['table_setting_id'], [
'meta_template' => $meta_template, '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( $indexColumnMenu = array_merge(