From e4138f365259647658893ee8aa54be1be47f2b69 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Tue, 21 Mar 2023 16:59:12 -0400 Subject: [PATCH 01/10] Allow Select2 select fields to be cleared. (CFM-258) (#84) --- app/templates/element/javascript.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/templates/element/javascript.php b/app/templates/element/javascript.php index acfdf8f7f..248eb605d 100644 --- a/app/templates/element/javascript.php +++ b/app/templates/element/javascript.php @@ -158,7 +158,8 @@ $("select").not("#limit").not(".duet-date__select--month").not(".duet-date__select--year").select2({ width: '100%', tags: true, - placeholder: "-- Select --" + placeholder: "-- Select --", + allowClear: true }); // Generic row click handling From c048c8bb10fe734051fd7c03279f13e32aa870f4 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 22 Mar 2023 08:59:17 -0400 Subject: [PATCH 02/10] Provide an inline Jobs json formatter. (CFM-252) (#83) * Allow for supplemental markup and/or JavaScript on a per-field basis. (CFM-252) * Shrink the size of field supplement markup slightly. (CFM-252) * Break field supplement into a two-part array "beforeField" and "afterField" (CFM-252) --- app/resources/locales/en_US/field.po | 3 ++ app/src/View/Helper/FieldHelper.php | 47 +++++++++++++++++++--------- app/templates/Jobs/fields.inc | 33 +++++++++++++++++-- app/webroot/css/co-base.css | 3 ++ 4 files changed, 70 insertions(+), 16 deletions(-) diff --git a/app/resources/locales/en_US/field.po b/app/resources/locales/en_US/field.po index 28273eb27..61d51b6a1 100644 --- a/app/resources/locales/en_US/field.po +++ b/app/resources/locales/en_US/field.po @@ -312,6 +312,9 @@ msgstr "Limit Global Search Scope" msgid "CoSettings.search_global_limited_models.desc" msgstr "If true, Global Search will only search Names, Email Addresses, and Identifiers. This may result in faster searches for larger deployments." +msgid "format" +msgstr "format" + msgid "GroupMembers.source" msgstr "Membership Source" diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index 02f014cdb..bc0664d77 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -99,6 +99,10 @@ public function control(string $fieldName, // Specify a class on the
  • form control wrapper $liClass = $cssClass; + + // Collect any supplemental markup and/or JavaScript to pass along for field construction. + // Suppliment is an array: supplement['beforeField' => 'string', 'afterField' => 'string']. + $fieldSupplement = !empty($config['supplement']) ? $config['supplement'] : []; // Remove prefix from field value if(isset($config['prefix'], $this->getView()->get('vv_obj')->$fieldName)) { @@ -154,8 +158,8 @@ public function control(string $fieldName, return $this->startLine($liClass) . $this->formNameDiv($fieldName, $labelText) . ( !empty($config['prefix']) ? - $this->formInfoWithPrefixDiv($controlCode, $config['prefix']) : - $this->formInfoDiv($controlCode) ) + $this->formInfoWithPrefixDiv($controlCode, $config['prefix'], $fieldSupplement) : + $this->formInfoDiv($controlCode, $fieldSupplement) ) . $this->endLine(); } @@ -275,10 +279,18 @@ protected function endLine(): string { * @return string Form Info HTML */ - protected function formInfoDiv(string $content): string { - return '
    - ' . $content . ' -
    '; + protected function formInfoDiv(string $content, array $supplement): string { + $div = '
    ' . PHP_EOL; + if(!empty($supplement['beforeField'])) { + $div .= $supplement['beforeField'] . PHP_EOL; + } + $div .= $content . PHP_EOL; + if(!empty($supplement['afterField'])) { + $div .= $supplement['afterField'] . PHP_EOL; + } + $div .= '
    ' . PHP_EOL; + + return $div; } /** @@ -290,14 +302,21 @@ protected function formInfoDiv(string $content): string { * @return string Form Info HTML */ - protected function formInfoWithPrefixDiv(string $context, string $prefix): string { - $div = '
    ' . PHP_EOL - . '
    ' . PHP_EOL - . '
    ' . PHP_EOL - . '' . $prefix . '' - . '
    ' . PHP_EOL - . $context - . '
    '; + protected function formInfoWithPrefixDiv(string $context, string $prefix, array $supplement): string { + $div = '
    ' . PHP_EOL; + if(!empty($supplement['beforeField'])) { + $div .= $supplement['beforeField'] . PHP_EOL; + } + $div .= '
    ' . PHP_EOL; + $div .= '
    ' . PHP_EOL; + $div .= '' . $prefix . ''; + $div .= '
    ' . PHP_EOL; + $div .= $context; + $div .= '
    '; + if(!empty($supplement['afterField'])) { + $div .= $supplement['afterField'] . PHP_EOL; + } + $div .= '
    '; return $div; } diff --git a/app/templates/Jobs/fields.inc b/app/templates/Jobs/fields.inc index c646f41f8..71c3eee08 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -37,8 +37,37 @@ if($vv_action == 'view') { status: (string)$vv_obj->percent_complete ); } - - print $this->Field->control('parameters'); + + $fieldSupplement = + [ + 'beforeField' => ' +
    +
    + + +
    +
    + ', + 'afterField' => ' + + ' + ]; + print $this->Field->control('parameters', [], null, ['supplement' => $fieldSupplement]); print $this->Field->control('register_time'); diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index a2354152c..910eae59b 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -1175,6 +1175,9 @@ ul.form-list li.field-stack textarea { width: 100%; resize: vertical; } +ul.form-list .field-suppliment { + font-size: 0.9em; +} .checkbox { margin-bottom: 0.5em; } From 25784ad917b780f9d5e53fa5b1f7acde7268c0cb Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Thu, 23 Mar 2023 14:34:27 -0400 Subject: [PATCH 03/10] Correct labels for read-only fields - e.g. Jobs UI (CFM-252) (#86) --- app/src/View/Helper/FieldHelper.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index bc0664d77..e965e048d 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -390,9 +390,7 @@ protected function formNameDiv(string $fieldName, string $labelText=null): strin return '
    ' - . ($this->editable - ? $this->Form->label($fn, $label) - : $label) + . $this->Form->label($fn, $label) . ($this->editable && in_array($fn, $this->reqFields) ? ' *' From 997a2070d803de9d034730ab3a4ebc207f1f2951 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Thu, 23 Mar 2023 14:49:34 -0400 Subject: [PATCH 04/10] Update label handling to accommodate checkboxes and special fields that do not have visible input elements. (CFM-219) (#85) * Update label handling to accommodate checkboxes and special fields that do not have input elements. (CFM-219) * Change variable name for clarity (CFM-219) * Post-rebase fix to correct labels for read-only fields - e.g. Jobs UI (CFM-219) --- app/src/View/Helper/FieldHelper.php | 45 ++++++++++++++++++++++------- app/templates/ApiUsers/fields.inc | 9 ++++-- app/templates/element/menuTop.php | 2 +- app/webroot/css/co-base.css | 17 ++--------- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index e965e048d..f7f14fa0c 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -99,10 +99,17 @@ public function control(string $fieldName, // Specify a class on the
  • form control wrapper $liClass = $cssClass; + + // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') + $fieldMap = $this->getView()->get('vv_field_types'); + $fieldType = $fieldMap[$fieldName]; // Collect any supplemental markup and/or JavaScript to pass along for field construction. // Suppliment is an array: supplement['beforeField' => 'string', 'afterField' => 'string']. $fieldSupplement = !empty($config['supplement']) ? $config['supplement'] : []; + + // For special fields that should not include
  • {{ this.txt.unverified }} @@ -91,7 +94,7 @@ export default {
  • @@ -101,7 +104,7 @@ export default {
  • {{ this.mvea.tag }} @@ -111,7 +114,7 @@ export default {
  • - {{ this.mvea.room }} {{ this.mvea.street }} + {{ this.mvea.room }} {{ this.mvea.street }}
    {{ this.mvea.locality }}{{ this.mvea.locality != '' && this.mvea.state != '' ? ', ' : ''}}{{ this.mvea.state }}
    @@ -127,7 +130,7 @@ export default {
  • {{ this.mvea.type.display_name }} @@ -136,7 +139,7 @@ export default {
  • @@ -146,7 +149,7 @@ export default {
  • {{ this.mvea.type.display_name }} diff --git a/app/webroot/js/comanage/components/mvea/mvea-modal.js b/app/webroot/js/comanage/components/mvea/mvea-modal.js new file mode 100644 index 000000000..0977d3ae2 --- /dev/null +++ b/app/webroot/js/comanage/components/mvea/mvea-modal.js @@ -0,0 +1,49 @@ +/** + * COmanage Registry MVEA Modal JavaScript + * + * Portions licensed to the University Corporation for Advanced Internet + * Development, Inc. ("UCAID") under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * UCAID licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @link https://www.internet2.edu/comanage COmanage Project + * @package registry + * @since COmanage Registry v5.0.0 + * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) + */ + +export default { + props: { + modal: Object, + core: Object, + txt: Object + }, + template: ` +