Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feature-cfm291-bulkActions (#198)
* Add first-pass at Bulk Actions box. Turn on bulk actions for Groups and Group Members.

* Support bulk delete

* Use Modal for bulk actions

* css tweaks

* Modal vue module

* Style the bulk select actions; provide "dismissable" configuration on alert component; add language strings (CFM-291)

* add datatables

* improvements

* mvea use common modal element

* remove obsolete dependency

* fix forgotten form field

* use api/ajax/v2 endpoint

* take into account restful and not only ajax requests.Description as a subject value on the report datatable.

* fix typo

* Stylistic and textual updates for Bulk Edit (CFM-291)

---------

Co-authored-by: Arlen Johnson <arlen@sphericalcowgroup.com>
Ioannis and arlen committed May 14, 2024
1 parent b26eba9 commit 207bb59
Showing 30 changed files with 1,491 additions and 77 deletions.
6 changes: 6 additions & 0 deletions app/resources/locales/en_US/information.po
@@ -108,5 +108,11 @@ msgstr "Active, Cannot Be Disabled"
msgid "plugin.inactive"
msgstr "Inactive"

msgid "record"
msgstr "Record"

msgid "report.for"
msgstr "Report for "

msgid "table.list"
msgstr "{0} List"
18 changes: 15 additions & 3 deletions app/resources/locales/en_US/operation.po
@@ -36,12 +36,12 @@ msgstr "Add"
msgid "add.a"
msgstr "Add a New {0}"

msgid "add.bulk"
msgstr "Bulk add"

msgid "add.member"
msgstr "Add member: "

msgid "apply"
msgstr "Apply"

msgid "autocomplete.pager.show.more"
msgstr "show more"

@@ -69,6 +69,12 @@ msgstr "Assign"
msgid "any"
msgstr "Any"

msgid "bulk.actions"
msgstr "Bulk Actions"

msgid "bulk.add"
msgstr "Bulk add"

msgid "cancel"
msgstr "Cancel"

@@ -171,6 +177,9 @@ msgstr "Display records"
msgid "page.goto"
msgstr "Go to page"

msgid "pick"
msgstr "Pick"

msgid "previous"
msgstr "Previous"

@@ -210,6 +219,9 @@ msgstr "Search"
msgid "search.global"
msgstr "Global Search"

msgid "select.prompt"
msgstr "Please select..."

msgid "skip_to_content"
msgstr "Skip to main content"

9 changes: 9 additions & 0 deletions app/resources/locales/en_US/result.po
@@ -57,6 +57,9 @@ msgstr "External Identity status recalculated from {0} to {1}"
msgid "ExternalIdentitySources.synced"
msgstr "External Identity Source sync complete"

msgid "failed"
msgstr "failed"

msgid "Groups.added"
msgstr "Group {0} created"

@@ -154,6 +157,9 @@ msgstr "Created new External Identity via Pipeline {0} ({1}) using Source {2} ({
msgid "Pipelines.started"
msgstr "Pipeline {0} ({1}) started for EIS {2} ({3}) source key {4}"

msgid "removed"
msgstr "removed"

msgid "saved"
msgstr "Saved"

@@ -190,3 +196,6 @@ msgstr "Database connection established"

msgid "test.mail.ok"
msgstr "Test message sent"

msgid "updated"
msgstr "updated"
11 changes: 10 additions & 1 deletion app/src/Controller/Component/RegistryAuthComponent.php
@@ -252,12 +252,21 @@ public function beforeFilter(EventInterface $event) {
}

if(Configure::read('debug')) {
// For testing purposes throw an error, but in production we want to
// For testing purposes, throw an error, but in production we want to
// redirect to /login
if($request->is('ajax') || $request->is('restful')) {
// Permission denied
throw new ForbiddenException(__d('error', 'perm'));
}
$controller->Flash->error("Authorization Failed (RegistryAuthComponent)");
return $controller->redirect("/");
}
}

if($request->is('ajax') || $request->is('restful')) {
// Permission denied
throw new ForbiddenException(__d('error', 'perm'));
}

// No authentication, redirect to login

