Skip to content

Improve access to related models (CO-2229) #57

merged 3 commits into from Jan 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
Provide tabbed subnavigation for related models. Deprecate Noty.js in…
… favor of Boostrap Alerts. (CO-2229)
arlen committed Jan 12, 2023
commit a3aa601b53038a0c8fe0bf3505c55e05cca4d568
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/default.po
@@ -810,3 +810,6 @@ msgstr "Matchgrid Configuration"

msgid "match.ti.matchgrid"
msgstr "Matchgrid: {0}"

msgid "match.ti.properties"
msgstr "Properties"
96 changes: 96 additions & 0 deletions app/src/View/Helper/AlertHelper.php
@@ -0,0 +1,96 @@
<?php
/**
* COmanage Match Alert Helper
*
* 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 Match v1.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types=1);

namespace App\View\Helper;

use \Cake\View\Helper;
use phpDocumentor\Reflection\Types\Boolean;

/**
* Helper which will produce Bootstrap based alert
*
* @param string $message Alert message
* @param string $type Define the type of Alert. The value should be one of
* [success,warning,danger,info]. Defaults to 'warning'
* @param boolean $dismissable Can the Alert be dismissed? Defaults to false.
* @param string|null $title Title to display (typically "Success", "Error", or "Warning"). Defaults to null.
* @param boolean $dis_text_dark Disable dark-text fonts for light|info color mode.
* @return mixed - a constructed HTML block
* @since COmanage Registry v5.0.0
*/
class AlertHelper extends Helper {

public $helpers = ['Html'];

public function alert(
string $message,
string $type = 'warning',
bool $dismissable = false,
string $title = null ) {

$closeButton = '';
$dismissableClass = '';
if($dismissable) {
$closeButton = '
<span class="alert-button">
<button type="button" class="btn-close nospin" data-bs-dismiss="alert" aria-label="Close"></button>
</span>
';
$dismissableClass = ' alert-dismissible';
}

$titleMarkup = '';
if(!empty($title)) {
$titleMarkup = '<span class="alert-title-text">' . $title . '</span>';
}

return '
<div class="alert alert-' . $type . $dismissableClass . ' co-alert" role="alert">
<div class="alert-body d-flex align-items-center">
<span class="alert-title d-flex align-items-center">
' . $this->getAlertIcon($type) . $titleMarkup . '
</span>
<span class="alert-message">
' . $message . '
</span>
' . $closeButton . '
</div>
</div>
';
}

public function getAlertIcon(string $type) {
switch($type) {
case('success'): return '<span class="material-icons-outlined alert-icon">check_circle</span>';
case('info'): return '<span class="material-icons-outlined alert-icon">info</span>';
default: return '<span class="material-icons-outlined alert-icon">report_problem</span>';
}
}

}
5 changes: 5 additions & 0 deletions app/templates/AttributeMappings/columns.inc
@@ -46,4 +46,9 @@ $topLinks = [
'icon' => 'file_download',
'label' => __('match.op.AttributeMappings.install.nicknames.en')
]
];

