chg: [genericElement:index-table] Automatically include selector if
topbar has multi-select actionspull/67/head
parent
359464b4a5
commit
9de600db97
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 [];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue