Skip to content

Commit

Permalink
Deprecate and remove jQuery UI (CO-2230) (#17)
Browse files Browse the repository at this point in the history
* Remove jQuery UI first commit. All index action command menus exposed as dropdowns by default for mobile. Dialog boxes converted to Bootstrap. (CO-2230)

* Index action command menus visible on wider screens (not in dropdown). (CO-2230)

* Change heading level for modal dialog box. (CO-2230)

* Small stylistic improvements for modal dialog box. (CO-2230)

* Update version comment for new file (CO-2230)

* Update version comment for new file (CO-2230)

* Stylistic improvements for dropdown menu and actions column (CO-2230)

* Make modal dialog an element (CO-2230)
  • Loading branch information
arlen authored Oct 12, 2021
1 parent 3c41125 commit 59edd61
Show file tree
Hide file tree
Showing 22 changed files with 503 additions and 2,594 deletions.
9 changes: 9 additions & 0 deletions app/resources/locales/en_US/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ msgstr "Build"
msgid "match.op.build.confirm"
msgstr "Are you sure you wish to (re)build this matchgrid?"

msgid "match.op.cancel"
msgstr "Cancel"

msgid "match.op.clear"
msgstr "Clear"

Expand All @@ -545,6 +548,9 @@ msgstr "Configure"
msgid "match.op.configure.a"
msgstr "Configure {0}"

msgid "match.op.confirm"
msgstr "Confirm"

msgid "match.op.delete"
msgstr "Delete"

Expand Down Expand Up @@ -626,6 +632,9 @@ msgstr "Generate New Reference ID"
msgid "match.op.reconcile.request"
msgstr "Reconcile Unresolved Request {0}/{1}"

msgid "match.op.remove"
msgstr "Remove"

msgid "match.op.save"
msgstr "Save"

Expand Down
2 changes: 1 addition & 1 deletion app/src/View/Helper/FieldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function submit($label) {
<span class="required">' . __('match.fd.req') . '</span>
</div>
<div class="field-info">
' . $this->Form->submit($label) . '
' . $this->Form->submit($label, ['class' => 'spin submit-button btn btn-primary']) . '
</div>
</li>';
}
Expand Down
86 changes: 86 additions & 0 deletions app/src/View/Helper/MenuHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* COmanage Match Menu 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 http://www.internet2.edu/comanage COmanage Project
* @package match
* @since COmanage Registry v1.0.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;

class MenuHelper extends Helper {

public $helpers = ['Html'];

/**
* Get the Menu Order per action
*
* @param string $action
* @return int|null
*
* @since COmanage Match v1.0.0
*/
public function getMenuOrder($action) {
if(empty($action)) {
return null;
}

$order = array(
'View' => 5, // visibility
'Edit' => 10, // edit
'Duplicate' => 15, // content_copy
'Default' => 20, // link - default starting order for arbitrary action menu items
'Delete' => 100 // delete
);

return $order[$action];
}

/**
* Get the Menu Icon per action
*
* @param string $action
* @return string|null
*
* @since COmanage Match v1.0.0
*/
public function getMenuIcon($action) {
if(empty($action)) {
return null;
}

$icon = array(
'View' => 'visibility',
'Edit' => 'edit',
'Duplicate' => 'content_copy',
'Default' => 'link', // default icon for arbitrary menu items
'Delete' => 'delete'
);

return $icon[$action];
}

}
3 changes: 2 additions & 1 deletion app/templates/AttributeMappings/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ $indexColumns = [

$topLinks = [
[
'label' => __('match.op.AttributeMappings.install.nicknames.en'),
'label' => '<em class="material-icons" aria-hidden="true">file_download</em> ' .
__('match.op.AttributeMappings.install.nicknames.en'),
'link' => [
'action' => 'install',
'mapping' => 'nicknames.en'
Expand Down
5 changes: 3 additions & 2 deletions app/templates/AttributeMaps/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ $indexColumns = [
$indexActions = [
[
'controller' => 'attribute_mappings',
'action' => 'index',
'class' => 'linkbutton'
'action' => 'index',
'class' => 'attribute-mappings',
'icon' => 'swap_vert'
]
];
3 changes: 2 additions & 1 deletion app/templates/Matchgrids/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $indexColumns = [
$indexActions = [
[
'action' => 'manage',
'class' => 'configurebutton'
'class' => 'manage',
'icon' => 'manage_accounts'
]
];
3 changes: 2 additions & 1 deletion app/templates/Rules/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ $indexActions = [
[
'controller' => 'rule_attributes',
'action' => 'index',
'class' => 'linkbutton'
'class' => 'rule-attributes',
'icon' => 'check'
]
];
148 changes: 104 additions & 44 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ function _column_key($modelsName, $c, $tz=null) {
<?php if($vv_permissions['add']): ?>
<ul id="topLinks">
<li>
<?= $this->Html->link(__('match.op.add.a', __('match.ct.'.$vv_modelname, [1])),
<?= $this->Html->link('<em class="material-icons" aria-hidden="true">add_circle</em> ' .
__('match.op.add.a', __('match.ct.'.$vv_modelname, [1])),
array_merge($linkFilter, ['action' => 'add']),
['class' => 'addbutton']); ?>
['escape' => false, 'class' => 'addbutton']); ?>
</li>
<?php
if(!empty($topLinks)) {
Expand All @@ -104,7 +105,7 @@ function _column_key($modelsName, $c, $tz=null) {
$this->Html->link(
$t['label'],
array_merge($linkFilter, $t['link']),
['class' => $t['class']]
['escape' => false, 'class' => $t['class']]
) . '
</li>';
}
Expand Down Expand Up @@ -156,7 +157,7 @@ function _column_key($modelsName, $c, $tz=null) {
}
?></th>
<?php endforeach; ?>
<th><?= __('match.fd.action'); ?></th>
<th class="actions"><?= __('match.fd.action'); ?></th>
</tr>
<?php foreach(${$vv_tablename} as $entity): ?>
<?php
Expand Down Expand Up @@ -279,77 +280,136 @@ function _column_key($modelsName, $c, $tz=null) {
?>
</td>
<?php endforeach; // $indexColumns ?>
<td>
<td class="actions">
<?php

// Action list for command menu dropdown / button listing
$action_args = array();
$action_args['vv_attr_mdl'] = "Index";
$action_args['vv_attr_id'] = $entity->id;

// Edit
if($vv_permissions['edit']) {
print $this->Html->link(
__('match.op.edit'),
array_merge_recursive(['action' => 'edit'], $linkArgs),
['class' => 'editbutton']
$action_args['vv_actions'][] = array(
'order' => $this->Menu->getMenuOrder('Edit'),
'icon' => $this->Menu->getMenuIcon('Edit'),
'url' => $this->Url->build(array_merge_recursive(['action' => 'edit'], $linkArgs)),
'label' => __('match.op.edit')
);
}

// Duplicate
if(isset($vv_permissions['duplicate']) && $vv_permissions['duplicate']) {
print $this->Html->link(
__('match.op.duplicate'),
array_merge_recursive(['action' => 'duplicate'], $linkArgs),
['class' => 'copybutton']
);
}

if($vv_permissions['delete']) {
// XXX this is throwing CSRF error even though delete button on edit-record page is working?
// probably because this is using Form helper, but we're outside of a form?
print $this->Form->postLink(
__('match.op.delete'),
array_merge_recursive(['action' => 'delete'], $linkArgs),
// XXX should be configurable which field we put in, maybe displayField?
['confirm' => __('match.op.delete.confirm', [$entity->id]),
'class' => 'deletebutton nospin']
$action_args['vv_actions'][] = array(
'order' => $this->Menu->getMenuOrder('Duplicate'),
'icon' => $this->Menu->getMenuIcon('Duplicate'),
'url' => $this->Url->build(array_merge_recursive(['action' => 'duplicate'], $linkArgs)),
'label' => __('match.op.duplicate')
);
}

// Insert additional actions as per the .inc file
if(!empty($indexActions)) {
// Insert additional actions as per the .inc file

if(!isset($entity->status) || $entity->status == StatusEnum::Active) {
$actionOrderDefault = $this->Menu->getMenuOrder('Default');
foreach($indexActions as $a) {
if($vv_permissions[ $a['action'] ]) {
// If we have a .confirm text, use postLink instead
$actionOrder = !empty($a['order']) ? $a['order'] : $actionOrderDefault++;
$actionIcon = !empty($a['icon']) ? $a['icon'] : $this->Menu->getMenuIcon('Default');
$actionClass = !empty($a['class']) ? $a['class'] : '';
$actionUrl = '';
$actionLabel = '';
$actionOnClick = []; // used for confirmation dialog

// Generate the link text and urls:

// If we have a .confirm text, we need to generate a confirm dialog box
$confirmKey = 'match.op.'.$a['action'].'.confirm';
$confirmTxt = __($confirmKey);

if($confirmTxt != $confirmKey) {
// We found the localized string

print $this->Form->postLink(
__('match.op.' . $a['action']),
array_merge_recursive(['action' => $a['action']], $linkArgs),
// XXX should be configurable which field we put in, maybe displayField?
['confirm' => __($confirmKey, [$entity->id]),
'class' => $a['class'] . ' nospin']
$actionPostBtnArray = array_merge_recursive(['action' => $a['action']], $linkArgs);
$actionUrl = $this->Url->build(array_merge_recursive(['action' => $a['action']], $linkArgs));
// XXX should be configurable which field we put in, maybe displayField?
$action_args['vv_actions'][] = array(
'order' => $actionOrder,
'icon' => $actionIcon,
'url' => 'javascript:void(0);',
'label' => __('match.op.' . $a['action']),
'class' => !empty($actionClass) ? $actionClass . ' nospin' : 'nospin',
'onclick' => array(
'dg_bd_txt' => __($confirmKey, [$entity->id]), // dialog body text
'dg_post_btn_array' => $actionPostBtnArray, // postButton array for building the postButton
'dg_url' => $actionUrl, // action url for building a unique ID
'dg_conf_btn' => __('match.op.confirm'), // dialog confirm button text
'dg_cancel_btn' => __('match.op.cancel'), // dialog cancel button text
'dg_title' => __('match.op.confirm') // dialog box title
),
);

} elseif(!empty($a['controller'])) {
// We're linking into a related controller
print $this->Html->link(
__('match.ct.' . Inflector::camelize(Inflector::pluralize($a['controller'])), [99]),
$actionLabel = __('match.ct.' . Inflector::camelize(Inflector::pluralize($a['controller'])), [99]);
$actionUrl = $this->Url->build(
['controller' => $a['controller'],
'action' => $a['action'],
'?' => [ $tableFK => $entity->id] ],
['class' => $a['class']]
'action' => $a['action'],
'?' => [ $tableFK => $entity->id] ]
);
} else {
print $this->Html->link(
__('match.op.' . $a['action']),
array_merge_recursive(['action' => $a['action']], $linkArgs),
['class' => $a['class']]
$actionLabel = __('match.op.' . $a['action']);
$actionUrl = $this->Url->build(
array_merge_recursive(['action' => $a['action']], $linkArgs)
);
}

// If a specific label is sent in the config, use it instead
if(!empty($a['label'])) {
$actionLabel = $a['label'];
}

// Set the action link configuration
$action_args['vv_actions'][] = array(
'order' => $actionOrder,
'icon' => $actionIcon,
'url' => $actionUrl,
'label' => $actionLabel,
'class' => $actionClass,
'onclick' => $actionOnClick
);
}
}
}
}

// Delete
if($vv_permissions['delete']) {
$actionPostBtnArray = array_merge_recursive(['action' => 'delete'], $linkArgs);
$actionUrl = $this->Url->build(array_merge_recursive(['action' => 'delete'], $linkArgs));
$action_args['vv_actions'][] = array(
'order' => $this->Menu->getMenuOrder('Delete'),
'icon' => $this->Menu->getMenuIcon('Delete'),
'url' => 'javascript:void(0);',
'label' => __('match.op.delete'),
'class' => 'deletebutton nospin',
'onclick' => array(
'dg_bd_txt' => __('match.op.delete.confirm', [$entity->id]),
'dg_post_btn_array' => $actionPostBtnArray,
'dg_url' => $actionUrl,
'dg_conf_btn' => __('match.op.remove'),
'dg_cancel_btn' => __('match.op.cancel'),
'dg_title' => __('match.op.remove')
),
);
}

if(!empty($action_args['vv_actions'])) {
print '<div class="field-actions">';
print $this->element('menuAction', $action_args);
print '</div>';
}

?>
</td>
</tr>
Expand All @@ -360,6 +420,6 @@ function _column_key($modelsName, $c, $tz=null) {
<?php endif; ?>
</table>
</div>

<?php
print $this->element("pagination");
Loading

0 comments on commit 59edd61

Please sign in to comment.