diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 8e1337346..0cd2d139e 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -66,7 +66,8 @@ public function generate(string $id) { // Let the view render if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 75e5c7128..0ff45ba24 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -128,7 +128,8 @@ public function add() { // Let the view render if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -431,7 +432,8 @@ public function edit(string $id) { if(in_array($this->name, [ 'Cous', 'CoSettings', 'ApiUsers', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -887,7 +889,8 @@ public function view($id = null) { // Let the view render if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Model/Table/HistoryRecordsTable.php b/app/src/Model/Table/HistoryRecordsTable.php index f78350ac3..c2a342f12 100644 --- a/app/src/Model/Table/HistoryRecordsTable.php +++ b/app/src/Model/Table/HistoryRecordsTable.php @@ -41,7 +41,8 @@ class HistoryRecordsTable extends Table { use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; use \App\Lib\Traits\SearchFilterTrait; - + use \App\Lib\Traits\AutoViewVarsTrait; + /** * Perform Cake Model initialization. * diff --git a/app/templates/AdHocAttributes/fields.inc b/app/templates/AdHocAttributes/fields.inc index b1f57e918..377b9b0e0 100644 --- a/app/templates/AdHocAttributes/fields.inc +++ b/app/templates/AdHocAttributes/fields.inc @@ -26,11 +26,26 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('tag'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'tag' + ]]); - print $this->Field->control('value'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'value' + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/HistoryRecords/fields.inc b/app/templates/HistoryRecords/fields.inc index 45c57a180..df320b062 100644 --- a/app/templates/HistoryRecords/fields.inc +++ b/app/templates/HistoryRecords/fields.inc @@ -27,7 +27,10 @@ // This view does not support edit if($vv_action == 'add' || $vv_action == 'view') { - print $this->Field->control('comment'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'comment', + ]]); if($vv_action == 'add') { // On manual add insert action @@ -39,7 +42,10 @@ if($vv_action == 'add' || $vv_action == 'view') { } if($vv_action == 'view') { - print $this->Field->control('action'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'action', + ]]); if(!empty($vv_obj->person->primary_name)) { $viewLink = [ @@ -49,12 +55,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->person->id ], ]; - - print $this->Field->statusControl( - 'person_id', - $vv_obj->person->primary_name->full_name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'person_id', + 'status' => $vv_obj->person->primary_name->full_name, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->person_role_id)) { @@ -65,12 +73,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->person_role_id ], ]; - - print $this->Field->statusControl( - 'person_role_id', - $vv_obj->person_role_id, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'person_role_id', + 'status' => $vv_obj->person_role_id, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->external_identity->primary_name)) { @@ -81,12 +91,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->external_identity->id ], ]; - - print $this->Field->statusControl( - 'external_identity_id', - $vv_obj->external_identity->primary_name->full_name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'external_identity_id', + 'status' => $vv_obj->external_identity->primary_name->full_name, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->external_identity_role_id)) { @@ -97,12 +109,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->external_identity_role_id ], ]; - - print $this->Field->statusControl( - 'external_identity_role_id', - $vv_obj->external_identity_role_id, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'external_identity_role_id', + 'status' => $vv_obj->external_identity_role_id, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->group_id)) { @@ -113,12 +127,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->group_id ], ]; - - print $this->Field->statusControl( - 'group_id', - $vv_obj->group->name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'group_id', + 'status' => $vv_obj->group->name, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->actor_person->names)) { @@ -129,15 +145,20 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->actor_person->id ], ]; - - print $this->Field->statusControl( - 'actor_person_id', - $vv_obj->actor_person->names[0]->full_name, - $viewLink, - __d('field', 'actor') - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'actor_person_id', + 'status' => $vv_obj->actor_person->names[0]->full_name, + 'link' => $viewLink, + 'labelText' => __d('field', 'actor') + ] + ]); } - - print $this->Field->control('created'); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'created', + ]]); } } diff --git a/app/templates/Identifiers/fields.inc b/app/templates/Identifiers/fields.inc index 532f29865..eb5e9c6d2 100644 --- a/app/templates/Identifiers/fields.inc +++ b/app/templates/Identifiers/fields.inc @@ -26,20 +26,45 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('identifier'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'identifier', + ]]); - print $this->Field->control('type_id', ['default' => $vv_default_type]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); if($vv_primary_link_attr == 'person_id') { // AR-Identifier-1 Only Persons can have a login flag - print $this->Field->control('login'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'login', + ]]); } else { + // Will be used by add-edit-view.php to append the hidden fields in the form $hidden['login'] = false; } - - print $this->Field->control('status', ['empty' => false]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status', + ]]); - print $this->Field->sourceControl($vv_obj); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} + +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/Names/fields.inc b/app/templates/Names/fields.inc index 3b16e5804..112e65923 100644 --- a/app/templates/Names/fields.inc +++ b/app/templates/Names/fields.inc @@ -31,22 +31,54 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { foreach(['honorific', 'given', 'middle', 'family', 'suffix'] as $f) { if(in_array($f, $vv_permitted_fields)) { - print $this->Field->control($f); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $f + ]]); } } - print $this->Field->control('type_id', ['default' => $vv_default_type]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); - print $this->Field->control('language'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'language' + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'display_name' + ]]); - print $this->Field->control('display_name'); // We don't allow unsetting of primary_name here because we need to know what // the new primary_name is, but we do allow this name to become primary // because afterSave will unset the old one. - print $this->Field->control('primary_name', ['readonly' => $vv_obj->primary_name]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description', + 'options' => [ + 'readonly' => $vv_obj->primary_name + ] + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); - print $this->Field->sourceControl($vv_obj); } + +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); +} \ No newline at end of file diff --git a/app/templates/PersonRoles/fields.inc b/app/templates/PersonRoles/fields.inc index 4748921f3..7265f1031 100644 --- a/app/templates/PersonRoles/fields.inc +++ b/app/templates/PersonRoles/fields.inc @@ -26,19 +26,38 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('cou_id'); - - print $this->Field->control('affiliation_type_id', labelText: __d('field', 'affiliation')); - - print $this->Field->control('status', ['empty' => false]); - - print $this->Field->control('ordr'); - - print $this->Field->control('title'); - - print $this->Field->control('organization'); - - print $this->Field->control('department'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'cou_id', + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' =>'affiliation_type_id', + 'labelText' => __d('field', 'affiliation') + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' =>'status', + 'options' => [ + 'empty' => false + ] + ] + ]); + + foreach(['ordr', + 'title', + 'organization', + 'department'] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } // For now, we render sponsor and manager as read only. // XXX Need People Picker (CFM-150) @@ -52,15 +71,39 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { $fname = $vv_obj->$fp->names[0]->full_name; $flink = ['url' => ['controller' => 'people', 'action' => 'edit', $vv_obj->$fp->id]]; } - - print $this->Field->statusControl($f.'_person_id', $fname, $flink, __d('field', $f)); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $f.'_person_id', + 'status' => $fname, + 'link' => $flink, + 'labelText' => __d('field', $f) + ] + ]); } - - print $this->Field->dateControl('valid_from'); - - print $this->Field->dateControl('valid_through'); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'valid_from', // timestamp + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'valid_through', // timestamp + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/TelephoneNumbers/fields.inc b/app/templates/TelephoneNumbers/fields.inc index 2f772914d..7161577a5 100644 --- a/app/templates/TelephoneNumbers/fields.inc +++ b/app/templates/TelephoneNumbers/fields.inc @@ -31,15 +31,37 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { foreach(['country_code', 'area_code', 'number', 'extension'] as $f) { if(in_array($f, $vv_permitted_fields)) { - print $this->Field->control($f); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $f + ]]); } } - - print $this->Field->control('type_id', ['default' => $vv_default_type]); - print $this->Field->control('description'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description' + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); + +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/element/form/infoDiv/source.php b/app/templates/element/form/infoDiv/source.php index 1666f00c9..5edeadce3 100644 --- a/app/templates/element/form/infoDiv/source.php +++ b/app/templates/element/form/infoDiv/source.php @@ -27,6 +27,8 @@ declare(strict_types = 1); +$entity = $vv_field_arguments['entity']; + ?>
Fieeld->sourceLink($entity) ?> diff --git a/app/templates/element/form/infoDiv/status.php b/app/templates/element/form/infoDiv/status.php index 72c0052ea..404c997c9 100644 --- a/app/templates/element/form/infoDiv/status.php +++ b/app/templates/element/form/infoDiv/status.php @@ -26,10 +26,17 @@ */ +/* + * Parameters: + * string $status + * array $link + */ + declare(strict_types = 1); +$status = $vv_field_arguments['status']; $linkHtml = $status; -$link = $link ?? []; +$link = $vv_field_arguments['link'] ?? []; if($link) { diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index cf4f50b3b..7d1490ca4 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -29,16 +29,12 @@ declare(strict_types = 1); // Make the element configuration available downstream -// XXX Even though we pass the parameters to the view globally -// they only live in the context of this element and its ancestors // XXX Unfortunately CAKEPHP doe not create a viewvar space for the element // parameters. As a result we do not know which one is which unles we: // - add a prefix and create a namespace // - wrap them in an array. // We choose the latter. -foreach($arguments as $key => $value) { - $this->set($key, $value); -} +$this->set('fieldName', $arguments['fieldName']); $this->set('vv_field_arguments', $arguments); // Additional classes calculation diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index ad0562998..8eca8c6c6 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -26,6 +26,13 @@ */ +/* + * Parameters + * string $fieldName + * string $labelText + * bool $labelIsTextOnly + */ + declare(strict_types = 1); // $fieldName: parameter @@ -48,7 +55,7 @@ } [$label, $desc] = $this->Fieeld->calculateLabelAndDescription($fn); -$label = $labelText ?? $label; +$label = $vv_field_arguments['labelText'] ?? $label; // Extra class required for the grouped controls elements if(isset($groupedControls)) {