diff --git a/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php b/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php index 7b59ca2a6..73ff750bb 100644 --- a/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php +++ b/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php @@ -42,6 +42,7 @@ class ApiSourcesTable extends Table { use \App\Lib\Traits\PrimaryLinkTrait; use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; + use \App\Lib\Traits\TabTrait; /** * Perform Cake Model initialization. @@ -74,6 +75,24 @@ public function initialize(array $config): void { $this->setPrimaryLink(['external_identity_source_id']); $this->setRequiresCO(true); + // All the tabs share the same configuration in the ModelTable file + // XXX Reenable when this doesn't throw an error (same error as https://todos.internet2.edu/browse/CFM-475 ) +// $this->setTabsConfig( +// [ +// // Ordered list of Tabs +// 'tabs' => ['ExternalIdentitySources', 'ApiConnector.ApiSources', 'ExternalIdentitySources@action.search'], +// // What actions will include the subnavigation header +// 'action' => [ +// // If a model renders in a subnavigation mode in edit/view mode, it cannot +// // render in index mode for the same use case/context +// // XXX edit should go first. +// 'ExternalIdentitySources' => ['edit', 'view', 'search'], +// 'ApiConnector.ApiSources' => ['edit'], +// 'ExternalIdentitySources@action.search' => [], +// ], +// ] +// ); + $this->setPermissions([ // Actions that operate over an entity (ie: require an $id) 'entity' => [ diff --git a/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc b/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc index 8bc3c67c9..faa75fdee 100644 --- a/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc +++ b/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc @@ -25,17 +25,14 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does currently not support read-only -if($vv_action == 'edit') { - if(!empty($vv_push_endpoint)) { - print $this->element('notify/banner', [ - 'info' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint]) - ]); - } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_source_id', - ] - ]); +if(!empty($vv_push_endpoint)) { + // XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning) + $banners = [ + __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint]) + ]; } + +$fields = [ + 'external_identity_source_id' +]; diff --git a/app/availableplugins/ApiConnector/templates/ApiSources/fields-nav.inc b/app/availableplugins/ApiConnector/templates/ApiSources/fields-nav.inc deleted file mode 100644 index b4d5a2809..000000000 --- a/app/availableplugins/ApiConnector/templates/ApiSources/fields-nav.inc +++ /dev/null @@ -1,31 +0,0 @@ - 'plugin', - 'active' => 'plugin' - ]; \ No newline at end of file diff --git a/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc b/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc index ef5dd13b5..aafecdcdc 100644 --- a/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc +++ b/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc @@ -26,10 +26,18 @@ */ // This view does currently not support read-only -if($vv_action == 'edit') { - print '
  • ' . __d('api_connector', 'field.ApiSources.push_mode') . '

  • '; - - print $this->element('notify/banner', [ - 'info' => __d('information', 'plugin.config.none',) - ]); +if($vv_action !== 'edit') { + return; } + +// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning) +$banners = [ + __d('information', 'plugin.config.none') +]; + +// XXX Revisit this - what's the "Push Mode" text attempting to convey here (with no other information)? +$fields = [ + 'SUBTITLE' => [ + 'subtitle' => __d('api_connector', 'field.ApiSources.push_mode') + ] +]; diff --git a/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc b/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc index d5e5c8353..ffecf0e93 100644 --- a/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc +++ b/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc @@ -25,11 +25,6 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does currently not support read-only -if($vv_action == 'add' || $vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'filename', - ] - ]); -} +$fields = [ + 'filename' +]; \ No newline at end of file diff --git a/app/availableplugins/FileConnector/templates/FileSources/fields.inc b/app/availableplugins/FileConnector/templates/FileSources/fields.inc index 2307d35f9..3fbde4e40 100644 --- a/app/availableplugins/FileConnector/templates/FileSources/fields.inc +++ b/app/availableplugins/FileConnector/templates/FileSources/fields.inc @@ -25,19 +25,10 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does currently not support read-only -if($vv_action == 'add' || $vv_action == 'edit') { - foreach([ - 'filename', - 'format', - 'archivedir', - 'threshold_check', - 'threshold_override', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } -} +$fields = [ + 'filename', + 'format', + 'archivedir', + 'threshold_check', + 'threshold_override', +]; diff --git a/app/availableplugins/PasswordAuthenticator/templates/PasswordAuthenticators/fields.inc b/app/availableplugins/PasswordAuthenticator/templates/PasswordAuthenticators/fields.inc index d7356d7c3..bf1640b56 100644 --- a/app/availableplugins/PasswordAuthenticator/templates/PasswordAuthenticators/fields.inc +++ b/app/availableplugins/PasswordAuthenticator/templates/PasswordAuthenticators/fields.inc @@ -24,10 +24,20 @@ * @since COmanage Registry v5.2.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'source_mode', + 'min_length', + 'max_length', + 'format_crypt_php', + 'format_sha1_ldap', + 'format_plaintext' +]; + ?> - - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source_mode', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets(false)' - ] - ] - ]); - - foreach(['min_length', - 'max_length' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'format_crypt_php', - 'fieldOptions' => [ - // When source is Self Select we want crypt to remain checked - // (though this will also be enforced in the backend) - 'onChange' => 'updateGadgets(false)' - ] - ] - ]); - - foreach(['format_sha1_ldap', - 'format_plaintext' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } -} + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#source-mode, #format_crypt_php').change(function() { + updateGadgets(); + }); + }); + \ No newline at end of file diff --git a/app/availableplugins/PasswordAuthenticator/templates/Passwords/fields.inc b/app/availableplugins/PasswordAuthenticator/templates/Passwords/fields.inc index 69b393fc0..98924df7e 100644 --- a/app/availableplugins/PasswordAuthenticator/templates/Passwords/fields.inc +++ b/app/availableplugins/PasswordAuthenticator/templates/Passwords/fields.inc @@ -28,21 +28,20 @@ // We provide the current password status in a banner message since that's all the // information we really want to display about a password. -print $this->element('notify/banner', ['info' => $vv_status->comment]); +// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning) +$banners = [ + $vv_status->comment +]; -if(!$vv_status->locked) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'password', - ] - ]); +$fields = []; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'password2', +if(!$vv_status->locked) { + $fields = [ + 'password', + 'password2' => [ 'fieldOptions' => [ 'type' => 'password' ] ] - ]); -} \ No newline at end of file + ]; +} diff --git a/app/availableplugins/PipelineToolkit/templates/IdentifierMappers/fields-nav.inc b/app/availableplugins/PipelineToolkit/templates/IdentifierMappers/fields-nav.inc deleted file mode 100644 index e5db5ae5c..000000000 --- a/app/availableplugins/PipelineToolkit/templates/IdentifierMappers/fields-nav.inc +++ /dev/null @@ -1,44 +0,0 @@ - 'plugin', - 'active' => 'plugin' -]; - -$topLinks[] = [ - 'icon' => 'transform', - 'order' => 'Default', - 'label' => __d('pipeline_toolkit', 'controller.LoginIdentifierTypes', [99]), - 'link' => [ - 'plugin' => 'PipelineToolkit', - 'controller' => 'LoginIdentifierTypes', - 'action' => 'index', - 'identifier_mapper_id' => $vv_obj->id - ], - 'class' => '' -]; diff --git a/app/availableplugins/PipelineToolkit/templates/IdentifierMappers/fields.inc b/app/availableplugins/PipelineToolkit/templates/IdentifierMappers/fields.inc index ad18b384e..403f3f929 100644 --- a/app/availableplugins/PipelineToolkit/templates/IdentifierMappers/fields.inc +++ b/app/availableplugins/PipelineToolkit/templates/IdentifierMappers/fields.inc @@ -27,4 +27,18 @@ // There are currently no directly configurable fields for this model.) $suppress_submit = true; -?> \ No newline at end of file + +// Top Links +$topLinks[] = [ + 'icon' => 'transform', + 'order' => 'Default', + 'label' => __d('pipeline_toolkit', 'controller.LoginIdentifierTypes', [99]), + 'link' => [ + 'plugin' => 'PipelineToolkit', + 'controller' => 'LoginIdentifierTypes', + 'action' => 'index', + 'identifier_mapper_id' => $vv_obj->id + ], + 'class' => '' +]; +?> diff --git a/app/availableplugins/PipelineToolkit/templates/LoginIdentifierTypes/fields.inc b/app/availableplugins/PipelineToolkit/templates/LoginIdentifierTypes/fields.inc index d1866d0a1..69c161ed5 100644 --- a/app/availableplugins/PipelineToolkit/templates/LoginIdentifierTypes/fields.inc +++ b/app/availableplugins/PipelineToolkit/templates/LoginIdentifierTypes/fields.inc @@ -25,14 +25,7 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does not support read-only -if($vv_action == 'add' || $vv_action == 'edit') { - foreach (['type_id', - 'login' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} +$fields = [ + 'type_id', + 'login' +]; diff --git a/app/availableplugins/PipelineToolkit/templates/PersonRoleMappers/fields-nav.inc b/app/availableplugins/PipelineToolkit/templates/PersonRoleMappers/fields-nav.inc deleted file mode 100644 index 2f2ed3258..000000000 --- a/app/availableplugins/PipelineToolkit/templates/PersonRoleMappers/fields-nav.inc +++ /dev/null @@ -1,44 +0,0 @@ - 'plugin', - 'active' => 'plugin' -]; - -$topLinks[] = [ - 'icon' => 'transform', - 'order' => 'Default', - 'label' => __d('pipeline_toolkit', 'controller.PersonRoleMappings', [99]), - 'link' => [ - 'plugin' => 'PipelineToolkit', - 'controller' => 'PersonRoleMappings', - 'action' => 'index', - 'person_role_mapper_id' => $vv_obj->id - ], - 'class' => '' -]; diff --git a/app/availableplugins/PipelineToolkit/templates/PersonRoleMappers/fields.inc b/app/availableplugins/PipelineToolkit/templates/PersonRoleMappers/fields.inc index c50caa436..5579fb55a 100644 --- a/app/availableplugins/PipelineToolkit/templates/PersonRoleMappers/fields.inc +++ b/app/availableplugins/PipelineToolkit/templates/PersonRoleMappers/fields.inc @@ -27,4 +27,19 @@ // There are currently no directly configurable fields for this model.) $suppress_submit = true; -?> \ No newline at end of file + +// Top Links +$topLinks[] = [ + 'icon' => 'transform', + 'order' => 'Default', + 'label' => __d('pipeline_toolkit', 'controller.PersonRoleMappings', [99]), + 'link' => [ + 'plugin' => 'PipelineToolkit', + 'controller' => 'PersonRoleMappings', + 'action' => 'index', + 'person_role_mapper_id' => $vv_obj->id + ], + 'class' => '' +]; + +?> diff --git a/app/availableplugins/PipelineToolkit/templates/PersonRoleMappings/fields.inc b/app/availableplugins/PipelineToolkit/templates/PersonRoleMappings/fields.inc index ddd7dd9b0..0cb08a6ec 100644 --- a/app/availableplugins/PipelineToolkit/templates/PersonRoleMappings/fields.inc +++ b/app/availableplugins/PipelineToolkit/templates/PersonRoleMappings/fields.inc @@ -24,9 +24,24 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'attribute' => [ + 'fieldType' => 'select' + ], + 'ad_hoc_tag', + 'affiliation_type_id', + 'comparison', + 'pattern', + 'target_cou_id', + 'target_affiliation_type_id', + 'ordr' +]; + ?> - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'attribute', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ], - 'fieldType' => 'select' - ] - ]); - - foreach (['ad_hoc_tag', - 'affiliation_type_id', - 'comparison', - 'pattern', - 'target_cou_id', - 'target_affiliation_type_id', - 'ordr' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} + + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#attribute').change(function() { + updateGadgets(); + }); + }); + \ No newline at end of file diff --git a/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc b/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc index 9ea45315a..5f96d7057 100644 --- a/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc +++ b/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc @@ -25,20 +25,35 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does currently not support read-only -if($vv_action == 'add' || $vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'server_id', +$fields = [ + 'server_id', + 'table_prefix' => [ + 'fieldOptions' => [ + 'default' => 'sp_' ] - ]); + ] +]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'table_prefix', - 'fieldOptions' => [ - 'default' => 'sp_' - ] - ] - ]); -} +// Top Links +$topLinks = [ + [ + 'icon' => 'history', + 'order' => 'Default', + 'label' => __d('sql_connector', 'operation.reapply'), + 'link' => [ + 'action' => 'reapply', + $vv_obj->id + ], + 'class' => '' + ], + [ + 'icon' => 'history', + 'order' => 'Default', + 'label' => __d('sql_connector', 'operation.resync'), + 'link' => [ + 'action' => 'resync', + $vv_obj->id + ], + 'class' => '' + ] +]; \ No newline at end of file diff --git a/app/availableplugins/SqlConnector/templates/SqlSources/fields-nav.inc b/app/availableplugins/SqlConnector/templates/SqlSources/fields-nav.inc deleted file mode 100644 index 1ac382831..000000000 --- a/app/availableplugins/SqlConnector/templates/SqlSources/fields-nav.inc +++ /dev/null @@ -1,31 +0,0 @@ - 'plugin', - 'active' => 'plugin' - ]; \ No newline at end of file diff --git a/app/availableplugins/SqlConnector/templates/SqlSources/fields.inc b/app/availableplugins/SqlConnector/templates/SqlSources/fields.inc index f0b65af0b..98018d745 100644 --- a/app/availableplugins/SqlConnector/templates/SqlSources/fields.inc +++ b/app/availableplugins/SqlConnector/templates/SqlSources/fields.inc @@ -24,8 +24,39 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'server_id', + 'table_mode' => [ + 'fieldType' => 'select' + ] +]; + +foreach([ + 'source_table', + 'address_type_id', + 'email_address_type_id', + 'identifier_type_id', + 'name_type_id', + 'pronouns_type_id', + 'telephone_number_type_id', + 'url_type_id' + ] as $field) { + $fields[$field] = [ + 'fieldOptions' => [ + 'required' => false + ] + ]; +} + +$fields = array_merge($fields, [ + 'threshold_check', + 'threshold_override' +]); + ?> - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'server_id' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'table_mode', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ], - 'fieldType' => 'select' - ] - ]); - foreach([ - 'source_table', - 'address_type_id', - 'email_address_type_id', - 'identifier_type_id', - 'name_type_id', - 'pronouns_type_id', - 'telephone_number_type_id', - 'url_type_id' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - 'fieldOptions' => [ - 'required' => false - ] - ] - ]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'threshold_check' - ] - ]); + $(function() { + // run on first load + updateGadgets(true); - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'threshold_override' - ] - ]); -} + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#table-mode').change(function() { + updateGadgets(); + }); + }); + \ No newline at end of file diff --git a/app/plugins/CoreApi/templates/MatchCallbacks/fields.inc b/app/plugins/CoreApi/templates/MatchCallbacks/fields.inc index 57c744426..1b3e8743d 100644 --- a/app/plugins/CoreApi/templates/MatchCallbacks/fields.inc +++ b/app/plugins/CoreApi/templates/MatchCallbacks/fields.inc @@ -26,16 +26,17 @@ */ // This view does currently not support read-only, and add is not used -if($vv_action == 'edit') { - if(!empty($vv_api_endpoint)) { - print $this->element('notify/banner', [ - 'info' => __d('core_api', 'information.endpoint.match.callback', [$vv_api_endpoint]) - ]); - } +if($vv_action !== 'edit') { + return; +} - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'server_id', - ] - ]); -} \ No newline at end of file +if(!empty($vv_api_endpoint)) { + // XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning) + $banners = [ + __d('core_api', 'information.endpoint.match.callback', [$vv_api_endpoint]) + ]; +} + +$fields = [ + 'server_id' +]; \ No newline at end of file diff --git a/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc b/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc index 681a95a7b..482436417 100644 --- a/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc +++ b/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc @@ -24,14 +24,30 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +// This view does currently not support read-only, and add is not used +if($vv_action !== 'edit') { + return; +} + +$fields = [ + 'format', + 'collision_mode', + 'permitted_characters', + 'minimum_length', + 'minimum', + 'maximum', + 'enable_transliteration' +]; ?> - - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'format' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'collision_mode', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ] - ]); - foreach([ - 'permitted_characters', - 'minimum_length', - 'minimum', - 'maximum', - 'enable_transliteration' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } -} + // register onchange events + $('#collision-mode').change(function() { + updateGadgets(); + }); + }); + diff --git a/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc b/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc index d2ede3a3d..2b2b3cbce 100644 --- a/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc +++ b/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc @@ -26,16 +26,12 @@ */ // This view does currently not support read-only, and add is not used -if($vv_action == 'edit') { - foreach([ - 'server_id', - 'source_table', - 'type_id', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } +if($vv_action !== 'edit') { + return; } + +$fields = [ + 'server_id', + 'source_table', + 'type_id' +]; diff --git a/app/plugins/CoreEnroller/resources/locales/en_US/core_enroller.po b/app/plugins/CoreEnroller/resources/locales/en_US/core_enroller.po index 666469f47..61bb47110 100644 --- a/app/plugins/CoreEnroller/resources/locales/en_US/core_enroller.po +++ b/app/plugins/CoreEnroller/resources/locales/en_US/core_enroller.po @@ -211,6 +211,9 @@ msgstr "Duration, in minutes, of the verification request before it expires" msgid "field.EmailVerifiers.verification_code_charset" msgstr "Verification Code Character Set" +msgid "field.EmailVerifiers.verification_code_charset.other_value" +msgstr "Other value" + msgid "field.EmailVerifiers.verification_code_charset.desc" msgstr "Set of characters for generating the verification code. Numbers and uppercase letters only." @@ -226,7 +229,6 @@ msgstr "Enable Attempt Blocker" msgid "field.EmailVerifiers.enable_blockonfailure.desc" msgstr "Enables blocking after consecutive failed attempts. Blocking duration increases exponentially based on the number of failed attempts." - msgid "field.EnrollmentAttributes.address_required_fields" msgstr "Required Address Fields" diff --git a/app/plugins/CoreEnroller/templates/ApprovalCollectors/fields.inc b/app/plugins/CoreEnroller/templates/ApprovalCollectors/fields.inc index 5b70e4daa..bcab2bc7b 100644 --- a/app/plugins/CoreEnroller/templates/ApprovalCollectors/fields.inc +++ b/app/plugins/CoreEnroller/templates/ApprovalCollectors/fields.inc @@ -1,6 +1,6 @@ element('form/listItem', [ - 'arguments' => ['fieldName' => $field] - ]); -} \ No newline at end of file +$fields = [ + 'require_comment', + 'denial_message_template_id', + 'redirect_on_denial' +]; diff --git a/app/plugins/CoreEnroller/templates/AttributeCollectors/fields-nav.inc b/app/plugins/CoreEnroller/templates/AttributeCollectors/fields-nav.inc deleted file mode 100644 index 45b5bbb81..000000000 --- a/app/plugins/CoreEnroller/templates/AttributeCollectors/fields-nav.inc +++ /dev/null @@ -1,39 +0,0 @@ - 'edit_attributes', - 'order' => 'Default', - 'label' => __d('core_enroller', 'controller.EnrollmentAttributes', [99]), - 'link' => [ - 'plugin' => 'CoreEnroller', - 'controller' => 'enrollment_attributes', - 'action' => 'index', - 'attribute_collector_id' => $vv_obj->id - ], - 'class' => '' -]; diff --git a/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc b/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc index 07658ffe0..48add49a8 100644 --- a/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc +++ b/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc @@ -32,8 +32,20 @@ if($vv_action !== 'edit') { return; } +$fields = [ + 'enable_person_find', +]; -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'enable_person_find', - ]]); +// Top Links +$topLinks[] = [ + 'icon' => 'edit_attributes', + 'order' => 'Default', + 'label' => __d('core_enroller', 'controller.EnrollmentAttributes', [99]), + 'link' => [ + 'plugin' => 'CoreEnroller', + 'controller' => 'enrollment_attributes', + 'action' => 'index', + 'attribute_collector_id' => $vv_obj->id + ], + 'class' => '' +]; \ No newline at end of file diff --git a/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/fields.inc b/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/fields.inc index 23c5a986c..04520baf4 100644 --- a/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/fields.inc +++ b/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/fields.inc @@ -26,20 +26,13 @@ */ // This view only supports edit -if($vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'name_type_id'] - ]); - - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'email_address_type_id'] - ]); - - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'affiliation_type_id'] - ]); - - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'cou_id'] - ]); -} +if($vv_action !== 'edit') { + return; +} + +$fields = [ + 'name_type_id', + 'email_address_type_id', + 'affiliation_type_id', + 'cou_id' +]; diff --git a/app/plugins/CoreEnroller/templates/EmailVerifiers/fields.inc b/app/plugins/CoreEnroller/templates/EmailVerifiers/fields.inc index 5cf5e674d..d3b08e4cb 100644 --- a/app/plugins/CoreEnroller/templates/EmailVerifiers/fields.inc +++ b/app/plugins/CoreEnroller/templates/EmailVerifiers/fields.inc @@ -35,33 +35,18 @@ $defaultValues = array_combine( array_keys($defaults) ); -foreach(['mode', - 'message_template_id' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => $field] - ]); -} - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'request_validity', +$fields = [ + 'mode', + 'message_template_id', + 'request_validity' => [ 'fieldOptions' => [ 'placeholder' => $defaultValues['DefaultVerificationValidity'] - ]] -]); - -// Textbox for "Other" -$otherField = $this->Form->control('verification_code_charset', [ - 'type' => 'text', - 'label' => false, - 'id' => 'verification-code-charset', - 'style' => !empty($vv_obj?->verification_code_charset) ? '' : 'display: none;', - 'required' => false, -]); + ] + ] +]; $checked = !empty($vv_obj?->verification_code_charset) ? 'checked' : ''; -$otherLabel = __d('field','other.value'); +$otherLabel = __d('core_enroller','field.EmailVerifiers.verification_code_charset.other_value'); $beforeField = <<
    @@ -69,7 +54,6 @@ $beforeField = <<$otherLabel
    -$otherField OTHER; $afterField = <<<'JS' @@ -107,10 +91,10 @@ document.addEventListener('DOMContentLoaded', function() { JS; $regexDisplayFirstTime = empty($vv_obj?->verification_code_charset) && empty($vv_obj?->verification_code_regex); -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'verification_code_regex', - 'fieldLabel' => __d('core_enroller','field.EmailVerifiers.verification_code_charset'), +$fields['verification_code_regex'] = [ + 'fieldLabel' => __d('core_enroller','field.EmailVerifiers.verification_code_charset'), + 'groupedControls' => [ + 'verification_code_regex' => [ 'fieldOptions' => [ 'id' => 'verification-code-regex', 'required' => false, @@ -120,24 +104,30 @@ print $this->element('form/listItem', [ 'fieldType' => 'select', 'fieldSelectOptions' => $permittedCharacters, ], - 'beforeField' => $beforeField, - 'afterField' => $afterField, - ] -); + 'verification_code_charset' => [ + 'fieldOptions' => [ + 'type' => 'text', + 'label' => false, + 'id' => 'verification-code-charset', + 'style' => !empty($vv_obj?->verification_code_charset) ? '' : 'display: none;', + 'required' => false, + 'checked' => !empty($vv_obj?->verification_code_charset) ? 'checked' : '' + ] + ] + ], + 'beforeField' => $beforeField, + 'afterField' => $afterField +]; -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'verification_code_length', - 'fieldOptions' => [ - 'required' => false, - 'placeholder' => $defaultValues['DefaultCodeLength'] - ]] -]); +$fields['verification_code_length'] = [ + 'fieldOptions' => [ + 'required' => false, + 'placeholder' => $defaultValues['DefaultCodeLength'] + ] +]; -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'enable_blockonfailure', - 'fieldOptions' => [ - 'default' => true, - ]] -]); +$fields['enable_blockonfailure'] = [ + 'fieldOptions' => [ + 'default' => true, + ] +]; diff --git a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc index 05ddb6644..e6476fac7 100644 --- a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc +++ b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc @@ -62,24 +62,18 @@ $this->set('vv_include_cancel', true); * - order * - required */ -foreach ( ['label', - 'description', - 'status', - 'ordr' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); -} - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'required', +$fields = [ + 'label', + 'description', + 'status', + 'ordr', + 'required' => [ + // XXX flatten fieldOptions 'fieldOptions' => [ 'default' => true ] - ]]); + ] +]; /* @@ -96,20 +90,16 @@ if ( !empty($vv_supported_attributes[$attribute_type]['mveaParents']) && count($vv_supported_attributes[$attribute_type]['mveaParents']) > 0 ) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'attribute_mvea_parent', - 'fieldOptions' => [ - 'empty' => false - ], - 'fieldType' => 'select', - 'fieldSelectOptions' => array_combine( - $vv_supported_attributes[$attribute_type]['mveaParents'], - $vv_supported_attributes[$attribute_type]['mveaParents'] - ) - ] - ]); - + $fields['attribute_mvea_parent'] = [ + 'fieldOptions' => [ + 'empty' => false + ], + 'fieldType' => 'select', + 'fieldSelectOptions' => array_combine( + $vv_supported_attributes[$attribute_type]['mveaParents'], + $vv_supported_attributes[$attribute_type]['mveaParents'] + ) + ]; // This field is called attribute_type and not attribute_type_id because we want this // to behave as a hidden value populated by the appropriate select, and we don't want @@ -118,17 +108,14 @@ if ( // Check if this mvea model supports types, if it does then render the attribute type // dropdown list if ($this->get($mveaAutoPopulatedVariable) !== null) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'attribute_type', - 'fieldLabel' => $attributes[$attribute_type] . ' Type', - 'fieldOptions' => [ - 'empty' => false - ], - 'fieldType' => 'select', - 'fieldSelectOptions' => $this->get($mveaAutoPopulatedVariable) - ] - ]); + $fields['attribute_type'] = [ + 'fieldLabel' => $attributes[$attribute_type] . ' Type', + 'fieldOptions' => [ + 'empty' => false + ], + 'fieldType' => 'select', + 'fieldSelectOptions' => $this->get($mveaAutoPopulatedVariable) + ]; } } @@ -141,16 +128,13 @@ if(str_ends_with($attribute_type, '_id')) { $suffix = Inflector::pluralize(Inflector::camelize($suffix)) ; $defaultValuesPopulated = 'defaultValue' . $suffix; if ($this->get($defaultValuesPopulated) !== null) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_value', - 'fieldOptions' => [ - 'empty' => true - ], - 'fieldType' => 'select', - 'fieldSelectOptions' => $this->get($defaultValuesPopulated) - ] - ]); + $fields['default_value'] = [ + 'fieldOptions' => [ + 'empty' => true + ], + 'fieldType' => 'select', + 'fieldSelectOptions' => $this->get($defaultValuesPopulated) + ]; } } @@ -160,23 +144,18 @@ if(str_ends_with($attribute_type, '_id')) { * Supported for attributes: adHocAttribute */ if (\in_array($attribute_type, ['adHocAttribute'], true)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'attribute_tag', - 'fieldOptions' => [ - 'required' => true - ] - ]]); + $fields['attribute_tag'] = [ + 'fieldOptions' => [ + 'required' => true + ] + ]; } /* * Attribute Language field */ if(\in_array($attribute_type, ['name', 'address', 'pronoun'], true)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'attribute_language', - ]]); + $fields[] = 'attribute_language'; } @@ -197,10 +176,7 @@ if ( && !\in_array($attribute_type, $personRoleExclude, true) ) ) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_value_env_name', - ]]); + $fields[] = 'default_value_env_name'; } /* @@ -208,25 +184,21 @@ if ( * */ if($attribute_type === 'valid_from') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_value_datetime', - 'fieldType' => 'datetime' - ]]); + $fields['default_value_datetime'] = [ + 'fieldType' => 'datetime' + ]; } /* * The valid through attribute is a textbox/number field */ if($attribute_type === 'valid_through') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_value', - 'fieldDescription' => __d('core_enroller', 'field.AttributeCollectors.valid_through.default.after.desc'), - 'fieldOptions' => [ - 'type' => 'number' - ] - ]]); + $fields['default_value'] = [ + 'fieldDescription' => __d('core_enroller', 'field.AttributeCollectors.valid_through.default.after.desc'), + 'fieldOptions' => [ + 'type' => 'number' + ] + ]; } /* @@ -237,17 +209,11 @@ if ( isset($vv_supported_attributes[$attribute_type]['model']) && \in_array($vv_supported_attributes[$attribute_type]['model'], ['PersonRole', 'Person', 'Group'], true) ) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'modifiable', - 'fieldOptions' => [ - 'default' => true - ] + $fields['modifiable'] = [ + 'fieldOptions' => [ + 'default' => true ] - ]); + ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'hidden' - ]]); + $fields[] = 'hidden'; } diff --git a/app/plugins/CoreEnroller/templates/IdentifierCollectors/fields.inc b/app/plugins/CoreEnroller/templates/IdentifierCollectors/fields.inc index d2eaa73be..a2c0482ec 100644 --- a/app/plugins/CoreEnroller/templates/IdentifierCollectors/fields.inc +++ b/app/plugins/CoreEnroller/templates/IdentifierCollectors/fields.inc @@ -26,8 +26,10 @@ */ // This view only supports edit -if($vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'type_id'] - ]); +if($vv_action !== 'edit') { + return; } + +$fields = [ + 'type_id' +]; diff --git a/app/plugins/CoreEnroller/templates/InvitationAccepters/fields.inc b/app/plugins/CoreEnroller/templates/InvitationAccepters/fields.inc index 211e9c435..f021b65df 100644 --- a/app/plugins/CoreEnroller/templates/InvitationAccepters/fields.inc +++ b/app/plugins/CoreEnroller/templates/InvitationAccepters/fields.inc @@ -26,17 +26,15 @@ */ // This view only supports edit -if($vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'invitation_validity', - 'fieldOptions' => [ - 'default' => 1440 - ] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'welcome_message'] - ]); +if($vv_action !== 'edit') { + return; } + +$fields = [ + 'invitation_validity' => [ + 'fieldOptions' => [ + 'default' => 1440 + ] + ], + 'welcome_message' +]; diff --git a/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php b/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php index 56cd5d5e8..ce25aa05a 100644 --- a/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php +++ b/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php @@ -116,7 +116,7 @@ 'vv_config' => $vv_config, ]) ?> - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'attribute', - 'fieldOptions' => [ - 'onChange' => 'resetType()' - ] - ]]); - - // type_id is a hidden field used to persist the type - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'type' => 'integer' - ] - ]]); - - // These are display widgets that are filtered to the correct available types - foreach ([ - 'address_type_id', - 'email_address_type_id', - 'identifier_type_id', - 'name_type_id', - 'telephone_number_type_id' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - 'fieldLabel' => __d('field', 'type'), - 'fieldOptions' => [ - 'onChange' => 'copyType("' . $field . '")' - ] - ] - ]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'required' - ]]); -} \ No newline at end of file diff --git a/app/plugins/CoreServer/templates/MatchServers/fields-nav.inc b/app/plugins/CoreServer/templates/MatchServers/fields-nav.inc deleted file mode 100644 index f1b582b4a..000000000 --- a/app/plugins/CoreServer/templates/MatchServers/fields-nav.inc +++ /dev/null @@ -1,45 +0,0 @@ -url)) { - $topLinks[] = [ - 'icon' => 'list', - 'order' => 'Default', - 'label' => __d('core_server', 'controller.MatchServerAttributes', [99]), - 'link' => [ - 'plugin' => 'CoreServer', - 'controller' => 'match_server_attributes', - 'action' => 'index', - 'match_server_id' => $vv_obj->id - ], - 'class' => '' - ]; -} \ No newline at end of file diff --git a/app/plugins/CoreServer/templates/MatchServers/fields.inc b/app/plugins/CoreServer/templates/MatchServers/fields.inc index b5aae1e1d..19d1b85e1 100644 --- a/app/plugins/CoreServer/templates/MatchServers/fields.inc +++ b/app/plugins/CoreServer/templates/MatchServers/fields.inc @@ -27,3 +27,21 @@ // At least initially we use only the HttpServer fields include ROOT . DS . "plugins" . DS . "CoreServer" . DS . "templates" . DS . "HttpServers" . DS . "fields.inc"; + +// If the Match Server URL is empty, then we're in the initial configuration, so we hide the +// Match Server Attributes link so the admin doesn't try to visit that link without finishing +// the main configuration +if(!empty($vv_obj->url)) { + $topLinks[] = [ + 'icon' => 'list', + 'order' => 'Default', + 'label' => __d('core_server', 'controller.MatchServerAttributes', [99]), + 'link' => [ + 'plugin' => 'CoreServer', + 'controller' => 'match_server_attributes', + 'action' => 'index', + 'match_server_id' => $vv_obj->id + ], + 'class' => '' + ]; +} diff --git a/app/plugins/CoreServer/templates/Oauth2Servers/fields.inc b/app/plugins/CoreServer/templates/Oauth2Servers/fields.inc index 580d27591..7dc4b2fa9 100644 --- a/app/plugins/CoreServer/templates/Oauth2Servers/fields.inc +++ b/app/plugins/CoreServer/templates/Oauth2Servers/fields.inc @@ -31,47 +31,29 @@ if($vv_action !== 'edit') { } // Render the Redirect URI -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'redirect_uri', +$fields = [ + 'redirect_uri' => [ 'fieldOptions' => [ 'readOnly' => true, 'default' => $vv_redirect_uri ] - ]]); - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'url' - ]]); - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'access_grant_type', + ], + 'url', + 'access_grant_type' => [ 'fieldSelectOptions' => $types, 'fieldType' => 'select', 'fieldOptions' => [ 'empty' => false, - ], - ]]); - -foreach ([ - "clientid", - "client_secret", - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); -} - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'scope', + ] + ], + 'clientid', + 'client_secret', + 'scope' => [ 'fieldOptions' => [ 'placeholder' => '/authenticate', - ], - ]]); + ] + ] +]; $generateLink = []; if(!empty($vv_obj->id)) { @@ -87,11 +69,8 @@ if(!empty($vv_obj->id)) { ]; } -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'access_token', - 'status' => !empty($vv_obj->access_token) ? __d('enumeration', 'SetBooleanEnum.1') : __d('enumeration', 'SetBooleanEnum.0'), - 'link' => $generateLink, - 'labelIsTextOnly' => true - ] -]); \ No newline at end of file +$fields['access_token'] = [ + 'status' => !empty($vv_obj->access_token) ? __d('enumeration', 'SetBooleanEnum.1') : __d('enumeration', 'SetBooleanEnum.0'), + 'link' => $generateLink, + 'labelIsTextOnly' => true +]; \ No newline at end of file diff --git a/app/plugins/CoreServer/templates/SmtpServers/fields.inc b/app/plugins/CoreServer/templates/SmtpServers/fields.inc index bac623cdc..34054a886 100644 --- a/app/plugins/CoreServer/templates/SmtpServers/fields.inc +++ b/app/plugins/CoreServer/templates/SmtpServers/fields.inc @@ -26,49 +26,26 @@ */ // This view does currently not support read-only, and add is not used -if($vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'hostname', - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'port', - 'fieldOptions' => [ - 'default' => 587 - ] - ]]); +if($vv_action !== 'edit') { + return; +} - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'username', +$fields = [ + 'hostname', + 'port' => [ + 'fieldOptions' => [ + 'default' => 587 ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'password', + ], + 'username', + 'password', + 'use_tls' => [ + 'fieldOptions' => [ + 'default' => true ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'use_tls', - 'fieldOptions' => [ - 'default' => true - ] - ]]); + ], + 'default_from', + 'default_reply_to', + 'override_to' +]; - foreach ([ - 'default_from', - 'default_reply_to', - 'override_to', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} diff --git a/app/plugins/CoreServer/templates/SqlServers/fields.inc b/app/plugins/CoreServer/templates/SqlServers/fields.inc index a15d291f9..c510cefcd 100644 --- a/app/plugins/CoreServer/templates/SqlServers/fields.inc +++ b/app/plugins/CoreServer/templates/SqlServers/fields.inc @@ -26,19 +26,15 @@ */ // This view does currently not support read-only, and add is not used -if($vv_action == 'edit') { - foreach([ - 'type', - 'hostname', - 'port', - 'databas', - 'username', - 'password', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } +if($vv_action !== 'edit') { + return; } + +$fields = [ + 'type', + 'hostname', + 'port', + 'databas', + 'username', + 'password' +]; diff --git a/app/plugins/EnvSource/templates/EnvSourceCollectors/fields.inc b/app/plugins/EnvSource/templates/EnvSourceCollectors/fields.inc index 713b393ba..1c89eefba 100644 --- a/app/plugins/EnvSource/templates/EnvSourceCollectors/fields.inc +++ b/app/plugins/EnvSource/templates/EnvSourceCollectors/fields.inc @@ -26,11 +26,12 @@ */ // This view only supports edit -if($vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_source_id', - 'fieldLabel' => __d('env_source', 'controller.EnvSources', [1]) - ] - ]); -} +if($vv_action !== 'edit') { + return; +} + +$fields = [ + 'external_identity_source_id' => [ + 'fieldLabel' => __d('env_source', 'controller.EnvSources', [1]) + ] +]; diff --git a/app/plugins/EnvSource/templates/EnvSources/fields-nav.inc b/app/plugins/EnvSource/templates/EnvSources/fields-nav.inc deleted file mode 100644 index e174c7b99..000000000 --- a/app/plugins/EnvSource/templates/EnvSources/fields-nav.inc +++ /dev/null @@ -1,31 +0,0 @@ - 'plugin', - 'active' => 'plugin' - ]; \ No newline at end of file diff --git a/app/plugins/EnvSource/templates/EnvSources/fields.inc b/app/plugins/EnvSource/templates/EnvSources/fields.inc index 073a6c39e..c5c35e70e 100644 --- a/app/plugins/EnvSource/templates/EnvSources/fields.inc +++ b/app/plugins/EnvSource/templates/EnvSources/fields.inc @@ -24,94 +24,85 @@ * @since COmanage Registry v5.1.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -?> -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ] - ]); - } +if($vv_action !== 'edit') { + return; +} - // Print a title - $title = __d('env_source', 'information.header.map'); - print $this->element('form/h3Inject', compact('title')); +$fields = [ + // 'duplicate_mode', + 'sp_mode', + 'sync_on_login', + 'address_type_id', + 'default_affiliation_type_id', + 'email_address_type_id', + 'name_type_id', + 'telephone_number_type_id', + 'redirect_on_duplicate', + 'lookaside_file', + // XXX Document the following useful convention + 'SUBTITLE' => [ + 'subtitle' => __d('env_source', 'information.header.map') + ] +]; - $defaultNames = [ - 'env_identifier_sourcekey' => 'ENV_SOURCE_KEY', - 'env_address_street' => 'ENV_STREET', - 'env_address_locality' => 'ENV_LOCALITY', - 'env_address_state' => 'ENV_STATE', - 'env_address_postalcode' => 'ENV_POSTALCODE', - 'env_address_country' => 'ENV_COUNTRY', - 'env_affiliation' => 'ENV_AFFILIATION', - 'env_department' => 'ENV_DEPARTMENT', - 'env_identifier_eppn' => 'ENV_EPPN', - 'env_identifier_eptid' => 'ENV_EPTID', - 'env_identifier_epuid' => 'ENV_EPUID', - 'env_identifier_network' => 'ENV_NETWORK', - 'env_identifier_oidcsub' => 'ENV_OIDCSUB', - 'env_identifier_samlpairwiseid' => 'ENV_SAMLPAIRWISE', - 'env_identifier_samlsubjectid' => 'ENV_SAMLSUBJECT', - 'env_mail' => 'ENV_MAIL', - 'env_name_honorific' => 'ENV_HONORIFIC', - 'env_name_given' => 'ENV_GIVEN', - 'env_name_middle' => 'ENV_MIDDLE', - 'env_name_family' => 'ENV_FAMILY', - 'env_name_suffix' => 'ENV_SUFFIX', - 'env_organization' => 'ENV_ORGANIZATION', - 'env_telephone_number' => 'ENV_TELEPHONE', - 'env_title' => 'ENV_TITLE' - ]; +$defaultNames = [ + 'env_identifier_sourcekey' => 'ENV_SOURCE_KEY', + 'env_address_street' => 'ENV_STREET', + 'env_address_locality' => 'ENV_LOCALITY', + 'env_address_state' => 'ENV_STATE', + 'env_address_postalcode' => 'ENV_POSTALCODE', + 'env_address_country' => 'ENV_COUNTRY', + 'env_affiliation' => 'ENV_AFFILIATION', + 'env_department' => 'ENV_DEPARTMENT', + 'env_identifier_eppn' => 'ENV_EPPN', + 'env_identifier_eptid' => 'ENV_EPTID', + 'env_identifier_epuid' => 'ENV_EPUID', + 'env_identifier_network' => 'ENV_NETWORK', + 'env_identifier_oidcsub' => 'ENV_OIDCSUB', + 'env_identifier_samlpairwiseid' => 'ENV_SAMLPAIRWISE', + 'env_identifier_samlsubjectid' => 'ENV_SAMLSUBJECT', + 'env_mail' => 'ENV_MAIL', + 'env_name_honorific' => 'ENV_HONORIFIC', + 'env_name_given' => 'ENV_GIVEN', + 'env_name_middle' => 'ENV_MIDDLE', + 'env_name_family' => 'ENV_FAMILY', + 'env_name_suffix' => 'ENV_SUFFIX', + 'env_organization' => 'ENV_ORGANIZATION', + 'env_telephone_number' => 'ENV_TELEPHONE', + 'env_title' => 'ENV_TITLE' +]; - foreach([ - 'env_identifier_sourcekey', - 'env_address_street', - 'env_address_locality', - 'env_address_state', - 'env_address_postalcode', - 'env_address_country', - 'env_affiliation', - 'env_department', - 'env_identifier_eppn', - 'env_identifier_eptid', - 'env_identifier_epuid', - 'env_identifier_network', - 'env_identifier_oidcsub', - 'env_identifier_samlpairwiseid', - 'env_identifier_samlsubjectid', - 'env_mail', - 'env_name_honorific', - 'env_name_given', - 'env_name_middle', - 'env_name_family', - 'env_name_suffix', - 'env_organization', - 'env_telephone_number', - 'env_title' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - 'fieldOptions' => [ - 'default' => $defaultNames[$field] - ] - ] - ]); - } +foreach([ + 'env_identifier_sourcekey', + 'env_address_street', + 'env_address_locality', + 'env_address_state', + 'env_address_postalcode', + 'env_address_country', + 'env_affiliation', + 'env_department', + 'env_identifier_eppn', + 'env_identifier_eptid', + 'env_identifier_epuid', + 'env_identifier_network', + 'env_identifier_oidcsub', + 'env_identifier_samlpairwiseid', + 'env_identifier_samlsubjectid', + 'env_mail', + 'env_name_honorific', + 'env_name_given', + 'env_name_middle', + 'env_name_family', + 'env_name_suffix', + 'env_organization', + 'env_telephone_number', + 'env_title' +] as $field) { + $fields[$field] = [ + 'fieldOptions' => [ + 'default' => $defaultNames[$field] + ] + ]; } diff --git a/app/plugins/OrcidSource/templates/OrcidSourceCollectors/fields.inc b/app/plugins/OrcidSource/templates/OrcidSourceCollectors/fields.inc index b56061f14..6475d5b07 100644 --- a/app/plugins/OrcidSource/templates/OrcidSourceCollectors/fields.inc +++ b/app/plugins/OrcidSource/templates/OrcidSourceCollectors/fields.inc @@ -26,11 +26,12 @@ */ // This view only supports edit -if($vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_source_id', - 'fieldLabel' => __d('orcid_source', 'controller.OrcidSources', [1]) - ] - ]); +if($vv_action !== 'edit') { + return; } + +$fields = [ + 'external_identity_source_id' => [ + 'fieldLabel' => __d('orcid_source', 'controller.OrcidSources', [1]) + ] +]; diff --git a/app/plugins/OrcidSource/templates/OrcidSources/fields-nav.inc b/app/plugins/OrcidSource/templates/OrcidSources/fields-nav.inc deleted file mode 100644 index 9a523fabe..000000000 --- a/app/plugins/OrcidSource/templates/OrcidSources/fields-nav.inc +++ /dev/null @@ -1,31 +0,0 @@ - 'plugin', - 'active' => 'plugin' - ]; \ No newline at end of file diff --git a/app/plugins/OrcidSource/templates/OrcidSources/fields.inc b/app/plugins/OrcidSource/templates/OrcidSources/fields.inc index d2966deac..3024e83b7 100644 --- a/app/plugins/OrcidSource/templates/OrcidSources/fields.inc +++ b/app/plugins/OrcidSource/templates/OrcidSources/fields.inc @@ -29,84 +29,57 @@ use OrcidSource\Lib\Enum\OrcidSourceScopeEnum; // This view does not currently support read-only if($vv_action !== 'edit') { - return; + return; } -// Render the Redirect URI -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'redirect_uri', - 'fieldOptions' => [ - 'readOnly' => true, - 'default' => $vv_redirect_uri - ] - ]]); - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'server_id', - 'fieldOptions' => [ - 'empty' => false, - 'required' => true, - ] - ]]); - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'api_type', - 'fieldSelectOptions' => $api_types, - 'fieldType' => 'select', - 'fieldOptions' => [ - 'empty' => false, - 'required' => true, - ] - ]]); - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'api_tier', - 'fieldSelectOptions' => $api_tiers, - 'fieldType' => 'select', - 'fieldOptions' => [ - 'empty' => false, - 'required' => true, - ] - ]]); - - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'scope_inherit', - ]]); - $vv_inherited_scopes = OrcidSourceScopeEnum::DEFAULT_SCOPE; if (filter_var($vv_obj->scope_inherit, FILTER_VALIDATE_BOOLEAN)) { - $vv_inherited_scopes = $vv_obj->server?->oauth2_server?->scope ?? OrcidSourceScopeEnum::DEFAULT_SCOPE; + $vv_inherited_scopes = $vv_obj->server?->oauth2_server?->scope ?? OrcidSourceScopeEnum::DEFAULT_SCOPE; } -// Render active scopes -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'Scope', - 'fieldOptions' => [ - 'readOnly' => true, - 'default' => $vv_inherited_scopes - ] - ]]); - -// Print a title -$title = __d('orcid_source', 'information.OrcidSources.default.types'); -print $this->element('form/h3Inject', compact('title')); - -foreach([ - 'address_type_id', - 'default_affiliation_type_id', - 'email_address_type_id', - 'name_type_id', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ] - ]); -} \ No newline at end of file +$fields = [ + // Render the Redirect URI + 'redirect_uri' => [ + 'fieldOptions' => [ + 'readOnly' => true, + 'default' => $vv_redirect_uri + ] + ], + 'server_id' => [ + 'fieldOptions' => [ + 'empty' => false, + 'required' => true, + ] + ], + 'api_type' => [ + 'fieldSelectOptions' => $api_types, + 'fieldType' => 'select', + 'fieldOptions' => [ + 'empty' => false, + 'required' => true, + ] + ], + 'api_tier' => [ + 'fieldSelectOptions' => $api_tiers, + 'fieldType' => 'select', + 'fieldOptions' => [ + 'empty' => false, + 'required' => true, + ] + ], + 'scope_inherit', + // Render active scopes + 'Scope' => [ + 'fieldOptions' => [ + 'readOnly' => true, + 'default' => $vv_inherited_scopes + ] + ], + 'SUBTITLE' => [ + 'subtitle' => __d('orcid_source', 'information.OrcidSources.default.types') + ], + 'address_type_id', + 'default_affiliation_type_id', + 'email_address_type_id', + 'name_type_id' +]; diff --git a/app/plugins/SshKeyAuthenticator/resources/locales/en_US/ssh_key_authenticator.po b/app/plugins/SshKeyAuthenticator/resources/locales/en_US/ssh_key_authenticator.po index 2097e9daf..58a546926 100644 --- a/app/plugins/SshKeyAuthenticator/resources/locales/en_US/ssh_key_authenticator.po +++ b/app/plugins/SshKeyAuthenticator/resources/locales/en_US/ssh_key_authenticator.po @@ -22,6 +22,9 @@ # @since COmanage Registry v5.2.0 # @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) +msgid "add.a" +msgstr "Add an SSH Key" + msgid "controller.SshKeyAuthenticators" msgstr "{0,plural,=1{SSH Key Authenticator} other{SSH Key Authenticators}}" @@ -74,4 +77,4 @@ msgid "result.registered" msgstr "{0} {1} registered" msgid "result.uploaded" -msgstr "SSH Key {0} uploaded" \ No newline at end of file +msgstr "SSH Key {0} uploaded" diff --git a/app/plugins/SshKeyAuthenticator/src/Controller/SshKeysController.php b/app/plugins/SshKeyAuthenticator/src/Controller/SshKeysController.php index 9297ddd1b..b9200e223 100644 --- a/app/plugins/SshKeyAuthenticator/src/Controller/SshKeysController.php +++ b/app/plugins/SshKeyAuthenticator/src/Controller/SshKeysController.php @@ -88,7 +88,7 @@ public function add() { $this->set('vv_supertitle', $supertitle); $this->set('vv_subtitle', $subtitle); - // Let the view render - see add.php for why we don't currently use the standard view - // $this->render('/Standard/add-edit-view'); + // Let the view render + $this->render('/Standard/add-edit-view'); } } diff --git a/app/plugins/SshKeyAuthenticator/templates/SshKeyAuthenticators/fields.inc b/app/plugins/SshKeyAuthenticator/templates/SshKeyAuthenticators/fields.inc index a99b02ce2..4bdc5d8ef 100644 --- a/app/plugins/SshKeyAuthenticator/templates/SshKeyAuthenticators/fields.inc +++ b/app/plugins/SshKeyAuthenticator/templates/SshKeyAuthenticators/fields.inc @@ -30,4 +30,8 @@ declare(strict_types = 1); $this->Field->disableFormEditMode(); // There are currently no configurable options for the SSH Key Authenticator -print $this->element('notify/banner', ['info' => __d('information', 'plugin.config.none')]); + +// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning) +$banners = [ + __d('information', 'plugin.config.none') +]; \ No newline at end of file diff --git a/app/plugins/SshKeyAuthenticator/templates/SshKeys/add.php b/app/plugins/SshKeyAuthenticator/templates/SshKeys/add.php deleted file mode 100644 index 713bb372c..000000000 --- a/app/plugins/SshKeyAuthenticator/templates/SshKeys/add.php +++ /dev/null @@ -1,46 +0,0 @@ - -
    -
    -

    -
    -
    -element('flash'); - - print $this->Form->create($vv_obj, ['type' => 'file']); - - // List of records to collect, this will be pulled from fields.inc - print $this->element('form/unorderedList'); - - // Close the Form - print $this->Form->end(); diff --git a/app/plugins/SshKeyAuthenticator/templates/SshKeys/fields.inc b/app/plugins/SshKeyAuthenticator/templates/SshKeys/fields.inc index 4260eca0f..e82af1307 100644 --- a/app/plugins/SshKeyAuthenticator/templates/SshKeys/fields.inc +++ b/app/plugins/SshKeyAuthenticator/templates/SshKeys/fields.inc @@ -27,6 +27,8 @@ use App\Lib\Util\StringUtilities; +$fields = []; + if($vv_action == 'add') { // Note for add this file is called by our local add.php file, not add-edit-view.php $vv_submit_button_label = __d('operation', 'upload'); @@ -39,22 +41,17 @@ if($vv_action == 'add') { ]; // As of v3.2.0, we only allow uploading of SSH Keys, not manually adding or editing - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'keyFile', - 'fieldOptions' => ['type' => 'file'] + $fields = [ + 'keyFile' => [ + 'fieldOptions' => [ + 'type' => 'file' + ] ] - ]); + ]; } elseif($vv_action == 'view') { - foreach([ 'type', - 'comment', - 'skey', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } -} \ No newline at end of file + $fields = [ + 'type', + 'comment', + 'skey' + ]; +} diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 4571a8537..79f85c566 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -56,14 +56,14 @@ public function generate(string $id) { $this->Flash->error($e->getMessage()); } - // Let the view render, but tell it to use a different fields file - $this->set('vv_fields_inc', 'fields-generate.inc'); [$title, , ] = StringUtilities::entityAndActionToTitle(null, 'api.key', $this->request->getParam('action')); $this->set('vv_title', $title); - // Let the view render + // Render the view. + // The /Standard/add-edit-view template will try to include fields from + // fields-ACTION.inc if it exists - in this case fields-generate.inc. $this->render('/Standard/add-edit-view'); } } \ No newline at end of file diff --git a/app/src/Controller/PetitionsController.php b/app/src/Controller/PetitionsController.php index b6f4a3fb1..1f9f94760 100644 --- a/app/src/Controller/PetitionsController.php +++ b/app/src/Controller/PetitionsController.php @@ -75,6 +75,8 @@ public function beforeRender(EventInterface $event) { if($id) { $this->set('vv_enrollee_name', $this->Petitions->getEnrolleeName((int)$id)); } + + $this->set('vv_alternate_template', 'petition.inc'); } return parent::beforeRender($event); diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index 60e3f9c31..9960ced48 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -692,4 +692,25 @@ public function getElementsForDisabledInput(string $element, array $formArgument // Print the original element print $orginalElement; } + + /** + * Determine if we have a file field to render. If we do, the form must be created + * with multipart/form-data encoding. This is used by the add-edit-view.php file + * when generating the form. + * + * @param array $fields The array of form fields. + * @return bool + * @since COmanage Registry v5.2.0 + */ + function includesFileField(array $array): bool { + foreach ($array as $subarray) { + // XXX flatten fieldOptions for all $fields[] --- then update this search. + if (is_array($subarray) + && isset($subarray['fieldOptions']['type']) + && $subarray['fieldOptions']['type'] === 'file') { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/app/templates/AdHocAttributes/fields.inc b/app/templates/AdHocAttributes/fields.inc index 377b9b0e0..3a25725b5 100644 --- a/app/templates/AdHocAttributes/fields.inc +++ b/app/templates/AdHocAttributes/fields.inc @@ -25,27 +25,12 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'tag' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'value' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'frozen' - ]]); -} +$fields = [ + 'tag', + 'value', + 'frozen' +]; if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = ['entity' => $vv_obj]; } diff --git a/app/templates/Addresses/fields.inc b/app/templates/Addresses/fields.inc index 4c23a1b46..6db71119e 100644 --- a/app/templates/Addresses/fields.inc +++ b/app/templates/Addresses/fields.inc @@ -25,45 +25,28 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - // Dynamic required fields is automatically handled by FormHelper via the - // validation rules - foreach (['street', - 'room', - 'locality', - 'state', - 'postal_code', - 'country', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'default' => $vv_default_type - ] - ]]); - - foreach (['language', - 'description', - 'frozen', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} +// Dynamic required fields are automatically handled by FormHelper via the +// validation rules +$fields = [ + 'street', + 'room', + 'locality', + 'state', + 'postal_code', + 'country', + 'type_id' => [ + // XXX fix fieldOptions - just make this flat + 'fieldOptions' => [ + 'default' => $vv_default_type + ] + ], + 'language', + 'description', + 'frozen' +]; if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = [ + 'entity' => $vv_obj + ]; } diff --git a/app/templates/ApiUsers/fields-generate.inc b/app/templates/ApiUsers/fields-generate.inc index b33f1ed3e..e7394695d 100644 --- a/app/templates/ApiUsers/fields-generate.inc +++ b/app/templates/ApiUsers/fields-generate.inc @@ -25,20 +25,17 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -print $this->element('notify/banner', [ 'info' => __d('information', 'api.key')]); +$banners = [ + __d('information', 'api.key') +]; -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'username', +$fields = [ + 'username' => [ 'status' => $vv_obj->username, 'labelIsTextOnly' => true - ] -]); - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'api_key', + ], + 'api_key' => [ 'status' => $vv_api_key, 'labelIsTextOnly' => true ] -]); +]; diff --git a/app/templates/ApiUsers/fields.inc b/app/templates/ApiUsers/fields.inc index cddb22c1b..8f6480246 100644 --- a/app/templates/ApiUsers/fields.inc +++ b/app/templates/ApiUsers/fields.inc @@ -25,72 +25,41 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does not support read-only -if($vv_action == 'add' || $vv_action == 'edit') { - if($vv_cur_co->id == 1) { - print $this->element('notify/banner', ['info' => __d('information', 'api.cmp')]); - } - - // AR-ApiUser-3 For namespacing purposes, API Users are named with a prefix consisting of the string "co_#.". - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'username', // string - 'fieldPrefix' => 'co_' . $vv_cur_co->id . '.' - ] - ]); - - // We link to the "Generate" button on edit only - $generateLink = []; - - if(!empty($vv_obj->id)) { - $generateLink = [ - 'url' => [ - 'controller' => 'api_users', - 'action' => 'generate', - $vv_obj->id - ], - 'label' => __d('operation', 'api.key.generate'), - 'class' => 'provisionbutton nospin btn btn-primary btn-sm', - 'confirm' => __d('operation', 'api.key.generate.confirm') - ]; - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'api_key', - 'status' => !empty($vv_obj->api_key) ? __d('enumeration', 'SetBooleanEnum.1') : __d('enumeration', 'SetBooleanEnum.0'), - 'link' => $generateLink, - 'labelIsTextOnly' => true - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status', // select - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'valid_from', // timestamp - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'valid_through', // timestamp - ] - ]); +if($vv_cur_co->id == 1) { + $banners = [ + __d('information', 'api.cmp') + ]; +} - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'remote_ip', // string - ] - ]); +// We link to the "Generate" button on edit only +$generateLink = []; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'privileged', // boolean - ] - ]); +if(!empty($vv_obj->id)) { + $generateLink = [ + 'url' => [ + 'controller' => 'api_users', + 'action' => 'generate', + $vv_obj->id + ], + 'label' => __d('operation', 'api.key.generate'), + 'class' => 'provisionbutton nospin btn btn-primary btn-sm', + 'confirm' => __d('operation', 'api.key.generate.confirm') + ]; } + +$fields = [ + 'username' => [ + // AR-ApiUser-3 For namespacing purposes, API Users are named with a prefix consisting of the string "co_#.". + 'fieldPrefix' => 'co_' . $vv_cur_co->id . '.' + ], + 'api_key' => [ + 'status' => !empty($vv_obj->api_key) ? __d('enumeration', 'SetBooleanEnum.1') : __d('enumeration', 'SetBooleanEnum.0'), + 'link' => $generateLink, + 'labelIsTextOnly' => true + ], + 'status', + 'valid_from', // timestamp + 'valid_through', // timestamp + 'remote_ip', // string + 'privileged', // boolean +]; diff --git a/app/templates/Apis/fields.inc b/app/templates/Apis/fields.inc index 5fa07ba6c..69553b5d7 100644 --- a/app/templates/Apis/fields.inc +++ b/app/templates/Apis/fields.inc @@ -24,28 +24,12 @@ * @since COmanage Registry v5.2.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -?> -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'plugin', - 'labelIsTextOnly' => true - ] - ]); - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'api_user_id' - ]]); -} +$fields = [ + 'description', + 'status', + 'plugin' => [ + 'labelIsTextOnly' => true + ], + 'api_user_id' +]; \ No newline at end of file diff --git a/app/templates/Authenticators/fields.inc b/app/templates/Authenticators/fields.inc index e69f1cb99..af527df08 100644 --- a/app/templates/Authenticators/fields.inc +++ b/app/templates/Authenticators/fields.inc @@ -24,28 +24,12 @@ * @since COmanage Registry v5.2.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -?> -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'plugin', - 'labelIsTextOnly' => true - ] - ]); - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'message_template_id' - ]]); -} +$fields = [ + 'description', + 'status', + 'plugin' => [ + 'labelIsTextOnly' => true + ], + 'message_template_id' +]; diff --git a/app/templates/CoSettings/fields.inc b/app/templates/CoSettings/fields.inc index 4b51f4165..d675a4d30 100644 --- a/app/templates/CoSettings/fields.inc +++ b/app/templates/CoSettings/fields.inc @@ -25,135 +25,66 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does not support add or read-only -if($vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'required_fields_address', - 'fieldOptions' => ['empty' => false] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_address_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_email_address_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_identifier_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_name_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'permitted_fields_name', - 'fieldOptions' => ['empty' => false] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'required_fields_name', - 'fieldOptions' => ['empty' => false] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_pronoun_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_telephone_number_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'permitted_fields_telephone_number', - 'fieldOptions' => ['empty' => false] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'default_url_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'search_global_limit' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'search_global_limited_models' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'person_picker_display_fields', - 'labelIsTextOnly' => true, - 'groupedControls' => [ - // each key is the fieldName of the control we are going to create - 'person_picker_email_address_type_id' => [ - 'fieldOptions' => [ - 'label' => __d('field', 'mail'), - 'empty' => '(' . __d('operation', 'all') . ')', +$fields = [ + 'required_fields_address' => [ + // XXX flatten fieldOptions + 'fieldOptions' => ['empty' => false] + ], + 'default_address_type_id', + 'default_email_address_type_id', + 'default_identifier_type_id', + 'default_name_type_id', + 'permitted_fields_name' => [ + // XXX flatten fieldOptions + 'fieldOptions' => ['empty' => false] + ], + 'required_fields_name' => [ + // XXX flatten fieldOptions + 'fieldOptions' => ['empty' => false] + ], + 'default_pronoun_type_id', + 'default_telephone_number_type_id', + 'permitted_fields_telephone_number' => [ + // XXX flatten fieldOptions + 'fieldOptions' => ['empty' => false] + ], + 'default_url_type_id', + 'search_global_limit', + 'search_global_limited_models', + 'person_picker_display_fields' => [ + 'labelIsTextOnly' => true, + 'groupedControls' => [ + // each key is the fieldName of the control we are going to create + 'person_picker_email_address_type_id' => [ + 'fieldOptions' => [ + 'label' => __d('field', 'mail'), + 'empty' => '(' . __d('operation', 'all') . ')', // 'all' => '(' . __d('operation', 'all') . ')' - ], ], - 'person_picker_identifier_type_id' => [ - 'fieldOptions' => [ - 'label' => __d('field', 'identifier'), - 'empty' => '(' . __d('operation', 'all') . ')', + ], + 'person_picker_identifier_type_id' => [ + 'fieldOptions' => [ + 'label' => __d('field', 'identifier'), + 'empty' => '(' . __d('operation', 'all') . ')', // 'all' => '(' . __d('operation', 'all') . ')', - ], ], - 'person_picker_display_types' => [ - 'singleRowItem' => true, - 'fieldLabel' => __d('field', 'CoSettings.person_picker_display_types') - ] ], - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'email_smtp_server_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'email_delivery_address_type_id' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'authn_events_api_disable' - ]]); - - if($vv_obj->co->isCOmanageCO()) { - // Fields prefixed platform_ are only available within the COmanage CO - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'platform_env_mfa' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'platform_env_mfa_value' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'platform_env_mfa_enable_eg' - ]]); - } + 'person_picker_display_types' => [ + 'singleRowItem' => true, + 'fieldLabel' => __d('field', 'CoSettings.person_picker_display_types') + ] + ], + ], + 'email_smtp_server_id', + 'email_delivery_address_type_id', + 'authn_events_api_disable' +]; + +if($vv_obj->co->isCOmanageCO()) { + // Fields prefixed platform_ are only available within the COmanage CO + $fields = array_merge($fields, [ + 'platform_env_mfa', + 'platform_env_mfa_value', + 'platform_env_mfa_enable_eg' + ]); } diff --git a/app/templates/Cos/fields.inc b/app/templates/Cos/fields.inc index fd9658a47..e5e4882fe 100644 --- a/app/templates/Cos/fields.inc +++ b/app/templates/Cos/fields.inc @@ -25,20 +25,8 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view supports read-only only for the COmanage CO -if($vv_action == 'add' || $vv_action == 'edit' || ($vv_action == 'view' && $vv_obj->name == 'COmanage')) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'name' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'description' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' - ]]); -} +$fields = [ + 'name', + 'description', + 'status' +]; diff --git a/app/templates/Cous/fields.inc b/app/templates/Cous/fields.inc index 60089c412..8a6f24e43 100644 --- a/app/templates/Cous/fields.inc +++ b/app/templates/Cous/fields.inc @@ -25,21 +25,13 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does not support read-only -if($vv_action == 'add' || $vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'name'] - ]); - print $this->element('form/listItem', [ - 'arguments' => ['fieldName' => 'description'] - ]); +$fields = [ + 'name', + 'description' +]; - if(!empty($parents)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'parent_id', - 'fieldLabel' => __d('field', 'parent_id') - ] - ]); - } +if(!empty($parents)) { + $fields['parent_id'] = [ + 'fieldLabel' => __d('field', 'parent_id') + ]; } diff --git a/app/templates/EmailAddresses/fields-nav.inc b/app/templates/EmailAddresses/fields-nav.inc deleted file mode 100644 index 025e0f3e1..000000000 --- a/app/templates/EmailAddresses/fields-nav.inc +++ /dev/null @@ -1,43 +0,0 @@ - 'verified_user', - 'order' => 'Default', - 'label' => __d('operation', 'EmailAddresses.verify.force'), - 'if' => 'notVerified', - 'link' => [ - 'action' => 'forceVerify', - $vv_obj->id - ], - 'class' => '' - ], - ]; - } \ No newline at end of file diff --git a/app/templates/EmailAddresses/fields.inc b/app/templates/EmailAddresses/fields.inc index b1ec9d109..11ca71589 100644 --- a/app/templates/EmailAddresses/fields.inc +++ b/app/templates/EmailAddresses/fields.inc @@ -27,58 +27,59 @@ use \App\Lib\Enum\VerificationMethodEnum; -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'mail' - ]]); +$fields = [ + 'mail', + 'type_id' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => $vv_default_type + ] + ], + 'description' +]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'default' => $vv_default_type - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'description' - ]]); - - if($vv_obj->verified && !empty($vv_obj->verification)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'verified', - 'fieldOptions' => [ - 'readonly' => true - ], - 'status' => __d('result', 'Verifications.status', [ VerificationMethodEnum::getLocalization($vv_obj->verification->method), - $this->Time->nice($vv_obj->verification->verification_time, $vv_tz) - ]) - ]]); - } else { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'verified', - 'fieldOptions' => [ - 'readonly' => true - ], - 'status' => __d('enumeration', 'YesBooleanEnum.0') - ]]); - } +if($vv_obj->verified && !empty($vv_obj->verification)) { + $fields['verified'] = [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'readonly' => true + ], + 'status' => __d('result', 'Verifications.status', [ + VerificationMethodEnum::getLocalization($vv_obj->verification->method), + $this->Time->nice($vv_obj->verification->verification_time, $vv_tz) + ]) + ]; +} else { + $fields['verified'] = [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'readonly' => true + ], + 'status' => __d('enumeration', 'YesBooleanEnum.0') + ]; +} - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'frozen' - ]]); +$fields[] = 'frozen'; +if($vv_action == 'edit' || $vv_action == 'view') { + $fields['source'] = [ + 'entity' => $vv_obj + ]; } -if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); +// Top Links +if($vv_action != 'add') { + $topLinks = [ + [ + 'icon' => 'verified_user', + 'order' => 'Default', + 'label' => __d('operation', 'EmailAddresses.verify.force'), + 'if' => 'notVerified', + 'link' => [ + 'action' => 'forceVerify', + $vv_obj->id + ], + 'class' => '' + ], + ]; } \ No newline at end of file diff --git a/app/templates/EnrollmentFlowSteps/fields.inc b/app/templates/EnrollmentFlowSteps/fields.inc index ffe5137ec..3651eba96 100644 --- a/app/templates/EnrollmentFlowSteps/fields.inc +++ b/app/templates/EnrollmentFlowSteps/fields.inc @@ -26,8 +26,22 @@ */ use \App\Lib\Enum\EnrollmentActorEnum; + +$fields = [ + 'description', + 'status', + 'plugin', + 'ordr', + 'actor_type', + 'approver_group_id', + 'message_template_id', + 'redirect_on_handoff', + 'notification_group_id', + 'notification_message_template_id' +]; ?> - - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'actor_type', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ]]); - - foreach (['approver_group_id', - 'message_template_id', - 'redirect_on_handoff' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'notification_group_id', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ]]); - - foreach (['notification_message_template_id' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#actor_type, #notification-group-id').change(function() { + updateGadgets(); + }); + }); + diff --git a/app/templates/EnrollmentFlows/fields.inc b/app/templates/EnrollmentFlows/fields.inc index 411633f7c..c6aa4ef76 100644 --- a/app/templates/EnrollmentFlows/fields.inc +++ b/app/templates/EnrollmentFlows/fields.inc @@ -27,8 +27,24 @@ declare(strict_types = 1); +$fields = [ + 'name', + 'description', + 'status', + 'authz_type', + 'authz_cou_id', + 'authz_group_id', + 'collect_enrollee_email', + 'redirect_on_duplicate', + 'redirect_on_finalize', + 'finalization_message_template_id', + 'notification_group_id', + 'notification_message_template_id' +]; + ?> - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'authz_type', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ] - ]); - - foreach (['authz_cou_id', - 'authz_group_id', - 'collect_enrollee_email', - 'redirect_on_duplicate', - 'redirect_on_finalize', - 'finalization_message_template_id' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'notification_group_id', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ] - ]); - - foreach (['notification_message_template_id' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#authz_type, #notification-group-id').change(function() { + updateGadgets(); + }); + }); + diff --git a/app/templates/ExtIdentitySourceRecords/fields-nav.inc b/app/templates/ExtIdentitySourceRecords/fields-nav.inc deleted file mode 100644 index 07c5b2b55..000000000 --- a/app/templates/ExtIdentitySourceRecords/fields-nav.inc +++ /dev/null @@ -1,65 +0,0 @@ -external_identity_id)) { - $topLinks[] = [ - 'icon' => 'visibility', - 'order' => 'Default', - 'label' => __d('operation', 'view.a', [__d('controller', 'ExternalIdentities', [1])]), - 'link' => [ - 'controller' => 'external_identities', - 'action' => 'view', - $vv_obj->external_identity_id - ] - ]; - $topLinks[] = [ - 'icon' => 'visibility', - 'order' => 'Default', - 'label' => __d('operation', 'ExternalIdentitySourceRecords.retrieve'), - 'link' => [ - 'controller' => 'external_identity_sources', - 'action' => 'retrieve', - $vv_obj->external_identity_source_id, - '?' => [ - 'source_key' => $vv_obj->source_key - ] - ] - ]; - - // primary name: $vv_obj->external_identity->person->primary_name->full_name - $subnav = [ - 'name' => 'person', - 'active' => 'external_identities', - 'subActive' => 'external_identity_roles', - 'tabsId' => $vv_obj->external_identity->person->id, - 'tabsController' => 'people', - 'subTabsId' => $vv_obj->external_identity->id, - 'subTabsController' => 'external_identities', - 'tabsSupertitle' => $vv_obj->external_identity->description - ]; -} \ No newline at end of file diff --git a/app/templates/ExtIdentitySourceRecords/fields.inc b/app/templates/ExtIdentitySourceRecords/fields.inc index c92535642..8081e39a8 100644 --- a/app/templates/ExtIdentitySourceRecords/fields.inc +++ b/app/templates/ExtIdentitySourceRecords/fields.inc @@ -42,16 +42,16 @@ $noticeText = __d( ] ); -print $this->element('notify/alert', [ - 'message' => $noticeText, - 'type' => 'information' -]); +// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning) +$banners = [ + $noticeText +]; // This view does not support add or edit if($vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_source_id', + + $fields = [ + 'external_identity_source_id' => [ 'status' => $vv_obj->external_identity_source->description, 'link' => [ 'url' => [ @@ -61,38 +61,32 @@ if($vv_action == 'view') { ] ] ] - ]); + ]; if(!empty($vv_obj->adopted_person_id)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'adopted_person_id', - 'status' => $vv_obj->adopted_person->primary_name->full_name, - 'link' => [ - 'url' => [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->adopted_person->id - ] + $fields['adopted_person_id'] = [ + 'status' => $vv_obj->adopted_person->primary_name->full_name, + 'link' => [ + 'url' => [ + 'controller' => 'people', + 'action' => 'edit', + $vv_obj->adopted_person->id ] ] - ]); + ]; } if(!empty($vv_obj->external_identity_id)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_id', - 'status' => $vv_obj->external_identity->names[0]->full_name, - 'link' => [ - 'url' => [ - 'controller' => 'external_identities', - 'action' => 'edit', - $vv_obj->external_identity->id - ] + $fields['external_identity_id'] = [ + 'status' => $vv_obj->external_identity->names[0]->full_name, + 'link' => [ + 'url' => [ + 'controller' => 'external_identities', + 'action' => 'edit', + $vv_obj->external_identity->id ] ] - ]); + ]; } foreach([ @@ -101,9 +95,46 @@ if($vv_action == 'view') { 'reference_identifier', 'source_record' ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ]]); + $fields[] = $field; } } + + +$topLinks = []; +if(!empty($vv_obj->external_identity_id)) { + $topLinks[] = [ + 'icon' => 'visibility', + 'order' => 'Default', + 'label' => __d('operation', 'view.a', [__d('controller', 'ExternalIdentities', [1])]), + 'link' => [ + 'controller' => 'external_identities', + 'action' => 'view', + $vv_obj->external_identity_id + ] + ]; + $topLinks[] = [ + 'icon' => 'visibility', + 'order' => 'Default', + 'label' => __d('operation', 'ExternalIdentitySourceRecords.retrieve'), + 'link' => [ + 'controller' => 'external_identity_sources', + 'action' => 'retrieve', + $vv_obj->external_identity_source_id, + '?' => [ + 'source_key' => $vv_obj->source_key + ] + ] + ]; + + // primary name: $vv_obj->external_identity->person->primary_name->full_name + $subnav = [ + 'name' => 'person', + 'active' => 'external_identities', + 'subActive' => 'external_identity_roles', + 'tabsId' => $vv_obj->external_identity->person->id, + 'tabsController' => 'people', + 'subTabsId' => $vv_obj->external_identity->id, + 'subTabsController' => 'external_identities', + 'tabsSupertitle' => $vv_obj->external_identity->description + ]; +} diff --git a/app/templates/ExternalIdentities/fields-nav.inc b/app/templates/ExternalIdentities/fields-nav.inc deleted file mode 100644 index 108b5e3f2..000000000 --- a/app/templates/ExternalIdentities/fields-nav.inc +++ /dev/null @@ -1,166 +0,0 @@ - 'history', - 'order' => 'Default', - 'label' => __d('controller', 'HistoryRecords', [99]), - 'link' => [ - 'controller' => 'history_records', - 'action' => 'index', - '?' => [ - 'external_identity_id' => $vv_obj->id - ] - ] - ], -]; - -if($vv_obj?->ext_identity_source_record?->id !== null) { - $topLinks[] = [ - 'icon' => 'visibility', - 'order' => 'Default', - 'class' => 'cm-modal-link nospin', // launch this in a modal - 'dataAttrs' => [ - ['data-cm-modal-title',__d('controller', 'ExtIdentitySourceRecords', 1)] - ], - 'label' => __d('operation', 'view.a', [__d('controller', 'ExtIdentitySourceRecords', 1)]), - 'link' => [ - 'controller' => 'ext_identity_source_records', - 'action' => 'view', - $vv_obj->ext_identity_source_record->id - ] - ]; - - $topLinks[] = [ - 'icon' => 'stroller', - 'order' => 'Default', - 'label' => __d('operation', 'adopt'), - 'link' => [ - 'action' => 'adopt', - $vv_obj->id - ], - 'confirm' => [ - 'dg_body_txt' => __d( - 'operation', - 'ExternalIdentities.adopt.confirm', - [ - $vv_obj->ext_identity_source_record->source_key, - $vv_obj->ext_identity_source_record->external_identity_source->description, - ]), - 'dg_confirm_btn' => __d('operation', 'adopt') - ] - ]; - - $topLinks[] = [ - 'icon' => 'move', - 'order' => 'Default', - 'label' => __d('operation', 'relink'), - 'link' => [ - 'action' => 'relink', - $vv_obj->id - ] - ]; -} - -// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: -// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. -$addMenuLinks = [ - [ - 'controller' => 'names', - 'action' => 'add', - 'icon' => 'account_box', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'email_addresses', - 'action' => 'add', - 'icon' => 'email', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'identifiers', - 'action' => 'add', - 'icon' => 'fingerprint' - ], - [ - 'controller' => 'ad_hoc_attributes', - 'action' => 'add', - 'icon' => 'user_attributes', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'addresses', - 'action' => 'add', - 'icon' => 'contact_mail', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'history_records', - 'action' => 'add', - 'icon' => 'history' - ], - [ - 'controller' => 'pronouns', - 'action' => 'add', - 'icon' => '3p', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'telephone_numbers', - 'action' => 'add', - 'icon' => 'phone' - ], - [ - 'controller' => 'urls', - 'action' => 'add', - 'icon' => 'link' - ] -]; - -$subnav = [ - 'name' => 'person', - 'active' => 'external_identities', - 'subActive' => 'properties' -]; \ No newline at end of file diff --git a/app/templates/ExternalIdentities/fields.inc b/app/templates/ExternalIdentities/fields.inc index 4f5eeaff2..a80f0aa9d 100644 --- a/app/templates/ExternalIdentities/fields.inc +++ b/app/templates/ExternalIdentities/fields.inc @@ -25,41 +25,171 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view will not support add/edit -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - if(!empty($vv_obj->ext_identity_source_record)) { +if(!empty($vv_obj->ext_identity_source_record)) { - $noticeText = __d( - 'information', - 'ExternalIdentities.source', - [ - $this->Html->link( - $vv_obj->ext_identity_source_record->external_identity_source->description, - [ - 'controller' => 'external-identity-sources', - 'action' => 'edit', - $vv_obj->ext_identity_source_record->external_identity_source->id - ] - ) - ] - ); + $noticeText = __d( + 'information', + 'ExternalIdentities.source', + [ + $this->Html->link( + $vv_obj->ext_identity_source_record->external_identity_source->description, + [ + 'controller' => 'external-identity-sources', + 'action' => 'edit', + $vv_obj->ext_identity_source_record->external_identity_source->id + ] + ) + ] + ); + + // XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning) + // XXX Also: the placement here is wrong; this should be displaying under the subtitle, not the main title. + $banners = [ + $noticeText + ]; +} + +$fields = [ + 'status', + 'date_of_birth' // date +]; + +// List the MVEAs that may be shown on the mveaCanvas +// When this array exists, the mveaCanvas.php element will render +$mveas = [ + 'names', + 'email_addresses', + 'identifiers', + 'ad_hoc_attributes', + 'addresses', + 'telephone_numbers', + 'urls', + 'pronouns' +]; - $this->element('notify/alert', [ - 'message' => $noticeText, - 'type' => 'information' - ]); +// Name the MVEAs Entity Type +$mveasEntityType = "external_identity"; - } +// Top Links +$topLinks = [ + [ + 'icon' => 'history', + 'order' => 'Default', + 'label' => __d('controller', 'HistoryRecords', [99]), + 'link' => [ + 'controller' => 'history_records', + 'action' => 'index', + '?' => [ + 'external_identity_id' => $vv_obj->id + ] + ] + ], +]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' +if($vv_obj?->ext_identity_source_record?->id !== null) { + $topLinks[] = [ + 'icon' => 'visibility', + 'order' => 'Default', + 'class' => 'cm-modal-link nospin', // launch this in a modal + 'dataAttrs' => [ + ['data-cm-modal-title',__d('controller', 'ExtIdentitySourceRecords', 1)] + ], + 'label' => __d('operation', 'view.a', [__d('controller', 'ExtIdentitySourceRecords', 1)]), + 'link' => [ + 'controller' => 'ext_identity_source_records', + 'action' => 'view', + $vv_obj->ext_identity_source_record->id ] - ]); + ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'date_of_birth', // date + $topLinks[] = [ + 'icon' => 'stroller', + 'order' => 'Default', + 'label' => __d('operation', 'adopt'), + 'link' => [ + 'action' => 'adopt', + $vv_obj->id + ], + 'confirm' => [ + 'dg_body_txt' => __d( + 'operation', + 'ExternalIdentities.adopt.confirm', + [ + $vv_obj->ext_identity_source_record->source_key, + $vv_obj->ext_identity_source_record->external_identity_source->description, + ]), + 'dg_confirm_btn' => __d('operation', 'adopt') ] - ]); + ]; + + $topLinks[] = [ + 'icon' => 'move', + 'order' => 'Default', + 'label' => __d('operation', 'relink'), + 'link' => [ + 'action' => 'relink', + $vv_obj->id + ] + ]; } + +// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: +// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. +$addMenuLinks = [ + [ + 'controller' => 'names', + 'action' => 'add', + 'icon' => 'account_box', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'email_addresses', + 'action' => 'add', + 'icon' => 'email', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'identifiers', + 'action' => 'add', + 'icon' => 'fingerprint' + ], + [ + 'controller' => 'ad_hoc_attributes', + 'action' => 'add', + 'icon' => 'user_attributes', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'addresses', + 'action' => 'add', + 'icon' => 'contact_mail', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'history_records', + 'action' => 'add', + 'icon' => 'history' + ], + [ + 'controller' => 'pronouns', + 'action' => 'add', + 'icon' => '3p', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'telephone_numbers', + 'action' => 'add', + 'icon' => 'phone' + ], + [ + 'controller' => 'urls', + 'action' => 'add', + 'icon' => 'link' + ] +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'external_identities', + 'subActive' => 'properties' +]; diff --git a/app/templates/ExternalIdentityRoles/fields-nav.inc b/app/templates/ExternalIdentityRoles/fields-nav.inc deleted file mode 100644 index e95652727..000000000 --- a/app/templates/ExternalIdentityRoles/fields-nav.inc +++ /dev/null @@ -1,68 +0,0 @@ - 'ad_hoc_attributes', - 'action' => 'add', - 'icon' => 'user_attributes', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'addresses', - 'action' => 'add', - 'icon' => 'contact_mail', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'telephone_numbers', - 'action' => 'add', - 'icon' => 'phone' - ] -]; - -// XXX: if CFM-218 (Make fields.inc configuration only) is accepted, move the contents of this file into fields.inc -$topLinks = []; - -$subnav = [ - 'name' => 'person', - 'active' => 'external_identities', - 'subActive' => 'external_identity_roles' -]; \ No newline at end of file diff --git a/app/templates/ExternalIdentityRoles/fields.inc b/app/templates/ExternalIdentityRoles/fields.inc index ab977c492..a88858a19 100644 --- a/app/templates/ExternalIdentityRoles/fields.inc +++ b/app/templates/ExternalIdentityRoles/fields.inc @@ -25,56 +25,63 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'affiliation_type_id', - 'fieldLabel' => __d('field', 'affiliation') - ] - ]); +$fields = [ + 'affiliation_type_id' => [ + 'fieldLabel' => __d('field', 'affiliation') + ], + 'status', + 'ordr', + 'title', + 'organization', + 'department', + + // XXX need to clarify this is an _identifier_ not an actual Person FK + 'sponsor_identifier' => [ + 'fieldLabel' => __d('field', 'sponsor') + ], + 'manager_identifier' => [ + 'fieldLabel' => __d('field', 'manager') + ], + + 'valid_from', + 'valid_through' +]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' - ] - ]); +// List the MVEAs that may be shown on the mveaCanvas +// When this array exists, the mveaCanvas.php element will render +$mveas = [ + 'ad_hoc_attributes', + 'addresses', + 'telephone_numbers' +]; - foreach([ - 'ordr', - 'title', - 'organization', - 'department' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } - -// XXX need to clarify this is an _identifier_ not an actual Person FK +// Name the MVEAs Entity Type +$mveasEntityType = 'external_identity_role'; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'sponsor_identifier', - 'fieldLabel' => __d('field', 'sponsor') - ] - ]); - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'manager_identifier', - 'fieldLabel' => __d('field', 'manager') - ] - ]); +// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: +// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. +$addMenuLinks = [ + [ + 'controller' => 'ad_hoc_attributes', + 'action' => 'add', + 'icon' => 'user_attributes', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'addresses', + 'action' => 'add', + 'icon' => 'contact_mail', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'telephone_numbers', + 'action' => 'add', + 'icon' => 'phone' + ] +]; - foreach([ - 'valid_from', - 'valid_through' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } -} +$subnav = [ + 'name' => 'person', + 'active' => 'external_identities', + 'subActive' => 'external_identity_roles' +]; \ No newline at end of file diff --git a/app/templates/ExternalIdentitySources/fields-nav.inc b/app/templates/ExternalIdentitySources/fields-nav.inc deleted file mode 100644 index c8b8d351b..000000000 --- a/app/templates/ExternalIdentitySources/fields-nav.inc +++ /dev/null @@ -1,39 +0,0 @@ - 'search', - 'order' => 'Default', - 'label' => __d('operation', 'ExternalIdentitySources.search'), - 'link' => [ - 'action' => 'search', - $vv_obj->id - ], - 'class' => '' - ] -]; diff --git a/app/templates/ExternalIdentitySources/fields.inc b/app/templates/ExternalIdentitySources/fields.inc index f0a7fb645..36b192c6d 100644 --- a/app/templates/ExternalIdentitySources/fields.inc +++ b/app/templates/ExternalIdentitySources/fields.inc @@ -24,29 +24,32 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -?> - [ - 'fieldName' => $field, - ] - ]; - if($field == 'status') { - $params['arguments']['fieldOptions'] = [ - 'default' => \App\Lib\Enum\SyncModeEnum::Disabled - ]; - } - print $this->element('form/listItem', $params); - } -} + +$fields = [ + 'description', + 'status' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => \App\Lib\Enum\SyncModeEnum::Disabled + ] + ], + 'plugin', + 'pipeline_id', + 'sor_label', + 'hash_source_record', + 'suppress_noop_logs' +]; + +// Top Links +$topLinks = [ + [ + 'icon' => 'search', + 'order' => 'Default', + 'label' => __d('operation', 'ExternalIdentitySources.search'), + 'link' => [ + 'action' => 'search', + $vv_obj->id + ], + 'class' => '' + ] +]; \ No newline at end of file diff --git a/app/templates/Flanges/fields.inc b/app/templates/Flanges/fields.inc index ab041494e..015913472 100644 --- a/app/templates/Flanges/fields.inc +++ b/app/templates/Flanges/fields.inc @@ -24,18 +24,10 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -?> -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} + +$fields = [ + 'description', + 'status', + 'plugin', + 'ordr' +]; diff --git a/app/templates/GroupMembers/fields-nav.inc b/app/templates/GroupMembers/fields-nav.inc deleted file mode 100644 index c18368a1f..000000000 --- a/app/templates/GroupMembers/fields-nav.inc +++ /dev/null @@ -1,29 +0,0 @@ - $vv_selected_person['id'] ]; - - // Present the person name in the view - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => '', - 'fieldLabel' => __d('field','name'), - 'groupmember' => $vv_selected_person - ] - ]); + // Present the person name in the view. Note that 'person_name' is not a real field. + // Because 'groupmember' is set in this field definition, this field information will be + // passed to the element/form/infoDiv/groupMember to display the Person name rather than + // generate a field. 'person_name' will be used only to set the class of the container
  • element. + $fields['person_name'] = [ + 'fieldLabel' => __d('field','name'), + 'groupmember' => $vv_selected_person + ]; } else { // Produce the autocomplete people selector on 'add' - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'person_id', - 'fieldOptions' => [ - 'class' => 'form-control people-autocomplete', - 'placeholder' => __d('operation','autocomplete.people.placeholder'), - 'id' => 'person_id', - ], - 'autocomplete' => [ - 'configuration' => [ - 'for' => 'GroupMembers', - 'action' => $vv_action, - 'groupId' => $this->getRequest()?->getQuery('group_id') - ] + $fields['person_id'] = [ + 'fieldOptions' => [ + 'class' => 'form-control people-autocomplete', + 'placeholder' => __d('operation','autocomplete.people.placeholder'), + 'id' => 'person_id', + ], + 'autocomplete' => [ + 'configuration' => [ + 'for' => 'GroupMembers', + 'action' => $vv_action, + 'groupId' => $this->getRequest()?->getQuery('group_id') ] ] - ]); + ]; } } else { $hidden = [ @@ -72,25 +70,17 @@ if($vv_action == 'add') { 'name' => $vv_obj->person->primary_name->full_name ]; $this->set('vv_selected_person', $selectedPerson); - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => '', - 'fieldLabel' => __d('field','name'), - 'groupmember' => $selectedPerson - ] - ]); + // See note in the 'add' section above regarding how 'person_name' is used. + // It is not a real field name. + $fields['person_name'] = [ + 'fieldLabel' => __d('field','name'), + 'groupmember' => $selectedPerson + ]; } -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'valid_from', - ] -]); - -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'valid_through', - ] +$fields = array_merge($fields, [ + 'valid_from', + 'valid_through' ]); // XXX RFE: Add links to EIS or Nesting info \ No newline at end of file diff --git a/app/templates/GroupNestings/fields.inc b/app/templates/GroupNestings/fields.inc index a82c8dc48..7c707e9e1 100644 --- a/app/templates/GroupNestings/fields.inc +++ b/app/templates/GroupNestings/fields.inc @@ -25,12 +25,12 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +$fields = []; + if($vv_action == 'add') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'target_group_id', - ] - ]); + $fields = [ + 'target_group_id' + ]; } elseif($vv_action == 'edit') { $link = [ 'url' => [ @@ -41,36 +41,25 @@ if($vv_action == 'add') { 'target' => '_top' ]; // The target group can't be changed after adding - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'target_group_id', + $fields = [ + 'target_group_id' => [ 'status' => $vv_obj->target_group->name, 'link' => $link ] - ]); -} - -if($vv_action == 'add' || $vv_action == 'edit') { - $link = [ - 'url' => [ - 'controller' => 'groups', - 'action' => 'edit', - $vv_bc_parent_obj->id, - ], - 'target' => '_top' ]; - // The target group can't be changed after adding - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'group_id', - 'status' => $vv_bc_parent_obj->name, - 'link' => $link - ] - ]); +} - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'negate', - ] - ]); -} \ No newline at end of file +$link = [ + 'url' => [ + 'controller' => 'groups', + 'action' => 'edit', + $vv_bc_parent_obj->id, + ], + 'target' => '_top' +]; +// The target group can't be changed after adding +$fields['group_id'] = [ + 'status' => $vv_bc_parent_obj->name, + 'link' => $link +]; +$fields[] = 'negate'; diff --git a/app/templates/Groups/fields-nav.inc b/app/templates/Groups/fields-nav.inc deleted file mode 100644 index 9067e576d..000000000 --- a/app/templates/Groups/fields-nav.inc +++ /dev/null @@ -1,152 +0,0 @@ - 'history', - 'order' => 'Default', - 'label' => __d('controller', 'HistoryRecords', [99]), - 'link' => [ - 'controller' => 'history_records', - 'action' => 'index', - '?' => [ - 'group_id' => $vv_obj->id - ] - ], - 'class' => '' - ], - [ - 'icon' => 'cloud_sync', - 'order' => 'Default', - 'label' => __d('operation', 'provisioning.status'), - 'link' => [ - 'controller' => 'provisioning_targets', - 'action' => 'status', - '?' => [ - 'group_id' => $vv_obj->id - ] - ], - 'class' => '' - ], - [ - 'icon' => 'badge', - 'order' => 'Default', - 'label' => __d('operation', 'identifiers.assign'), - 'link' => [ - 'controller' => 'identifier_assignments', - 'action' => 'assign', - '?' => [ - 'group_id' => $vv_obj->id - ] - ], - 'if' => 'notAutomatic', - 'confirm' => [ - 'dg_body_txt' => __d('operation', 'identifiers.assign.confirm',[$vv_obj->id]), - 'dg_confirm_btn' => __d('operation', 'assign') - ], - 'class' => '' - ], - [ - 'icon' => 'sync', - 'order' => 'Default', - 'label' => __d('operation', 'reconcile'), - 'link' => [ - 'action' => 'reconcile', - $vv_obj->id - ], - 'confirm' => [ - 'dg_body_txt' => __d('operation', 'reconcile.confirm', [$vv_obj->id]), - 'dg_confirm_btn' => __d('operation', 'reconcile') - ], - 'class' => '' - ] -]; - -if(!$vv_obj->isOwners()) { - // Most actions aren't available for Owners Groups - $topLinks += [ - [ - 'icon' => 'cloud_sync', - 'order' => 'Default', - 'label' => __d('operation', 'provisioning.status'), - 'link' => [ - 'controller' => 'provisioning_targets', - 'action' => 'status', - '?' => [ - 'group_id' => $vv_obj->id - ] - ], - 'class' => '' - ], - [ - 'icon' => 'badge', - 'order' => 'Default', - 'label' => __d('operation', 'identifiers.assign'), - 'link' => [ - 'controller' => 'identifier_assignments', - 'action' => 'assign', - '?' => [ - 'group_id' => $vv_obj->id - ] - ], - 'class' => '' - ], - [ - 'icon' => 'sync', - 'order' => 'Default', - 'label' => __d('operation', 'reconcile'), - 'link' => [ - 'action' => 'reconcile', - $vv_obj->id - ], - 'class' => '' - ] - ]; -} - -// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: -// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. - -if(!$vv_obj->isOwners()) { - $addMenuLinks = [ - [ - 'controller' => 'identifiers', - 'action' => 'add', - 'icon' => 'fingerprint' - ] - ]; -} diff --git a/app/templates/Groups/fields.inc b/app/templates/Groups/fields.inc index c55299873..69309f430 100644 --- a/app/templates/Groups/fields.inc +++ b/app/templates/Groups/fields.inc @@ -32,50 +32,179 @@ if($vv_obj->isOwners()) { $options['readonly'] = true; } -foreach(['name', - 'description', - 'status', - 'open', - 'nesting_mode_all'] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - 'fieldOptions' => $options - ] - ]); -} +$fields = [ + 'name' => [ + // XXX flatten fieldOptions + 'fieldOptions' => $options + ], + 'description' => [ + // XXX flatten fieldOptions + 'fieldOptions' => $options + ], + 'status' => [ + // XXX flatten fieldOptions + 'fieldOptions' => $options + ], + 'open' => [ + // XXX flatten fieldOptions + 'fieldOptions' => $options + ], + 'nesting_mode_all' => [ + // XXX flatten fieldOptions + 'fieldOptions' => $options + ] +]; if($vv_action != 'add') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'group_type', - 'fieldOptions' => [ - 'readonly' => true - ] + $fields['group_type'] = [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'readonly' => true ] - ]); + ]; if($vv_obj->isOwners()) { // Link to the main group if(!empty($vv_obj->owners_for_group)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'owners_group_id', - 'status' => $vv_obj->owners_for_group->name, - 'link' => ['url' => ['controller' => 'groups', 'action' => 'edit', $vv_obj->owners_for_group->id]], - 'labelIsTextOnly' => true - ] - ]); + $fields['owners_group_id'] = [ + 'fieldLabel' => 'Members Group', + 'status' => $vv_obj->owners_for_group->name, + 'link' => ['url' => ['controller' => 'groups', 'action' => 'edit', $vv_obj->owners_for_group->id]], + 'labelIsTextOnly' => true + ]; } } else { // Link to the owners group - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'owners_group_id', - 'status' => $vv_obj->owners_group->name ?? '', - 'link' => ['url' => ['controller' => 'groups', 'action' => 'edit', $vv_obj->owners_group_id]], - 'labelIsTextOnly' => true - ] - ]); + $fields['owners_group_id'] = [ + 'status' => $vv_obj->owners_group->name ?? '', + 'link' => ['url' => ['controller' => 'groups', 'action' => 'edit', $vv_obj->owners_group_id]], + 'labelIsTextOnly' => true + ]; } } + +// List the MVEAs that may be shown on the mveaCanvas +// When this array exists, the mveaCanvas.php element will render +$mveas = [ + 'identifiers' +]; + +// Name the MVEAs Entity Type +$mveasEntityType = "group"; + +// XXX: if CFM-218 (Make fields.inc configuration only) is accepted, move the contents of this file into fields.inc +$topLinks = [ + [ + 'icon' => 'history', + 'order' => 'Default', + 'label' => __d('controller', 'HistoryRecords', [99]), + 'link' => [ + 'controller' => 'history_records', + 'action' => 'index', + '?' => [ + 'group_id' => $vv_obj->id + ] + ], + 'class' => '' + ], + [ + 'icon' => 'cloud_sync', + 'order' => 'Default', + 'label' => __d('operation', 'provisioning.status'), + 'link' => [ + 'controller' => 'provisioning_targets', + 'action' => 'status', + '?' => [ + 'group_id' => $vv_obj->id + ] + ], + 'class' => '' + ], + [ + 'icon' => 'badge', + 'order' => 'Default', + 'label' => __d('operation', 'identifiers.assign'), + 'link' => [ + 'controller' => 'identifier_assignments', + 'action' => 'assign', + '?' => [ + 'group_id' => $vv_obj->id + ] + ], + 'if' => 'notAutomatic', + 'confirm' => [ + 'dg_body_txt' => __d('operation', 'identifiers.assign.confirm',[$vv_obj->id]), + 'dg_confirm_btn' => __d('operation', 'assign') + ], + 'class' => '' + ], + [ + 'icon' => 'sync', + 'order' => 'Default', + 'label' => __d('operation', 'reconcile'), + 'link' => [ + 'action' => 'reconcile', + $vv_obj->id + ], + 'confirm' => [ + 'dg_body_txt' => __d('operation', 'reconcile.confirm', [$vv_obj->id]), + 'dg_confirm_btn' => __d('operation', 'reconcile') + ], + 'class' => '' + ] +]; + +if(!$vv_obj->isOwners()) { + // Most actions aren't available for Owners Groups + $topLinks += [ + [ + 'icon' => 'cloud_sync', + 'order' => 'Default', + 'label' => __d('operation', 'provisioning.status'), + 'link' => [ + 'controller' => 'provisioning_targets', + 'action' => 'status', + '?' => [ + 'group_id' => $vv_obj->id + ] + ], + 'class' => '' + ], + [ + 'icon' => 'badge', + 'order' => 'Default', + 'label' => __d('operation', 'identifiers.assign'), + 'link' => [ + 'controller' => 'identifier_assignments', + 'action' => 'assign', + '?' => [ + 'group_id' => $vv_obj->id + ] + ], + 'class' => '' + ], + [ + 'icon' => 'sync', + 'order' => 'Default', + 'label' => __d('operation', 'reconcile'), + 'link' => [ + 'action' => 'reconcile', + $vv_obj->id + ], + 'class' => '' + ] + ]; +} + +// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: +// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. + +if(!$vv_obj->isOwners()) { + $addMenuLinks = [ + [ + 'controller' => 'identifiers', + 'action' => 'add', + 'icon' => 'fingerprint' + ] + ]; +} diff --git a/app/templates/HistoryRecords/fields.inc b/app/templates/HistoryRecords/fields.inc index d4ac9479d..248c22987 100644 --- a/app/templates/HistoryRecords/fields.inc +++ b/app/templates/HistoryRecords/fields.inc @@ -27,10 +27,10 @@ // This view does not support edit if($vv_action == 'add' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'comment', - ]]); + + $fields = [ + 'comment' + ]; if($vv_action == 'add') { // On manual add insert action @@ -42,10 +42,8 @@ if($vv_action == 'add' || $vv_action == 'view') { } if($vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'action', - ]]); + + $fields[] = 'action'; if(!empty($vv_obj->person->primary_name)) { $viewLink = [ @@ -56,13 +54,10 @@ if($vv_action == 'add' || $vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'person_id', - 'status' => $vv_obj->person->primary_name->full_name, - 'link' => $viewLink - ] - ]); + $fields['person_id'] = [ + 'status' => $vv_obj->person->primary_name->full_name, + 'link' => $viewLink + ]; } if(!empty($vv_obj->person_role_id)) { @@ -74,13 +69,10 @@ if($vv_action == 'add' || $vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'person_role_id', - 'status' => $vv_obj->person_role_id, - 'link' => $viewLink - ] - ]); + $fields['person_role_id'] = [ + 'status' => $vv_obj->person_role_id, + 'link' => $viewLink + ]; } if(!empty($vv_obj->external_identity)) { @@ -92,13 +84,10 @@ if($vv_action == 'add' || $vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_id', - 'status' => !empty($vv_obj->external_identity->names[0]) ? $vv_obj->external_identity->names[0]->full_name : $vv_obj->external_identity->id, - 'link' => $viewLink - ] - ]); + $fields['external_identity_id'] = [ + 'status' => !empty($vv_obj->external_identity->names[0]) ? $vv_obj->external_identity->names[0]->full_name : $vv_obj->external_identity->id, + 'link' => $viewLink + ]; } if(!empty($vv_obj->external_identity_role_id)) { @@ -110,13 +99,10 @@ if($vv_action == 'add' || $vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_role_id', - 'status' => $vv_obj->external_identity_role_id, - 'link' => $viewLink - ] - ]); + $fields['external_identity_role_id'] = [ + 'status' => $vv_obj->external_identity_role_id, + 'link' => $viewLink + ]; } if(!empty($vv_obj->group_id)) { @@ -128,13 +114,10 @@ if($vv_action == 'add' || $vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'group_id', - 'status' => $vv_obj->group->name, - 'link' => $viewLink - ] - ]); + $fields['group_id'] = [ + 'status' => $vv_obj->group->name, + 'link' => $viewLink + ]; } if(!empty($vv_obj->actor_person->names)) { @@ -146,19 +129,13 @@ if($vv_action == 'add' || $vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'actor_person_id', - 'status' => $vv_obj->actor_person->names[0]->full_name, - 'link' => $viewLink, - 'fieldLabel' => __d('field', 'actor') - ] - ]); + $fields['actor_person_id'] = [ + 'status' => $vv_obj->actor_person->names[0]->full_name, + 'link' => $viewLink, + 'fieldLabel' => __d('field', 'actor') + ]; } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'created', - ]]); + $fields[] = 'created'; } } diff --git a/app/templates/IdentifierAssignments/fields.inc b/app/templates/IdentifierAssignments/fields.inc index 93ca8e381..db324c229 100644 --- a/app/templates/IdentifierAssignments/fields.inc +++ b/app/templates/IdentifierAssignments/fields.inc @@ -24,8 +24,23 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'description', + 'status', + 'plugin', + 'context', + 'identifier_type_id', + 'login', + 'email_address_type_id', + 'group_id', + 'allow_empty', + 'ordr' +]; + ?> - - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ]]); - } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'context', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'identifier_type_id', - 'fieldOptions' => [ - 'onChange' => 'resetType("email-address-type-id")' - ] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'login' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'email_address_type_id', - 'fieldOptions' => [ - 'onChange' => 'resetType("identifier-type-id")' - ] - ] - ]); - - foreach(['group_id', - 'allow_empty', - 'ordr' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ]]); - } -} \ No newline at end of file + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#context').change(function() { + updateGadgets(); + }); + $('#identifier-type-id').change(function() { + resetType("email-address-type-id"); + }); + $('#email-address-type-id').change(function() { + resetType("identifier_type_id"); + }); + }); + diff --git a/app/templates/Identifiers/fields-nav.inc b/app/templates/Identifiers/fields-nav.inc deleted file mode 100644 index 59f806711..000000000 --- a/app/templates/Identifiers/fields-nav.inc +++ /dev/null @@ -1,45 +0,0 @@ -identifier) && $vv_obj->isLogin()) { - $topLinks = [ - [ - 'icon' => 'lock', - 'order' => 'Default', - 'label' => __d('controller', 'AuthenticationEvents', [99]), - 'link' => [ - 'controller' => 'authentication_events', - 'action' => 'index', - '?' => [ - 'authenticated_identifier' => - \App\Lib\Util\StringUtilities::urlbase64encode($vv_obj->identifier) - ] - ], - 'class' => '' - ] - ]; -} \ No newline at end of file diff --git a/app/templates/Identifiers/fields.inc b/app/templates/Identifiers/fields.inc index 5d0b03a34..5633b81f1 100644 --- a/app/templates/Identifiers/fields.inc +++ b/app/templates/Identifiers/fields.inc @@ -25,46 +25,52 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'identifier', - ]]); +$fields = [ + 'identifier', + 'type_id' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => $vv_default_type + ] + ] +]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'default' => $vv_default_type - ] - ]]); - if($vv_primary_link_attr == 'person_id') { - // AR-Identifier-1 Only Persons can have a login flag - 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->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status', - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'frozen' - ]]); +if($vv_primary_link_attr == 'person_id') { + // AR-Identifier-1 Only Persons can have a login flag + $fields[] = 'login'; +} else { + // Will be used by add-edit-view.php to append the hidden fields in the form + $hidden['login'] = false; } +$fields = array_merge($fields, [ + 'status', + 'frozen' +]); + if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = [ + 'entity' => $vv_obj + ]; } + +// Top Links +if(!empty($vv_obj->identifier) && $vv_obj->isLogin()) { + $topLinks = [ + [ + 'icon' => 'lock', + 'order' => 'Default', + 'label' => __d('controller', 'AuthenticationEvents', [99]), + 'link' => [ + 'controller' => 'authentication_events', + 'action' => 'index', + '?' => [ + 'authenticated_identifier' => + \App\Lib\Util\StringUtilities::urlbase64encode($vv_obj->identifier) + ] + ], + 'class' => '' + ] + ]; +} \ No newline at end of file diff --git a/app/templates/JobHistoryRecords/fields.inc b/app/templates/JobHistoryRecords/fields.inc index f742fcdaf..ce904da6e 100644 --- a/app/templates/JobHistoryRecords/fields.inc +++ b/app/templates/JobHistoryRecords/fields.inc @@ -25,20 +25,18 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +$fields = []; + // This view does not support add or edit if($vv_action == 'view') { - foreach(['record_key', - 'comment', - 'status' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } -// Rewrite these to always emit the column even if the field is blank + $fields = [ + 'record_key', + 'comment', + 'status' + ]; + + // Rewrite these to always emit the column even if the field is blank if(!empty($vv_obj->person->primary_name)) { $viewLink = [ 'url' => [ @@ -48,13 +46,10 @@ if($vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'person_id', - 'status' => $vv_obj->person->primary_name->full_name, - 'link' => $viewLink, - ] - ]); + $fields['person_id'] = [ + 'status' => $vv_obj->person->primary_name->full_name, + 'link' => $viewLink, + ]; } if(!empty($vv_obj->external_identity->primary_name)) { @@ -66,18 +61,11 @@ if($vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'external_identity_id', - 'status' => $vv_obj->external_identity->primary_name->full_name, - 'link' => $viewLink, - ] - ]); + $fields['external_identity_id'] = [ + 'status' => $vv_obj->external_identity->primary_name->full_name, + 'link' => $viewLink, + ]; } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'created' - ] - ]); + $fields[] = 'created'; } diff --git a/app/templates/Jobs/fields-nav.inc b/app/templates/Jobs/fields-nav.inc deleted file mode 100644 index 2cb97142b..000000000 --- a/app/templates/Jobs/fields-nav.inc +++ /dev/null @@ -1,56 +0,0 @@ - 'history', - 'order' => 'Default', - 'label' => __d('controller', 'JobHistoryRecords', [99]), - 'link' => [ - 'controller' => 'job_history_records', - 'action' => 'index', - 'job_id' => $vv_obj->id - ], - 'class' => '' -]; - -if(!empty($vv_obj) && $vv_obj->canCancel()) { - $topLinks[] = [ - 'icon' => 'cancel', - 'order' => 'Default', - 'label' => __d('operation', 'cancel'), - 'link' => [ - 'action' => 'cancel', - $vv_obj->id - ], - 'confirm' => [ - 'dg_body_txt' => __d('operation', 'Jobs.cancel.confirm', [$vv_obj->id]), - 'dg_confirm_btn' => __d('operation', 'confirm.yes'), - 'dg_cancel_btn' => __d('operation', 'confirm.no') - ], - 'class' => '' - ]; -} \ No newline at end of file diff --git a/app/templates/Jobs/fields.inc b/app/templates/Jobs/fields.inc index a6e16d5f2..b876c0742 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -25,151 +25,81 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +$fields = []; + // This view does not support edit if($vv_action == 'add') { // We are registering a Job, so the fields we accept are somewhat limited/different // from view - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'plugin', + $fields = [ + 'plugin' => [ 'fieldLabel' => __d('controller', 'Jobs', [1]) ] - ]); + ]; } elseif($vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'plugin', + $fields = [ + 'plugin' => [ 'fieldLabel' => __d('controller', 'Jobs', [1]), + // XXX flatten fieldOptions 'fieldOptions' => [ 'type' => 'text' ] ] - ]); + ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' - ] - ]); + $fields[] = 'status'; if($vv_obj->status == \App\Lib\Enum\JobStatusEnum::InProgress) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'percent_complete', - 'status' => (string)$vv_obj->percent_complete - ] - ]); + $fields['percent_complete'] = [ + 'status' => (string)$vv_obj->percent_complete + ]; } - - // Establish the supplemental field wrappers for the parameters field - $beforeField = - '
    -
    - - -
    -
    '; - - $afterField = - ''; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'parameters', + $fields = array_merge($fields, [ + 'parameters' => [ + // Establish the supplemental field wrappers for the parameters field + 'beforeField' => + '
    +
    + + +
    +
    ', + 'afterField' => + '' ], - 'beforeField' => $beforeField, - 'afterField' => $afterField - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'register_time', - 'labelIsTextOnly' => true - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'register_summary' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'register_time', + 'register_time' => [ 'labelIsTextOnly' => true - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'assigned_host' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'assigned_pid' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'start_after_time', + ], + 'register_summary', + 'assigned_host', + 'assigned_pid', + 'start_after_time' => [ 'labelIsTextOnly' => true - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'start_time', + ], + 'start_time' => [ 'labelIsTextOnly' => true - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'start_summary' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'finish_time', + ], + 'start_summary', + 'finish_time' => [ 'labelIsTextOnly' => true - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'finish_summary' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'requeue_interval' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'retry_interval' - ] + ], + 'finish_summary', + 'requeue_interval', + 'retry_interval' ]); if(!empty($vv_obj->requeued_from_job->id)) { @@ -180,12 +110,40 @@ if($vv_action == 'add') { $vv_obj->requeued_from_job->id ] ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'requeued_from_job_id', - 'status' => (string)$vv_obj->requeued_from_job->id, - 'link' => $link, - ] - ]); + $fields['requeued_from_job_id'] = [ + 'status' => (string)$vv_obj->requeued_from_job->id, + 'link' => $link, + ]; } } + +// Top Links +$topLinks[] = [ + 'icon' => 'history', + 'order' => 'Default', + 'label' => __d('controller', 'JobHistoryRecords', [99]), + 'link' => [ + 'controller' => 'job_history_records', + 'action' => 'index', + 'job_id' => $vv_obj->id + ], + 'class' => '' +]; + +if(!empty($vv_obj) && $vv_obj->canCancel()) { + $topLinks[] = [ + 'icon' => 'cancel', + 'order' => 'Default', + 'label' => __d('operation', 'cancel'), + 'link' => [ + 'action' => 'cancel', + $vv_obj->id + ], + 'confirm' => [ + 'dg_body_txt' => __d('operation', 'Jobs.cancel.confirm', [$vv_obj->id]), + 'dg_confirm_btn' => __d('operation', 'confirm.yes'), + 'dg_cancel_btn' => __d('operation', 'confirm.no') + ], + 'class' => '' + ]; +} diff --git a/app/templates/MessageTemplates/fields.inc b/app/templates/MessageTemplates/fields.inc index db5e7a712..745c39721 100644 --- a/app/templates/MessageTemplates/fields.inc +++ b/app/templates/MessageTemplates/fields.inc @@ -24,15 +24,42 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'description', + 'status', + 'context', + 'format', + 'subject', + 'body_text' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'class' => 'big-textarea' + ] + ], + 'body_html' => [ + 'afterField' => + '', + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'class' => 'big-textarea' + ] + ], + 'cc', + 'bcc', + 'reply_to' +]; ?> - + - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'format', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'subject' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'body_text', - 'fieldOptions' => [ - 'class' => 'big-textarea' - ] - ] - ]); - $afterField = - ''; - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'body_html', - 'fieldOptions' => [ - 'class' => 'big-textarea' - ] - ], - 'afterField' => $afterField - ]); + $(function() { + // run on first load + updateGadgets(true); - foreach ([ - 'cc', - 'bcc', - 'reply_to', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#format').change(function() { + updateGadgets(); + }); + }); + diff --git a/app/templates/MostlyStaticPages/fields-nav.inc b/app/templates/MostlyStaticPages/fields-nav.inc deleted file mode 100644 index 5145147b7..000000000 --- a/app/templates/MostlyStaticPages/fields-nav.inc +++ /dev/null @@ -1,36 +0,0 @@ - 'arrow_outward', - 'order' => 'Default', - 'label' => __d('operation', 'view'), - 'url' => $vv_base_url . '/' . $vv_obj->name, - 'class' => '' - ]; -} diff --git a/app/templates/MostlyStaticPages/fields.inc b/app/templates/MostlyStaticPages/fields.inc index 95a432a45..b0d79180b 100644 --- a/app/templates/MostlyStaticPages/fields.inc +++ b/app/templates/MostlyStaticPages/fields.inc @@ -25,8 +25,44 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +$fields = [ + 'title', + 'name', + 'pageUrl' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'readOnly' => true + ] + ], + 'description', + 'status', + 'context', + 'body' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'class' => 'big-textarea' + ], + 'afterField' => + '' + ] +]; + +// Top Links +if($vv_action == 'edit') { + $topLinks[] = [ + 'icon' => 'arrow_outward', + 'order' => 'Default', + 'label' => __d('operation', 'view'), + 'url' => $vv_base_url . '/' . $vv_obj->name, + 'class' => '' + ]; +} ?> - - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'title' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'name', - 'fieldOptions' => [ - 'onChange' => 'jsLocalOnLoad()' - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'pageUrl', - 'fieldOptions' => [ - 'readOnly' => true - ] - ]]); - foreach ([ - 'description', - 'status', - 'context' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } + $(function() { + // run on first load + setPageUrl(); - $afterField = - ''; - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'body', - 'fieldOptions' => [ - 'class' => 'big-textarea' - ] - ], - 'afterField' => $afterField - ]); -} \ No newline at end of file + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#name').change(function() { + setPageUrl(); + }); + }); + diff --git a/app/templates/Names/fields.inc b/app/templates/Names/fields.inc index f4a19b41d..e17be4f4b 100644 --- a/app/templates/Names/fields.inc +++ b/app/templates/Names/fields.inc @@ -25,60 +25,40 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - // Dynamic required fields is automatically handled by FormHelper via the - // validation rules, but we need to manually check permitted fields. +$fields = []; - foreach(['honorific', 'given', 'middle', 'family', 'suffix'] as $f) { - if(in_array($f, $vv_permitted_fields)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $f - ]]); - } +// Dynamic required fields are automatically handled by FormHelper via the +// validation rules, but we need to manually check permitted fields. +foreach(['honorific', 'given', 'middle', 'family', 'suffix'] as $f) { + if(in_array($f, $vv_permitted_fields)) { + $fields[] = $f; } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'default' => $vv_default_type - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'language' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => '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->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'description', - 'fieldOptions' => [ - 'readonly' => $vv_obj->primary_name - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'frozen' - ]]); - } +$fields = array_merge($fields, [ + 'type_id' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => $vv_default_type + ] + ], + 'language', + 'display_name', + 'primary_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. + + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'readonly' => $vv_obj->primary_name + ] + ], + 'frozen' +]); + if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = [ + 'entity' => $vv_obj + ]; } \ No newline at end of file diff --git a/app/templates/Notifications/fields-nav.inc b/app/templates/Notifications/fields-nav.inc deleted file mode 100644 index 654b7b7fb..000000000 --- a/app/templates/Notifications/fields-nav.inc +++ /dev/null @@ -1,62 +0,0 @@ -canCancel()) { - $topLinks[] = [ - 'icon' => 'cancel', - 'order' => 'Default', - 'label' => __d('operation', 'cancel'), - 'link' => [ - 'action' => 'cancel', - $vv_obj->id - ], - 'confirm' => [ - 'dg_body_txt' => __d('operation', 'Notifications.cancel.confirm'), - 'dg_cancel_btn' => __d('enumeration', 'YesBooleanEnum.0'), - 'dg_confirm_btn' => __d('enumeration', 'YesBooleanEnum.1') - ], - 'class' => '' - ]; -} - -if(!empty($vv_obj) && $vv_obj->canNotify()) { - $topLinks[] = [ - 'icon' => 'send', - 'order' => 'Default', - 'label' => __d('operation', 'resend'), - 'link' => [ - 'action' => 'resend', - $vv_obj->id - ], - 'confirm' => [ - 'dg_body_txt' => __d('operation', 'Notifications.resend.confirm'), - 'dg_cancel_btn' => __d('enumeration', 'YesBooleanEnum.0'), - 'dg_confirm_btn' => __d('enumeration', 'YesBooleanEnum.1') - ], - 'class' => '' - ]; -} \ No newline at end of file diff --git a/app/templates/Notifications/fields.inc b/app/templates/Notifications/fields.inc index 769b6428b..300473aa7 100644 --- a/app/templates/Notifications/fields.inc +++ b/app/templates/Notifications/fields.inc @@ -26,144 +26,138 @@ */ use \App\Lib\Enum\NotificationStatusEnum; -?> -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } + + $fields = [ + 'comment', + 'action', + 'source', + 'created', + ]; if($vv_obj->status == NotificationStatusEnum::PendingAcknowledgment) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status', - 'status' => __d('enumeration', 'NotificationStatusEnum.PA'), - 'link' => [ - 'url' => [ - 'action' => 'acknowledge', - $vv_obj->id - ], - 'label' => __d('operation', 'acknowledge'), - 'confirm' => __d('operation', 'Notifications.acknowledge.confirm') - ] - ] - ]); + $fields['status'] = [ + 'status' => __d('enumeration', 'NotificationStatusEnum.PA'), + 'link' => [ + 'url' => [ + 'action' => 'acknowledge', + $vv_obj->id + ], + 'label' => __d('operation', 'acknowledge'), + 'confirm' => __d('operation', 'Notifications.acknowledge.confirm') + ] + ]; } else { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' - ]]); + $fields[] = 'status'; } - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'subject_person_id', - 'status' => $vv_obj->subject_person->primary_name?->full_name ?? '', - 'link' => !empty($vv_obj->subject_person) - ? ['url' => [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->subject_person->id - ]] - : [] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'subject_group_id', + $fields = array_merge($fields, [ + 'subject_person_id' => [ + 'status' => $vv_obj->subject_person->primary_name?->full_name ?? '', + 'link' => !empty($vv_obj->subject_person) + ? ['url' => [ + 'controller' => 'people', + 'action' => 'edit', + $vv_obj->subject_person->id + ]] + : [] + ], + 'subject_group_id' => [ 'status' => $vv_obj->subject_group->name ?? '', 'link' => !empty($vv_obj->subject_group) - ? ['url' => [ - 'controller' => 'groups', - 'action' => 'edit', - $vv_obj->subject_group->id - ]] - : [] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'recipient_person_id', + ? ['url' => [ + 'controller' => 'groups', + 'action' => 'edit', + $vv_obj->subject_group->id + ]] + : [] + ], + 'recipient_person_id' => [ 'status' => $vv_obj->recipient_person->primary_name?->full_name ?? '', 'link' => !empty($vv_obj->recipient_person) - ? ['url' => [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->recipient_person->id - ]] - : [] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'recipient_group_id', + ? ['url' => [ + 'controller' => 'people', + 'action' => 'edit', + $vv_obj->recipient_person->id + ]] + : [] + ], + 'recipient_group_id' => [ 'status' => $vv_obj->recipient_group->name ?? '', 'link' => !empty($vv_obj->recipient_group) - ? ['url' => [ - 'controller' => 'groups', - 'action' => 'edit', - $vv_obj->recipient_group->id - ]] - : [] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'actor_person_id', + ? ['url' => [ + 'controller' => 'groups', + 'action' => 'edit', + $vv_obj->recipient_group->id + ]] + : [] + ], + 'actor_person_id' => [ 'status' => $vv_obj->actor_person->primary_name?->full_name ?? '', 'link' => !empty($vv_obj->actor_person) - ? ['url' => [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->actor_person->id - ]] - : [] - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'resolution_time', - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'resolver_person_id', + ? ['url' => [ + 'controller' => 'people', + 'action' => 'edit', + $vv_obj->actor_person->id + ]] + : [] + ], + 'resolution_time', + 'resolver_person_id' => [ 'status' => $vv_obj->resolver_person->primary_name?->full_name ?? '', 'link' => !empty($vv_obj->resolver_person) - ? ['url' => [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->resolver_person->id - ]] - : [] - ] + ? ['url' => [ + 'controller' => 'people', + 'action' => 'edit', + $vv_obj->resolver_person->id + ]] + : [] + ], + 'notification_time', + 'email_subject', + 'email_body_text', + 'resolution_subject', + 'resolution_body' ]); +} - foreach ([ - 'notification_time', - 'email_subject', - 'email_body_text', - 'resolution_subject', - 'resolution_body', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } +// Top Links +if(!empty($vv_obj) && $vv_obj->canCancel()) { + $topLinks[] = [ + 'icon' => 'cancel', + 'order' => 'Default', + 'label' => __d('operation', 'cancel'), + 'link' => [ + 'action' => 'cancel', + $vv_obj->id + ], + 'confirm' => [ + 'dg_body_txt' => __d('operation', 'Notifications.cancel.confirm'), + 'dg_cancel_btn' => __d('enumeration', 'YesBooleanEnum.0'), + 'dg_confirm_btn' => __d('enumeration', 'YesBooleanEnum.1') + ], + 'class' => '' + ]; +} + +if(!empty($vv_obj) && $vv_obj->canNotify()) { + $topLinks[] = [ + 'icon' => 'send', + 'order' => 'Default', + 'label' => __d('operation', 'resend'), + 'link' => [ + 'action' => 'resend', + $vv_obj->id + ], + 'confirm' => [ + 'dg_body_txt' => __d('operation', 'Notifications.resend.confirm'), + 'dg_cancel_btn' => __d('enumeration', 'YesBooleanEnum.0'), + 'dg_confirm_btn' => __d('enumeration', 'YesBooleanEnum.1') + ], + 'class' => '' + ]; } diff --git a/app/templates/People/fields-nav.inc b/app/templates/People/fields-nav.inc deleted file mode 100644 index 9f4b6f856..000000000 --- a/app/templates/People/fields-nav.inc +++ /dev/null @@ -1,175 +0,0 @@ - 'history', - 'order' => 'Default', - 'label' => __d('controller', 'HistoryRecords', [99]), - 'link' => [ - 'controller' => 'history_records', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - 'class' => '' - ], - [ - 'icon' => 'cloud_sync', - 'order' => 'Default', - 'label' => __d('operation', 'provisioning.status'), - 'link' => [ - 'controller' => 'provisioning_targets', - 'action' => 'status', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - 'class' => '' - ], - [ - 'icon' => 'lock', - 'order' => 'Default', - // We use "Authenticators" as the label because it's less confusiong - 'label' => __d('controller', 'Authenticators', [99]), - 'link' => [ - 'controller' => 'authenticator_statuses', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - 'class' => '' - ], - [ - 'icon' => 'notifications', - 'iconClass' => 'material-symbols-outlined', - 'order' => 'Default', - 'label' => __d('controller', 'Notifications', [99]), - 'link' => [ - 'controller' => 'notifications', - 'action' => 'index', - '?' => [ - 'subject_person_id' => $vv_obj->id -// XXX person_id is auto-inserted but isn't needed - ] - ], - 'class' => '' - ], - [ - 'icon' => 'badge', - 'iconClass' => 'material-symbols-outlined', - 'order' => 'Default', - 'label' => __d('operation', 'identifiers.assign'), - 'link' => [ - 'controller' => 'identifier_assignments', - 'action' => 'assign', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - 'confirm' => [ - 'dg_body_txt' => __d('operation', 'identifiers.assign.confirm', [$vv_obj->id]), - 'dg_confirm_btn' => __d('operation', 'assign') - ], - 'class' => '' - ] -]; - -// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: -// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. -$addMenuLinks = [ - [ - 'controller' => 'names', - 'action' => 'add', - 'icon' => 'account_box', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'email_addresses', - 'action' => 'add', - 'icon' => 'email', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'identifiers', - 'action' => 'add', - 'icon' => 'fingerprint' - ], - [ - 'controller' => 'ad_hoc_attributes', - 'action' => 'add', - 'icon' => 'user_attributes', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'addresses', - 'action' => 'add', - 'icon' => 'contact_mail', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'pronouns', - 'action' => 'add', - 'icon' => '3p', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'telephone_numbers', - 'action' => 'add', - 'icon' => 'phone' - ], - [ - 'controller' => 'urls', - 'action' => 'add', - 'icon' => 'link' - ] -]; - -$subnav = [ - 'name' => 'person', - 'active' => 'person', - 'subActive' => 'properties' -]; \ No newline at end of file diff --git a/app/templates/People/fields.inc b/app/templates/People/fields.inc index d479e5c2a..be3301fad 100644 --- a/app/templates/People/fields.inc +++ b/app/templates/People/fields.inc @@ -25,7 +25,8 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -// This view does not currently support read-only +$fields = []; + if($vv_action == 'add') { // Adding a new CO Person is a bit non-standard vs most views. We need a // Primary Name (which we'll collect here) along with possibly collecting @@ -33,26 +34,23 @@ if($vv_action == 'add') { foreach(['honorific', 'given', 'middle', 'family', 'suffix'] as $f) { if(in_array($f, $vv_permitted_name_fields)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'names.0.'.$f, - 'fieldOptions' => [ - 'required' => in_array($f, $vv_required_name_fields) - ], - 'fieldType' => 'string' - ]]); + $fields['names.0.'.$f] = [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'required' => in_array($f, $vv_required_name_fields) + ], + 'fieldType' => 'string' + ]; } } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'names.0.type_id', - 'fieldOptions' => [ - 'default' => $vv_default_name_type, - 'required' => true - ], - 'fieldType' => 'string' - ]]); + + $fields['names.0.type_id'] = [ + 'fieldOptions' => [ + 'default' => $vv_default_name_type, + 'required' => true + ], + 'fieldType' => 'string' + ]; // AR-Name-1 Since this is the first name for this Person, it must be // designated primary @@ -65,13 +63,155 @@ if($vv_action == 'add') { } if($vv_action == 'add' || $vv_action == 'edit') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' - ]]); + $fields[] = 'status'; + $fields[] = 'date_of_birth'; +} + +// List the MVEAs that may be shown on the mveaCanvas +// When this array exists, the mveaCanvas.php element will render +$mveas = [ + 'names', + 'email_addresses', + 'identifiers', + 'ad_hoc_attributes', + 'addresses', + 'telephone_numbers', + 'urls', + 'pronouns' +]; + +// Name the MVEAs Entity Type +$mveasEntityType = "person"; + +// Output for $topLinks from this specific configuration is presented in the mveaCanvas.php "Actions" menu. +$topLinks = [ + [ + 'icon' => 'history', + 'order' => 'Default', + 'label' => __d('controller', 'HistoryRecords', [99]), + 'link' => [ + 'controller' => 'history_records', + 'action' => 'index', + '?' => [ + 'person_id' => $vv_obj->id + ] + ], + 'class' => '' + ], + [ + 'icon' => 'cloud_sync', + 'order' => 'Default', + 'label' => __d('operation', 'provisioning.status'), + 'link' => [ + 'controller' => 'provisioning_targets', + 'action' => 'status', + '?' => [ + 'person_id' => $vv_obj->id + ] + ], + 'class' => '' + ], + [ + 'icon' => 'lock', + 'order' => 'Default', + // We use "Authenticators" as the label because it's less confusiong + 'label' => __d('controller', 'Authenticators', [99]), + 'link' => [ + 'controller' => 'authenticator_statuses', + 'action' => 'index', + '?' => [ + 'person_id' => $vv_obj->id + ] + ], + 'class' => '' + ], + [ + 'icon' => 'notifications', + 'iconClass' => 'material-symbols-outlined', + 'order' => 'Default', + 'label' => __d('controller', 'Notifications', [99]), + 'link' => [ + 'controller' => 'notifications', + 'action' => 'index', + '?' => [ + 'subject_person_id' => $vv_obj->id + // XXX person_id is auto-inserted but isn't needed + ] + ], + 'class' => '' + ], + [ + 'icon' => 'badge', + 'iconClass' => 'material-symbols-outlined', + 'order' => 'Default', + 'label' => __d('operation', 'identifiers.assign'), + 'link' => [ + 'controller' => 'identifier_assignments', + 'action' => 'assign', + '?' => [ + 'person_id' => $vv_obj->id + ] + ], + 'confirm' => [ + 'dg_body_txt' => __d('operation', 'identifiers.assign.confirm', [$vv_obj->id]), + 'dg_confirm_btn' => __d('operation', 'assign') + ], + 'class' => '' + ] +]; + +// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: +// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. +$addMenuLinks = [ + [ + 'controller' => 'names', + 'action' => 'add', + 'icon' => 'account_box', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'email_addresses', + 'action' => 'add', + 'icon' => 'email', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'identifiers', + 'action' => 'add', + 'icon' => 'fingerprint' + ], + [ + 'controller' => 'ad_hoc_attributes', + 'action' => 'add', + 'icon' => 'user_attributes', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'addresses', + 'action' => 'add', + 'icon' => 'contact_mail', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'pronouns', + 'action' => 'add', + 'icon' => '3p', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'telephone_numbers', + 'action' => 'add', + 'icon' => 'phone' + ], + [ + 'controller' => 'urls', + 'action' => 'add', + 'icon' => 'link' + ] +]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'date_of_birth' - ]]); -} \ No newline at end of file +$subnav = [ + 'name' => 'person', + 'active' => 'person', + 'subActive' => 'properties' +]; \ No newline at end of file diff --git a/app/templates/PersonRoles/fields-nav.inc b/app/templates/PersonRoles/fields-nav.inc deleted file mode 100644 index 8e8480c97..000000000 --- a/app/templates/PersonRoles/fields-nav.inc +++ /dev/null @@ -1,68 +0,0 @@ - 'ad_hoc_attributes', - 'action' => 'add', - 'icon' => 'user_attributes', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'addresses', - 'action' => 'add', - 'icon' => 'contact_mail', - 'iconClass' => 'material-symbols-outlined' - ], - [ - 'controller' => 'telephone_numbers', - 'action' => 'add', - 'icon' => 'phone' - ] -]; - -$subnav = [ - 'name' => 'person', - 'active' => 'person_roles', - 'subActive' => 'properties' -]; \ No newline at end of file diff --git a/app/templates/PersonRoles/fields.inc b/app/templates/PersonRoles/fields.inc index 59b8ccd73..9283241a8 100644 --- a/app/templates/PersonRoles/fields.inc +++ b/app/templates/PersonRoles/fields.inc @@ -25,84 +25,88 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'cou_id', - ] - ]); +$fields = [ + 'cou_id', + 'affiliation_type_id' => [ + 'fieldLabel' => __d('field', 'affiliation') + ], + 'status', + 'ordr', + 'title', + 'organization', + 'department' +]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' =>'affiliation_type_id', - 'fieldLabel' => __d('field', 'affiliation') - ] - ]); +// Provide people-picker for sponsor and manager +foreach(['sponsor', 'manager'] as $f) { + $fp = $f . '_person'; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' =>'status' - ] - ]); - - foreach(['ordr', - 'title', - 'organization', - 'department'] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, + $vv_autocomplete_arguments = [ + 'fieldLabel' => __d('field', $f), + 'autocomplete' => [ + 'configuration' => [ + 'action' => 'GET', + 'for' => 'co' ] - ]); - } + ] + ]; - // For now, we render sponsor and manager as read only. - // XXX Need People Picker (CFM-150) - foreach(['sponsor', 'manager'] as $f) { - $fp = $f . '_person'; - - $vv_autocomplete_arguments = [ - 'fieldName' => $f.'_person_id', - 'fieldLabel' => __d('field', $f), - 'autocomplete' => [ - 'configuration' => [ - 'action' => 'GET', - 'for' => 'co' - ] - ] + if(!empty($vv_obj->$fp->names[0])) { + $vv_autocomplete_arguments['fieldOptions'] = [ + 'default' => $vv_obj->$fp->id ]; - - if(!empty($vv_obj->$fp->names[0])) { - $vv_autocomplete_arguments['fieldOptions'] = [ - 'default' => $vv_obj->$fp->id - ]; - } - - print $this->element('form/listItem', ['arguments' => $vv_autocomplete_arguments]); } - 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' - ]]); + $fields[$f.'_person_id'] = $vv_autocomplete_arguments; } +$fields = array_merge($fields, [ + 'valid_from', + 'valid_through', + 'frozen' +]); + if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = [ + 'entity' => $vv_obj + ]; } + +// List the MVEAs that may be shown on the mveaCanvas +// When this array exists, the mveaCanvas.php element will render +$mveas = [ + 'ad_hoc_attributes', + 'addresses', + 'telephone_numbers' +]; + +// Name the MVEAs Entity Type +$mveasEntityType = "person_role"; + +// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: +// it is a page-global menu used for adding MVEAs and is given special treatment in element/mveaCanvas.php. +$addMenuLinks = [ + [ + 'controller' => 'ad_hoc_attributes', + 'action' => 'add', + 'icon' => 'user_attributes', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'addresses', + 'action' => 'add', + 'icon' => 'contact_mail', + 'iconClass' => 'material-symbols-outlined' + ], + [ + 'controller' => 'telephone_numbers', + 'action' => 'add', + 'icon' => 'phone' + ] +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'person_roles', + 'subActive' => 'properties' +]; \ No newline at end of file diff --git a/app/templates/Petitions/fields-nav.inc b/app/templates/Petitions/fields-nav.inc deleted file mode 100644 index 962ecc198..000000000 --- a/app/templates/Petitions/fields-nav.inc +++ /dev/null @@ -1,54 +0,0 @@ - 'cancel', - 'order' => 'Default', - // We localize the text as "terminate" to make the confirmation dialog less confusing - 'label' => __d('operation', 'terminate'), - 'link' => [ - 'action' => 'terminate', - $vv_obj->id - ], - 'confirm' => [ - 'dg_body_txt' => __d('operation', 'Petitions.terminate.confirm', [$vv_obj->id]), - 'dg_confirm_btn' => __d('operation', 'terminate') - ] - ], - [ - 'icon' => 'resume', - 'order' => 'Default', - 'label' => __d('operation', 'resume'), - 'link' => [ - 'action' => 'resume', - $vv_obj->id - ] - ] -]; diff --git a/app/templates/Petitions/fields.inc b/app/templates/Petitions/fields.inc index c732f6175..696cc4e19 100644 --- a/app/templates/Petitions/fields.inc +++ b/app/templates/Petitions/fields.inc @@ -1,6 +1,6 @@ status); -$statusCssClass = 'petition-status-title petition-status-title-' . Inflector::dasherize($statusTitle); -?> - -
  • -

    - -

    -
  • -
  • -

    - -

    -
  • -enrollee_person?->id)): ?> -
  • -
    -
    -
    -
    - - : - - - Html->link( - $vv_obj->enrollee_person->primary_name->full_name ?? __d('field', 'Petitions.enrollee.new'), - [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->enrollee_person_id - ] - ); - ?> - -
    -
    -
    -
    - enrollee_email)): ?> -
    - - : - - - Html->link( - $vv_obj->enrollee_email, - 'mailto:' . $vv_obj->enrollee_email, - ['class' => 'nospin'] - ); - ?> - -
    - - enrollee_identifier)): ?> -
    - - : - - - enrollee_identifier ?> - -
    - -
    -
    -
  • - -
    -
    -
    - -
    -
    -
    - Html->link( - $vv_obj->enrollee_person->primary_name->full_name ?? __d('field', 'Petitions.enrollee.new'), - [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->enrollee_person_id - ] - ); - ?> -
    -
    - - enrollee_email)): ?> -
  • -
    -
    -
    - -
    -
    -
    - Html->link( - $vv_obj->enrollee_email, - 'mailto:' . $vv_obj->enrollee_email, - ['class' => 'nospin'] - ); - ?> -
    -
    -
  • - - enrollee_identifier)): ?> -
  • -
    -
    -
    - -
    -
    -
    - enrollee_identifier ?> -
    -
    -
  • - - */ ?> - - -petitioner_person?->id)) { - $petitionerStatus = $vv_obj?->petitioner_person?->primary_name?->full_name ?? ''; - $petitionerLink = [ - 'url' => [ - 'controller' => 'people', - 'action' => 'edit', - $vv_obj->petitioner_person->id + * + * This view uses only navigation config in the fields.inc file. For the 'view' action, the controller + * sets $vv_formless_template and points to 'petition.inc' which is included instead of a standard form. + */ + +// Top Links +$topLinks = [ + // Note we don't need an 'if' test for cancel or resume because the generalized permission + // calculation will call isReadOnly() (and not insert these items when true) which is sufficient. + [ + 'icon' => 'cancel', + 'order' => 'Default', + // We localize the text as "terminate" to make the confirmation dialog less confusing + 'label' => __d('operation', 'terminate'), + 'link' => [ + 'action' => 'terminate', + $vv_obj->id + ], + 'confirm' => [ + 'dg_body_txt' => __d('operation', 'Petitions.terminate.confirm', [$vv_obj->id]), + 'dg_confirm_btn' => __d('operation', 'terminate') ] - ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'petitioner_person_id', - 'status' => $petitionerStatus, - 'link' => !empty($vv_obj->petitioner_person->id) ? $petitionerLink : [] + ], + [ + 'icon' => 'resume', + 'order' => 'Default', + 'label' => __d('operation', 'resume'), + 'link' => [ + 'action' => 'resume', + $vv_obj->id ] - ]); -} -?> - -
  • - -
    -
    -
    - -
    -
    -
    - Html->link( - $vv_obj->enrollment_flow->name, - [ - 'controller' => 'enrollment_flows', - 'action' => 'edit', - $vv_obj->enrollment_flow->id - ] - ) - ?> -
    -
    -
  • -
  • - -
    -
    -
    - -
    -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    - -
    -
    -
    - enrollee_email ?> -
    -
    -
  • -
  • - -
    -
    -
    - -
    -
    -
    - enrollee_identifier ?> -
    -
    -
  • -
  • - -
    -
    -
    - : created ?> -
    -
    -
    - : modified ?> -
    -
    -
  • - -
  • -

    - -

    -
    - enrollment_flow->enrollment_flow_steps as $step) { - $stepIds .= 'collapse-box-' . $step->id . ' '; - } - ?> - -
    -
  • - - -enrollment_flow->enrollment_flow_steps as $step): ?> - petition_step_results, "{n}[enrollment_flow_step_id=$step->id]"); ?> -
  • -
    -
    -
    - description ?> -
    -
    -
    -
    - comment : '' ?> -
    -
    - - modified ?> - - -
    -
    -
    -
    -

    plugin ?>

    - cell($step->plugin, [$vv_obj->id], ['vv_obj' => $vv_obj, 'vv_step' => $step, 'viewVars' => $this->viewVars]) ?> -
    -
  • - - - -petition_history_records)): - // XXX Generalize this into an element for all history records if we use this output elsewhere -?> -
  • -

    - -

    -
  • -
  • -
    - - - - - - - - - - - - petition_history_records as $hr): ?> - - - - - - - - -
    - action //__d('enumeration','PetitionActionEnum.' . $hr['action']) - ?> - - actor_person_id) - ? $this->Html->link( - $hr->actor_person->primary_name->full_name, - [ - 'controller' => 'people', - 'action' => 'edit', - $hr->actor_person_id - ] - ) - : "" - ?> - comment ?>created ?>
    -
    -
  • - + ] +]; diff --git a/app/templates/Petitions/petition.inc b/app/templates/Petitions/petition.inc new file mode 100644 index 000000000..7acdbda8e --- /dev/null +++ b/app/templates/Petitions/petition.inc @@ -0,0 +1,389 @@ +status); +$statusCssClass = 'petition-status-title petition-status-title-' . Inflector::dasherize($statusTitle); +?> + + \ No newline at end of file diff --git a/app/templates/Pipelines/fields-nav.inc b/app/templates/Pipelines/fields-nav.inc deleted file mode 100644 index c71fcd7d9..000000000 --- a/app/templates/Pipelines/fields-nav.inc +++ /dev/null @@ -1,38 +0,0 @@ - 'fork_left', // XXX CFM-404 this should be "valve" once we switch to Material Symbols - 'order' => 'Default', - 'label' => __d('controller', 'Flanges', [99]), - 'link' => [ - 'controller' => 'flanges', - 'action' => 'index', - 'pipeline_id' => $vv_obj->id - ], - 'class' => '' -]; diff --git a/app/templates/Pipelines/fields.inc b/app/templates/Pipelines/fields.inc index 349767fb4..fdc19b15f 100644 --- a/app/templates/Pipelines/fields.inc +++ b/app/templates/Pipelines/fields.inc @@ -24,14 +24,46 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'description', + 'status', + 'match_strategy', + 'match_email_address_type_id', + 'match_identifier_type_id', + 'match_server_id', + // 'sync_on_update', + // 'sync_on_delete', + 'sync_status_on_delete', + 'sync_cou_id', + 'sync_replace_cou_id', + 'sync_affiliation_type_id', + 'sync_identifier_type_id', + 'sync_verify_email_addresses' + // XXX Connections +]; + +// Top Links +$topLinks[] = [ + 'icon' => 'nest_thermostat_gen_3', + 'order' => 'Default', + 'label' => __d('controller', 'Flanges', [99]), + 'link' => [ + 'controller' => 'flanges', + 'action' => 'index', + 'pipeline_id' => $vv_obj->id + ], + 'class' => '' +]; ?> - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'description' - ] - ]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' - ] - ]); - - // Match Strategy - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'match_strategy', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()' - ] - ] - ]); - foreach([ - 'match_email_address_type_id', - 'match_identifier_type_id', - 'match_server_id', -// 'sync_on_update', -// 'sync_on_delete', - 'sync_status_on_delete', - 'sync_cou_id', - 'sync_replace_cou_id', - 'sync_affiliation_type_id', - 'sync_identifier_type_id', - 'sync_verify_email_addresses' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field, - ] - ]); - } - - // Connections -//XXX -} + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#match-strategy').change(function() { + updateGadgets(); + }); + }); + diff --git a/app/templates/Pronouns/fields.inc b/app/templates/Pronouns/fields.inc index 0104a3b7f..b2bc53453 100644 --- a/app/templates/Pronouns/fields.inc +++ b/app/templates/Pronouns/fields.inc @@ -25,35 +25,20 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'pronouns' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'default' => $vv_default_type - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'language' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'frozen' - ]]); -} +$fields = [ + 'pronouns', + 'type_id' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => $vv_default_type + ] + ], + 'language', + 'frozen' +]; if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = [ + 'entity' => $vv_obj + ]; } diff --git a/app/templates/ProvisioningHistoryRecords/fields.inc b/app/templates/ProvisioningHistoryRecords/fields.inc index 027766e58..3f305e71e 100644 --- a/app/templates/ProvisioningHistoryRecords/fields.inc +++ b/app/templates/ProvisioningHistoryRecords/fields.inc @@ -25,18 +25,15 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +$fields = []; + // This view does not support add or edit if($vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'comment' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status' - ]]); - + $fields = [ + 'comment', + 'status' + ]; + // Currently these records only apply to People and Groups, but that will probably change if(!empty($vv_obj->person->primary_name)) { $viewLink = [ @@ -47,13 +44,10 @@ if($vv_action == 'view') { ], ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'person_id', - 'status' => $vv_obj->person->primary_name->full_name, - 'link' => $viewLink, - ] - ]); + $fields['person_id'] = [ + 'status' => $vv_obj->person->primary_name->full_name, + 'link' => $viewLink, + ]; } else { $viewLink = [ 'url' => [ @@ -63,24 +57,15 @@ if($vv_action == 'view') { ] ]; - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'group_id', - 'status' => $vv_obj->group->name, - 'link' => $viewLink, - ] - ]); + $fields['group_id'] = [ + 'status' => $vv_obj->group->name, + 'link' => $viewLink, + ]; } - foreach([ - 'subject_model', - 'subjectid', - 'created', - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ] - ]); - } + $fields = array_merge($fields, [ + 'subject_model', + 'subjectid', + 'created' + ]); } diff --git a/app/templates/ProvisioningTargets/fields-nav.inc b/app/templates/ProvisioningTargets/fields-nav.inc deleted file mode 100644 index 25c275b46..000000000 --- a/app/templates/ProvisioningTargets/fields-nav.inc +++ /dev/null @@ -1,31 +0,0 @@ - 'plugin', - 'active' => 'properties' - ]; \ No newline at end of file diff --git a/app/templates/ProvisioningTargets/fields.inc b/app/templates/ProvisioningTargets/fields.inc index 1e3b025de..9d46c0849 100644 --- a/app/templates/ProvisioningTargets/fields.inc +++ b/app/templates/ProvisioningTargets/fields.inc @@ -24,66 +24,58 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'description', + 'status' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => \App\Lib\Enum\ProvisionerModeEnum::QueueOnError + ] + ], + 'retry_interval' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => 900 + ] + ], + 'plugin', + // todo: Not yet implemented (CFM-26) + // 'provisioning_group_id', + 'ordr' +]; + +$subnav = [ + 'name' => 'plugin', + 'active' => 'properties' +]; ?> - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'description' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'status', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()', - 'default' => \App\Lib\Enum\ProvisionerModeEnum::QueueOnError - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'retry_interval', - 'fieldOptions' => [ - 'default' => 900 - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'plugin' - ]]); - -// // todo: Not yet implemented (CFM-26) -// print $this->element('form/listItem', [ -// 'arguments' => [ -// 'fieldName' => 'provisioning_group_id' -// ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'ordr' - ]]); -} diff --git a/app/templates/Servers/fields.inc b/app/templates/Servers/fields.inc index 76054295d..65af804ba 100644 --- a/app/templates/Servers/fields.inc +++ b/app/templates/Servers/fields.inc @@ -24,24 +24,11 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -?> -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'plugin', - 'labelIsTextOnly' => true - ] - ]); -} +$fields = [ + 'description', + 'status', + 'plugin' => [ + 'labelIsTextOnly' => true + ] +]; diff --git a/app/templates/Standard/add-edit-view.php b/app/templates/Standard/add-edit-view.php index 1e2a8dbad..7ce0990e8 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -37,18 +37,25 @@ // $vv_template_path will be set for plugins $templatePath = $vv_template_path ?? ROOT . DS . "templates" . DS . $modelsName; -// If you're looking to set a custom $vv_title, you might be able to use -// generateDisplayField() on the Table instead +// Include fields configuration for the form. This will typically include the $fields array. +$fields = []; // Backstop the fields array: some configs have no fields. +$fieldsFile = "fields.inc"; // This is the default. +if(file_exists($templatePath . DS . 'fields-' . $vv_action . '.inc')) { + // We have an action file override in the form of "fields-ACTION.inc". Use it. + $fieldsFile = 'fields-' . $vv_action . '.inc'; +} +include($templatePath . DS . $fieldsFile); -// Include subnavigation structures on add/edit/view pages -// XXX: if CFM-218 (Make fields.inc configuration only) is accepted, move the contents of fields-nav.inc into fields.inc -// When subnav exists, include on all Edit/View views and on Add views for items with a parent. -if($vv_action == 'edit' || $vv_action == 'view' || !empty($vv_bc_parent_obj) || !empty($vv_primary_link_id)) { - if(file_exists($templatePath . DS . "fields-nav.inc")) { - include($templatePath . DS . "fields-nav.inc"); - } +// $flashArgs pass banner messages to the flash element container +$flashArgs = []; +if(!empty($banners)) { + // Pass in any configured banners from the fields file + $flashArgs['vv_banners'] = $banners; } +// If you're looking to set a custom $vv_title, you might be able to use +// generateDisplayField() on the Table instead + // $linkFilter is used for models that belong to a specific parent model (eg: co_id) $linkFilter = []; @@ -58,7 +65,7 @@ // Subnavigation $hasSubnav = false; -if(file_exists(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc')) { +if($vv_action !== 'add' && file_exists(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc')) { include(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc'); $hasSubnav = $this->get('hasSupertitle'); } @@ -102,92 +109,94 @@ } ?> id; - - foreach(($topLinks ?? []) as $t) { - $perm = false; - - if(!empty($t['url'])) { - // We are passing in a plain URL. Pass it along directly. - // For the moment (v5.1+), this is only used to create a toplink to a Mostly Static Page. - $perm = true; - $t['link'] = $t['url']; - } elseif(!empty($t['link']['controller'])) { - // We're linking into a related model, which may or may not be in a plugin - - $linkModel = \Cake\Utility\Inflector::camelize($t['link']['controller']); - - if(!empty($t['link']['plugin'])) { - $linkModel = \Cake\Utility\Inflector::camelize($t['link']['plugin']) - . "." . $linkModel; - } - - if(isset($vv_permissions[$linkModel][ $t['link']['action'] ])) { - $perm = $vv_permissions[$linkModel][ $t['link']['action'] ]; - } + if($vv_action !== 'add') { + // Action list for top menu dropdown / button listing + $action_args = array(); + $action_args['vv_attr_id'] = $vv_obj->id; - // Inject a link to the current object ID - $t['link']['?'][\App\Lib\Util\StringUtilities::entityToForeignKey($vv_obj)] = $vv_obj->id; - } else { - $perm = $vv_permissions[ $t['link']['action'] ]; + foreach(($topLinks ?? []) as $t) { + $perm = false; - // We need to inject $linkFilter, but not overwrite any existing query params - if(!empty($t['link']['?'])) { - $t['link']['?'] = array_merge($t['link']['?'], $linkFilter); + if(!empty($t['url'])) { + // We are passing in a plain URL. Pass it along directly. + // For the moment (v5.1+), this is only used to create a toplink to a Mostly Static Page. + $perm = true; + $t['link'] = $t['url']; + } elseif(!empty($t['link']['controller'])) { + // We're linking into a related model, which may or may not be in a plugin + + $linkModel = \Cake\Utility\Inflector::camelize($t['link']['controller']); + + if(!empty($t['link']['plugin'])) { + $linkModel = \Cake\Utility\Inflector::camelize($t['link']['plugin']) + . "." . $linkModel; + } + + if(isset($vv_permissions[$linkModel][$t['link']['action']])) { + $perm = $vv_permissions[$linkModel][$t['link']['action']]; + } + + // Inject a link to the current object ID + $t['link']['?'][\App\Lib\Util\StringUtilities::entityToForeignKey($vv_obj)] = $vv_obj->id; } else { - $t['link']['?'] = $linkFilter; + $perm = $vv_permissions[$t['link']['action']]; + + // We need to inject $linkFilter, but not overwrite any existing query params + if(!empty($t['link']['?'])) { + $t['link']['?'] = array_merge($t['link']['?'], $linkFilter); + } else { + $t['link']['?'] = $linkFilter; + } + } + + if($perm && !empty($t['if'])) { + // If there's a conditional on the field, test the entity + $f = $t['if']; + + $perm = $vv_obj->$f(); + } + + if($perm) { + $action_args['vv_actions'][] = $t; + $key = array_key_last($action_args['vv_actions']); + $action_args['vv_actions'][$key]['order'] = $this->Menu->getMenuOrder($t['order']); + $action_args['vv_actions'][$key]['icon'] = $this->Menu->getMenuIcon($t['icon']); + $action_args['vv_actions'][$key]['url'] = $t['link'] ?? ''; + $action_args['vv_actions'][$key]['class'] = $t['class'] ?? ''; + $action_args['vv_actions'][$key]['confirm'] = $t['confirm'] ?? ''; } } - - if($perm && !empty($t['if'])) { - // If there's a conditional on the field, test the entity - $f = $t['if']; - $perm = $vv_obj->$f(); + // Delete + if($vv_action != 'add' && !empty($vv_obj->id) && $vv_permissions['delete']) { + $action_args['vv_actions'][] = [ + 'order' => $this->Menu->getMenuOrder('Delete'), + 'icon' => $this->Menu->getMenuIcon('Delete'), + 'iconClass' => 'material-symbols-outlined', + 'url' => ['action' => 'delete', $vv_obj->id], + 'label' => __d('operation', 'delete'), + 'class' => 'deletebutton', + 'confirm' => [ + 'method' => 'post', + 'dg_title' => __d('operation', 'delete'), + 'dg_body_txt' => __d('operation', 'delete.confirm', [$vv_obj->id]), + 'dg_confirm_btn' => __d('operation', 'delete') + ] + ]; } - - if($perm) { - $action_args['vv_actions'][] = $t; - $key = array_key_last($action_args['vv_actions']); - $action_args['vv_actions'][$key]['order'] = $this->Menu->getMenuOrder($t['order']); - $action_args['vv_actions'][$key]['icon'] = $this->Menu->getMenuIcon($t['icon']); - $action_args['vv_actions'][$key]['url'] = $t['link'] ?? ''; - $action_args['vv_actions'][$key]['class'] = $t['class'] ?? ''; - $action_args['vv_actions'][$key]['confirm'] = $t['confirm'] ?? ''; + + if(!empty($action_args['vv_actions'])) { + print ''; } } - - // Delete - if($vv_action != 'add' && !empty($vv_obj->id) && $vv_permissions['delete']) { - $action_args['vv_actions'][] = [ - 'order' => $this->Menu->getMenuOrder('Delete'), - 'icon' => $this->Menu->getMenuIcon('Delete'), - 'iconClass' => 'material-symbols-outlined', - 'url' => ['action' => 'delete', $vv_obj->id], - 'label' => __d('operation', 'delete'), - 'class' => 'deletebutton', - 'confirm' => [ - 'method' => 'post', - 'dg_title' => __d('operation', 'delete'), - 'dg_body_txt' => __d('operation', 'delete.confirm', [$vv_obj->id]), - 'dg_confirm_btn' => __d('operation', 'delete') - ] - ]; - } - - if(!empty($action_args['vv_actions'])) { - print ''; - } ?> - element('flash') ?> + element('flash', $flashArgs) ?> Form->create($vv_obj); +if(!empty($vv_alternate_template)) { + // We have a special template. Include the template directly here. It does not include the standard form. + // For the moment, this is used to provide a special view for Petitions. Note that the fields.inc + // file may still include other configuration (e.g. for navigation). + include($templatePath . DS . $vv_alternate_template); +} else { + // We will output the standard Form (for add, edit, and view). + // By default, the form will POST to the current controller. + // Note we need to open the form for view so Cake will autopopulate values. + if($this->Field->includesFileField($fields)) { + // A file upload field is in the fields.inc configuration. + // We will change the form encoding type to multipart/form-data. + print $this->Form->create($vv_obj, ['type' => 'file']); + } else { + // We are using the standard form. + print $this->Form->create($vv_obj); + } + + // Output the visible form fields (or values, in the case of view): + if(!empty($fields)) { + print $this->element('form/unorderedList', ['vv_fields' => $fields]); + } -// List of records to collect -// Form body -print $this->element('form/unorderedList'); + // Inject hidden fields set by the fields.inc file. + // We don't need to output hidden fields for view actions. + if($vv_action !== 'view') { + if(!empty($hidden)) { + foreach($hidden as $attr => $v) { + print $this->Form->hidden($attr, ['value' => $v]); + } + } + // Include the $linkId if present + if(!empty($linkId)) { + print $this->Form->hidden($vv_primary_link, ['value' => $linkId]); + } + } -if(!empty($linkId) - && ($vv_action == 'add' || $vv_action == 'edit')) { - // We don't want/need to output these for view actions - print $this->Form->hidden($vv_primary_link, ['value' => $linkId]); + // Close the Form + print $this->Form->end(); } -// Close the Form -print $this->Form->end(); - /** MVEA Canvas output **/ if($vv_action != 'add' && !empty($mveas)) { // Pass along the $mveas and any $addMenuLinks defined in templates/.../fields-nav.inc config. diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index 581ad77ef..91db29dda 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -76,6 +76,7 @@ // $flashArgs pass banner messages to the flash element container $flashArgs = []; if(!empty($banners)) { + // Pass in any configured banners from columns.inc $flashArgs['vv_banners'] = $banners; } diff --git a/app/templates/TelephoneNumbers/fields.inc b/app/templates/TelephoneNumbers/fields.inc index fe47db851..9ec9c1423 100644 --- a/app/templates/TelephoneNumbers/fields.inc +++ b/app/templates/TelephoneNumbers/fields.inc @@ -25,43 +25,29 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - // Dynamic required fields is automatically handled by FormHelper via the - // validation rules, but we need to manually check permitted fields. - - foreach(['country_code', 'area_code', 'number', 'extension'] as $f) { - if(in_array($f, $vv_permitted_fields)) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $f - ]]); - } - } - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'default' => $vv_default_type - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'description' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'frozen' - ]]); +$fields = []; +// Dynamic required fields is automatically handled by FormHelper via the +// validation rules, but we need to manually check permitted fields. +foreach(['country_code', 'area_code', 'number', 'extension'] as $f) { + if(in_array($f, $vv_permitted_fields)) { + $fields[] = $f; + } } +$fields = array_merge($fields, [ + 'type_id' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => $vv_default_type + ] + ], + 'description', + 'frozen' +]); + if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = [ + 'entity' => $vv_obj + ]; } diff --git a/app/templates/TrafficDetours/fields.inc b/app/templates/TrafficDetours/fields.inc index b6c0a72e3..76788ed67 100644 --- a/app/templates/TrafficDetours/fields.inc +++ b/app/templates/TrafficDetours/fields.inc @@ -24,18 +24,10 @@ * @since COmanage Registry v5.1.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -?> -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} + +$fields = [ + 'description', + 'plugin', + 'status', + 'ordr' +]; diff --git a/app/templates/Types/fields.inc b/app/templates/Types/fields.inc index f90568fd6..210fe77ee 100644 --- a/app/templates/Types/fields.inc +++ b/app/templates/Types/fields.inc @@ -24,8 +24,24 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + +$fields = [ + 'attribute' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'readonly' => $vv_action == 'edit' + ] + ], + 'display_name', + 'value', + 'status', + 'case_insensitive', + 'edupersonaffiliation' +]; + ?> - - -element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'attribute', - 'fieldOptions' => [ - 'onChange' => 'updateGadgets()', - 'readonly' => $vv_action == 'edit' - ] - ]]); - foreach (['display_name', - 'value', - 'status', - 'case_insensitive', - 'edupersonaffiliation' - ] as $field) { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => $field - ]]); - } -} + // register onchange events + // note that underscores in field names above must be represented with hyphens here. + $('#attribute').change(function() { + updateGadgets(); + }); + }); + \ No newline at end of file diff --git a/app/templates/Urls/fields.inc b/app/templates/Urls/fields.inc index 4d48a815a..b1f09fae4 100644 --- a/app/templates/Urls/fields.inc +++ b/app/templates/Urls/fields.inc @@ -25,35 +25,20 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'url' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'type_id', - 'fieldOptions' => [ - 'default' => $vv_default_type - ] - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'description' - ]]); - - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'frozen' - ]]); -} +$fields = [ + 'url', + 'type_id' => [ + // XXX flatten fieldOptions + 'fieldOptions' => [ + 'default' => $vv_default_type + ] + ], + 'description', + 'frozen' +]; if($vv_action == 'edit' || $vv_action == 'view') { - print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'source', - 'entity' => $vv_obj - ]]); + $fields['source'] = [ + 'entity' => $vv_obj + ]; } diff --git a/app/templates/element/filter/filter.php b/app/templates/element/filter/filter.php index 3635aeaf1..7259b98cd 100644 --- a/app/templates/element/filter/filter.php +++ b/app/templates/element/filter/filter.php @@ -29,7 +29,7 @@ ?> -