From dd5804d39e43f6e5ea1d99e87b3fc04eb4277b6d Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 28 Dec 2022 11:35:12 -0500 Subject: [PATCH] Update flash messages to better support RTL languages (CFM-221) (#65) * Update flash messages to better support RTL languages and render them in an element container so the messages can be placed under the appropriate title depending on the existence of subnavigation. (CFM-221) * Improve code comments/documentation. (CFM-221) --- app/resources/locales/en_US/information.po | 12 ------ app/templates/Standard/add-edit-view.php | 32 ++++++++------- app/templates/Standard/index.php | 35 ++++++++-------- app/templates/element/flash.php | 44 +++++++++++++++++++++ app/templates/element/flash/default.php | 10 ++--- app/templates/element/flash/error.php | 8 ++-- app/templates/element/flash/information.php | 11 +++--- app/templates/element/flash/success.php | 11 ++++-- 8 files changed, 100 insertions(+), 63 deletions(-) create mode 100644 app/templates/element/flash.php diff --git a/app/resources/locales/en_US/information.po b/app/resources/locales/en_US/information.po index fa0fe170c..9ae8226af 100644 --- a/app/resources/locales/en_US/information.po +++ b/app/resources/locales/en_US/information.po @@ -36,18 +36,6 @@ msgstr "You are not an active member in any collaboration. If your request for e msgid "cos.select" msgstr "Please select the collaboration (CO) you wish to manage." -msgid "flash.default" -msgstr "Notice: " - -msgid "flash.error" -msgstr "Error: " - -msgid "flash.information" -msgstr "Information: " - -msgid "flash.success" -msgstr "Success: " - msgid "entity.id" msgstr "ID: {0}" diff --git a/app/templates/Standard/add-edit-view.php b/app/templates/Standard/add-edit-view.php index cce8353c9..09020cc13 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -52,6 +52,15 @@ if(!empty($vv_primary_link) && !empty($this->request->getQuery($vv_primary_link))) { $linkFilter = [$vv_primary_link => $this->request->getQuery($vv_primary_link)]; } + +// $flashArgs pass banner messages to the flash element container +$flashArgs = []; +if(!empty($banners)) { + // XXX this doesn't work yet because we don't include fields.inc until later + // either create a second file to include earlier, or use a function to emit + // the fields (which would be more consistent with how Views render...) + $flashArgs['vv_banners'] = $banners; +} ?> @@ -65,6 +74,10 @@ + + + element('flash', $flashArgs); ?> + element('subnavigation', $subnav); ?> @@ -142,21 +155,10 @@ ?> - -
- Flash->render() ?> - - Alert->alert($b, 'warning'); - } - } - ?> -
+ + + element('flash', $flashArgs); ?> + request->getQuery($vv_primary_link))) { $linkFilter = [$vv_primary_link => $this->request->getQuery($vv_primary_link)]; } + +// $flashArgs pass banner messages to the flash element container +$flashArgs = []; +if(!empty($indexBanners)) { + $flashArgs['vv_index_banners'] = $indexBanners; +} +if(!empty($banners)) { + $flashArgs['vv_banners'] = $banners; +} ?> @@ -71,6 +80,10 @@ + + + element('flash', $flashArgs); ?> + element('subnavigation', $subnav); ?> @@ -147,23 +160,11 @@ - -
- Flash->render() ?> - - - - Alert->alert($b, 'warning') ?> - - - - - - Alert->alert($b, 'warning') ?> - - -
- + + + element('flash', $flashArgs); ?> + + element('filter'); ?> diff --git a/app/templates/element/flash.php b/app/templates/element/flash.php new file mode 100644 index 000000000..5c6a91f26 --- /dev/null +++ b/app/templates/element/flash.php @@ -0,0 +1,44 @@ + + + +
+ Flash->render() ?> + + + + Alert->alert($b, 'warning') ?> + + + + + + Alert->alert($b, 'warning') ?> + + +
\ No newline at end of file diff --git a/app/templates/element/flash/default.php b/app/templates/element/flash/default.php index 5c05e86a8..325e35513 100644 --- a/app/templates/element/flash/default.php +++ b/app/templates/element/flash/default.php @@ -1,15 +1,13 @@ - Alert->alert($message, 'warning', true, __d('information','flash.default')) ?> + + Alert->alert($message, 'warning', true) ?> diff --git a/app/templates/element/flash/error.php b/app/templates/element/flash/error.php index 04fd0e19a..8069a15da 100644 --- a/app/templates/element/flash/error.php +++ b/app/templates/element/flash/error.php @@ -3,10 +3,10 @@ $message = h($message); } ?> - -*/ ?> - Alert->alert($message, 'danger', true, __d('information','flash.error')) ?> + + Alert->alert($message, 'danger', true) ?> diff --git a/app/templates/element/flash/information.php b/app/templates/element/flash/information.php index 1df1a9641..26dc52329 100644 --- a/app/templates/element/flash/information.php +++ b/app/templates/element/flash/information.php @@ -1,11 +1,12 @@ - + Alert->alert($message, 'information', true) ?> \ No newline at end of file diff --git a/app/templates/element/flash/success.php b/app/templates/element/flash/success.php index f71124cfa..6f0671bb0 100644 --- a/app/templates/element/flash/success.php +++ b/app/templates/element/flash/success.php @@ -1,9 +1,12 @@ - Alert->alert($message, 'success', true, __d('information','flash.success')) ?> + + Alert->alert($message, 'success', true) ?> \ No newline at end of file