Skip to content

Update Person edit page to hold the person "canvas". Remove the /canvas action from the People controller. (CFM-205) #79

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions app/src/Controller/PeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,66 +76,4 @@ 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));
}
}
173 changes: 0 additions & 173 deletions app/templates/People/canvas.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/templates/People/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $indexColumns = [
'type' => 'link',
'model' => 'primary_name',
'field' => 'full_name',
'action' => 'canvas',
'action' => 'edit',
// XXX see comments in the controller about sorting on given vs family
'sortable' => 'PrimaryName.family'
],
Expand Down
Loading