$subnav = [
'name' => 'attribute_map',
'active' => 'mappings'
];
34 changes: 34 additions & 0 deletions app/templates/AttributeMappings/fields-nav.inc
@@ -0,0 +1,34 @@
<?php
/**
* COmanage Match Attribute Mappings Edit Navigation
*
* 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 Match v1.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// XXX: If fields.inc can become configuration only, move the contents of this file into fields.inc
$topLinks = [];

$subnav = [
'name' => 'attribute_map',
'active' => 'mappings'
];
34 changes: 34 additions & 0 deletions app/templates/AttributeMaps/fields-nav.inc
@@ -0,0 +1,34 @@
<?php
/**
* COmanage Match Attribute Maps Edit Navigation
*
* 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 Match v1.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// XXX: If fields.inc can become configuration only, move the contents of this file into fields.inc
$topLinks = [];

$subnav = [
'name' => 'attribute_map',
'active' => 'properties'
];
2 changes: 1 addition & 1 deletion app/templates/Matchgrids/configure.php
@@ -27,7 +27,7 @@

declare(strict_types = 1);
?>
<div class="titleNavContainer">
<div class="pageTitleContainer">
<div class="pageTitle">
<h1><?= $vv_title; ?></h1>
</div>
2 changes: 1 addition & 1 deletion app/templates/Matchgrids/manage.php
@@ -27,7 +27,7 @@

declare(strict_types = 1);
?>
<div class="titleNavContainer">
<div class="pageTitleContainer">
<div class="pageTitle">
<h1><?= $vv_title; ?></h1>
</div>
5 changes: 5 additions & 0 deletions app/templates/RuleAttributes/columns.inc
@@ -42,4 +42,9 @@ $indexColumns = [
'class' => 'SearchTypeEnum',
'sortable' => true
]
];

$subnav = [
'name' => 'rule',
'active' => 'attributes'
];
34 changes: 34 additions & 0 deletions app/templates/RuleAttributes/fields-nav.inc
@@ -0,0 +1,34 @@
<?php
/**
* COmanage Match Rules Attributes Edit Navigation
*
* 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 Match v1.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// XXX: If fields.inc can become configuration only, move the contents of this file into fields.inc
$topLinks = [];

$subnav = [
'name' => 'rule',
'active' => 'attributes'
];
34 changes: 34 additions & 0 deletions app/templates/Rules/fields-nav.inc
@@ -0,0 +1,34 @@
<?php
/**
* COmanage Match Rules Edit Navigation
*
* 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 Match v1.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// XXX: If fields.inc can become configuration only, move the contents of this file into fields.inc
$topLinks = [];

$subnav = [
'name' => 'rule',
'active' => 'properties'
];
69 changes: 53 additions & 16 deletions app/templates/Standard/add-edit-view.php
@@ -32,10 +32,57 @@
$action = $this->request->getParam('action');
// $this->name = Models
$modelsName = $this->name;

// Include subnavigation structures on add/edit/view pages
// XXX: if fields.inc is made configuration only, move the contents of fields-nav.inc into fields.inc
// Include subnav on all but the top-level object's Add view when subnav exists.
if((!empty($vv_primary_link_model) && $vv_primary_link_model != 'Matchgrids') || $action != 'add') {
if(file_exists(ROOT . DS . "templates" . DS . $modelsName . DS . "fields-nav.inc")) {
include(ROOT . DS . "templates" . DS . $modelsName . DS . "fields-nav.inc");
}
}

// $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;
}
?>
<div class="titleNavContainer">

<?php if(!empty($subnav)): ?>
<div id="subnavigation">
<div class="supertitle">
<h1>
<?php
if(!empty($vv_primary_link_obj)
&& !empty($vv_primary_link_model)
&& $vv_primary_link_model != 'Matchgrids') {
print $vv_primary_link_obj->name;
} else {
// we are editing the top-level object
print $vv_obj-> name;
}
?>
</h1>
</div>

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

<?= $this->element('subnavigation', $subnav); ?>
</div>
<?php endif; ?>

<div class="pageTitleContainer">
<div class="pageTitle">
<h1><?= $vv_title; ?></h1>
<?php if(empty($subnav)): ?>
<h1><?= $vv_title; ?></h1>
<?php else: ?>
<h2><?= $vv_title; ?></h2>
<?php endif; ?>
</div>

<?php if(
@@ -180,20 +227,10 @@
<?php endif; ?>
</div>

<?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...)
?>
<?php if(!empty($banners)): ?>
<?php foreach($banners as $b): ?>
<div class="co-info-topbox">
<em class="material-icons">info</em>
<?php print $b; ?>
</div>
<?php endforeach; // $banners ?>
<?php endif; // $banners ?>

<?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