diff --git a/app/resources/locales/en_US/operation.po b/app/resources/locales/en_US/operation.po index e42c7d582..6fb8f252b 100644 --- a/app/resources/locales/en_US/operation.po +++ b/app/resources/locales/en_US/operation.po @@ -393,6 +393,9 @@ msgstr "Visit Page" msgid "visit.link" msgstr "Visit link" +msgid "visit.tandc" +msgstr "Visit Terms and Conditions URL" + msgid "view.PersonRoles.a" msgstr "View Role {0}" diff --git a/app/src/Model/Table/TermsAndConditionsTable.php b/app/src/Model/Table/TermsAndConditionsTable.php index a9627ec99..199d85224 100644 --- a/app/src/Model/Table/TermsAndConditionsTable.php +++ b/app/src/Model/Table/TermsAndConditionsTable.php @@ -45,6 +45,7 @@ class TermsAndConditionsTable extends Table { use \App\Lib\Traits\CoLinkTrait; use \App\Lib\Traits\PermissionsTrait; use \App\Lib\Traits\PrimaryLinkTrait; + use \App\Lib\Traits\QueryModificationTrait; use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; @@ -77,6 +78,10 @@ public function initialize(array $config): void { $this->setAllowLookupPrimaryLink(['proxy', 'revoke']); $this->setAllowLookupRelatedPrimaryLink(['status' => ['person_id']]); + $this->setIndexContains([ + 'MostlyStaticPages' + ]); + $this->setAutoViewVars([ 'cous' => [ 'type' => 'select', diff --git a/app/templates/MostlyStaticPages/columns.inc b/app/templates/MostlyStaticPages/columns.inc index 533162acb..8a0d55ca4 100644 --- a/app/templates/MostlyStaticPages/columns.inc +++ b/app/templates/MostlyStaticPages/columns.inc @@ -50,7 +50,7 @@ $rowActions = [ [ 'icon' => 'arrow_outward', 'label' => __d('operation', 'visit.msp'), - 'url' => function($entity) { + 'callbackUrl' => function($entity) { return '/' . $entity->co_id . '/' . $entity->name; } ] diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index bc86da373..52b6264b6 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -292,15 +292,10 @@ if (isset($vv_permission_set[$entity->id][$relTableName][$a['action']])) { $ok = $vv_permission_set[$entity->id][$relTableName][$a['action']]; } - } elseif(!empty($a['url'])) { - if(is_callable($a['url'])) { - // We are constructing a URL in a callback function. - $callbackUrl = $a['url']($entity); - } else { - // We are setting a static URL override. - $callbackUrl = $a['url']; - } - $ok = true; + } elseif(!empty($a['callbackUrl']) && is_callable($a['callbackUrl'])) { + // We are constructing a URL in a callback function. + $callbackUrl = $a['callbackUrl']($entity); + $ok = true; // There is no action to test in this case. } else { $ok = $vv_permission_set[$entity->id][$a['action']]; } diff --git a/app/templates/TermsAndConditions/columns.inc b/app/templates/TermsAndConditions/columns.inc index bd0113d87..79dd0053b 100644 --- a/app/templates/TermsAndConditions/columns.inc +++ b/app/templates/TermsAndConditions/columns.inc @@ -43,4 +43,19 @@ $indexColumns = [ 'type' => 'fk', 'sortable' => true ] +]; + +$rowActions = [ + [ + 'icon' => 'arrow_outward', + 'label' => __d('operation', 'visit.tandc'), + 'callbackUrl' => function($entity) { + // There should always be either a Mostly Static Page or a URL to reference. + if(!empty($entity->mostly_static_page->name)) { + // The T&C is a mostly static page. Provide a link to it. + return '/' . $entity->co_id . '/' . $entity->mostly_static_page->name; + } + return $entity->url; + } + ] ]; \ No newline at end of file