Skip to content

Provide a "deleted" action and view for deletion within iframe views (CFM-392) #233

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ msgstr "Attribute Modal"
msgid "global.attributes"
msgstr "Attributes"

msgid "global.attributes.none"
msgstr "There are no attributes of this type"

msgid "global.records.none"
msgstr "There are no records to display."

Expand Down
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/result.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ msgstr "Added {0} to group {1} via nesting of group {2} ({3})"
msgid "GroupMembers.deleted"
msgstr "Removed {0} from group {1}"

msgid "GroupMembers.deleted.generic"
msgstr "Removed member from group"

msgid "GroupMembers.deleted.nesting"
msgstr "Removed {0} from group {1} via nesting of group {2} ({3})"

Expand Down
5 changes: 3 additions & 2 deletions app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ protected function primaryLinkLookup(): void

// At the end we need to have a Primary Link
if(empty($this->cur_pl->value)
&& !$this->$modelsName->allowEmptyPrimaryLink($this->request->getParam('action'))) {
&& !$this->$modelsName->allowEmptyPrimaryLink($this->request->getParam('action'))
&& $this->request->getParam('action') != 'deleted') {
throw new \RuntimeException(__d('error', 'primary_link'));
}
}
Expand Down Expand Up @@ -531,7 +532,7 @@ protected function populateAvailableCos() {
*/

protected function setCO() {
if($this->cur_co) {
if($this->cur_co || $this->request->getParam('action') == 'deleted') {
// Nothing to do...
return;
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/Controller/GroupMembersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,18 @@ public function add() {

return parent::add();
}

/**
* Handle the deleted action for a Group Member.
* This is used to set the view title.
*
* @since COmanage Registry v5.0.0
*/

public function deleted() {
// Override the standard title
$this->set('vv_title', __d('result','GroupMembers.deleted.generic'));

return parent::deleted();
}
}
4 changes: 2 additions & 2 deletions app/src/Controller/MVEAController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function beforeFilter(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;

if(!$this->request->is('restful')) {
if(!$this->request->is('restful') && $this->request->getParam('action') != 'deleted') {
// Provide additional hints to BreadcrumbsComponent. This needs to be here
// and not in beforeRender because the component beforeRender will run first.

Expand Down Expand Up @@ -143,7 +143,7 @@ public function beforeRender(\Cake\Event\EventInterface $event) {
// field = model (or model_name)
$fieldName = Inflector::underscore(Inflector::singularize($modelsName));

if(!$this->request->is('restful')) {
if(!$this->request->is('restful') && $this->request->getParam('action') != 'deleted') {
// If there is a default type setting for this model, pass it to the view
if($this->$modelsName->getSchema()->hasColumn('type_id')) {
$defaultTypeField = "default_" . $fieldName . "_type_id";
Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/NamesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NamesController extends MVEAController {
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
if(!$this->request->is('restful')) {
if(!$this->request->is('restful') && $this->request->getParam('action') != 'deleted') {
// Get the set of permitted name fields to pass to the view.
// (We don't need required name fields since FormHelper will handle that.)

Expand Down
31 changes: 27 additions & 4 deletions app/src/Controller/StandardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Cake\ORM\TableRegistry;
use InvalidArgumentException;
use \Cake\Http\Exception\BadRequestException;
use Cake\Utility\Inflector;
use \App\Lib\Enum\ProvisioningContextEnum;
use \App\Lib\Enum\SuspendableStatusEnum;
use \App\Lib\Util\{StringUtilities, FunctionUtilities};
Expand Down Expand Up @@ -169,8 +170,10 @@ public function beforeRender(\Cake\Event\EventInterface $event) {
$table = $this->$modelsName;

// Provide some hints to the views
$this->getFieldTypes();
$this->getRequiredFields();
if($this->request->getParam('action') != 'deleted') {
$this->getFieldTypes();
$this->getRequiredFields();
}

// Set the display field as a view var to make it available to the views
$this->set('vv_display_field', $table->getDisplayField());
Expand Down Expand Up @@ -307,6 +310,23 @@ public function delete($id) {
return $this->redirect(['action' => 'edit', $id]);
}

/**
* Handle a deleted action for a Standard object.
*
* @since COmanage Registry v5.0.0
*/

public function deleted() {
// Set the title when not set at the individual controller
if(empty($this->viewBuilder()->getVar('vv_title'))) {
$modelsName = $this->name;
$fieldName = Inflector::singularize($modelsName);
$this->set('vv_title', __d('result', 'deleted.a', [$fieldName]));
}
// Render the view
$this->render('/Standard/deleted');
}

/**
* Handle an edit action for a Standard object.
*
Expand Down Expand Up @@ -451,8 +471,11 @@ public function generateRedirect($entity) {
$redirectGoal = 'index';
}
}

if($redirectGoal == 'self'

if($redirectGoal == 'deleted') {
// Immediately redirect to the (mostly blank) deleted view
return $this->redirect(['action' => 'deleted']);
} elseif($redirectGoal == 'self'
&& $entity
&& in_array($this->request->getParam('action'), ['add', 'edit'])) {
// We typically want to redirect to the edit view of the record,
Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/TelephoneNumbersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TelephoneNumbersController extends MVEAController {
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
if(!$this->request->is('restful')) {
if(!$this->request->is('restful') && $this->request->getParam('action') != 'deleted') {
$CoSettings = TableRegistry::getTableLocator()->get('CoSettings');

$settings = $CoSettings->find()->where(['co_id' => $this->getCOID()])->firstOrFail();
Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Traits/PrimaryLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public function setPrimaryLink($fields) {
*/

public function setRedirectGoal(string $goal, string $action='*') {
if(!in_array($goal, ['index', 'pluggableLink', 'primaryLink', 'self', 'special'])) {
if(!in_array($goal, ['deleted', 'index', 'pluggableLink', 'primaryLink', 'self', 'special'])) {
throw new \InvalidArgumentException(__d('error', 'invalid', [$goal]));
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/AdHocAttributesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function initialize(array $config): void {
$this->setPrimaryLink(['external_identity_id', 'external_identity_role_id', 'person_id', 'person_role_id']);
$this->setRequiresCO(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setAllowLookupPrimaryLink(['unfreeze']);
$this->setEditContains(['ExternalIdentities', 'ExternalIdentityRoles', 'SourceAdHocAttributes']);

Expand All @@ -103,7 +104,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/AddressesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function initialize(array $config): void {
// Models that AcceptCoId should be expicitly added to StandardApiController::initialize()
$this->setAcceptsCoId(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setAllowLookupPrimaryLink(['unfreeze']);
$this->setEditContains(['ExternalIdentities', 'ExternalIdentityRoles', 'SourceAddresses']);

Expand Down Expand Up @@ -131,7 +132,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/EmailAddressesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function initialize(array $config): void {
$this->setAllowLookupPrimaryLink(['primary']);
$this->setRequiresCO(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setAllowLookupPrimaryLink(['forceVerify', 'unfreeze']);
$this->setEditContains(['ExternalIdentities', 'SourceEmailAddresses']);

Expand All @@ -133,7 +134,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);
}
Expand Down
6 changes: 4 additions & 2 deletions app/src/Model/Table/GroupMembersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class GroupMembersTable extends Table {
*/
public function getLayout(string $action = ''): string {
return match($action) {
'add','edit','view' => 'iframe',
'add','edit','view','deleted' => 'iframe',
default => 'default'
};
}
Expand Down Expand Up @@ -93,6 +93,7 @@ public function initialize(array $config): void {
$this->setPrimaryLink(['group_id', 'person_id']);
$this->setRequiresCO(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');

$this->setEditContains(['Groups', 'People.PrimaryName']);
$this->setViewContains(['Groups', 'People.PrimaryName']);
Expand Down Expand Up @@ -125,7 +126,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);

Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/IdentifiersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public function initialize(array $config): void {
$this->setPrimaryLink(['external_identity_id', 'group_id', 'person_id']);
$this->setRequiresCO(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setAllowLookupPrimaryLink(['unfreeze']);
$this->setEditContains(['ExternalIdentities', 'SourceIdentifiers']);

Expand Down Expand Up @@ -146,7 +147,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
],
// Related models whose permissions we'll need, typically for table views
'related' => [
Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/NamesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function initialize(array $config): void {
// Models that AcceptCoId should be explicitly added to StandardApiController::initialize()
$this->setAcceptsCoId(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setEditContains(['ExternalIdentities', 'SourceNames']);

$this->setAutoViewVars([
Expand Down Expand Up @@ -137,7 +138,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/PronounsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function initialize(array $config): void {
$this->setPrimaryLink(['external_identity_id', 'person_id']);
$this->setRequiresCO(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setAllowLookupPrimaryLink(['unfreeze']);
$this->setEditContains(['ExternalIdentities', 'SourcePronouns']);

Expand Down Expand Up @@ -123,7 +124,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/TelephoneNumbersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function initialize(array $config): void {
// Models that AcceptCoId should be expicitly added to StandardApiController::initialize()
$this->setAcceptsCoId(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setAllowLookupPrimaryLink(['unfreeze']);
$this->setEditContains(['ExternalIdentities', 'ExternalIdentityRoles', 'SourceTelephoneNumbers']);

Expand All @@ -128,7 +129,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/UrlsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function initialize(array $config): void {
$this->setPrimaryLink(['external_identity_id', 'person_id']);
$this->setRequiresCO(true);
$this->setRedirectGoal('self');
$this->setRedirectGoal(action: 'delete', goal: 'deleted');
$this->setAllowLookupPrimaryLink(['unfreeze']);
$this->setEditContains(['ExternalIdentities', 'ExternalIdentityRoles', 'SourceUrls']);

Expand All @@ -119,7 +120,8 @@ public function initialize(array $config): void {
// Actions that operate over a table (ie: do not require an $id)
'table' => [
'add' => ['platformAdmin', 'coAdmin'],
'index' => ['platformAdmin', 'coAdmin']
'index' => ['platformAdmin', 'coAdmin'],
'deleted' => ['platformAdmin', 'coAdmin']
]
]);
}
Expand Down
1 change: 1 addition & 0 deletions app/src/View/Helper/VueHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class VueHelper extends Helper {
'unverified'
],
'information' => [
'global.attributes.none',
'global.value.none',
'record',
'report.for',
Expand Down
28 changes: 15 additions & 13 deletions app/templates/EmailAddresses/fields-nav.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ $subnav = [
'active' => 'person', // default for person. 'external identities' are special cased
'subActive' => 'email_addresses'
];

$topLinks = [
[
'icon' => 'verified_user',
'order' => 'Default',
'label' => __d('operation', 'EmailAddresses.verify.force'),
'if' => 'notVerified',
'link' => [
'action' => 'forceVerify',
$vv_obj->id

if($vv_action != 'add') {
$topLinks = [
[
'icon' => 'verified_user',
'order' => 'Default',
'label' => __d('operation', 'EmailAddresses.verify.force'),
'if' => 'notVerified',
'link' => [
'action' => 'forceVerify',
$vv_obj->id
],
'class' => ''
],
'class' => ''
],
];
];
}
Loading