76 changes: 76 additions & 0 deletions app/src/Lib/Enum/BulkActionEnum.php
@@ -0,0 +1,76 @@
<?php
/**
* COmanage Registry Bulk Action Enum
*
* 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)
*/

declare(strict_types = 1);

namespace App\Lib\Enum;

class BulkActionEnum extends StandardEnum {
public const Delete = 'delete';
public const PromoteToOwner = 'owner';

/**
* Return action to request http method
*
* @param string $action
*
* @return string
* @since COmanage Registry v5.0.0
*/

public static function actionToMethod(string $action) : string
{
return match($action) {
'delete' => 'delete',
'owner' => 'post',
default => 'get'
};
}

/**
* Return actions to request http methods
*
* @param array $actions
*
* @return array
* @since COmanage Registry v5.0.0
*/

public static function actionsToMethods() : array
{
$ret = [];
foreach (self::getConstValues() as $act) {
$ret[$act] = match($act) {
'delete' => 'delete',
'owner' => 'post',
default => 'get'
};
}

return $ret;
}
}
39 changes: 39 additions & 0 deletions app/src/Lib/Enum/StandardEnum.php
@@ -82,4 +82,43 @@ public static function getConstValues() : array {

return array_values($consts);
}

/**
* Get the Keys for the constants in the Enumeration in Humanized form.
*
* @since COmanage Registry v5.0.0
* @return array Array of enumeration keys
*/

public static function getConstHumanized() : array {
// Get the keys for this enum
$reflect = new ReflectionClass(get_called_class());

$consts = $reflect->getConstants();

return collection(array_keys($consts))->map(
fn($key) => Inflector::humanize(Inflector::underscore($key))
)->toList();
}

/**
* Reverse the Const. The key is now the value is the humanized form
* of the key. Ideal for Select elements
*
* @since COmanage Registry v5.0.0
* @return array
*/

public static function getHumanized() : array {
// Get the keys for this enum
$reflect = new ReflectionClass(get_called_class());

$consts = $reflect->getConstants();

$humanized = collection(array_keys($consts))->map(
fn($key) => Inflector::humanize(Inflector::underscore($key))
)->toList();

return array_combine(array_values($consts), $humanized);
}
}
10 changes: 9 additions & 1 deletion app/src/View/Helper/VueHelper.php
@@ -51,11 +51,14 @@ class VueHelper extends Helper {
'login',
'primary',
'datepicker.hour',
'status',
'unverified'
],
'information' => [
'global.value.none',
'datepicker.hour'
'datepicker.hour',
'record',
'report.for'
],
'operation' => [
'add',
@@ -65,6 +68,11 @@ class VueHelper extends Helper {
'autocomplete.people.label',
'autocomplete.people.placeholder',
'close'
],
'result' => [
'failed',
'removed',
'updated'
]
];

14 changes: 7 additions & 7 deletions app/templates/GroupMembers/columns.inc
@@ -25,6 +25,8 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

use App\Lib\Enum\BulkActionEnum;

$indexColumns = [
'name' => [
'type' => 'link',
@@ -83,13 +85,11 @@ $topLinks = [
*/
];

/*
// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
$bulkActions = [
// TODO: develop bulk actions. For now, use a placeholder.
'delete' => true
];
*/

// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
// The array should contain a list of actions to be made available.
$bulkActions = [BulkActionEnum::Delete];


$subnav = [
'name' => 'group',
13 changes: 6 additions & 7 deletions app/templates/Groups/columns.inc
@@ -25,6 +25,8 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

use App\Lib\Enum\BulkActionEnum;

$indexColumns = [
'name' => [
'type' => 'link'
@@ -73,10 +75,7 @@ $rowActions = [
]
];

/*
// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
$bulkActions = [
// TODO: develop bulk actions. For now, use a placeholder.
'delete' => true
];
*/

// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
// The array should contain a list of actions to be made available.
$bulkActions = [BulkActionEnum::Delete];
5 changes: 4 additions & 1 deletion app/templates/Notifications/fields.inc
@@ -58,7 +58,10 @@ if($vv_action == 'view') {
]
]);
} else {
print $this->Field->control('status');
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'status'
]]);
}

print $this->element('form/listItem', [

0 comments on commit 207bb59

Please sign in to comment.