From a1a9029053483c9b237051b4abdf3c117d418205 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Mon, 20 Dec 2021 14:28:04 +0100 Subject: [PATCH] chg: [metaTemplate] Better placement of notice message --- templates/MetaTemplates/index.php | 32 ++++++++++++------- .../IndexTable/index_table.php | 4 +++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/templates/MetaTemplates/index.php b/templates/MetaTemplates/index.php index 49bea89..6723411 100644 --- a/templates/MetaTemplates/index.php +++ b/templates/MetaTemplates/index.php @@ -2,24 +2,33 @@ use Cake\Utility\Hash; if (!empty($updateableTemplates['new'])) { - $alertHtml = sprintf('%s %s', __('New meta-templates available!'), __n('There is one new template on disk that can be loaded in the database', 'There are {0} new templates on disk that can be loaded in the database:', count($updateableTemplates['new']))); - $alertList = Hash::combine( - $updateableTemplates, - null, - ['%s :: %s', 'new.{s}.template.namespace', 'new.{s}.template.name'], - 'new.{n}.template.namespace' + $alertHtml = sprintf( + '%s %s', + __('New meta-templates available!'), + __n('There is one new template on disk that can be loaded in the database', 'There are {0} new templates on disk that can be loaded in the database:', count($updateableTemplates['new'])) ); + $alertList = []; + $alertList = Hash::extract($updateableTemplates['new'], '{s}.template'); $alertList = array_map(function($entry) { - return h($entry); + return sprintf('%s:%s %s', + h($entry['namespace']), + h($entry['name']), + $this->Bootstrap->button([ + 'variant' => 'link', + 'size' => 'sm', + 'icon' => 'download', + 'title' => __('Create this template'), + 'params' => [ + 'onclick' => "UI.submissionModalForIndex('/metaTemplates/createNewTemplate/{$entry['uuid']}', '/meta-templates')" + ] + ]) + ); }, $alertList); $alertHtml .= $this->Html->nestedList($alertList); - echo $this->Bootstrap->alert([ - 'html' => $alertHtml, - 'variant' => 'warning', - ]); } echo $this->element('genericElements/IndexTable/index_table', [ + 'notice' => !empty($alertHtml) ? ['html' => $alertHtml, 'variant' => 'warning',] : false, 'data' => [ 'data' => $data, 'top_bar' => [ @@ -162,7 +171,6 @@ echo $this->element('genericElements/IndexTable/index_table', [ ], 'title' => __('Meta Field Templates'), 'description' => __('The various templates used to enrich certain objects by a set of standardised fields.'), - 'pull' => 'right', 'actions' => [ [ 'url' => '/metaTemplates/view', diff --git a/templates/element/genericElements/IndexTable/index_table.php b/templates/element/genericElements/IndexTable/index_table.php index 850be4b..114c9d9 100644 --- a/templates/element/genericElements/IndexTable/index_table.php +++ b/templates/element/genericElements/IndexTable/index_table.php @@ -54,6 +54,10 @@ if (!empty($data['title'])) { ); } +if(!empty($notice)) { + echo $this->Bootstrap->alert($notice); +} + if (!empty($modelStatistics)) { echo $this->element('genericElements/IndexTable/Statistics/index_statistic_scaffold', [ 'statistics' => $modelStatistics,