Skip to content

Commit

Permalink
VBO actions using AMI UUIDs. Almost there. Probably another 20 lines …
Browse files Browse the repository at this point in the history
…of code

and PUFFF... a lily transforms into a weee fish... beautiful magic @alliomeria
  • Loading branch information
DiegoPino committed Oct 11, 2024
1 parent 9fbd9bb commit 92ea91a
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 9 deletions.
12 changes: 9 additions & 3 deletions ami.links.task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,26 @@ ami_set_entity.delete_process_form:
title: Delete Processed ADOs
weight: 12

ami_set_entity.action_process_form:
route_name: entity.ami_set_entity.action_process_form
base_route: entity.ami_set_entity.canonical
title: Run Action on Processed ADOs
weight: 13

ami_set_entity.reconcile_form:
route_name: entity.ami_set_entity.reconcile_form
base_route: entity.ami_set_entity.canonical
title: Reconcile LoD
weight: 13
weight: 14

entity.ami_set_entity.reconcileedit_form:
route_name: entity.ami_set_entity.reconcileedit_form
base_route: entity.ami_set_entity.canonical
title: Edit Reconciled LoD
weight: 14
weight: 15

entity.ami_set_entity.report_form:
route_name: entity.ami_set_entity.report_form
base_route: entity.ami_set_entity.canonical
title: Reports
weight: 15
weight: 16
5 changes: 5 additions & 0 deletions ami.permissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@ deleteados amiset entity:
restrict access: TRUE
deleteados own amiset entity:
title: 'Delete ADOs generated through own AMI Set Entities'
actionados amiset entity:
title: 'Run Action on ADOs referenced on any AMI Set Entities'
restrict access: TRUE
actionados own amiset entity:
title: 'Run Action on ADOs referenced on own AMI Set Entities'
override file destination ami entity:
title: 'Override default persistent file destination and naming for Files ingested via AMI Set Entities. This permission breaks how Archipelago conceives file preservation as a core concern so out of the box will not trigger any chance without enabled a Drupal settings.php global option. See Documentation for this'
9 changes: 9 additions & 0 deletions ami.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ entity.ami_set_entity.delete_process_form:
requirements:
_entity_access: 'ami_set_entity.deleteados'

entity.ami_set_entity.action_process_form:
path: '/amiset/{ami_set_entity}/actionprocessed'
defaults:
_entity_form: ami_set_entity.actionprocessed
_title: 'Run Action on Ami Set'
requirements:
_entity_access: 'ami_set_entity.actionados'


entity.ami_set_entity.reconcile_form:
path: '/amiset/{ami_set_entity}/reconcile'
defaults:
Expand Down
2 changes: 1 addition & 1 deletion src/AmiUtilityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ public static function checkAmiSetDeleteAdosAccess(EntityInterface $entity): boo
if ($set_field instanceof \Drupal\strawberryfield\Field\StrawberryFieldItemList) {
$set = json_decode($entity->get('set')->getString(), TRUE);
if (json_last_error() == JSON_ERROR_NONE) {
$deleteados_access = (empty($set['pluginconfig']['op']) || !in_array($set['pluginconfig']['op'], ['update', 'patch']));
$deleteados_access = (empty($set['pluginconfig']['op']) || !in_array($set['pluginconfig']['op'], ['update', 'patch', 'sync']));
\Drupal::cache()->set($cache_id, $deleteados_access);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/Entity/Controller/amiSetEntityAccessControlHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
->cachePerPermissions()
->addCacheableDependency($entity);
}
case 'actionados':
if ($account->hasPermission('actionados amiset entity')) {
return AccessResult::allowed()->cachePerPermissions();
}
if ($account->hasPermission('actionados own amiset entity') && $is_owner) {
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
}
else {
return AccessResult::neutral()
->cachePerPermissions()
->addCacheableDependency($entity);
}
default:
return AccessResult::neutral()->cachePerPermissions();
}
Expand Down
7 changes: 7 additions & 0 deletions src/Entity/Controller/amiSetEntityListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public function getOperations(EntityInterface $entity) {
'url' => $this->ensureDestination($entity->toUrl('delete-process-form')),
];
}
if ($entity->access('actionados') && $entity->hasLinkTemplate('action-process-form')) {
$operations['action_processed'] = [
'title' => $this->t('Run Action on Processed ADOs'),
'weight' => 12,
'url' => $this->ensureDestination($entity->toUrl('action-process-form')),
];
}
}
return $operations;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/amiSetEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
* "delete" = "Drupal\ami\Form\amiSetEntityDeleteForm",
* "process" = "Drupal\ami\Form\amiSetEntityProcessForm",
* "deleteprocessed" = "Drupal\ami\Form\amiSetEntityDeleteProcessedForm",
* "actionprocessed" = "Drupal\ami\Form\amiSetEntityActionProcessedForm",
* "reconcile" = "Drupal\ami\Form\amiSetEntityReconcileForm",
* "editreconcile" = "Drupal\ami\Form\amiSetEntityReconcileCleanUpForm",
* "report" = "Drupal\ami\Form\amiSetEntityReportForm"
Expand All @@ -104,6 +105,7 @@
* "edit-form" = "/amiset/{ami_set_entity}/edit",
* "process-form" = "/amiset/{ami_set_entity}/process",
* "delete-process-form" = "/amiset/{ami_set_entity}/deleteprocessed",
* "action-form" = "/amiset/{ami_set_entity}/actionprocessed",
* "reconcile-form" = "/amiset/{ami_set_entity}/reconcile",
* "edit-reconcile-form" = "/amiset/{ami_set_entity}/editreconcile",
* "delete-form" = "/amiset/{ami_set_entity}/delete",
Expand Down
Loading

0 comments on commit 92ea91a

Please sign in to comment.