From 462546359dbf3de9351a8a9cb48a968fa127423a Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 28 Dec 2022 11:23:15 -0500 Subject: [PATCH 1/2] 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) --- 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..0956bacc6 --- /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..278140799 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..9ec7ebf67 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..9d47599ca 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..881ae6459 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 From fa38d5e9da609858729393af8f5646874baef9fe Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 28 Dec 2022 11:33:53 -0500 Subject: [PATCH 2/2] Improve code comments/documentation. (CFM-221) --- app/templates/element/flash.php | 8 ++++---- app/templates/element/flash/default.php | 4 ++-- app/templates/element/flash/error.php | 4 ++-- app/templates/element/flash/information.php | 4 ++-- app/templates/element/flash/success.php | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/templates/element/flash.php b/app/templates/element/flash.php index 0956bacc6..5c6a91f26 100644 --- a/app/templates/element/flash.php +++ b/app/templates/element/flash.php @@ -33,12 +33,12 @@ 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 278140799..325e35513 100644 --- a/app/templates/element/flash/default.php +++ b/app/templates/element/flash/default.php @@ -6,8 +6,8 @@ + we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included + directly in the language strings instead. */ ?> Alert->alert($message, 'warning', true) ?> diff --git a/app/templates/element/flash/error.php b/app/templates/element/flash/error.php index 9ec7ebf67..8069a15da 100644 --- a/app/templates/element/flash/error.php +++ b/app/templates/element/flash/error.php @@ -6,7 +6,7 @@ + we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included + directly in the language strings instead. */ ?> Alert->alert($message, 'danger', true) ?> diff --git a/app/templates/element/flash/information.php b/app/templates/element/flash/information.php index 9d47599ca..26dc52329 100644 --- a/app/templates/element/flash/information.php +++ b/app/templates/element/flash/information.php @@ -6,7 +6,7 @@ + we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included + directly in the language strings instead. */ ?> 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 881ae6459..6f0671bb0 100644 --- a/app/templates/element/flash/success.php +++ b/app/templates/element/flash/success.php @@ -6,7 +6,7 @@ + we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included + directly in the language strings instead. */ ?> Alert->alert($message, 'success', true) ?> \ No newline at end of file