From 9de600db9788e4950d664ecbe721f48f2d44ba61 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Mon, 5 Jul 2021 09:30:20 +0200 Subject: [PATCH] chg: [genericElement:index-table] Automatically include selector if topbar has multi-select actions --- templates/Inbox/index.php | 16 ++++++---------- templates/Outbox/index.php | 16 ++++++---------- .../IndexTable/index_table.php | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/templates/Inbox/index.php b/templates/Inbox/index.php index b9d02e1..cef2ccb 100644 --- a/templates/Inbox/index.php +++ b/templates/Inbox/index.php @@ -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', diff --git a/templates/Outbox/index.php b/templates/Outbox/index.php index c7ac4f9..2685171 100644 --- a/templates/Outbox/index.php +++ b/templates/Outbox/index.php @@ -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', diff --git a/templates/element/genericElements/IndexTable/index_table.php b/templates/element/genericElements/IndexTable/index_table.php index 9a407d4..221b70a 100644 --- a/templates/element/genericElements/IndexTable/index_table.php +++ b/templates/element/genericElements/IndexTable/index_table.php @@ -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 @@ }); }); + +