chg: [genericElement:index-table] Automatically include selector if

topbar has multi-select actions
pull/67/head
mokaddem 2021-07-05 09:30:20 +02:00
parent 359464b4a5
commit 9de600db97
3 changed files with 31 additions and 20 deletions

View File

@ -9,6 +9,7 @@ echo $this->element('genericElements/IndexTable/index_table', [
'top_bar' => [
'children' => [
[
'type' => 'multi_select_actions',
'children' => [
[
'text' => __('Discard requests'),
@ -16,7 +17,11 @@ echo $this->element('genericElements/IndexTable/index_table', [
'onclick' => 'discardRequests',
]
],
'type' => 'multi_select_actions',
'data' => [
'id' => [
'value_path' => 'id'
]
]
],
[
'type' => 'context_filters',
@ -33,15 +38,6 @@ echo $this->element('genericElements/IndexTable/index_table', [
]
],
'fields' => [
[
'element' => 'selector',
'class' => 'short',
'data' => [
'id' => [
'value_path' => 'id'
]
]
],
[
'name' => '#',
'sort' => 'id',

View File

@ -9,6 +9,7 @@ echo $this->element('genericElements/IndexTable/index_table', [
'top_bar' => [
'children' => [
[
'type' => 'multi_select_actions',
'children' => [
[
'text' => __('Delete messages'),
@ -16,7 +17,11 @@ echo $this->element('genericElements/IndexTable/index_table', [
'onclick' => 'deleteMessages',
]
],
'type' => 'multi_select_actions',
'data' => [
'id' => [
'value_path' => 'id'
]
]
],
[
'type' => 'context_filters',
@ -33,15 +38,6 @@ echo $this->element('genericElements/IndexTable/index_table', [
]
],
'fields' => [
[
'element' => 'selector',
'class' => 'short',
'data' => [
'id' => [
'value_path' => 'id'
]
]
],
[
'name' => '#',
'sort' => 'id',

View File

@ -44,6 +44,15 @@
'/genericElements/IndexTable/pagination_links'
);
}
$multiSelectData = getMultiSelectData($data['top_bar']);
if (!empty($multiSelectData)) {
$multiSelectField = [
'element' => 'selector',
'class' => 'short',
'data' => $multiSelectData['data']
];
array_unshift($data['fields'], $multiSelectField);
}
if (!empty($data['top_bar'])) {
echo $this->element(
'/genericElements/ListTopBar/scaffold',
@ -130,3 +139,13 @@
});
});
</script>
<?php
function getMultiSelectData($topbar) {
foreach ($topbar['children'] as $child) {
if (!empty($child['type']) && $child['type'] == 'multi_select_actions') {
return $child;
}
}
return [];
}