Skip to content

Commit

Permalink
Link to T&C page from Terms and Conditions index view (CFM-501)
Browse files Browse the repository at this point in the history
  • Loading branch information
arlen committed Mar 13, 2026
1 parent c57b93f commit f996f21
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/operation.po
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
5 changes: 5 additions & 0 deletions app/src/Model/Table/TermsAndConditionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/templates/MostlyStaticPages/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
]
Expand Down
13 changes: 4 additions & 9 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']];
}
Expand Down
15 changes: 15 additions & 0 deletions app/templates/TermsAndConditions/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
]
];

0 comments on commit f996f21

Please sign in to comment.