Skip to content

Addition of Person Overview/Canvas (CFM-205) #62

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/resources/locales/en_US/field.po
Expand Up @@ -29,8 +29,8 @@
# When adding entries to this file, group non-model specific translations at the top,
# then model specific translations alphabetically by model.

msgid "action"
msgstr "Action"
msgid "actions"
msgstr "{0,plural,=1{Action} other{Actions}}"

msgid "actor"
msgstr "Actor"
Expand Down Expand Up @@ -159,6 +159,9 @@ msgstr "Plugin"
msgid "postal_code"
msgstr "Postal Code"

msgid "primary"
msgstr "Primary"

msgid "primary_name"
msgstr "Primary Name"

Expand Down Expand Up @@ -243,6 +246,9 @@ msgstr "Value"
msgid "verified"
msgstr "Verified"

msgid "unverified"
msgstr "Unverified"

msgid "ApiUsers.privileged.desc"
msgstr "A privileged API user has full access to the CO. Unprivileged API users may be granted specific permissions where supported."

Expand Down
6 changes: 6 additions & 0 deletions app/resources/locales/en_US/information.po
Expand Up @@ -56,3 +56,9 @@ msgstr "There are no records to display."

msgid "global.title.none"
msgstr "No title"

msgid "global.value.none"
msgstr "No value"

msgid "global.visit.link"
msgstr "Visit link"
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/operation.po
Expand Up @@ -27,6 +27,9 @@
msgid "activate"
msgstr "Activate"

msgid "add"
msgstr "Add"

msgid "add.a"
msgstr "Add a New {0}"

Expand Down
62 changes: 62 additions & 0 deletions app/src/Controller/PeopleController.php
Expand Up @@ -76,4 +76,66 @@ public function beforeRender(\Cake\Event\EventInterface $event) {

return parent::beforeRender($event);
}

/**
* Person overview / canvas
*
* @since COmanage Registry v5.0.0
*/

public function canvas(string $id) {
/* XXX Simply including parent::edit() is nearly all that's required - but we need
to delve a little deeper to get data from underlying relationships. We might send a contains()
override to parent::edit() which would allow this to be more DRY
// Keep the following as an example for now.
parent::edit($id, false);
// We've just set the vv_supertitle in the parent controller.
// Pass it to the title for use in the breadcrumbs.
$this->set('vv_title', $this->viewBuilder()->getVar('vv_supertitle'));
*/

/* The following is nearly identical to parent::edit/view */
$modelsName = $this->name;
$table = $this->$modelsName;
$tableName = $table->getTable();
$query = $table->findById($id);

// This contain() directive is the primary deviation from standard edit()/view().
// We need to drill down to deeper related models for display.
$query = $query->contain([
'PrimaryName',
'Names' => ['Types'],
'Addresses' => ['Types'],
'AdHocAttributes',
'EmailAddresses' => ['Types'],
'GroupMembers',
'GroupOwners',
'Identifiers' => ['Types'],
'PersonRoles' => ['Cous','Types'],
'Pronouns',
'TelephoneNumbers' => ['Types'],
'Urls' => ['Types']
]);

try {
// Pull the current record
$obj = $query->firstOrFail();
} catch(\Exception $e) {
// findById throws Cake\Datasource\Exception\RecordNotFoundException
$this->Flash->error($e->getMessage());
// XXX This redirects to an Exception page because $id is not found.
// XXX A 404 with error would be better.
return $this->generateRedirect((int)$id);
}

$this->set('vv_obj', $obj);
$this->getPrimaryLink();
$this->populateAutoViewVars($obj);

$this->set('vv_title', $table->generateDisplayField($obj));
$this->set('vv_supertitle', $table->generateDisplayField($obj));
// Pass the display field also into subtitle for dealing with External IDs
$this->set('vv_subtitle', $table->generateDisplayField($obj));
}
}
9 changes: 7 additions & 2 deletions app/src/Controller/StandardController.php
Expand Up @@ -331,8 +331,9 @@ public function edit(string $id) {
}
catch(\Exception $e) {
// findById throws Cake\Datasource\Exception\RecordNotFoundException

$this->Flash->error($e->getMessage());
// XXX This redirects to an Exception page because $id is not found.
// XXX A 404 with error would be better.
Comment on lines +335 to +336
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but is adding this comment necessary for this commit? (Same below.) We could open a new JIRA for improving error rendering.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - it's not necessary - I just didn't want to forget about it. I'll add a jira and remove these.

return $this->generateRedirect((int)$id);
}

Expand Down Expand Up @@ -724,8 +725,9 @@ public function view($id = null) {
}
catch(\Exception $e) {
// findById throws Cake\Datasource\Exception\RecordNotFoundException

$this->Flash->error($e->getMessage());
// XXX This redirects to an Exception page because $id is not found.
// XXX A 404 with error would be better.
return $this->generateRedirect((int)$id);
}

