From ed3a2d4069e862276466fb67046f80ec2c7df937 Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Sun, 18 Feb 2024 12:22:43 -0500 Subject: [PATCH] Miscellaneous EIS fixes and improvements --- app/src/Lib/Traits/PrimaryLinkTrait.php | 21 +++++---- .../Table/ExtIdentitySourceRecordsTable.php | 25 +++++++++- .../Model/Table/ExternalIdentitiesTable.php | 1 + app/src/Model/Table/PipelinesTable.php | 3 +- .../ExtIdentitySourceRecords/columns.inc | 46 +++++++++++++++++++ .../ExternalIdentities/fields-nav.inc | 2 +- 6 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 app/templates/ExtIdentitySourceRecords/columns.inc diff --git a/app/src/Lib/Traits/PrimaryLinkTrait.php b/app/src/Lib/Traits/PrimaryLinkTrait.php index 995caca74..f78af0d0a 100644 --- a/app/src/Lib/Traits/PrimaryLinkTrait.php +++ b/app/src/Lib/Traits/PrimaryLinkTrait.php @@ -38,9 +38,9 @@ trait PrimaryLinkTrait { // pairs, where the key is the field (eg: co_id) and the value is the table // (eg: Cos). private $primaryLinks = []; - + // Allow empty primary link? - private $allowEmpty = false; + private $allowEmptyActions = []; // Actions that can have an unkeyed (ie: self asserted) primary link ID private $unkeyedActions = ['add', 'index']; @@ -69,14 +69,15 @@ public function acceptsCoId(): bool { } /** - * Whether the primary link is permitted to be empty. + * Check to see whether the specified actions permits the primary link to be empty. * * @since COmanage Registry v5.0.0 - * @param boolean $allowEmpty true if the primary link is permitted to be empty + * @param string $action Action + * @return boolean true if permitted, false otherwise */ - public function allowEmptyPrimaryLink() { - return $this->allowEmpty; + public function allowEmptyPrimaryLink(string $action) { + return in_array($action , $this->allowEmptyActions); } /** @@ -251,7 +252,7 @@ public function getPrimaryLinks(): array { */ public function getPrimaryLinkTableName(string $primaryLink): string { - return $this->primaryLinks[$primaryLink]; + return $this->primaryLinks[$primaryLink] ?? 'Cos'; } /** @@ -421,11 +422,11 @@ public function setAcceptsCoId(bool $accepts) { * Set whether the primary link is permitted to be empty. * * @since COmanage Registry v5.0.0 - * @param boolean $allowEmpty true if the primary link is permitted to be empty + * @param array $actions Actions where the primary link is allowed to be empty */ - public function setAllowEmptyPrimaryLink(bool $allowEmpty) { - $this->allowEmpty = $allowEmpty; + public function setAllowEmptyPrimaryLink(array $actions) { + $this->allowEmptyActions = array_merge($this->allowEmptyActions, $actions); } /** diff --git a/app/src/Model/Table/ExtIdentitySourceRecordsTable.php b/app/src/Model/Table/ExtIdentitySourceRecordsTable.php index fec143baf..be3cb834f 100644 --- a/app/src/Model/Table/ExtIdentitySourceRecordsTable.php +++ b/app/src/Model/Table/ExtIdentitySourceRecordsTable.php @@ -45,6 +45,7 @@ class ExtIdentitySourceRecordsTable extends Table { use \App\Lib\Traits\PermissionsTrait; use \App\Lib\Traits\PrimaryLinkTrait; use \App\Lib\Traits\QueryModificationTrait; + use \App\Lib\Traits\SearchFilterTrait; use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; @@ -72,10 +73,32 @@ public function initialize(array $config): void { $this->setPrimaryLink(['external_identity_source_id']); $this->setRequiresCO(true); - $this->setViewContains([ + // These are required for the link to work from the Artifacts page + $this->setAllowUnkeyedPrimaryCO(['index']); + $this->setAllowEmptyPrimaryLink(['index']); + + $this->setIndexContains([ 'ExternalIdentitySources' ]); + $this->setViewContains([ + 'ExternalIdentitySources' + ]); +/* +// XXX This doesn't seem to correlate to what actually renders? + $this->setFilterConfig([ + 'external_identity_source_id' => [ + 'type' => 'field', + 'active' => true, + 'order' => 1 + ], + 'source_key' => [ + 'type' => 'field', + 'active' => true, + 'order' => 2 + ] + ]);*/ + $this->setPermissions([ // Actions that operate over an entity (ie: require an $id) 'entity' => [ diff --git a/app/src/Model/Table/ExternalIdentitiesTable.php b/app/src/Model/Table/ExternalIdentitiesTable.php index 83fdaa6a2..bf3d4fb02 100644 --- a/app/src/Model/Table/ExternalIdentitiesTable.php +++ b/app/src/Model/Table/ExternalIdentitiesTable.php @@ -33,6 +33,7 @@ use Cake\ORM\RulesChecker; use Cake\ORM\Table; use Cake\Validation\Validator; +use \App\Lib\Enum\ActionEnum; use \App\Lib\Enum\ExternalIdentityStatusEnum; class ExternalIdentitiesTable extends Table { diff --git a/app/src/Model/Table/PipelinesTable.php b/app/src/Model/Table/PipelinesTable.php index 32f088a1d..edeaf910c 100644 --- a/app/src/Model/Table/PipelinesTable.php +++ b/app/src/Model/Table/PipelinesTable.php @@ -1172,7 +1172,8 @@ protected function syncExternalIdentity( // ever able to add persistant record keys to the Backend // interface this code should "just work". - // We do rely on this block to process EIR related models. + // We do rely on this block to process EIR related models, + // which have roleIdentifiers that allow us to match records. foreach($externalIdentity->$amodel as $aentity) { if($aentity->id == $arecord['id']) { diff --git a/app/templates/ExtIdentitySourceRecords/columns.inc b/app/templates/ExtIdentitySourceRecords/columns.inc new file mode 100644 index 000000000..66e28f068 --- /dev/null +++ b/app/templates/ExtIdentitySourceRecords/columns.inc @@ -0,0 +1,46 @@ + [ + 'type' => 'link' + ], + 'external_identity_source_id' => [ + 'type' => 'relatedLink', + 'model' => 'external_identity_source', + 'field' => 'description', + 'sortable' => true + ], + 'source_key' => [ + 'type' => 'echo', + 'sortable' => true + ], + 'last_update' => [ + 'type' => 'datetime' + ] +]; diff --git a/app/templates/ExternalIdentities/fields-nav.inc b/app/templates/ExternalIdentities/fields-nav.inc index 9624c9c13..292a9c683 100644 --- a/app/templates/ExternalIdentities/fields-nav.inc +++ b/app/templates/ExternalIdentities/fields-nav.inc @@ -46,7 +46,7 @@ $topLinks = [ [ 'icon' => 'history', 'order' => 'Default', - 'label' => __d('operation', 'HistoryRecords'), + 'label' => __d('controller', 'HistoryRecords', [99]), 'link' => [ 'controller' => 'history_records', 'action' => 'index',