From 7c2970675e181da3529bac2ed2d129a79bb3e135 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Mon, 13 Mar 2023 12:25:51 -0400 Subject: [PATCH 1/3] Allow for supplemental JavaScript and markup on a per-field basis. Provide an inline Jobs json formatter. (CFM-252) --- app/resources/locales/en_US/field.po | 3 +++ app/src/View/Helper/FieldHelper.php | 17 +++++++++++------ app/templates/Jobs/fields.inc | 28 ++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 8 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..faf3a1653 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -99,6 +99,9 @@ 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 + $fieldSupplement = !empty($config['supplement']) ? $config['supplement'] : ''; // Remove prefix from field value if(isset($config['prefix'], $this->getView()->get('vv_obj')->$fieldName)) { @@ -154,8 +157,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,9 +278,9 @@ protected function endLine(): string { * @return string Form Info HTML */ - protected function formInfoDiv(string $content): string { + protected function formInfoDiv(string $content, string $supplement): string { return '
    - ' . $content . ' + ' . $content . $supplement . '
    '; } @@ -290,14 +293,16 @@ protected function formInfoDiv(string $content): string { * @return string Form Info HTML */ - protected function formInfoWithPrefixDiv(string $context, string $prefix): string { + protected function formInfoWithPrefixDiv(string $context, string $prefix, string $supplement): string { $div = '
    ' . PHP_EOL . '
    ' . PHP_EOL . '
    ' . PHP_EOL . '' . $prefix . '' . '
    ' . PHP_EOL . $context - . '
    '; + . '' + . $supplement + . ''; return $div; } diff --git a/app/templates/Jobs/fields.inc b/app/templates/Jobs/fields.inc index c646f41f8..f8d066b0c 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -37,8 +37,32 @@ if($vv_action == 'view') { status: (string)$vv_obj->percent_complete ); } - - print $this->Field->control('parameters'); + + $fieldSupplement = ' +
    +
    + + +
    +
    + + '; + print $this->Field->control('parameters', [], null, ['supplement' => $fieldSupplement]); print $this->Field->control('register_time'); From 1f32a341f48842578f33d69037ff665319d4a050 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Mon, 13 Mar 2023 12:34:45 -0400 Subject: [PATCH 2/3] Shrink the size of field supplement markup slightly. (CFM-252) --- app/webroot/css/co-base.css | 3 +++ 1 file changed, 3 insertions(+) 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 8ddb5bc5b823072907af4d0506f0851de43b462d Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Fri, 17 Mar 2023 14:01:39 -0400 Subject: [PATCH 3/3] Break field supplement into a two-part array "beforeField" and "afterField" (CFM-252) --- app/src/View/Helper/FieldHelper.php | 46 ++++++++++++++++--------- app/templates/Jobs/fields.inc | 53 ++++++++++++++++------------- 2 files changed, 59 insertions(+), 40 deletions(-) diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index faf3a1653..bc0664d77 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -100,8 +100,9 @@ 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 - $fieldSupplement = !empty($config['supplement']) ? $config['supplement'] : ''; + // 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)) { @@ -278,10 +279,18 @@ protected function endLine(): string { * @return string Form Info HTML */ - protected function formInfoDiv(string $content, string $supplement): string { - return '
    - ' . $content . $supplement . ' -
    '; + 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; } /** @@ -293,16 +302,21 @@ protected function formInfoDiv(string $content, string $supplement): string { * @return string Form Info HTML */ - protected function formInfoWithPrefixDiv(string $context, string $prefix, string $supplement): string { - $div = '
    ' . PHP_EOL - . '
    ' . PHP_EOL - . '
    ' . PHP_EOL - . '' . $prefix . '' - . '
    ' . PHP_EOL - . $context - . '
    ' - . $supplement - . '
    '; + 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 f8d066b0c..71c3eee08 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -38,30 +38,35 @@ if($vv_action == 'view') { ); } - $fieldSupplement = ' -
    -
    - - -
    -
    - - '; + $fieldSupplement = + [ + 'beforeField' => ' +
    +
    + + +
    +
    + ', + 'afterField' => ' + + ' + ]; print $this->Field->control('parameters', [], null, ['supplement' => $fieldSupplement]); print $this->Field->control('register_time');