Skip to content

Flash message improvements (CFM-365) #315

Merged
merged 1 commit into from
May 15, 2025
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
2 changes: 1 addition & 1 deletion app/templates/ApiUsers/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Output advisory banner when co=1
if($vv_cur_co->id == 1) {
$indexBanners = [
$banners = [
__d('information','api.cmp')
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/ApiUsers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// This view does not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
if($vv_cur_co->id == 1) {
print $this->element('banner', ['info' => __d('information', 'api.cmp')]);
print $this->element('notify/banner', ['info' => __d('information', 'api.cmp')]);
}

// AR-ApiUser-3 For namespacing purposes, API Users are named with a prefix consisting of the string "co_#.".
Expand Down
2 changes: 2 additions & 0 deletions app/templates/Cos/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
</div>
</div>

<?= $this->element('flash') // Flash messages ?>

<?php if(count($vv_available_cos) == 0): ?>
<?= $this->element('notify/alert', ['message' => __d('information','cos.none')]) ?>
<?php else: // vv_available_cos ?>
Expand Down
2 changes: 2 additions & 0 deletions app/templates/Dashboards/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
</div>
</div>

<?= $this->element('flash') // Flash messages ?>

<section class="inner-content">
<?php if(!empty($vv_platform_menu_items)): ?>
<h2 class="config-subtitle"><?= __d('menu','co.configuration.panel.platform') ?></h2>
Expand Down
17 changes: 1 addition & 16 deletions app/templates/Dashboards/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,7 @@
<?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->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $indexBanners ?>
<?php endif; // $indexBanners ?>

<?php if(!empty($banners)): ?>
<?php foreach($banners as $b): ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $banners ?>
<?php endif; // $banners ?>
</div>
<?= $this->element('flash') // Flash messages ?>

<div id="search-results">
<?php if($resultsCount): ?>
Expand Down
2 changes: 2 additions & 0 deletions app/templates/EnrollmentFlows/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
</div>
</div>

<?= $this->element('flash') // Flash messages ?>

<?php
// Enrollment Flow Start has its own file of fields
$this->set('vv_fields_inc', 'start.inc');
Expand Down
2 changes: 2 additions & 0 deletions app/templates/ExternalIdentities/relink.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
</div>
</div>

<?= $this->element('flash') // Flash messages ?>

<?php
print $this->Form->create(null, [
'id' => 'ei-relink-form',
Expand Down
3 changes: 3 additions & 0 deletions app/templates/ExternalIdentitySources/retrieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
}
?>
<?= $this->element('notify/alert', ['message' => $noticeText,'type' => 'information']) ?>

<?= $this->element('flash') // Flash messages ?>

<div class="innerContent">
<div class="table-container">
<h3><?= __d('information','ExternalIdentitySourceRecords.metadata') ?></h3>
Expand Down
2 changes: 2 additions & 0 deletions app/templates/ExternalIdentitySources/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
</div>
</div>

<?= $this->element('flash') // Flash messages ?>

<?php if(empty($vv_search_attrs)): ?>
<?= $this->element('notify/alert', [
'message' => __d('information', 'ExternalIdentitySources.search.attrs.none'),
Expand Down
2 changes: 1 addition & 1 deletion app/templates/HistoryRecords/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$indexBanners = [
$banners = [
// CFM-76 info message pending eventual "virtual" view consolidating all History Record types
__d('information', 'HistoryRecords.xref')
];
Expand Down
17 changes: 1 addition & 16 deletions app/templates/MostlyStaticPages/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,7 @@
</div>
</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>
<?= $this->element('flash') // Flash messages ?>

<div class="page-body">
<?= $vv_body ?>
Expand Down
17 changes: 1 addition & 16 deletions app/templates/Petitions/resume.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,7 @@
<?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>
<?= $this->element('flash') // Flash messages ?>

<!-- Our view is similar to index.php -->
<div class="table-container">
Expand Down
17 changes: 1 addition & 16 deletions app/templates/ProvisioningTargets/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,7 @@
</div>
</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->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $indexBanners ?>
<?php endif; // $indexBanners ?>

<?php if(!empty($banners)): ?>
<?php foreach($banners as $b): ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $banners ?>
<?php endif; // $banners ?>
</div>
<?= $this->element('flash') // Flash messages ?>

<!-- Our view is similar to index.php -->
<div class="table-container">
Expand Down
15 changes: 3 additions & 12 deletions app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,15 @@
$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;
}

// Subnavigation
$hasSubnav = false;
if(file_exists(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc')) {
include(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc');
$hasSubnav = $this->get('hasSupertitle');
}

// When under a subnavigation we do not want a title with Edit or Add or View followed by a number
// We might find ourselved in that situation since we calculate the title for the breadcrumbs and
// When under subnavigation we do not want a title with Edit or Add or View followed by a number.
// We might find ourselves in that situation since we calculate the title for the breadcrumbs and
// this simple description is not wrong. It is just not appropriate for the subnavigation title
$title = $vv_title;
$re = '/^(Add|Edit|View)\s([a-zA-Z]+?)\s[0-9]+/m';
Expand Down Expand Up @@ -186,7 +177,7 @@

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

<?php
Expand Down
9 changes: 1 addition & 8 deletions app/templates/Standard/deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,7 @@
</div>
</div>

<?php
// $flashArgs pass banner messages to the flash element container
$flashArgs = [];
if(!empty($banners)) {
$flashArgs['vv_banners'] = $banners;
}
print $this->element('flash', $flashArgs);
?>
<?= $this->element('flash') // Flash messages ?>

<button
class="btn btn-primary cm-deleted-close-button"
Expand Down
17 changes: 1 addition & 16 deletions app/templates/Standard/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,7 @@
</div>
</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>
<?= $this->element('flash') // Flash messages ?>

<?php
// Set the Include file name
Expand Down
15 changes: 6 additions & 9 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,19 @@
$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;
}

// First, complete all the initial calculations and then start including
// this way we have more ViewVars available
include($incFile);
if(isset($indexColumns)) {
$this->set('vv_indexColumns', $indexColumns);
}

// $flashArgs pass banner messages to the flash element container
$flashArgs = [];
if(!empty($banners)) {
$flashArgs['vv_banners'] = $banners;
}

// Subnavigation
$hasSubnav = false;
if(file_exists(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc')) {
Expand Down
33 changes: 20 additions & 13 deletions app/templates/element/flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@

<!-- 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->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $vv_index_banners ?>
<?php endif; // $vv_index_banners ?>

<?php if(!empty($vv_banners)): ?>
<?php foreach($vv_banners as $b): ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $vv_banners ?>
<?php endif; // $vv_banners ?>
<?php
/* Render any Flash messages that have bubbled up.
These will adopt the styles defined in the
app/templates/element/flash/ directory. */
print $this->Flash->render();

/* Render information banners explicitly defined in Configuration.
In columns.inc files, these are defined in the banners[] array.
See app/templates/ApiUsers/columns.inc for an example. These must
be passed in as $vv_banners to this element from the calling template.
NOTE: In fields.inc files, add information banners by referencing
the 'notify/alert' element directly (just as we do here).
*/
if(!empty($vv_banners)) {
foreach($vv_banners as $b) {
print $this->element('notify/alert', ['message' => $b]);
}
}
?>
</div>