Expand All @@ -742,6 +744,9 @@ public function view($id = null) {
// We don't use a trait for this since each table will implement different logic

$this->set('vv_title', __d('operation', 'view.ai', $table->generateDisplayField($obj)));
$this->set('vv_supertitle', $table->generateDisplayField($obj));
// Pass the display field also into subtitle for dealing with External IDs
$this->set('vv_subtitle', $table->generateDisplayField($obj));
} else {
// Default view title is the object display field
$field = $table->getDisplayField();
Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Traits/PrimaryLinkTrait.php
Expand Up @@ -46,7 +46,7 @@ trait PrimaryLinkTrait {
private $unkeyedActions = ['add', 'index'];

// Actions where the primary link can be obtained by looking up the record ID
private $lookupActions = ['delete', 'edit', 'view'];
private $lookupActions = ['delete', 'edit', 'canvas', 'view'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we specifically remove the canvas action? ie: There's no need for PeopleController to have both an edit and a canvas action, and canvas just requires a bunch of special case handling, so why not just implement the canvas functionality under edit? (I'm pretty sure we decided this a few months ago.)

I realize this will complicate the view file, below, but we can handle that pretty generically by eg allowing the controller to not use the standard view.

Copy link
Author

@arlen arlen Dec 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, we kind of need both because of the way the tabs work under the overview. Edit = "properties" tab. There's a lot to be done to move to a complete ajax model, and I'd like this stuff to work in the meantime. There are things to like about the current approach, and we should do some A/B comparisons before we fully commit. (I'm going to work up some miro boards as well.)


// Where to redirect on add or edit, can be 'self', 'index', or 'primaryLink'
private $redirectGoal = 'index';
Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Util/StringUtilities.php
Expand Up @@ -46,7 +46,7 @@ class StringUtilities {
public static function columnKey($modelsName, $c, $tz=null, $useCustomClMdlLabel=false): string {
if(strpos($c, "_id", strlen($c)-3)) {
// Key is of the form field_id, use .ct label instead
$k = $this->foreignKeyToClassName($c);
$k = self::foreignKeyToClassName($c);

return __d('controller', $k, [1]);
}
Expand Down
1 change: 1 addition & 0 deletions app/src/Model/Table/PeopleTable.php
Expand Up @@ -150,6 +150,7 @@ public function initialize(array $config): void {
'entity' => [
'delete' => ['platformAdmin', 'coAdmin'],
'edit' => ['platformAdmin', 'coAdmin'],
'canvas' => ['platformAdmin', 'coAdmin'],
'view' => ['platformAdmin', 'coAdmin']
],
// Actions that operate over a table (ie: do not require an $id)
Expand Down
2 changes: 1 addition & 1 deletion app/templates/AdHocAttributes/columns.inc
Expand Up @@ -41,6 +41,6 @@ $bulkActions = [

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'ad_hoc_attributes'
];
2 changes: 1 addition & 1 deletion app/templates/AdHocAttributes/fields-nav.inc
Expand Up @@ -30,6 +30,6 @@ $topLinks = [];

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'ad_hoc_attributes'
];
2 changes: 1 addition & 1 deletion app/templates/Addresses/columns.inc
Expand Up @@ -45,6 +45,6 @@ $bulkActions = [

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'addresses'
];
2 changes: 1 addition & 1 deletion app/templates/Addresses/fields-nav.inc
Expand Up @@ -30,6 +30,6 @@ $topLinks = [];

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'addresses'
];
2 changes: 1 addition & 1 deletion app/templates/EmailAddresses/columns.inc
Expand Up @@ -41,6 +41,6 @@ $bulkActions = [

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'email_addresses'
];
2 changes: 1 addition & 1 deletion app/templates/EmailAddresses/fields-nav.inc
Expand Up @@ -30,6 +30,6 @@ $topLinks = [];

$subnav = [
'name' => 'person',
'active' => 'attributes', // default for person. 'external identities' are special cased
'active' => 'person', // default for person. 'external identities' are special cased
'subActive' => 'email_addresses'
];
2 changes: 1 addition & 1 deletion app/templates/Identifiers/columns.inc
Expand Up @@ -56,6 +56,6 @@ $bulkActions = [

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'identifiers'
];
2 changes: 1 addition & 1 deletion app/templates/Identifiers/fields-nav.inc
Expand Up @@ -30,6 +30,6 @@ $topLinks = [];

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'identifiers'
];
2 changes: 1 addition & 1 deletion app/templates/Names/columns.inc
Expand Up @@ -58,6 +58,6 @@ $bulkActions = [

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'names'
];
2 changes: 1 addition & 1 deletion app/templates/Names/fields-nav.inc
Expand Up @@ -30,6 +30,6 @@ $topLinks = [];

$subnav = [
'name' => 'person',
'active' => 'attributes',
'active' => 'person',
'subActive' => 'names'
];