From 41749ae5a83d1c916bf627e0f53f882eeec58253 Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 25 May 2023 16:22:49 +0200 Subject: [PATCH] fix: [users] added the country information to the index / view --- src/Controller/UsersController.php | 2 +- src/Model/Table/UsersTable.php | 3 ++- templates/Organisations/add.php | 2 +- templates/Users/index.php | 6 +++++- templates/Users/view.php | 4 ++++ templates/element/genericElements/Form/fieldScaffold.php | 4 ++++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index dad2bc7..95db80a 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -11,7 +11,7 @@ use Cake\Http\Exception\NotFoundException; class UsersController extends AppController { - public $filterFields = ['Individuals.uuid', 'username', 'Individuals.email', 'Individuals.first_name', 'Individuals.last_name', 'Organisations.name']; + public $filterFields = ['Individuals.uuid', 'username', 'Individuals.email', 'Individuals.first_name', 'Individuals.last_name', 'Organisations.name', 'Organisation.nationality']; public $quickFilterFields = ['Individuals.uuid', ['username' => true], ['Individuals.first_name' => true], ['Individuals.last_name' => true], 'Individuals.email']; public $containFields = ['Individuals', 'Roles', 'UserSettings', 'Organisations']; diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php index 86160d5..cc2c0ba 100644 --- a/src/Model/Table/UsersTable.php +++ b/src/Model/Table/UsersTable.php @@ -47,7 +47,8 @@ class UsersTable extends AppTable 'Organisations', [ 'dependent' => false, - 'cascadeCallbacks' => false + 'cascadeCallbacks' => false, + 'strategy' => 'join' ] ); $this->hasMany( diff --git a/templates/Organisations/add.php b/templates/Organisations/add.php index e430cc6..75eeee6 100644 --- a/templates/Organisations/add.php +++ b/templates/Organisations/add.php @@ -2,7 +2,7 @@ echo $this->element('genericElements/Form/genericForm', array( 'data' => array( 'description' => __('Organisations can be equivalent to legal entities or specific individual teams within such entities. Their purpose is to relate individuals to their affiliations and for release control of information using the Trust Circles.'), - 'model' => 'Organisations', + 'model' => 'Organisation', 'fields' => array( array( 'field' => 'name' diff --git a/templates/Users/index.php b/templates/Users/index.php index 1dff40d..d06578c 100644 --- a/templates/Users/index.php +++ b/templates/Users/index.php @@ -1,7 +1,6 @@ element('genericElements/IndexTable/index_table', [ 'data' => [ 'data' => $data, @@ -88,6 +87,11 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'url' => '/roles/view/{{0}}', 'url_vars' => ['role.id'] ], + [ + 'name' => __('Country'), + 'sort' => 'organisation.nationality', + 'data_path' => 'organisation.nationality' + ], [ 'name' => __('# User Settings'), 'element' => 'count_summary', diff --git a/templates/Users/view.php b/templates/Users/view.php index 4e2bda7..5ffafda 100644 --- a/templates/Users/view.php +++ b/templates/Users/view.php @@ -44,6 +44,10 @@ $fields = [ 'key' => __('Last name'), 'path' => 'individual.last_name' ], + [ + 'key' => __('Country'), + 'path' => 'organisation.nationality' + ], [ 'key' => __('Alignments'), 'type' => 'alignment', diff --git a/templates/element/genericElements/Form/fieldScaffold.php b/templates/element/genericElements/Form/fieldScaffold.php index f95bdde..6a6d789 100644 --- a/templates/element/genericElements/Form/fieldScaffold.php +++ b/templates/element/genericElements/Form/fieldScaffold.php @@ -1,5 +1,9 @@ request->getParam('controller')))) : + h($data['model']); $fieldTemplate = 'genericField'; if (!empty($fieldData['type'])) { if (file_exists(ROOT . '/templates/element/genericElements/Form/Fields/' . $fieldData['type'] . 'Field.php')) {