Skip to content

Update flash messages to better support RTL languages (CFM-221) #65

Merged
merged 2 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
32 changes: 17 additions & 15 deletions app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
?>

<?php if(!empty($subnav)): ?>
Expand All @@ -65,6 +74,10 @@
<?php endif; ?>
</h1>
</div>

<?php /* Flash Messages are placed below supertitle when subnavigation exists. */ ?>
<?= $this->element('flash', $flashArgs); ?>

<?= $this->element('subnavigation', $subnav); ?>
</div>
<?php endif; ?>
Expand Down Expand Up @@ -142,21 +155,10 @@
?>
</div>

<!-- Flash Messages and defined Info Banners -->
<div class="alert-container" id="flash-messages">
<?= $this->Flash->render() ?>

<?php
// 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...)
if(!empty($banners)) {
foreach($banners as $b) {
print $this->Alert->alert($b, 'warning');
}
}
?>
</div>
<?php if(empty($subnav)): ?>
<?php /* Flash Messages are placed below the main title when there's no subnavigation. */ ?>
<?= $this->element('flash', $flashArgs); ?>
<?php endif; ?>

<?php
// By default, the form will POST to the current controller
Expand Down
35 changes: 18 additions & 17 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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($indexBanners)) {
$flashArgs['vv_index_banners'] = $indexBanners;
}
if(!empty($banners)) {
$flashArgs['vv_banners'] = $banners;
}
?>

<?php if(!empty($subnav)): ?>
Expand All @@ -71,6 +80,10 @@
<?php endif; ?>
</h1>
</div>

<?php /* Flash Messages are placed below supertitle when subnavigation exists. */ ?>
<?= $this->element('flash', $flashArgs); ?>

<?= $this->element('subnavigation', $subnav); ?>
</div>
<?php endif; ?>
Expand Down Expand Up @@ -147,23 +160,11 @@
<?php endif; ?>
</div>

<!-- Flash Messages and defined Info Banners -->
<div class="alert-container" id="flash-messages">
<?= $this->Flash->render() ?>

<?php if(!empty($indexBanners)): ?>
<?php foreach($indexBanners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?php endforeach; // $indexBanners ?>
<?php endif; // $indexBanners ?>

<?php if(!empty($banners)): ?>
<?php foreach($banners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?php endforeach; // $banners ?>
<?php endif; // $banners ?>
</div>

<?php if(empty($subnav)): ?>
<?php /* Flash Messages are placed below the main title when there's no subnavigation. */ ?>
<?= $this->element('flash', $flashArgs); ?>
<?php endif; ?>

<!-- Search block -->
<?php if(isset($vv_searchable_attributes)): ?>
<?= $this->element('filter'); ?>
Expand Down
44 changes: 44 additions & 0 deletions app/templates/element/flash.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/*
* COmanage Registry Flash Message Container
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/
?>

<!-- Flash Messages and defined Info Banners -->
<div class="alert-container" id="flash-messages">
<?= $this->Flash->render() ?>

<?php if(!empty($vv_index_banners)): ?>
<?php foreach($vv_index_banners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?php endforeach; // $vv_index_banners ?>
<?php endif; // $vv_index_banners ?>

<?php if(!empty($vv_banners)): ?>
<?php foreach($vv_banners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?php endforeach; // $vv_banners ?>
<?php endif; // $vv_banners ?>
</div>
10 changes: 4 additions & 6 deletions app/templates/element/flash/default.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php
// XXX are these classes set anywhere? Are they in use?
$class = 'message';
if (!empty($params['class'])) {
$class .= ' ' . $params['class'];
}
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
?>

<?php if(!empty($message)): ?>
<?= $this->Alert->alert($message, 'warning', true, __d('information','flash.default')) ?>
<?php /* CFM-221: while a prefix such as "Error: " or "Success: " can be sent with the Alert,
we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included
directly in the language strings instead. */ ?>
<?= $this->Alert->alert($message, 'warning', true) ?>
<?php endif; ?>

8 changes: 4 additions & 4 deletions app/templates/element/flash/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
$message = h($message);
}
?>
<?php /*
<div class="message error" onclick="this.classList.add('hidden');"><?= $message ?></div>
*/ ?>

<?php if(!empty($message)): ?>
<?= $this->Alert->alert($message, 'danger', true, __d('information','flash.error')) ?>
<?php /* CFM-221: while a prefix such as "Error: " or "Success: " can be sent with the Alert,
we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included
directly in the language strings instead. */ ?>
<?= $this->Alert->alert($message, 'danger', true) ?>
<?php endif; ?>
11 changes: 6 additions & 5 deletions app/templates/element/flash/information.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
?>

<?php if(!empty($message)): ?>
<?php /* Note: unlike Notice, Error, and Success messages, Information messages require
no prefix. That is, we don't include "Information: " in front of the message. */ ?>
<?php /* CFM-221: while a prefix such as "Error: " or "Success: " can be sent with the Alert,
we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included
directly in the language strings instead. */ ?>
<?= $this->Alert->alert($message, 'information', true) ?>
<?php endif; ?>
11 changes: 7 additions & 4 deletions app/templates/element/flash/success.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
?>

<?php if(!empty($message)): ?>
<?= $this->Alert->alert($message, 'success', true, __d('information','flash.success')) ?>
<?php /* CFM-221: while a prefix such as "Error: " or "Success: " can be sent with the Alert,
we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included
directly in the language strings instead. */ ?>
<?= $this->Alert->alert($message, 'success', true) ?>
<?php endif; ?>