From 16fe4c2cd6a4f7766a687157ce8d7ce77cd3f619 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 20:30:26 +0300 Subject: [PATCH] People --- app/src/Controller/ApiUsersController.php | 2 +- app/src/Controller/StandardController.php | 6 +-- app/templates/People/fields.inc | 40 +++++++++++++------- app/templates/Standard/add-edit-view-new.php | 8 ---- app/templates/element/form/nameDiv.php | 2 + app/templates/element/form/unorderedList.php | 12 +++++- 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 5e97f13e3..97fd1aff8 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -69,7 +69,7 @@ public function generate(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index d460f4413..c54268a6d 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -131,7 +131,7 @@ public function add() { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -441,7 +441,7 @@ public function edit(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -900,7 +900,7 @@ public function view($id = null) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/People/fields.inc b/app/templates/People/fields.inc index dee3cd5be..d16a99e31 100644 --- a/app/templates/People/fields.inc +++ b/app/templates/People/fields.inc @@ -33,19 +33,25 @@ if($vv_action == 'add') { foreach(['honorific', 'given', 'middle', 'family', 'suffix'] as $f) { if(in_array($f, $vv_permitted_name_fields)) { - print $this->Field->control( - fieldName: 'names.0.'.$f, - options: ['required' => in_array($f, $vv_required_name_fields)], - controlType: 'string' - ); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'names.0.'.$f, + 'options' => [ + 'required' => in_array($f, $vv_required_name_fields) + ], + 'fieldType' => 'string' + ]]); } } - - print $this->Field->control( - fieldName: 'names.0.type_id', - options: ['empty' => false, 'default' => $vv_default_name_type], - controlType: 'string' - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'names.0.type_id', + 'options' => [ + 'default' => $vv_default_name_type + ], + 'fieldType' => 'string' + ]]); // AR-Name-1 Since this is the first name for this Person, it must be // designated primary @@ -58,7 +64,13 @@ if($vv_action == 'add') { } if($vv_action == 'add' || $vv_action == 'edit') { - print $this->Field->control('status', ['empty' => false]); - - print $this->Field->dateControl('date_of_birth', \App\Lib\Enum\DateTypeEnum::DateOnly); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'date_of_birth' + ]]); } \ No newline at end of file diff --git a/app/templates/Standard/add-edit-view-new.php b/app/templates/Standard/add-edit-view-new.php index d327ce81d..b1e5fdb29 100644 --- a/app/templates/Standard/add-edit-view-new.php +++ b/app/templates/Standard/add-edit-view-new.php @@ -195,14 +195,6 @@ // Form body print $this->element('form/unorderedList'); -// Import all the hidden fields in the Form -if(!empty($hidden)) { - // Inject any hidden variables set by the included file - foreach($hidden as $attr => $v) { - print $this->Form->hidden($attr, ['value' => $v]); - } -} - if(!empty($linkId) && ($vv_action == 'add' || $vv_action == 'edit')) { // We don't want/need to output these for view actions diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index e36e85d1e..028709d6e 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -35,6 +35,8 @@ declare(strict_types = 1); +use Cake\Utility\Inflector; + // $fieldName: parameter $classes = ''; diff --git a/app/templates/element/form/unorderedList.php b/app/templates/element/form/unorderedList.php index d0a304382..4d3f8a9aa 100644 --- a/app/templates/element/form/unorderedList.php +++ b/app/templates/element/form/unorderedList.php @@ -41,6 +41,7 @@ element('form/submit', ['label' => __d('operation', 'save')]); ?> - \ No newline at end of file + + + $v) { + print $this->Form->hidden($attr, ['value' => $v]); + } +} \ No newline at end of file