From 96758a174165fc17c10182cce64276fa08df3477 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Thu, 25 Apr 2024 19:21:53 +0300 Subject: [PATCH 01/35] Decouple markup from FieldHelper.Move to elements. --- app/src/Controller/StandardController.php | 33 +- app/src/View/Helper/FieeldHelper.php | 410 ++++++++++++++++++ app/templates/ApiUsers/fields.inc | 69 ++- app/templates/Cous/fields.inc | 17 +- app/templates/Standard/add-edit-view-new.php | 227 ++++++++++ app/templates/element/banner.php | 39 ++ app/templates/element/form/entityID.php | 37 ++ app/templates/element/form/fieldDiv.php | 46 ++ app/templates/element/form/infoDiv.php | 33 ++ app/templates/element/form/infoDivStatus.php | 60 +++ .../element/form/infoDivWithPrefix.php | 38 ++ app/templates/element/form/listItem.php | 48 ++ app/templates/element/form/nameDiv.php | 79 ++++ app/templates/element/form/notSetDiv.php | 32 ++ app/templates/element/form/requiredSpan.php | 33 ++ app/templates/element/form/submit.php | 43 ++ app/templates/element/form/unorderedList.php | 54 +++ app/templates/element/mveaJs.php | 50 ++- app/templates/element/peopleAutocomplete.php | 18 +- app/templates/layout/default.php | 6 +- app/templates/layout/iframe.php | 4 +- 21 files changed, 1311 insertions(+), 65 deletions(-) create mode 100644 app/src/View/Helper/FieeldHelper.php create mode 100644 app/templates/Standard/add-edit-view-new.php create mode 100644 app/templates/element/banner.php create mode 100644 app/templates/element/form/entityID.php create mode 100644 app/templates/element/form/fieldDiv.php create mode 100644 app/templates/element/form/infoDiv.php create mode 100644 app/templates/element/form/infoDivStatus.php create mode 100644 app/templates/element/form/infoDivWithPrefix.php create mode 100644 app/templates/element/form/listItem.php create mode 100644 app/templates/element/form/nameDiv.php create mode 100644 app/templates/element/form/notSetDiv.php create mode 100644 app/templates/element/form/requiredSpan.php create mode 100644 app/templates/element/form/submit.php create mode 100644 app/templates/element/form/unorderedList.php diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index b1ee0a7d6..29c31a386 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -126,7 +126,15 @@ public function add() { $this->set('vv_subtitle', $subtitle); // Let the view render - $this->render('/Standard/add-edit-view'); + if(in_array($this->name, [ + 'Cous', 'ApiUsers' + ]) + ) { + $this->render('/Standard/add-edit-view-new'); + } else { + // Let the view render + $this->render('/Standard/add-edit-view'); + } } /** @@ -423,9 +431,16 @@ public function edit(string $id) { $this->set('vv_title', $title); $this->set('vv_supertitle', $supertitle); $this->set('vv_subtitle', $subtitle); - - // Let the view render - $this->render('/Standard/add-edit-view'); + + if(in_array($this->name, [ + 'Cous' + ]) + ) { + $this->render('/Standard/add-edit-view-new'); + } else { + // Let the view render + $this->render('/Standard/add-edit-view'); + } } /** @@ -872,6 +887,14 @@ public function view($id = null) { $this->set('vv_subtitle', $subtitle); // Let the view render - $this->render('/Standard/add-edit-view'); + if(in_array($this->name, [ + 'Cous', 'ApiUsers' + ]) + ) { + $this->render('/Standard/add-edit-view-new'); + } else { + // Let the view render + $this->render('/Standard/add-edit-view'); + } } } \ No newline at end of file diff --git a/app/src/View/Helper/FieeldHelper.php b/app/src/View/Helper/FieeldHelper.php new file mode 100644 index 000000000..8882e2354 --- /dev/null +++ b/app/src/View/Helper/FieeldHelper.php @@ -0,0 +1,410 @@ +reqFields = $this->getView()->get('vv_required_fields'); + $this->modelName = $this->getView()->getName(); + $this->action = $this->getView()->get('vv_action'); + $this->editable = \in_array($this->action, ['add', 'edit']); + $this->pluginName = $this->getView()->getPlugin(); + $this->entity = $this->getView()->get('vv_obj'); + $this->fieldTypes = $this->getView()->get('vv_field_types'); + } + + + /** + * Emit a date/time form control. + * This is a wrapper function for $this->control() + * + * @param string $fieldName Form field + * @param string $dateType Standard, DateOnly, FromTime, ThroughTime + * @param array|null $queryParams Request Query parameters used by the filtering Blocks to get the date values + * @param string|null $label + * + * @return array HTML for control + * @since COmanage Registry v5.0.0 + */ + + public function dateField(string $fieldName, + string $dateType=DateTypeEnum::Standard, + array $queryParams=null, + string $label=null): string + { + // Initialize + $dateFormat = $dateType === DateTypeEnum::DateOnly ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'; + $dateTitle = $dateType === DateTypeEnum::DateOnly ? 'datepicker.enterDate' : 'datepicker.enterDateTime'; + $datePattern = $dateType === DateTypeEnum::DateOnly ? '\d{4}-\d{2}-\d{2}' : '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'; + $date_object = null; + + if(isset($queryParams)) { + if(!empty($queryParams[$fieldName])) { + $date_object = FrozenTime::parse($queryParams[$fieldName]); + } + } else { + // This is an entity view. We are getting the data from the object + $entity = $this->getView()->get('vv_obj'); + $date_object = $entity->$fieldName; + } + + // Create the options array for the (text input) form control + $coptions = []; + + // A datetime field will be rendered as a plain text input with adjacent date and time pickers + // that will interact with the field value. Allowing direct access to the input field is for + // accessibility purposes. + + // ACTION VIEW + if($this->action == 'view') { + // return the date as plaintext + $element = $this->notSetElement(); + if ($date_object !== null) { + // Adjust the time back to the user's timezone + $element = ''; + } + + // Return this to the generic control() function + return $element; + } + + // Special-case the very common "valid_from" and "valid_through" fields, so we won't need + // to specify their types in fields.inc. + $pickerType = match ($fieldName) { + 'valid_from' => DateTypeEnum::FromTime, + 'valid_through' => DateTypeEnum::ThroughTime, + default => $dateType + }; + + // Append the timezone to the label + $coptions['class'] = 'form-control datepicker'; + $coptions['placeholder'] = $dateFormat; + if(!empty($label)) { + $coptions['label'] = $label; + } + $coptions['pattern'] = $datePattern; + $coptions['title'] = __d('field', $dateTitle); + + $coptions['id'] = str_replace('_', '-', $fieldName); + + + // Default the picker date to today + $now = FrozenTime::now(); + $pickerDate = $now->i18nFormat($dateFormat); + + // Get the existing values, if present + if($date_object !== null) { + // Adjust the time back to the user's timezone + $coptions['value'] = $date_object->i18nFormat($dateFormat); + $pickerDate = $date_object->i18nFormat($dateFormat); + } + + // Set the date picker floor year value (-100 years)() + $pickerDateFT = new FrozenTime($pickerDate); + $pickerDateFT = $pickerDateFT->subYears(100); + $pickerFloor = $pickerDateFT->i18nFormat($dateFormat); + + $date_picker_args = [ + 'fieldName' => $fieldName, + 'pickerDate' => $pickerDate, + 'pickerType' => $pickerType, + 'pickerFloor' => $pickerFloor, + ]; + + // Create a text field to hold our value and call the datePicker + return $this->Form->text($fieldName, $coptions) . $this->getView()->element('datePicker', $date_picker_args); + } + + /** + * Create the actual Form element + * + * @param string $fieldName Form field + * @param array|null $options FormHelper control options + * By setting the options you are requesting a select field + * @param string|null $labelText + * @param string $prefix Field prefix - used for API Usernames + * @param string|null $fieldType + * + * @return string HTML for control + * @since COmanage Registry v5.0.0 + */ + public function formField(string $fieldName, + array $options = null, + string $labelText = null, + string $prefix = '', // api user + string $fieldType = null): string { + $fieldArgs = $options ?? []; + $fieldArgs['label'] = $options['label'] ?? false; + $fieldArgs['readonly'] = !$this->editable + || (isset($options['readonly']) && $options['readonly']) + || ($fieldName == 'plugin' && $this->action == 'edit'); + + // Selects, Checkboxes, and Radio Buttons use "disabled" + $fieldArgs['disabled'] = $fieldArgs['readonly']; + $fieldArgs['required'] = (bool)$this->getReqField($fieldName); + + // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') + $fieldType = $fieldType ?? $this->getFieldType($fieldName); + + // Remove prefix from field value + if(!empty($prefix) && !empty($this->getEntity()->$fieldName)) { + $vv_obj = $this->getView()->get('vv_obj'); + $fieldValue = $vv_obj->$fieldName; + $fieldValueTemp = str_replace($prefix, '', $fieldValue); + $vv_obj->$fieldName = $fieldValueTemp; + $this->getView()->set('vv_obj', $vv_obj); + } + + if($fieldName !== 'status' + && !isset($options['empty']) + && (!isset($options['suppressBlank']) || !$options['suppressBlank'])) { + // Cause any select (except status) to render with a blank option, even + // if the field is required. This makes it clear when a value needs to be set. + // Note this will be ignored for non-select controls. + $fieldArgs['empty'] = true; + } + + // A boolean field is a checkbox. Set the label and class to improve rendering + // and accessibility. + if($fieldType === 'boolean') { + $fieldArgs['label'] = $labelText; + $fieldArgs['class'] = 'form-check-input'; + } elseif($fieldType === 'date') { + return $this->dateField($fieldName, DateTypeEnum::DateOnly); + } elseif($fieldType == 'datetime' || $fieldType == 'timestamp') { + return $this->dateField($fieldName); + } + + // Generate the form control or pass along the markup generated in a wrapper function + return $this->Form->control($fieldName, $fieldArgs); + + } + + + /** + * We autogenerate field labels and descriptions from the field name. + * + * @param string $fieldName + * + * @return array + */ + public function calculateLabelAndDescription(string $fieldName): array + { + $desc = null; + $label = null; + + // First, try to autogenerate the field label (if we weren't given one). + $pluginDomain = (!empty($this->getPluginName()) + ? Inflector::underscore($this->getPluginName()) + : null); + + $modelName = $this->getModelName(); + // We try to automagically determine if a description for the field exists by + // looking for the corresponding .desc language translation. + // We autogenerate field labels and descriptions from the field name. + + // We loop over the field generation logic twice, first for a plugin + // context (if set) and then generally (if no plugin localization was found). + + // We use $core as the variable for this loop, so the rest of the code + // is easier to read (!$core = plugin) + for($core = 0;$core < 2;$core++) { + if(!$core && empty($this->pluginName)) { + // No plugin set, go to the core field checks + continue; + } + + // Is there a model specific key? For plugins, this will be in field.Model.Field + + $key = (!$core ? 'field.' : '') . "$modelName.$fieldName"; + $label = __d(($core ? 'field' : $pluginDomain), $key); + + if($label === $key) { + // Model-specific label isn't found, try again for a general label + + $f = null; + + if(preg_match('/^(.*?)_id$/', $fieldName, $f)) { + // Map foreign keys (foo_id) to the controller label + $key = (!$core ? 'controller.' : '') . Inflector::camelize(Inflector::pluralize($f[1])); + $label = __d(($core ? 'controller' : $pluginDomain), $key, [1]); + + if($key !== $label) { + break; + } + } + + // Look up the key + $key = (!$core ? 'field.' : '') . $fieldName; + $label = __d(($core ? 'field' : $pluginDomain), $key); + + if($key !== $label) { + break; + } + } else { + // If we found a key, break the loop + break; + } + } + // We try to automagically determine if a description for the field exists by + // looking for the corresponding .desc language translation. + + for($core = 0;$core < 2;$core++) { + if(!$core && empty($this->pluginName)) { + // No plugin set, just go to the core field checks + continue; + } + + $key = (!$core ? 'field.' : '') . "$modelName.$fieldName.desc"; + $desc = __d(($core ? 'field' : $pluginDomain), $key); + + // If the description is the literal key we just generated, there is no description + if($desc === $key) { + $desc = null; + } else { + break; + } + } + + return [$label, $desc]; + } + + /** + * @return bool + */ + public function isEditable(): bool + { + return $this->editable; + } + + /** + * @return string|null + */ + public function getPluginName(): ?string + { + return $this->pluginName; + } + + /** + * @return string|null + */ + public function getModelName(): ?string + { + return $this->modelName; + } + + /** + * @return object|null + */ + public function getEntity(): ?object + { + return $this->entity; + } + + /** + * @return array + */ + public function getReqFields(): array + { + return $this->reqFields; + } + + /** + * @param string $field + * + * @return string|null + */ + public function getReqField(string $field): ?string + { + return $this->reqFields[$field] ?? null; + } + + + /** + * @return array + */ + public function getFieldTypes(): array + { + return $this->fieldTypes; + } + + /** + * @param string $field + * + * @return string|null + */ + public function getFieldType(string $field): ?string + { + return $this->fieldTypes[$field] ?? null; + } + + +} \ No newline at end of file diff --git a/app/templates/ApiUsers/fields.inc b/app/templates/ApiUsers/fields.inc index 2c3887e6e..007a2681b 100644 --- a/app/templates/ApiUsers/fields.inc +++ b/app/templates/ApiUsers/fields.inc @@ -28,16 +28,21 @@ // This view does not support read-only if($vv_action == 'add' || $vv_action == 'edit') { if($vv_cur_co->id == 1) { - print $this->Field->banner(__d('information', 'api.cmp')); + print $this->element('banner', __d('information', 'api.cmp')); } // AR-ApiUser-3 For namespacing purposes, API Users are named with a prefix consisting of the string "co_#.". - print $this->Field->control('username', prefix: 'co_' . $vv_cur_co->id . '.'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'username', // string + 'prefix' => 'co_' . $vv_cur_co->id . '.' + ] + ]); // We link to the "Generate" button on edit only $generateLink = []; $labelIsTextOnly = false; - + if(!empty($vv_obj->id)) { $generateLink = [ 'url' => [ @@ -49,22 +54,48 @@ if($vv_action == 'add' || $vv_action == 'edit') { 'class' => 'provisionbutton nospin btn btn-primary btn-sm', 'confirm' => __d('operation', 'api.key.generate.confirm') ]; - + $labelIsTextOnly = true; } - - print $this->Field->statusControl('api_key', - !empty($vv_obj->api_key) ? __d('enumeration', 'SetBooleanEnum.1') : __d('enumeration', 'SetBooleanEnum.0'), - $generateLink, - labelIsTextOnly: $labelIsTextOnly); - - print $this->Field->control('status', ['empty' => false]); - - print $this->Field->dateControl('valid_from'); - - print $this->Field->dateControl('valid_through'); - - print $this->Field->control('remote_ip'); - - print $this->Field->control('privileged'); + + 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' => $labelIsTextOnly + ] + ]); + + + 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 + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'remote_ip', // string + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'privileged', // boolean + ] + ]); } diff --git a/app/templates/Cous/fields.inc b/app/templates/Cous/fields.inc index 89aa3fd11..bdce4df30 100644 --- a/app/templates/Cous/fields.inc +++ b/app/templates/Cous/fields.inc @@ -27,11 +27,20 @@ // This view does not support read-only if($vv_action == 'add' || $vv_action == 'edit') { - print $this->Field->control('name'); - - print $this->Field->control('description'); + print $this->element('form/listItem', [ + 'arguments' => ['fieldName' => 'name'] + ]); + print $this->element('form/listItem', [ + 'arguments' => ['fieldName' => 'description'] + ]); if(!empty($parents)) { - print $this->Field->control('parent_id', ['empty' => true], __d('field', 'parent_id')); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'parent_id', + 'options' => ['empty' => true], + 'labelText' => __d('field', 'parent_id') + ] + ]); } } diff --git a/app/templates/Standard/add-edit-view-new.php b/app/templates/Standard/add-edit-view-new.php new file mode 100644 index 000000000..d327ce81d --- /dev/null +++ b/app/templates/Standard/add-edit-view-new.php @@ -0,0 +1,227 @@ +template; +// $this->name = Models +$modelsName = $this->name; +// $tablename = models +// XXX backport to match? +$tableName = \Cake\Utility\Inflector::tableize(\Cake\Utility\Inflector::singularize($this->name)); + +// $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 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"); + } +} + +if(file_exists($templatePath . DS . "fields-links.inc")) { + include($templatePath . DS . "fields-links.inc"); +} + +// $linkFilter is used for models that belong to a specific parent model (eg: co_id) +$linkFilter = []; + +if(!empty($vv_primary_link) && !empty($this->request->getQuery($vv_primary_link))) { + $linkFilter = [$vv_primary_link => $this->request->getQuery($vv_primary_link)]; +} + +// $flashArgs pass banner messages to the flash element container +$flashArgs = []; +if(!empty($banners)) { + // XXX this doesn't work yet because we don't include fields.inc until later + // either create a second file to include earlier, or use a function to emit + // the fields (which would be more consistent with how Views render...) + $flashArgs['vv_banners'] = $banners; +} + +// If subnavigation is present a supertitle and the subnavigation will be placed above +// the normal page title. The flash messages will be shown up there as well. +if(!empty($subnav)) { + // Include the $flashArgs for the subnavigation element + $subnav['flashArgs'] = $flashArgs; + if(!empty($topLinks) && ($modelsName == 'People' && $vv_action == 'edit')) { + // We are in Person canvas mode: pass along the top links for building the Actions menu. + $subnav['topLinks'] = $topLinks; + } + // Generate the subnavigation title and tabs + print $this->element('subnavigation', $subnav); +} +?> + +
+
+ +

+ +

+ +
+ id; + + foreach(($topLinks ?? []) as $t) { + $perm = false; + + if(!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 { + $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) { + $action_args['vv_actions'][] = [ + 'order' => $this->Menu->getMenuOrder($t['order']), + 'icon' => $this->Menu->getMenuIcon($t['icon']), + 'url' => $t['link'], + 'label' => $t['label'], + 'class' => !empty($t['class']) ? $t['class'] : '', + 'confirm' => !empty($t['confirm']) ? $t['confirm'] : [] + ]; + } + } + + // 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'), + 'url' => ['action' => 'delete', $vv_obj->id], + 'label' => __d('operation', 'delete'), + 'class' => 'deletebutton', + 'confirm' => [ + 'method' => 'post', + 'dg_title' => __d('operation', 'remove'), + 'dg_body_txt' => __d('operation', 'delete.confirm', [$vv_obj->id]), + 'dg_confirm_btn' => __d('operation', 'remove') + ] + ]; + } + + if(!empty($action_args['vv_actions'])) { + print ''; + } + ?> +
+ + + + element('flash', $flashArgs); ?> + + +request->getQuery($vv_primary_link))) { + $linkId = $this->request->getQuery($vv_primary_link); + } elseif(!empty($this->request->getData($vv_primary_link))) { + $linkId = $this->request->getData($vv_primary_link); + } elseif(!empty($vv_obj->$vv_primary_link)) { + $linkId = $vv_obj->$vv_primary_link; + } +} + +/* + * Views have a set() method that is analogous to the set() found in Controller objects. + * Using set() from your view file will add the variables to the layout and elements + * that will be rendered later. + */ + +// By default, the form will POST to the current controller +// Note we need to open the form for view so Cake will autopopulate values +print $this->Form->create($vv_obj); + +// List of records to collect +// Form body +print $this->element('form/unorderedList'); + +// Import all the hidden fields in the Form +if(!empty($hidden)) { + // Inject any hidden variables set by the included file + foreach($hidden as $attr => $v) { + print $this->Form->hidden($attr, ['value' => $v]); + } +} + +if(!empty($linkId) + && ($vv_action == 'add' || $vv_action == 'edit')) { + // We don't want/need to output these for view actions + print $this->Form->hidden($vv_primary_link, ['value' => $linkId]); +} + +// 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. + print $this->element('mveaCanvas', + [ + 'vv_mveas' => $mveas, + 'vv_add_menu_links' => !empty($addMenuLinks) ? $addMenuLinks : '', + 'vv_entity_type' => $mveasEntityType + ]); +} + +// XXX insert changelog metadata (+nav? or maybe we should have a dedicate index view that shows all records in revision order?) diff --git a/app/templates/element/banner.php b/app/templates/element/banner.php new file mode 100644 index 000000000..c0393c6c1 --- /dev/null +++ b/app/templates/element/banner.php @@ -0,0 +1,39 @@ + + + +
  • + Alert->alert($info, 'warning') ?> +
  • diff --git a/app/templates/element/form/entityID.php b/app/templates/element/form/entityID.php new file mode 100644 index 000000000..9f24868e0 --- /dev/null +++ b/app/templates/element/form/entityID.php @@ -0,0 +1,37 @@ + + +id)): ?> +
  • + id) ?> +
  • + + diff --git a/app/templates/element/form/fieldDiv.php b/app/templates/element/form/fieldDiv.php new file mode 100644 index 000000000..6248982b3 --- /dev/null +++ b/app/templates/element/form/fieldDiv.php @@ -0,0 +1,46 @@ + + +
    + element('form/nameDiv'); + + // Info Div + if(isset($vv_field_arguments['prefix'])) { + print $this->element('form/infoDivWithPrefix'); + } elseif(isset($vv_field_arguments['status'])) { + print $this->element('form/infoDivStatus'); + } else { + print $this->element('form/infoDiv'); + } + ?> +
    \ No newline at end of file diff --git a/app/templates/element/form/infoDiv.php b/app/templates/element/form/infoDiv.php new file mode 100644 index 000000000..9d1e86eb7 --- /dev/null +++ b/app/templates/element/form/infoDiv.php @@ -0,0 +1,33 @@ + +
    + Fieeld->formField(...$vv_field_arguments) ?> +
    \ No newline at end of file diff --git a/app/templates/element/form/infoDivStatus.php b/app/templates/element/form/infoDivStatus.php new file mode 100644 index 000000000..47443b023 --- /dev/null +++ b/app/templates/element/form/infoDivStatus.php @@ -0,0 +1,60 @@ +Html->link( + $link['label'], + $link['url'], + $link + ); + } else { + // Make $status the link + + $linkHtml = $this->Html->link( + $status, + $link['url'], + // Pass whatever other args are specified + $link + ); + } +} + +?> +
    + +
    \ No newline at end of file diff --git a/app/templates/element/form/infoDivWithPrefix.php b/app/templates/element/form/infoDivWithPrefix.php new file mode 100644 index 000000000..c5a80d0a7 --- /dev/null +++ b/app/templates/element/form/infoDivWithPrefix.php @@ -0,0 +1,38 @@ + +
    +
    +
    + +
    + Fieeld->formField(...$vv_field_arguments)?> +
    +
    diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php new file mode 100644 index 000000000..2f9ef736a --- /dev/null +++ b/app/templates/element/form/listItem.php @@ -0,0 +1,48 @@ + $value) { + $this->set($key, $value); +} +$this->set('vv_field_arguments', $arguments); + +// Additional classes calculation +$classes = ''; +// XXX Even though i set the view vars above i can not access their values here/yet. +if(in_array($this->Fieeld->getFieldType($arguments['fieldName']), ['date', 'datetime', 'timestamp'])) { + $classes .= 'fields-datepicker '; +} + +?> + +
  • + element('form/fieldDiv')?> +
  • diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php new file mode 100644 index 000000000..07598383c --- /dev/null +++ b/app/templates/element/form/nameDiv.php @@ -0,0 +1,79 @@ +name; +$fn = $fieldName; + +if(str_contains($fieldName, '.')) { + // othermodels.0.field + + $bits = explode('.', $fieldName, 3); + $mn = Inflector::classify($bits[0]); + $fn = $bits[2]; +} + +// First, try to autogenerate the field label (if we weren't given one). +$pluginDomain = (!empty($this->Fieeld->pluginName()) + ? Inflector::underscore($this->Fieeld->pluginName()) + : null); + +[$label, $desc] = $this->Fieeld->calculateLabelAndDescription($pluginDomain, $mn, $fn); +$label = $labelText ?? $label; + +?> + +
    +
    + + + Form->label($fn, $label) ?> + + + + Fieeld->isEditable() && in_array($fn, $vv_required_fields, true)) { + print $this->element('form/requiredSpan'); + } + ?> +
    + +
    + +
    \ No newline at end of file diff --git a/app/templates/element/form/notSetDiv.php b/app/templates/element/form/notSetDiv.php new file mode 100644 index 000000000..c156d03fb --- /dev/null +++ b/app/templates/element/form/notSetDiv.php @@ -0,0 +1,32 @@ + + +
    \ No newline at end of file diff --git a/app/templates/element/form/requiredSpan.php b/app/templates/element/form/requiredSpan.php new file mode 100644 index 000000000..20e2a2a50 --- /dev/null +++ b/app/templates/element/form/requiredSpan.php @@ -0,0 +1,33 @@ + + + + \ No newline at end of file diff --git a/app/templates/element/form/submit.php b/app/templates/element/form/submit.php new file mode 100644 index 000000000..a32069142 --- /dev/null +++ b/app/templates/element/form/submit.php @@ -0,0 +1,43 @@ + + +Fieeld->isEditable()): ?> +
  • +
    +
    + * +
    +
    + Form->submit($label) ?> +
    +
    +
  • + \ No newline at end of file diff --git a/app/templates/element/form/unorderedList.php b/app/templates/element/form/unorderedList.php new file mode 100644 index 000000000..d0a304382 --- /dev/null +++ b/app/templates/element/form/unorderedList.php @@ -0,0 +1,54 @@ + + \ No newline at end of file diff --git a/app/templates/element/mveaJs.php b/app/templates/element/mveaJs.php index 3ae2e54b5..7360b44e1 100644 --- a/app/templates/element/mveaJs.php +++ b/app/templates/element/mveaJs.php @@ -67,7 +67,8 @@ action: '' }, txt: JSON.parse('locales()) ?>'), - isLoading: true + isLoading: true, + title: '' } }, components: { @@ -113,32 +114,33 @@ }, created() { this.refreshComponent(); - } + }, + template: + `
    +
    +

    + {{ title }} + + + +

    +
    +
      +
    • Loading...
    • +
    + + +
    +
    +
    + ` }); // Mount the component and provide a global reference for this app instance. window.mvea = app.mount("#"); -
    -
    -
    -

    - - - - -

    -
    -
      -
    • Loading...
    • -
    - - -
    -
    -
    -
    +
    diff --git a/app/templates/element/peopleAutocomplete.php b/app/templates/element/peopleAutocomplete.php index a1d8efc22..bf7fbe1f4 100644 --- a/app/templates/element/peopleAutocomplete.php +++ b/app/templates/element/peopleAutocomplete.php @@ -104,7 +104,15 @@ console.error(res); console.log('Status Code: ', res.status) } - } + }, + template: ` + + + ` }); @@ -118,10 +126,4 @@ window. = app.mount("#-container"); -
    - - -
    +
    diff --git a/app/templates/layout/default.php b/app/templates/layout/default.php index 0138389d1..54212e4c1 100644 --- a/app/templates/layout/default.php +++ b/app/templates/layout/default.php @@ -64,13 +64,13 @@ ]) . PHP_EOL ?> - + Html->script([ 'bootstrap/bootstrap.bundle.min.js', 'jquery/jquery.min.js', 'vue/vue-3.2.31.global.prod.js', - 'vue/primevue-3.48.1.core.min.js', - 'vue/primevue-3.48.1.autocomplete.min.js' + 'vue/primevue-3.51.0.core.min.js', + 'vue/primevue-3.51.0.autocomplete.min.js' ]) . PHP_EOL ?> diff --git a/app/templates/layout/iframe.php b/app/templates/layout/iframe.php index cffdcf1a4..725e645e1 100644 --- a/app/templates/layout/iframe.php +++ b/app/templates/layout/iframe.php @@ -69,8 +69,8 @@ 'bootstrap/bootstrap.bundle.min.js', 'jquery/jquery.min.js', 'vue/vue-3.2.31.global.prod.js', - 'vue/primevue-3.48.1.core.min.js', - 'vue/primevue-3.48.1.autocomplete.min.js' + 'vue/primevue-3.51.0.core.min.js', + 'vue/primevue-3.51.0.autocomplete.min.js' ]) . PHP_EOL ?> From 77205b7ac56f3ef38e0ead39916e9af3ff1293f1 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 10:45:41 +0300 Subject: [PATCH 02/35] CoSettings --- app/templates/ApiUsers/fields.inc | 8 +- app/templates/CoSettings/fields.inc | 131 ++++++++++++------ app/templates/element/form/fieldDiv.php | 10 +- .../form/{infoDiv.php => infoDiv/default.php} | 0 .../element/form/infoDiv/grouped.php | 51 +++++++ .../{infoDivStatus.php => infoDiv/status.php} | 1 - .../withPrefix.php} | 0 app/templates/element/form/listItem.php | 9 +- app/templates/element/form/nameDiv.php | 21 ++- 9 files changed, 169 insertions(+), 62 deletions(-) rename app/templates/element/form/{infoDiv.php => infoDiv/default.php} (100%) create mode 100644 app/templates/element/form/infoDiv/grouped.php rename app/templates/element/form/{infoDivStatus.php => infoDiv/status.php} (99%) rename app/templates/element/form/{infoDivWithPrefix.php => infoDiv/withPrefix.php} (100%) diff --git a/app/templates/ApiUsers/fields.inc b/app/templates/ApiUsers/fields.inc index 007a2681b..f5390c24e 100644 --- a/app/templates/ApiUsers/fields.inc +++ b/app/templates/ApiUsers/fields.inc @@ -26,11 +26,11 @@ */ // This view does not support read-only -if($vv_action == 'add' || $vv_action == 'edit') { +if($vv_action == 'add' || $vv_action == 'edit') { if($vv_cur_co->id == 1) { print $this->element('banner', __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' => [ @@ -38,7 +38,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { 'prefix' => 'co_' . $vv_cur_co->id . '.' ] ]); - + // We link to the "Generate" button on edit only $generateLink = []; $labelIsTextOnly = false; @@ -67,14 +67,12 @@ if($vv_action == 'add' || $vv_action == 'edit') { ] ]); - print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'status', // select ] ]); - print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'valid_from', // timestamp diff --git a/app/templates/CoSettings/fields.inc b/app/templates/CoSettings/fields.inc index 5db14134a..3410d0171 100644 --- a/app/templates/CoSettings/fields.inc +++ b/app/templates/CoSettings/fields.inc @@ -28,54 +28,105 @@ Field->control('required_fields_address', ['suppressBlank' => true]); - - print $this->Field->control('default_address_type_id'); - - print $this->Field->control('default_email_address_type_id'); - - print $this->Field->control('default_identifier_type_id'); - - print $this->Field->control('default_name_type_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'required_fields_address', + 'options' => ['empty' => false] + ]]); - print $this->Field->control('permitted_fields_name', ['suppressBlank' => true]); - - print $this->Field->control('required_fields_name', ['suppressBlank' => true]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'default_address_type_id' + ]]); - print $this->Field->control('default_pronoun_type_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'default_email_address_type_id' + ]]); - print $this->Field->control('default_telephone_number_type_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'default_identifier_type_id' + ]]); - print $this->Field->control('permitted_fields_telephone_number', ['suppressBlank' => true]); - - print $this->Field->control('default_url_type_id'); - - print $this->Field->control('search_global_limit'); - - print $this->Field->control('search_global_limited_models'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'default_name_type_id' + ]]); - print $this->Field->groupedControls( - [ - 'person_picker_email_address_type_id' => [ - 'options' => [ - 'suppressBlank' => true, - 'label' => __d('field', 'mail'), + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'permitted_fields_name', + 'options' => ['empty' => false] + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'required_fields_name', + 'options' => ['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', + 'options' => ['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', + 'groupedControls' => [ + // each key is the fieldName of the control we are going to create + 'person_picker_email_address_type_id' => [ + 'options' => [ + 'empty' => true, + 'label' => __d('field', 'mail'), + ], ], - ], - 'person_picker_identifier_type_id' => [ - 'options' => [ - 'suppressBlank' => true, - 'label' => __d('field', 'identifier'), + 'person_picker_identifier_type_id' => [ + 'options' => [ + 'empty' => true, + 'label' => __d('field', 'identifier'), + ], ], + 'person_picker_display_types' => [ + 'singleRowItem' => true + ] ], - 'person_picker_display_types' => [ - 'singleRowItem' => true - ] - ], - 'person_picker_display_fields' - ); + ]]); - print $this->Field->control('email_smtp_server_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'email_smtp_server_id' + ]]); - print $this->Field->control('email_delivery_address_type_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'email_delivery_address_type_id' + ]]); } diff --git a/app/templates/element/form/fieldDiv.php b/app/templates/element/form/fieldDiv.php index 6248982b3..c494c2fdc 100644 --- a/app/templates/element/form/fieldDiv.php +++ b/app/templates/element/form/fieldDiv.php @@ -33,14 +33,16 @@ element('form/nameDiv'); - + // Info Div if(isset($vv_field_arguments['prefix'])) { - print $this->element('form/infoDivWithPrefix'); + print $this->element('form/infoDiv/withPrefix'); } elseif(isset($vv_field_arguments['status'])) { - print $this->element('form/infoDivStatus'); + print $this->element('form/infoDiv/status'); + } elseif(isset($vv_field_arguments['groupedControls'])) { + print $this->element('form/infoDiv/grouped'); } else { - print $this->element('form/infoDiv'); + print $this->element('form/infoDiv/default'); } ?> \ No newline at end of file diff --git a/app/templates/element/form/infoDiv.php b/app/templates/element/form/infoDiv/default.php similarity index 100% rename from app/templates/element/form/infoDiv.php rename to app/templates/element/form/infoDiv/default.php diff --git a/app/templates/element/form/infoDiv/grouped.php b/app/templates/element/form/infoDiv/grouped.php new file mode 100644 index 000000000..d5278f945 --- /dev/null +++ b/app/templates/element/form/infoDiv/grouped.php @@ -0,0 +1,51 @@ + + +
    + $fieldArguments): ?> + +
    +
    + Fieeld->formField($fieldName, ...$fieldArguments) ?> +
    +
    + +
    \ No newline at end of file diff --git a/app/templates/element/form/infoDivStatus.php b/app/templates/element/form/infoDiv/status.php similarity index 99% rename from app/templates/element/form/infoDivStatus.php rename to app/templates/element/form/infoDiv/status.php index 47443b023..0d117520c 100644 --- a/app/templates/element/form/infoDivStatus.php +++ b/app/templates/element/form/infoDiv/status.php @@ -33,7 +33,6 @@ if($link) { // Construct HTML for the requested link - if(!empty($link['label'])) { // Create a separate link after $status diff --git a/app/templates/element/form/infoDivWithPrefix.php b/app/templates/element/form/infoDiv/withPrefix.php similarity index 100% rename from app/templates/element/form/infoDivWithPrefix.php rename to app/templates/element/form/infoDiv/withPrefix.php diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index 2f9ef736a..cf4f50b3b 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -29,6 +29,13 @@ declare(strict_types = 1); // Make the element configuration available downstream +// XXX Even though we pass the parameters to the view globally +// they only live in the context of this element and its ancestors +// XXX Unfortunately CAKEPHP doe not create a viewvar space for the element +// parameters. As a result we do not know which one is which unles we: +// - add a prefix and create a namespace +// - wrap them in an array. +// We choose the latter. foreach($arguments as $key => $value) { $this->set($key, $value); } @@ -43,6 +50,6 @@ ?> -
  • +
  • element('form/fieldDiv')?>
  • diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index 07598383c..ad0562998 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -30,13 +30,13 @@ // $fieldName: parameter -$fieldType = $vv_field_types[$fieldName]; +$classes = ''; // We'll accept a fieldName of the form other_models.0.foo for forms that // request associated data. Note, however, that model names for language // keys are OtherModel, so we'll need to inflect. -$mn = $this->name; +$mn = $this->Fieeld->getModelName(); $fn = $fieldName; if(str_contains($fieldName, '.')) { @@ -47,28 +47,27 @@ $fn = $bits[2]; } -// First, try to autogenerate the field label (if we weren't given one). -$pluginDomain = (!empty($this->Fieeld->pluginName()) - ? Inflector::underscore($this->Fieeld->pluginName()) - : null); - -[$label, $desc] = $this->Fieeld->calculateLabelAndDescription($pluginDomain, $mn, $fn); +[$label, $desc] = $this->Fieeld->calculateLabelAndDescription($fn); $label = $labelText ?? $label; +// Extra class required for the grouped controls elements +if(isset($groupedControls)) { + $classes .= 'align-top '; +} ?> -
    +
    + && $this->Fieeld->getFieldType($fieldName) !== 'boolean'): ?> Form->label($fn, $label) ?> Fieeld->isEditable() && in_array($fn, $vv_required_fields, true)) { + if($this->Fieeld->isEditable() && in_array($fn, $this->Fieeld->getReqFields(), true)) { print $this->element('form/requiredSpan'); } ?> From ddeb738323531e53178c4cf0a5f55b543e55b388 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 11:23:23 +0300 Subject: [PATCH 03/35] ApiUsers fields-generate.inc --- app/templates/ApiUsers/fields-generate.inc | 16 +++++++++++++--- app/templates/element/form/infoDiv/status.php | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/templates/ApiUsers/fields-generate.inc b/app/templates/ApiUsers/fields-generate.inc index 293f2a1c1..a290c60d4 100644 --- a/app/templates/ApiUsers/fields-generate.inc +++ b/app/templates/ApiUsers/fields-generate.inc @@ -25,8 +25,18 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ -print $this->Field->banner(__d('information', 'api.key')); +print $this->element('banner', [ 'info' => __d('information', 'api.key')]); -print $this->Field->statusControl('username', $vv_obj->username); +print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'username', + 'status' => $vv_obj->username, + ] +]); -print $this->Field->statusControl('api_key', $vv_api_key); +print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'api_key', + 'status' => $vv_api_key, + ] +]); diff --git a/app/templates/element/form/infoDiv/status.php b/app/templates/element/form/infoDiv/status.php index 0d117520c..72c0052ea 100644 --- a/app/templates/element/form/infoDiv/status.php +++ b/app/templates/element/form/infoDiv/status.php @@ -29,6 +29,7 @@ declare(strict_types = 1); $linkHtml = $status; +$link = $link ?? []; if($link) { From f03e0ada78ecbba452b956965e3dbe74bf7b0d81 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 11:26:51 +0300 Subject: [PATCH 04/35] Cos --- app/templates/Cos/fields.inc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/templates/Cos/fields.inc b/app/templates/Cos/fields.inc index 258f85d7d..fd9658a47 100644 --- a/app/templates/Cos/fields.inc +++ b/app/templates/Cos/fields.inc @@ -27,9 +27,18 @@ // 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->Field->control('name'); - - print $this->Field->control('description'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'name' + ]]); - print $this->Field->control('status', ['empty' => false]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description' + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ]]); } From 56c5f054ad7d87237ef52e50637b1d8827eb4cb9 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 11:54:19 +0300 Subject: [PATCH 05/35] Addresses --- app/templates/Addresses/fields.inc | 54 ++++++++++++------- app/templates/element/form/infoDiv/source.php | 34 ++++++++++++ 2 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 app/templates/element/form/infoDiv/source.php diff --git a/app/templates/Addresses/fields.inc b/app/templates/Addresses/fields.inc index 757f13db9..7433c3c60 100644 --- a/app/templates/Addresses/fields.inc +++ b/app/templates/Addresses/fields.inc @@ -28,26 +28,42 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { // Dynamic required fields is automatically handled by FormHelper via the // validation rules - - print $this->Field->control('street'); + foreach (['street', + 'room', + 'locality', + 'state', + 'postal_code', + 'country', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ]]); + } - print $this->Field->control('room'); - - print $this->Field->control('locality'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); - print $this->Field->control('state'); - - print $this->Field->control('postal_code'); - - print $this->Field->control('country'); - - print $this->Field->control('type_id', ['default' => $vv_default_type]); - - print $this->Field->control('language'); - - print $this->Field->control('description'); - - print $this->Field->control('frozen'); + foreach (['language', + 'description', + 'frozen', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ]]); + } +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/element/form/infoDiv/source.php b/app/templates/element/form/infoDiv/source.php new file mode 100644 index 000000000..9eda537f0 --- /dev/null +++ b/app/templates/element/form/infoDiv/source.php @@ -0,0 +1,34 @@ + +
    + Fieeld->sourceLink($entity) ?> +
    + From 92a736e99c55851f5c04973a61676a6edb999562 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 12:07:32 +0300 Subject: [PATCH 06/35] EmailAddresses --- app/src/Model/Table/AdHocAttributesTable.php | 3 +- app/templates/EmailAddresses/fields.inc | 40 +++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/app/src/Model/Table/AdHocAttributesTable.php b/app/src/Model/Table/AdHocAttributesTable.php index 3bdb8a142..7822a3e0f 100644 --- a/app/src/Model/Table/AdHocAttributesTable.php +++ b/app/src/Model/Table/AdHocAttributesTable.php @@ -43,7 +43,8 @@ class AdHocAttributesTable extends Table { use \App\Lib\Traits\ValidationTrait; use \App\Lib\Traits\SearchFilterTrait; use \App\Lib\Traits\QueryModificationTrait; - + use \App\Lib\Traits\AutoViewVarsTrait; + /** * Provide the default layout * diff --git a/app/templates/EmailAddresses/fields.inc b/app/templates/EmailAddresses/fields.inc index 7676ffb3e..fcc811108 100644 --- a/app/templates/EmailAddresses/fields.inc +++ b/app/templates/EmailAddresses/fields.inc @@ -26,16 +26,44 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('mail'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'mail' + ]]); - print $this->Field->control('type_id', ['default' => $vv_default_type]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); - print $this->Field->control('description'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description' + ]]); // XXX CFM-129 need to implement verification - print $this->Field->control('verified', ['readonly' => true]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'verified', + 'options' => [ + 'readonly' => true + ] + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); - print $this->Field->sourceControl($vv_obj); } + +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); +} \ No newline at end of file From ea1d94744cb8b178a87b584ab69829f5c93d97dd Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 12:47:12 +0300 Subject: [PATCH 07/35] Groups --- app/templates/Groups/fields.inc | 75 +++++++++++++++++---------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/app/templates/Groups/fields.inc b/app/templates/Groups/fields.inc index 6669ba563..fb6282ef2 100644 --- a/app/templates/Groups/fields.inc +++ b/app/templates/Groups/fields.inc @@ -32,50 +32,53 @@ if($vv_obj->isOwners()) { $options['readonly'] = true; } -print $this->Field->control( - fieldName: 'name', - options: $options -); - -print $this->Field->control( - fieldName: 'description', - options: $options -); - -print $this->Field->control( - fieldName: 'status', - options: $options -); - -print $this->Field->control( - fieldName: 'open', - options: $options -); +foreach(['name', + 'description', + 'status', + 'open',] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + 'options' => $options + ] + ]); +} -print $this->Field->control('nesting_mode_all'); +print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'nesting_mode_all', + ] +]); if($vv_action != 'add') { - print $this->Field->control( - fieldName: 'group_type', - options: ['readonly' => true] - ); - + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'group_type', + 'options' => [ + 'readonly' => true + ] + ] + ]); + if($vv_obj->isOwners()) { // Link to the main group if(!empty($vv_obj->owners_for_group)) { - print $this->Field->statusControl( - fieldName: 'owners_group_id', - status: $vv_obj->owners_for_group->name, - link: ['url' => ['controller' => 'groups', 'action' => 'edit', $vv_obj->owners_for_group->id]] - ); + 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]], + ] + ]); } } else { // Link to the owners group - - print $this->Field->statusControl( - fieldName: 'owners_group_id', - status: $vv_obj->owners_group->name ?? '', - link: ['url' => ['controller' => 'groups', 'action' => 'edit', $vv_obj->owners_group_id]] - ); + 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]] + ] + ]); } } From e722c7792134374d4d56b407f0101aad03b15693 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 12:56:06 +0300 Subject: [PATCH 08/35] Urls, Types, Servers --- app/src/Controller/ApiUsersController.php | 14 ++++++-- app/src/Controller/StandardController.php | 9 ++++-- app/templates/Servers/fields.inc | 13 +++++--- app/templates/Types/fields.inc | 32 +++++++++++-------- app/templates/Urls/fields.inc | 31 +++++++++++++++--- app/templates/element/form/fieldDiv.php | 2 ++ app/templates/element/form/infoDiv/source.php | 1 - 7 files changed, 73 insertions(+), 29 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 25a690757..8e1337346 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -62,7 +62,17 @@ public function generate(string $id) { 'api.key', $this->request->getParam('action')); $this->set('vv_title', $title); - - $this->render('/Standard/add-edit-view'); + + // Let the view render + if(in_array($this->name, [ + 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', + 'Groups', 'Servers', 'Types', 'Urls' + ]) + ) { + $this->render('/Standard/add-edit-view-new'); + } else { + // Let the view render + $this->render('/Standard/add-edit-view'); + } } } \ No newline at end of file diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 29c31a386..8ca4dc259 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -127,7 +127,8 @@ public function add() { // Let the view render if(in_array($this->name, [ - 'Cous', 'ApiUsers' + 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', + 'Groups', 'Servers', 'Types', 'Urls' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -433,7 +434,8 @@ public function edit(string $id) { $this->set('vv_subtitle', $subtitle); if(in_array($this->name, [ - 'Cous' + 'Cous', 'CoSettings', 'ApiUsers', 'Cos', 'Addresses', 'EmailAddresses', + 'Groups', 'Servers', 'Types', 'Urls' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -888,7 +890,8 @@ public function view($id = null) { // Let the view render if(in_array($this->name, [ - 'Cous', 'ApiUsers' + 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', + 'Groups', 'Servers', 'Types', 'Urls' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/Servers/fields.inc b/app/templates/Servers/fields.inc index ea9c1e85d..0e27460e0 100644 --- a/app/templates/Servers/fields.inc +++ b/app/templates/Servers/fields.inc @@ -28,9 +28,14 @@ Field->control('description'); + foreach (['description', + 'status', + 'plugin' + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ]]); + } - print $this->Field->control('status'); - - print $this->Field->control('plugin'); } diff --git a/app/templates/Types/fields.inc b/app/templates/Types/fields.inc index 8e89035de..476167f6e 100644 --- a/app/templates/Types/fields.inc +++ b/app/templates/Types/fields.inc @@ -48,19 +48,23 @@ Field->control( - fieldName: 'attribute', - options: [ - 'onChange' => 'updateGadgets()', - 'readonly' => $vv_action == 'edit' - ] - ); - - print $this->Field->control('display_name'); - - print $this->Field->control('value'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'attribute', + 'options' => [ + 'onChange' => 'updateGadgets()', + 'readonly' => $vv_action == 'edit' + ] + ]]); - print $this->Field->control('status'); - - print $this->Field->control('edupersonaffiliation'); + foreach (['display_name', + 'value', + 'status', + 'edupersonaffiliation' + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ]]); + } } diff --git a/app/templates/Urls/fields.inc b/app/templates/Urls/fields.inc index 93ca41f36..4e45ab386 100644 --- a/app/templates/Urls/fields.inc +++ b/app/templates/Urls/fields.inc @@ -26,13 +26,34 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('url'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'url' + ]]); - print $this->Field->control('type_id', ['default' => $vv_default_type]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); - print $this->Field->control('description'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description' + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/element/form/fieldDiv.php b/app/templates/element/form/fieldDiv.php index c494c2fdc..e676faa28 100644 --- a/app/templates/element/form/fieldDiv.php +++ b/app/templates/element/form/fieldDiv.php @@ -41,6 +41,8 @@ print $this->element('form/infoDiv/status'); } elseif(isset($vv_field_arguments['groupedControls'])) { print $this->element('form/infoDiv/grouped'); + } elseif(isset($vv_field_arguments['entity'])) { + print $this->element('form/infoDiv/source'); } else { print $this->element('form/infoDiv/default'); } diff --git a/app/templates/element/form/infoDiv/source.php b/app/templates/element/form/infoDiv/source.php index 9eda537f0..1666f00c9 100644 --- a/app/templates/element/form/infoDiv/source.php +++ b/app/templates/element/form/infoDiv/source.php @@ -31,4 +31,3 @@
    Fieeld->sourceLink($entity) ?>
    - From e8f5d6780e79059bf20428a487e364cdc6a6a158 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 26 Apr 2024 17:54:41 +0300 Subject: [PATCH 09/35] Identifiers,HistoryRecords,TelephoneNumbers,Names,AdHocAttributes,PersonRoles --- app/src/Controller/ApiUsersController.php | 3 +- app/src/Controller/StandardController.php | 9 +- app/src/Model/Table/HistoryRecordsTable.php | 3 +- app/templates/AdHocAttributes/fields.inc | 23 +++- app/templates/HistoryRecords/fields.inc | 103 +++++++++++------- app/templates/Identifiers/fields.inc | 39 +++++-- app/templates/Names/fields.inc | 46 ++++++-- app/templates/PersonRoles/fields.inc | 85 +++++++++++---- app/templates/TelephoneNumbers/fields.inc | 34 +++++- app/templates/element/form/infoDiv/source.php | 2 + app/templates/element/form/infoDiv/status.php | 9 +- app/templates/element/form/listItem.php | 6 +- app/templates/element/form/nameDiv.php | 9 +- 13 files changed, 273 insertions(+), 98 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 8e1337346..0cd2d139e 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -66,7 +66,8 @@ public function generate(string $id) { // Let the view render if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 8ca4dc259..07582ab8b 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -128,7 +128,8 @@ public function add() { // Let the view render if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -435,7 +436,8 @@ public function edit(string $id) { if(in_array($this->name, [ 'Cous', 'CoSettings', 'ApiUsers', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -891,7 +893,8 @@ public function view($id = null) { // Let the view render if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls' + 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Model/Table/HistoryRecordsTable.php b/app/src/Model/Table/HistoryRecordsTable.php index e3917a7d0..d37567c0f 100644 --- a/app/src/Model/Table/HistoryRecordsTable.php +++ b/app/src/Model/Table/HistoryRecordsTable.php @@ -41,7 +41,8 @@ class HistoryRecordsTable extends Table { use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; use \App\Lib\Traits\SearchFilterTrait; - + use \App\Lib\Traits\AutoViewVarsTrait; + /** * Perform Cake Model initialization. * diff --git a/app/templates/AdHocAttributes/fields.inc b/app/templates/AdHocAttributes/fields.inc index b1f57e918..377b9b0e0 100644 --- a/app/templates/AdHocAttributes/fields.inc +++ b/app/templates/AdHocAttributes/fields.inc @@ -26,11 +26,26 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('tag'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'tag' + ]]); - print $this->Field->control('value'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'value' + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/HistoryRecords/fields.inc b/app/templates/HistoryRecords/fields.inc index 45c57a180..df320b062 100644 --- a/app/templates/HistoryRecords/fields.inc +++ b/app/templates/HistoryRecords/fields.inc @@ -27,7 +27,10 @@ // This view does not support edit if($vv_action == 'add' || $vv_action == 'view') { - print $this->Field->control('comment'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'comment', + ]]); if($vv_action == 'add') { // On manual add insert action @@ -39,7 +42,10 @@ if($vv_action == 'add' || $vv_action == 'view') { } if($vv_action == 'view') { - print $this->Field->control('action'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'action', + ]]); if(!empty($vv_obj->person->primary_name)) { $viewLink = [ @@ -49,12 +55,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->person->id ], ]; - - print $this->Field->statusControl( - 'person_id', - $vv_obj->person->primary_name->full_name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'person_id', + 'status' => $vv_obj->person->primary_name->full_name, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->person_role_id)) { @@ -65,12 +73,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->person_role_id ], ]; - - print $this->Field->statusControl( - 'person_role_id', - $vv_obj->person_role_id, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'person_role_id', + 'status' => $vv_obj->person_role_id, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->external_identity->primary_name)) { @@ -81,12 +91,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->external_identity->id ], ]; - - print $this->Field->statusControl( - 'external_identity_id', - $vv_obj->external_identity->primary_name->full_name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'external_identity_id', + 'status' => $vv_obj->external_identity->primary_name->full_name, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->external_identity_role_id)) { @@ -97,12 +109,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->external_identity_role_id ], ]; - - print $this->Field->statusControl( - 'external_identity_role_id', - $vv_obj->external_identity_role_id, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'external_identity_role_id', + 'status' => $vv_obj->external_identity_role_id, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->group_id)) { @@ -113,12 +127,14 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->group_id ], ]; - - print $this->Field->statusControl( - 'group_id', - $vv_obj->group->name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'group_id', + 'status' => $vv_obj->group->name, + 'link' => $viewLink + ] + ]); } if(!empty($vv_obj->actor_person->names)) { @@ -129,15 +145,20 @@ if($vv_action == 'add' || $vv_action == 'view') { $vv_obj->actor_person->id ], ]; - - print $this->Field->statusControl( - 'actor_person_id', - $vv_obj->actor_person->names[0]->full_name, - $viewLink, - __d('field', 'actor') - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'actor_person_id', + 'status' => $vv_obj->actor_person->names[0]->full_name, + 'link' => $viewLink, + 'labelText' => __d('field', 'actor') + ] + ]); } - - print $this->Field->control('created'); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'created', + ]]); } } diff --git a/app/templates/Identifiers/fields.inc b/app/templates/Identifiers/fields.inc index 532f29865..eb5e9c6d2 100644 --- a/app/templates/Identifiers/fields.inc +++ b/app/templates/Identifiers/fields.inc @@ -26,20 +26,45 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('identifier'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'identifier', + ]]); - print $this->Field->control('type_id', ['default' => $vv_default_type]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); if($vv_primary_link_attr == 'person_id') { // AR-Identifier-1 Only Persons can have a login flag - print $this->Field->control('login'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'login', + ]]); } else { + // Will be used by add-edit-view.php to append the hidden fields in the form $hidden['login'] = false; } - - print $this->Field->control('status', ['empty' => false]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status', + ]]); - print $this->Field->sourceControl($vv_obj); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} + +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/Names/fields.inc b/app/templates/Names/fields.inc index 3b16e5804..112e65923 100644 --- a/app/templates/Names/fields.inc +++ b/app/templates/Names/fields.inc @@ -31,22 +31,54 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { foreach(['honorific', 'given', 'middle', 'family', 'suffix'] as $f) { if(in_array($f, $vv_permitted_fields)) { - print $this->Field->control($f); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $f + ]]); } } - print $this->Field->control('type_id', ['default' => $vv_default_type]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); - print $this->Field->control('language'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'language' + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'display_name' + ]]); - print $this->Field->control('display_name'); // We don't allow unsetting of primary_name here because we need to know what // the new primary_name is, but we do allow this name to become primary // because afterSave will unset the old one. - print $this->Field->control('primary_name', ['readonly' => $vv_obj->primary_name]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description', + 'options' => [ + 'readonly' => $vv_obj->primary_name + ] + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); - print $this->Field->sourceControl($vv_obj); } + +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); +} \ No newline at end of file diff --git a/app/templates/PersonRoles/fields.inc b/app/templates/PersonRoles/fields.inc index 4748921f3..7265f1031 100644 --- a/app/templates/PersonRoles/fields.inc +++ b/app/templates/PersonRoles/fields.inc @@ -26,19 +26,38 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('cou_id'); - - print $this->Field->control('affiliation_type_id', labelText: __d('field', 'affiliation')); - - print $this->Field->control('status', ['empty' => false]); - - print $this->Field->control('ordr'); - - print $this->Field->control('title'); - - print $this->Field->control('organization'); - - print $this->Field->control('department'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'cou_id', + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' =>'affiliation_type_id', + 'labelText' => __d('field', 'affiliation') + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' =>'status', + 'options' => [ + 'empty' => false + ] + ] + ]); + + foreach(['ordr', + 'title', + 'organization', + 'department'] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } // For now, we render sponsor and manager as read only. // XXX Need People Picker (CFM-150) @@ -52,15 +71,39 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { $fname = $vv_obj->$fp->names[0]->full_name; $flink = ['url' => ['controller' => 'people', 'action' => 'edit', $vv_obj->$fp->id]]; } - - print $this->Field->statusControl($f.'_person_id', $fname, $flink, __d('field', $f)); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $f.'_person_id', + 'status' => $fname, + 'link' => $flink, + 'labelText' => __d('field', $f) + ] + ]); } - - print $this->Field->dateControl('valid_from'); - - print $this->Field->dateControl('valid_through'); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'valid_from', // timestamp + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'valid_through', // timestamp + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/TelephoneNumbers/fields.inc b/app/templates/TelephoneNumbers/fields.inc index 2f772914d..7161577a5 100644 --- a/app/templates/TelephoneNumbers/fields.inc +++ b/app/templates/TelephoneNumbers/fields.inc @@ -31,15 +31,37 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { foreach(['country_code', 'area_code', 'number', 'extension'] as $f) { if(in_array($f, $vv_permitted_fields)) { - print $this->Field->control($f); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $f + ]]); } } - - print $this->Field->control('type_id', ['default' => $vv_default_type]); - print $this->Field->control('description'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description' + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); + +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/element/form/infoDiv/source.php b/app/templates/element/form/infoDiv/source.php index 1666f00c9..5edeadce3 100644 --- a/app/templates/element/form/infoDiv/source.php +++ b/app/templates/element/form/infoDiv/source.php @@ -27,6 +27,8 @@ declare(strict_types = 1); +$entity = $vv_field_arguments['entity']; + ?>
    Fieeld->sourceLink($entity) ?> diff --git a/app/templates/element/form/infoDiv/status.php b/app/templates/element/form/infoDiv/status.php index 72c0052ea..404c997c9 100644 --- a/app/templates/element/form/infoDiv/status.php +++ b/app/templates/element/form/infoDiv/status.php @@ -26,10 +26,17 @@ */ +/* + * Parameters: + * string $status + * array $link + */ + declare(strict_types = 1); +$status = $vv_field_arguments['status']; $linkHtml = $status; -$link = $link ?? []; +$link = $vv_field_arguments['link'] ?? []; if($link) { diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index cf4f50b3b..7d1490ca4 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -29,16 +29,12 @@ declare(strict_types = 1); // Make the element configuration available downstream -// XXX Even though we pass the parameters to the view globally -// they only live in the context of this element and its ancestors // XXX Unfortunately CAKEPHP doe not create a viewvar space for the element // parameters. As a result we do not know which one is which unles we: // - add a prefix and create a namespace // - wrap them in an array. // We choose the latter. -foreach($arguments as $key => $value) { - $this->set($key, $value); -} +$this->set('fieldName', $arguments['fieldName']); $this->set('vv_field_arguments', $arguments); // Additional classes calculation diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index ad0562998..8eca8c6c6 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -26,6 +26,13 @@ */ +/* + * Parameters + * string $fieldName + * string $labelText + * bool $labelIsTextOnly + */ + declare(strict_types = 1); // $fieldName: parameter @@ -48,7 +55,7 @@ } [$label, $desc] = $this->Fieeld->calculateLabelAndDescription($fn); -$label = $labelText ?? $label; +$label = $vv_field_arguments['labelText'] ?? $label; // Extra class required for the grouped controls elements if(isset($groupedControls)) { From f47dd8d5c035848893154cd5be95141ad01ed2c7 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 16:57:28 +0300 Subject: [PATCH 10/35] ExternalIdentities,ExternalIdentityRoles,ExternalIdentitySources --- app/src/Controller/ApiUsersController.php | 3 +- app/src/Controller/StandardController.php | 9 ++- app/templates/ExternalIdentities/fields.inc | 14 +++- .../ExternalIdentityRoles/fields-nav.inc | 2 +- .../ExternalIdentityRoles/fields.inc | 67 ++++++++++++++----- .../ExternalIdentitySources/fields.inc | 29 +++++--- 6 files changed, 88 insertions(+), 36 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 0cd2d139e..c00389945 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -67,7 +67,8 @@ public function generate(string $id) { if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', + 'ExternalIdentityRoles', 'ExternalIdentitySources' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 07582ab8b..59c8e57c5 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -129,7 +129,8 @@ public function add() { if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', + 'ExternalIdentityRoles', 'ExternalIdentitySources' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -437,7 +438,8 @@ public function edit(string $id) { if(in_array($this->name, [ 'Cous', 'CoSettings', 'ApiUsers', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', + 'ExternalIdentityRoles', 'ExternalIdentitySources' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -894,7 +896,8 @@ public function view($id = null) { if(in_array($this->name, [ 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles' + 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', + 'ExternalIdentityRoles', 'ExternalIdentitySources' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/ExternalIdentities/fields.inc b/app/templates/ExternalIdentities/fields.inc index 65d4411d9..8741f75ad 100644 --- a/app/templates/ExternalIdentities/fields.inc +++ b/app/templates/ExternalIdentities/fields.inc @@ -47,7 +47,15 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->Alert->alert($noticeText, 'information', false); } - print $this->Field->control('status', ['empty' => false]); - - print $this->Field->dateControl('date_of_birth', \App\Lib\Enum\DateTypeEnum::DateOnly); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'date_of_birth', // date + ] + ]); } diff --git a/app/templates/ExternalIdentityRoles/fields-nav.inc b/app/templates/ExternalIdentityRoles/fields-nav.inc index 653919ff4..ca3a42217 100644 --- a/app/templates/ExternalIdentityRoles/fields-nav.inc +++ b/app/templates/ExternalIdentityRoles/fields-nav.inc @@ -34,7 +34,7 @@ $mveas = [ ]; // Name the MVEAs Entity Type -$mveasEntityType = "external_identity_role"; +$mveasEntityType = 'external_identity_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. diff --git a/app/templates/ExternalIdentityRoles/fields.inc b/app/templates/ExternalIdentityRoles/fields.inc index abab0817b..3e1c11af2 100644 --- a/app/templates/ExternalIdentityRoles/fields.inc +++ b/app/templates/ExternalIdentityRoles/fields.inc @@ -26,24 +26,55 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('affiliation_type_id', labelText: __d('field', 'affiliation')); - - print $this->Field->control('status', ['empty' => false]); - - print $this->Field->control('ordr'); - - print $this->Field->control('title'); - - print $this->Field->control('organization'); - - print $this->Field->control('department'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'affiliation_type_id', + 'labelText' => __d('field', 'affiliation') + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ] + ]); + + 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 - print $this->Field->control('sponsor_identifier', labelText: __d('field', 'sponsor')); - - print $this->Field->control('manager_identifier', labelText: __d('field', 'manager')); - - print $this->Field->dateControl('valid_from'); - - print $this->Field->dateControl('valid_through'); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'sponsor_identifier', + 'labelText' => __d('field', 'sponsor') + ] + ]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'manager_identifier', + 'labelText' => __d('field', 'manager') + ] + ]); + + foreach([ + 'valid_from', + 'valid_through' + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } } diff --git a/app/templates/ExternalIdentitySources/fields.inc b/app/templates/ExternalIdentitySources/fields.inc index cd1ef8fc5..85a746c38 100644 --- a/app/templates/ExternalIdentitySources/fields.inc +++ b/app/templates/ExternalIdentitySources/fields.inc @@ -28,14 +28,23 @@ Field->control('description'); - - print $this->Field->control('status', - ['default' => \App\Lib\Enum\SyncModeEnum::Disabled]); - - print $this->Field->control('plugin'); - - print $this->Field->control('pipeline_id'); - - print $this->Field->control('sor_label'); + foreach([ + 'description', + 'status', + 'plugin', + 'pipeline_id', + 'sor_label', + ] as $field) { + $params = [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]; + if($field == 'status') { + $params['arguments']['options'] = [ + 'default' => \App\Lib\Enum\SyncModeEnum::Disabled + ]; + } + print $this->element('form/listItem', $params); + } } From b146ddc13ed4ae261612fa0a4dcd80e7cf47be9b Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 17:51:00 +0300 Subject: [PATCH 11/35] ExternalIdentitySourceRecords,IdentifierAssignments --- app/src/Controller/ApiUsersController.php | 3 +- app/src/Controller/StandardController.php | 9 +- .../ExtIdentitySourceRecords/fields.inc | 19 +++-- .../IdentifierAssignments/fields.inc | 83 ++++++++++++------- app/templates/element/form/listItem.php | 15 ++-- app/templates/element/form/nameDiv.php | 5 +- 6 files changed, 83 insertions(+), 51 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index c00389945..b119806b1 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -68,7 +68,8 @@ public function generate(string $id) { 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources' + 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', + 'IdentifierAssignments' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 59c8e57c5..b25085757 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -130,7 +130,8 @@ public function add() { 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources' + 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', + 'IdentifierAssignments' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -439,7 +440,8 @@ public function edit(string $id) { 'Cous', 'CoSettings', 'ApiUsers', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources' + 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', + 'IdentifierAssignments' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -897,7 +899,8 @@ public function view($id = null) { 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources' + 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', + 'IdentifierAssignments' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/ExtIdentitySourceRecords/fields.inc b/app/templates/ExtIdentitySourceRecords/fields.inc index 59d62580c..b1eb8aa5f 100644 --- a/app/templates/ExtIdentitySourceRecords/fields.inc +++ b/app/templates/ExtIdentitySourceRecords/fields.inc @@ -47,12 +47,15 @@ print $this->Alert->alert($noticeText, 'information', false); // This view does not support add or edit if($vv_action == 'view') { // Link to External Identity, if known - - print $this->Field->control('source_key'); - - print $this->Field->control('last_update'); - - print $this->Field->control('reference_identifier'); - - print $this->Field->control(fieldName: 'source_record', cssClass: 'source-record'); + foreach([ + 'source_key', + 'last_update', + 'reference_identifier', + 'source_record' + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ]]); + } } diff --git a/app/templates/IdentifierAssignments/fields.inc b/app/templates/IdentifierAssignments/fields.inc index 864157b9b..7dfcb6d43 100644 --- a/app/templates/IdentifierAssignments/fields.inc +++ b/app/templates/IdentifierAssignments/fields.inc @@ -1,6 +1,6 @@ Field->control('description'); + foreach([ + 'description', + 'status', + 'plugin' + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ]]); + } - print $this->Field->control('status'); - - print $this->Field->control('plugin'); - - print $this->Field->control( - fieldName: 'context', - options: [ - 'onChange' => 'updateGadgets()' - ] - ); - - print $this->Field->control( - fieldName: 'identifier_type_id', - options: [ - 'onChange' => 'resetType("email-address-type-id")' + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'context', + 'options' => [ + 'onChange' => 'updateGadgets()' + ] ] - ); - - print $this->Field->control( - fieldName: 'login', - cssClass: 'subfield' - ); + ]); - print $this->Field->control( - fieldName: 'email_address_type_id', - options: [ - 'onChange' => 'resetType("identifier-type-id")' + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'identifier_type_id', + 'options' => [ + 'onChange' => 'resetType("email-address-type-id")' + ] ] - ); + ]); - print $this->Field->control('group_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'login' + ] + ]); - print $this->Field->control('allow_empty'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'email_address_type_id', + 'options' => [ + 'onChange' => 'resetType("identifier-type-id")' + ] + ] + ]); - print $this->Field->control('ordr'); + foreach(['group_id', + 'allow_empty', + 'ordr' + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ]]); + } } \ No newline at end of file diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index 7d1490ca4..0c6ff4995 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -38,14 +38,17 @@ $this->set('vv_field_arguments', $arguments); // Additional classes calculation -$classes = ''; -// XXX Even though i set the view vars above i can not access their values here/yet. -if(in_array($this->Fieeld->getFieldType($arguments['fieldName']), ['date', 'datetime', 'timestamp'])) { - $classes .= 'fields-datepicker '; -} +$classes = match ($arguments['fieldName']) { + 'date', + 'datetime', + 'timestamp' => 'fields-datepicker ', + 'source_record' => 'source-record ', + 'login' => 'subfield ', + default => '' +}; ?> -
  • +
  • element('form/fieldDiv')?>
  • diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index 8eca8c6c6..9d90cf458 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -64,6 +64,8 @@ ?>
    + +
    - + +
    \ No newline at end of file From 28a9aee53ddcfb4ff56ede60a5c20fa1f1477c77 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 18:11:59 +0300 Subject: [PATCH 12/35] fixes --- app/templates/element/form/listItem.php | 2 +- app/templates/element/form/nameDiv.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index 0c6ff4995..6505d3e1d 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -38,7 +38,7 @@ $this->set('vv_field_arguments', $arguments); // Additional classes calculation -$classes = match ($arguments['fieldName']) { +$classes = match ($this->Fieeld->getFieldType($arguments['fieldName'])) { 'date', 'datetime', 'timestamp' => 'fields-datepicker ', diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index 9d90cf458..e36e85d1e 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -64,19 +64,20 @@ ?>
    - - +
    - Fieeld->getFieldType($fieldName) !== 'boolean'): ?> Form->label($fn, $label) ?> - + + + Fieeld->isEditable() && in_array($fn, $this->Fieeld->getReqFields(), true)) { + if($this->Fieeld->isEditable() && $this->Fieeld->isReqField($fn)) { print $this->element('form/requiredSpan'); } ?> @@ -84,5 +85,4 @@
    -
    \ No newline at end of file From 2d7c9220f26b0fe2257fe82dba10d2acdd4273d0 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 18:14:23 +0300 Subject: [PATCH 13/35] update FieeldHelper --- app/src/View/Helper/FieeldHelper.php | 232 ++++++++++++++++----------- 1 file changed, 138 insertions(+), 94 deletions(-) diff --git a/app/src/View/Helper/FieeldHelper.php b/app/src/View/Helper/FieeldHelper.php index 8882e2354..6ca565231 100644 --- a/app/src/View/Helper/FieeldHelper.php +++ b/app/src/View/Helper/FieeldHelper.php @@ -81,6 +81,93 @@ public function initialize(array $config): void $this->fieldTypes = $this->getView()->get('vv_field_types'); } + /** + * We autogenerate field labels and descriptions from the field name. + * + * @param string $fieldName + * + * @return array + */ + public function calculateLabelAndDescription(string $fieldName): array + { + $desc = null; + $label = null; + + // First, try to autogenerate the field label (if we weren't given one). + $pluginDomain = (!empty($this->getPluginName()) + ? Inflector::underscore($this->getPluginName()) + : null); + + $modelName = $this->getModelName(); + // We try to automagically determine if a description for the field exists by + // looking for the corresponding .desc language translation. + // We autogenerate field labels and descriptions from the field name. + + // We loop over the field generation logic twice, first for a plugin + // context (if set) and then generally (if no plugin localization was found). + + // We use $core as the variable for this loop, so the rest of the code + // is easier to read (!$core = plugin) + for($core = 0;$core < 2;$core++) { + if(!$core && empty($this->pluginName)) { + // No plugin set, go to the core field checks + continue; + } + + // Is there a model specific key? For plugins, this will be in field.Model.Field + + $key = (!$core ? 'field.' : '') . "$modelName.$fieldName"; + $label = __d(($core ? 'field' : $pluginDomain), $key); + + if($label === $key) { + // Model-specific label isn't found, try again for a general label + + $f = null; + + if(preg_match('/^(.*?)_id$/', $fieldName, $f)) { + // Map foreign keys (foo_id) to the controller label + $key = (!$core ? 'controller.' : '') . Inflector::camelize(Inflector::pluralize($f[1])); + $label = __d(($core ? 'controller' : $pluginDomain), $key, [1]); + + if($key !== $label) { + break; + } + } + + // Look up the key + $key = (!$core ? 'field.' : '') . $fieldName; + $label = __d(($core ? 'field' : $pluginDomain), $key); + + if($key !== $label) { + break; + } + } else { + // If we found a key, break the loop + break; + } + } + // We try to automagically determine if a description for the field exists by + // looking for the corresponding .desc language translation. + + for($core = 0;$core < 2;$core++) { + if(!$core && empty($this->pluginName)) { + // No plugin set, just go to the core field checks + continue; + } + + $key = (!$core ? 'field.' : '') . "$modelName.$fieldName.desc"; + $desc = __d(($core ? 'field' : $pluginDomain), $key); + + // If the description is the literal key we just generated, there is no description + if($desc === $key) { + $desc = null; + } else { + break; + } + } + + return [$label, $desc]; + } /** * Emit a date/time form control. @@ -91,7 +178,7 @@ public function initialize(array $config): void * @param array|null $queryParams Request Query parameters used by the filtering Blocks to get the date values * @param string|null $label * - * @return array HTML for control + * @return string HTML element * @since COmanage Registry v5.0.0 */ @@ -126,7 +213,7 @@ public function dateField(string $fieldName, // ACTION VIEW if($this->action == 'view') { // return the date as plaintext - $element = $this->notSetElement(); + $element = $this->getView()->element('form/notSetDiv'); if ($date_object !== null) { // Adjust the time back to the user's timezone $element = ''; @@ -188,19 +275,19 @@ public function dateField(string $fieldName, * * @param string $fieldName Form field * @param array|null $options FormHelper control options - * By setting the options you are requesting a select field * @param string|null $labelText * @param string $prefix Field prefix - used for API Usernames * @param string|null $fieldType * - * @return string HTML for control + * @return string HTML element * @since COmanage Registry v5.0.0 */ public function formField(string $fieldName, array $options = null, string $labelText = null, string $prefix = '', // api user - string $fieldType = null): string { + string $fieldType = null): string + { $fieldArgs = $options ?? []; $fieldArgs['label'] = $options['label'] ?? false; $fieldArgs['readonly'] = !$this->editable @@ -209,7 +296,7 @@ public function formField(string $fieldName, // Selects, Checkboxes, and Radio Buttons use "disabled" $fieldArgs['disabled'] = $fieldArgs['readonly']; - $fieldArgs['required'] = (bool)$this->getReqField($fieldName); + $fieldArgs['required'] = (bool)$this->isReqField($fieldName); // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') $fieldType = $fieldType ?? $this->getFieldType($fieldName); @@ -223,12 +310,14 @@ public function formField(string $fieldName, $this->getView()->set('vv_obj', $vv_obj); } - if($fieldName !== 'status' - && !isset($options['empty']) - && (!isset($options['suppressBlank']) || !$options['suppressBlank'])) { - // Cause any select (except status) to render with a blank option, even - // if the field is required. This makes it clear when a value needs to be set. - // Note this will be ignored for non-select controls. + // Cause any select (except status) to render with a blank option, even + // if the field is required. This makes it clear when a value needs to be set. + // Note this will be ignored for non-select controls. + if($fieldName === 'status') { + $fieldArgs['empty'] = false; + } elseif(isset($options['empty'])) { + $fieldArgs['empty'] = $options['empty']; + } else { $fieldArgs['empty'] = true; } @@ -248,93 +337,48 @@ public function formField(string $fieldName, } - /** - * We autogenerate field labels and descriptions from the field name. + * Emit a source control for an MVEA that has a source_foo_id field pointing + * to an External Identity attribute. * - * @param string $fieldName + * @param Entity $entity Entity to emit control for * - * @return array + * @return string Source Link + * @since COmanage Registry v5.0.0 */ - public function calculateLabelAndDescription(string $fieldName): array + public function sourceLink($entity): string { - $desc = null; - $label = null; - - // First, try to autogenerate the field label (if we weren't given one). - $pluginDomain = (!empty($this->getPluginName()) - ? Inflector::underscore($this->getPluginName()) - : null); - - $modelName = $this->getModelName(); - // We try to automagically determine if a description for the field exists by - // looking for the corresponding .desc language translation. - // We autogenerate field labels and descriptions from the field name. - - // We loop over the field generation logic twice, first for a plugin - // context (if set) and then generally (if no plugin localization was found). - - // We use $core as the variable for this loop, so the rest of the code - // is easier to read (!$core = plugin) - for($core = 0;$core < 2;$core++) { - if(!$core && empty($this->pluginName)) { - // No plugin set, go to the core field checks - continue; - } - - // Is there a model specific key? For plugins, this will be in field.Model.Field - - $key = (!$core ? 'field.' : '') . "$modelName.$fieldName"; - $label = __d(($core ? 'field' : $pluginDomain), $key); - - if($label === $key) { - // Model-specific label isn't found, try again for a general label - - $f = null; - - if(preg_match('/^(.*?)_id$/', $fieldName, $f)) { - // Map foreign keys (foo_id) to the controller label - $key = (!$core ? 'controller.' : '') . Inflector::camelize(Inflector::pluralize($f[1])); - $label = __d(($core ? 'controller' : $pluginDomain), $key, [1]); - - if($key !== $label) { - break; - } - } - - // Look up the key - $key = (!$core ? 'field.' : '') . $fieldName; - $label = __d(($core ? 'field' : $pluginDomain), $key); - - if($key !== $label) { - break; - } - } else { - // If we found a key, break the loop - break; - } + // eg: Identifiers + // eg: source_identifier_id, or source_external_identity_role_id + $sourceFK = $this->getView()->get('vv_source_fk'); + // e.g.: source_identifier - we need to construct this from the $sourceFK + $sourceEntityName = substr($sourceFK, 0, strlen($sourceFK) - 3); + // In most cases, $sourceModelName = $modelName, but not for PersonRoles + $sourceModelName = substr(StringUtilities::foreignKeyToClassName($sourceFK), 6); + + $link = ''; + if (!empty($entity->$sourceFK)) { + $link .= $this->Html->Link( + title: __d('controller', $sourceModelName, [1]), + url: [ + 'controller' => $sourceModelName, + 'action' => 'view', + $entity->$sourceFK + ] + ); } - // We try to automagically determine if a description for the field exists by - // looking for the corresponding .desc language translation. - - for($core = 0;$core < 2;$core++) { - if(!$core && empty($this->pluginName)) { - // No plugin set, just go to the core field checks - continue; - } - - $key = (!$core ? 'field.' : '') . "$modelName.$fieldName.desc"; - $desc = __d(($core ? 'field' : $pluginDomain), $key); - // If the description is the literal key we just generated, there is no description - if($desc === $key) { - $desc = null; - } else { - break; - } + if (!empty($entity->$sourceEntityName)) { + $link .= ', ' . $this->Html->Link( + title: __d('controller', 'ExternalIdentities', [1]), + url: [ + 'controller' => 'external_identities', + 'action' => 'view', + $entity->$sourceEntityName->external_identity_id + ] + ); } - - return [$label, $desc]; + return $link; } /** @@ -380,11 +424,11 @@ public function getReqFields(): array /** * @param string $field * - * @return string|null + * @return bool */ - public function getReqField(string $field): ?string + public function isReqField(string $field): bool { - return $this->reqFields[$field] ?? null; + return \in_array($field, $this->reqFields, true); } From a2dac6bbd0e9e87338abc46b75aa088b2abd35d9 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 18:54:36 +0300 Subject: [PATCH 14/35] Jobs --- app/templates/Jobs/fields.inc | 107 ++++++++---------- app/templates/element/form/infoDiv/check.php | 53 +++++++++ .../element/form/infoDiv/default.php | 5 + 3 files changed, 103 insertions(+), 62 deletions(-) create mode 100644 app/templates/element/form/infoDiv/check.php diff --git a/app/templates/Jobs/fields.inc b/app/templates/Jobs/fields.inc index 238a9da85..6e5157983 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -32,73 +32,56 @@ if($vv_action == 'view') { print $this->Field->control('status'); if($vv_obj->status == \App\Lib\Enum\JobStatusEnum::InProgress) { - print $this->Field->statusControl( - fieldName: 'percent_complete', - status: (string)$vv_obj->percent_complete - ); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'percent_complete', + 'status' => (string)$vv_obj->percent_complete + ] + ]); } - $beforeField = ' -
    -
    - - -
    -
    - '; - $afterField = ' - - '; - print $this->Field->control('parameters', beforeField: $beforeField, afterField: $afterField); - - print $this->Field->control('register_time'); - - print $this->Field->control('register_summary'); - - print $this->Field->control('assigned_host'); - - print $this->Field->control('assigned_pid'); - - print $this->Field->control('start_after_time'); - - print $this->Field->control('start_time'); + print $this->Field->control('parameters'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'parameters', + 'check' => true + ] + ]); - print $this->Field->control('start_summary'); - - print $this->Field->control('finish_time'); - - print $this->Field->control('finish_summary'); - - print $this->Field->control('requeue_interval'); - - print $this->Field->control('retry_interval'); + foreach([ + 'register_time', + 'register_summary', + 'assigned_host', + 'assigned_pid', + 'start_after_time', + 'start_time', + 'start_summary', + 'finish_time', + 'finish_summary', + 'requeue_interval', + 'retry_interval', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } if(!empty($vv_obj->requeued_from_job->id)) { - print $this->Field->statusControl( - fieldName: 'requeued_from_job_id', - status: (string)$vv_obj->requeued_from_job->id, - link: [ - 'url' => [ - 'controller' => 'jobs', - 'action' => 'view', - $vv_obj->requeued_from_job->id - ] + $link = [ + 'url' => [ + 'controller' => 'jobs', + 'action' => 'view', + $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, ] - ); + ]); } } diff --git a/app/templates/element/form/infoDiv/check.php b/app/templates/element/form/infoDiv/check.php new file mode 100644 index 000000000..7f19f34c8 --- /dev/null +++ b/app/templates/element/form/infoDiv/check.php @@ -0,0 +1,53 @@ + + + + +
    +
    + + +
    +
    diff --git a/app/templates/element/form/infoDiv/default.php b/app/templates/element/form/infoDiv/default.php index 9d1e86eb7..806e627d9 100644 --- a/app/templates/element/form/infoDiv/default.php +++ b/app/templates/element/form/infoDiv/default.php @@ -29,5 +29,10 @@ declare(strict_types = 1); ?>
    + element('form/infoDiv/check'); + } + ?> Fieeld->formField(...$vv_field_arguments) ?>
    \ No newline at end of file From 367b3dafec6c3e5506986377b4aa67076b045579 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 19:08:37 +0300 Subject: [PATCH 15/35] JobHistoryRecords --- app/src/Controller/ApiUsersController.php | 2 +- app/src/Controller/StandardController.php | 6 +-- app/templates/JobHistoryRecords/fields.inc | 49 ++++++++++++------- app/templates/Jobs/fields.inc | 5 +- app/templates/element/form/fieldDiv.php | 2 + app/templates/element/form/infoDiv/check.php | 42 ++++++++-------- .../element/form/infoDiv/default.php | 5 -- 7 files changed, 61 insertions(+), 50 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index b119806b1..5e97f13e3 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -69,7 +69,7 @@ public function generate(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index b25085757..d460f4413 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -131,7 +131,7 @@ public function add() { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -441,7 +441,7 @@ public function edit(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -900,7 +900,7 @@ public function view($id = null) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/JobHistoryRecords/fields.inc b/app/templates/JobHistoryRecords/fields.inc index ea26401a1..f742fcdaf 100644 --- a/app/templates/JobHistoryRecords/fields.inc +++ b/app/templates/JobHistoryRecords/fields.inc @@ -27,11 +27,16 @@ // This view does not support add or edit if($vv_action == 'view') { - print $this->Field->control('record_key'); - - print $this->Field->control('comment'); - - print $this->Field->control('status'); + 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 if(!empty($vv_obj->person->primary_name)) { @@ -42,12 +47,14 @@ if($vv_action == 'view') { $vv_obj->person->id ], ]; - - print $this->Field->statusControl( - 'person_id', - $vv_obj->person->primary_name->full_name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'person_id', + 'status' => $vv_obj->person->primary_name->full_name, + 'link' => $viewLink, + ] + ]); } if(!empty($vv_obj->external_identity->primary_name)) { @@ -58,13 +65,19 @@ if($vv_action == 'view') { $vv_obj->external_identity->id ], ]; - - print $this->Field->statusControl( - 'external_identity_id', - $vv_obj->external_identity->primary_name->full_name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'external_identity_id', + 'status' => $vv_obj->external_identity->primary_name->full_name, + 'link' => $viewLink, + ] + ]); } - print $this->Field->control('created'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'created' + ] + ]); } diff --git a/app/templates/Jobs/fields.inc b/app/templates/Jobs/fields.inc index 6e5157983..2f839227a 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -1,6 +1,6 @@ Field->control('parameters'); + print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'parameters', diff --git a/app/templates/element/form/fieldDiv.php b/app/templates/element/form/fieldDiv.php index e676faa28..bc3b63bc5 100644 --- a/app/templates/element/form/fieldDiv.php +++ b/app/templates/element/form/fieldDiv.php @@ -43,6 +43,8 @@ print $this->element('form/infoDiv/grouped'); } elseif(isset($vv_field_arguments['entity'])) { print $this->element('form/infoDiv/source'); + } elseif(isset($vv_field_arguments['check']) && $vv_field_arguments['check']) { + print $this->element('form/infoDiv/check'); } else { print $this->element('form/infoDiv/default'); } diff --git a/app/templates/element/form/infoDiv/check.php b/app/templates/element/form/infoDiv/check.php index 7f19f34c8..d70790494 100644 --- a/app/templates/element/form/infoDiv/check.php +++ b/app/templates/element/form/infoDiv/check.php @@ -30,24 +30,26 @@ ?> - - -
    -
    - - +
    +
    +
    + + +
    -
    + Fieeld->formField(...$vv_field_arguments) ?> + +
    \ No newline at end of file diff --git a/app/templates/element/form/infoDiv/default.php b/app/templates/element/form/infoDiv/default.php index 806e627d9..9d1e86eb7 100644 --- a/app/templates/element/form/infoDiv/default.php +++ b/app/templates/element/form/infoDiv/default.php @@ -29,10 +29,5 @@ declare(strict_types = 1); ?>
    - element('form/infoDiv/check'); - } - ?> Fieeld->formField(...$vv_field_arguments) ?>
    \ No newline at end of file From 1808c07a02c19d76ba5d645243da876b3618553e Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 19:12:54 +0300 Subject: [PATCH 16/35] CoreAssigne, CoreServer --- .../templates/FormatAssigners/fields.inc | 34 +++++++++++++------ .../templates/SqlAssigners/fields.inc | 16 ++++++--- .../templates/SqlServers/fields.inc | 25 ++++++++------ 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc b/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc index f382bc570..b6d06487a 100644 --- a/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc +++ b/app/plugins/CoreAssigner/templates/FormatAssigners/fields.inc @@ -47,18 +47,30 @@ Field->control('format'); - - print $this->Field->control( - fieldName: 'collision_mode', - options: [ - 'onChange' => 'updateGadgets()' + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'format' ] - ); - - print $this->Field->control('permitted_characters'); + ]); - print $this->Field->control('minimum'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'collision_mode', + 'options' => [ + 'onChange' => 'updateGadgets()' + ] + ] + ]); - print $this->Field->control('maximum'); + foreach([ + 'permitted_characters', + 'minimum', + 'maximum', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } } diff --git a/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc b/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc index d0b2f5942..d2ede3a3d 100644 --- a/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc +++ b/app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc @@ -27,9 +27,15 @@ // This view does currently not support read-only, and add is not used if($vv_action == 'edit') { - print $this->Field->control('server_id'); - - print $this->Field->control('source_table'); - - print $this->Field->control('type_id'); + foreach([ + 'server_id', + 'source_table', + 'type_id', + ] 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 0d0a13d04..a15d291f9 100644 --- a/app/plugins/CoreServer/templates/SqlServers/fields.inc +++ b/app/plugins/CoreServer/templates/SqlServers/fields.inc @@ -27,15 +27,18 @@ // This view does currently not support read-only, and add is not used if($vv_action == 'edit') { - print $this->Field->control('type'); - - print $this->Field->control('hostname'); - - print $this->Field->control('port'); - - print $this->Field->control('databas'); - - print $this->Field->control('username'); - - print $this->Field->control('password'); + foreach([ + 'type', + 'hostname', + 'port', + 'databas', + 'username', + 'password', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } } From ab2f6a26b145026fcae73b649e4c1a1b6fba6a82 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 19:26:29 +0300 Subject: [PATCH 17/35] Pronouns,ProvisioningTargets,ProvisioningHistoryRecords --- app/templates/Pronouns/fields.inc | 31 +++++++++-- .../ProvisioningHistoryRecords/fields.inc | 54 +++++++++++------- app/templates/ProvisioningTargets/fields.inc | 55 ++++++++++++------- app/templates/element/form/listItem.php | 1 + 4 files changed, 94 insertions(+), 47 deletions(-) diff --git a/app/templates/Pronouns/fields.inc b/app/templates/Pronouns/fields.inc index a5361fc5e..aa57d4a69 100644 --- a/app/templates/Pronouns/fields.inc +++ b/app/templates/Pronouns/fields.inc @@ -26,13 +26,34 @@ */ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { - print $this->Field->control('pronouns'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'pronouns' + ]]); - print $this->Field->control('type_id', ['default' => $vv_default_type]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'type_id', + 'options' => [ + 'default' => $vv_default_type + ] + ]]); - print $this->Field->control('language'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'language' + ]]); - print $this->Field->control('frozen'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'frozen' + ]]); +} - print $this->Field->sourceControl($vv_obj); +if($vv_action == 'edit' || $vv_action == 'view') { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'source', + 'entity' => $vv_obj + ]]); } diff --git a/app/templates/ProvisioningHistoryRecords/fields.inc b/app/templates/ProvisioningHistoryRecords/fields.inc index d6b9ca9ec..d1b8e63d1 100644 --- a/app/templates/ProvisioningHistoryRecords/fields.inc +++ b/app/templates/ProvisioningHistoryRecords/fields.inc @@ -40,29 +40,41 @@ if($vv_action == 'view') { $vv_obj->person->id ], ]; - - print $this->Field->statusControl( - 'person_id', - $vv_obj->person->primary_name->full_name, - $viewLink - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'person_id', + 'status' => $vv_obj->person->primary_name->full_name, + 'link' => $viewLink, + ] + ]); } else { - print $this->Field->statusControl( - 'group_id', - $vv_obj->group->name, - [ - 'url' => [ - 'controller' => 'groups', - 'action' => 'edit', - $vv_obj->group->id - ] + $viewLink = [ + 'url' => [ + 'controller' => 'groups', + 'action' => 'edit', + $vv_obj->group->id ] - ); - } + ]; - print $this->Field->control('subject_model'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'group_id', + 'status' => $vv_obj->group->name, + 'link' => $viewLink, + ] + ]); + } - print $this->Field->control('subjectid'); - - print $this->Field->control('created'); + foreach([ + 'subject_model', + 'subjectid', + 'created', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ] + ]); + } } diff --git a/app/templates/ProvisioningTargets/fields.inc b/app/templates/ProvisioningTargets/fields.inc index fd4ed02cf..0162116d2 100644 --- a/app/templates/ProvisioningTargets/fields.inc +++ b/app/templates/ProvisioningTargets/fields.inc @@ -49,28 +49,41 @@ alert("Queue modes not yet implemented"); // XXX CFM-26 Field->control('description'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description' + ]]); - print $this->Field->control( - fieldName: 'status', - options: [ - 'onChange' => 'updateGadgets()', - 'default' => \App\Lib\Enum\ProvisionerModeEnum::QueueOnError - ] - ); - - print $this->Field->control( - fieldName: 'retry_interval', - options: [ - 'default' => 900 - ], - cssClass: 'subfield' - ); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description', + 'options' => [ + 'onChange' => 'updateGadgets()', + 'default' => \App\Lib\Enum\ProvisionerModeEnum::QueueOnError + ] + ]]); - print $this->Field->control('plugin'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description', + 'options' => [ + 'default' => 900 + ] + ]]); -// Not yet implemented (CFM-26) -// print $this->Field->control('provisioning_group_id'); - - print $this->Field->control('ordr'); + 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/element/form/listItem.php b/app/templates/element/form/listItem.php index 6505d3e1d..c14ba9e6e 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -43,6 +43,7 @@ 'datetime', 'timestamp' => 'fields-datepicker ', 'source_record' => 'source-record ', + 'retry_interval', 'login' => 'subfield ', default => '' }; From 5944be3efc6ff1895cb4d395b8eb4501ef87da46 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 19:28:40 +0300 Subject: [PATCH 18/35] ProvisioningHistoryRecords --- app/templates/ProvisioningHistoryRecords/fields.inc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/templates/ProvisioningHistoryRecords/fields.inc b/app/templates/ProvisioningHistoryRecords/fields.inc index d1b8e63d1..027766e58 100644 --- a/app/templates/ProvisioningHistoryRecords/fields.inc +++ b/app/templates/ProvisioningHistoryRecords/fields.inc @@ -27,9 +27,15 @@ // This view does not support add or edit if($vv_action == 'view') { - print $this->Field->control('comment'); - - print $this->Field->control('status'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'comment' + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ]]); // Currently these records only apply to People and Groups, but that will probably change if(!empty($vv_obj->person->primary_name)) { From 16fe4c2cd6a4f7766a687157ce8d7ce77cd3f619 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 20:30:26 +0300 Subject: [PATCH 19/35] People --- app/src/Controller/ApiUsersController.php | 2 +- app/src/Controller/StandardController.php | 6 +-- app/templates/People/fields.inc | 40 +++++++++++++------- app/templates/Standard/add-edit-view-new.php | 8 ---- app/templates/element/form/nameDiv.php | 2 + app/templates/element/form/unorderedList.php | 12 +++++- 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 5e97f13e3..97fd1aff8 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -69,7 +69,7 @@ public function generate(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index d460f4413..c54268a6d 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -131,7 +131,7 @@ public function add() { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -441,7 +441,7 @@ public function edit(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -900,7 +900,7 @@ public function view($id = null) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/People/fields.inc b/app/templates/People/fields.inc index dee3cd5be..d16a99e31 100644 --- a/app/templates/People/fields.inc +++ b/app/templates/People/fields.inc @@ -33,19 +33,25 @@ if($vv_action == 'add') { foreach(['honorific', 'given', 'middle', 'family', 'suffix'] as $f) { if(in_array($f, $vv_permitted_name_fields)) { - print $this->Field->control( - fieldName: 'names.0.'.$f, - options: ['required' => in_array($f, $vv_required_name_fields)], - controlType: 'string' - ); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'names.0.'.$f, + 'options' => [ + 'required' => in_array($f, $vv_required_name_fields) + ], + 'fieldType' => 'string' + ]]); } } - - print $this->Field->control( - fieldName: 'names.0.type_id', - options: ['empty' => false, 'default' => $vv_default_name_type], - controlType: 'string' - ); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'names.0.type_id', + 'options' => [ + 'default' => $vv_default_name_type + ], + 'fieldType' => 'string' + ]]); // AR-Name-1 Since this is the first name for this Person, it must be // designated primary @@ -58,7 +64,13 @@ if($vv_action == 'add') { } if($vv_action == 'add' || $vv_action == 'edit') { - print $this->Field->control('status', ['empty' => false]); - - print $this->Field->dateControl('date_of_birth', \App\Lib\Enum\DateTypeEnum::DateOnly); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'date_of_birth' + ]]); } \ No newline at end of file diff --git a/app/templates/Standard/add-edit-view-new.php b/app/templates/Standard/add-edit-view-new.php index d327ce81d..b1e5fdb29 100644 --- a/app/templates/Standard/add-edit-view-new.php +++ b/app/templates/Standard/add-edit-view-new.php @@ -195,14 +195,6 @@ // Form body print $this->element('form/unorderedList'); -// Import all the hidden fields in the Form -if(!empty($hidden)) { - // Inject any hidden variables set by the included file - foreach($hidden as $attr => $v) { - print $this->Form->hidden($attr, ['value' => $v]); - } -} - if(!empty($linkId) && ($vv_action == 'add' || $vv_action == 'edit')) { // We don't want/need to output these for view actions diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index e36e85d1e..028709d6e 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -35,6 +35,8 @@ declare(strict_types = 1); +use Cake\Utility\Inflector; + // $fieldName: parameter $classes = ''; diff --git a/app/templates/element/form/unorderedList.php b/app/templates/element/form/unorderedList.php index d0a304382..4d3f8a9aa 100644 --- a/app/templates/element/form/unorderedList.php +++ b/app/templates/element/form/unorderedList.php @@ -41,6 +41,7 @@ element('form/submit', ['label' => __d('operation', 'save')]); ?> - \ No newline at end of file + + + $v) { + print $this->Form->hidden($attr, ['value' => $v]); + } +} \ No newline at end of file From 6f87b158fa098666c3e3a1ed70767f8df6c84c37 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 20:39:54 +0300 Subject: [PATCH 20/35] Pipelines --- app/src/View/Helper/FieeldHelper.php | 2 +- app/templates/Pipelines/fields.inc | 63 ++++++++++++++++------------ 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/app/src/View/Helper/FieeldHelper.php b/app/src/View/Helper/FieeldHelper.php index 6ca565231..21e69ed2e 100644 --- a/app/src/View/Helper/FieeldHelper.php +++ b/app/src/View/Helper/FieeldHelper.php @@ -313,7 +313,7 @@ public function formField(string $fieldName, // Cause any select (except status) to render with a blank option, even // if the field is required. This makes it clear when a value needs to be set. // Note this will be ignored for non-select controls. - if($fieldName === 'status') { + if(\in_array($fieldName, ['status', 'sync_status_on_delete'], true)) { $fieldArgs['empty'] = false; } elseif(isset($options['empty'])) { $fieldArgs['empty'] = $options['empty']; diff --git a/app/templates/Pipelines/fields.inc b/app/templates/Pipelines/fields.inc index e4efd0ca2..a9ee9794f 100644 --- a/app/templates/Pipelines/fields.inc +++ b/app/templates/Pipelines/fields.inc @@ -50,37 +50,46 @@ Field->control('description'); - - print $this->Field->control('status'); - - // Match Strategy - print $this->Field->control( - fieldName: 'match_strategy', - controlType: 'select', - options: [ - 'onChange' => 'updateGadgets()' + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'description' ] - ); - - print $this->Field->control('match_email_address_type_id'); - - print $this->Field->control('match_identifier_type_id'); - - // Sync Strategy -// print $this->Field->control('sync_on_update'); - -// print $this->Field->control('sync_on_delete'); + ]); - print $this->Field->control('sync_status_on_delete', ['empty' => false]); - - print $this->Field->control('sync_cou_id'); - - print $this->Field->control('sync_replace_cou_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ] + ]); - print $this->Field->control('sync_affiliation_type_id'); + // Match Strategy + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'match_strategy', + 'options' => [ + 'onChange' => 'updateGadgets()' + ], + 'fieldType' => 'select' + ] + ]); - print $this->Field->control('sync_identifier_type_id'); + foreach([ + 'match_email_address_type_id', + 'match_identifier_type_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', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } // Connections //XXX From 28fd8c74bc2d827679b9b530310f0c65443917e9 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 20:43:05 +0300 Subject: [PATCH 21/35] Jobs --- app/templates/Jobs/fields.inc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/templates/Jobs/fields.inc b/app/templates/Jobs/fields.inc index 2f839227a..769b51c27 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -27,9 +27,18 @@ // This view does not support add or edit if($vv_action == 'view') { - print $this->Field->control('plugin', labelText: __d('controller', 'Jobs', [1])); - - print $this->Field->control('status'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'plugin', + 'labelText' => __d('controller', 'Jobs', [1]) + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'status' + ] + ]); if($vv_obj->status == \App\Lib\Enum\JobStatusEnum::InProgress) { print $this->element('form/listItem', [ From 7f63b4b4209815e85d66e503a79920ede12c42ce Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 20:58:03 +0300 Subject: [PATCH 22/35] GroupNestings --- app/src/Controller/ApiUsersController.php | 2 +- app/src/Controller/StandardController.php | 6 +-- app/templates/GroupNestings/fields.inc | 51 +++++++++++++++++------ 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 97fd1aff8..6b39a7b69 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -69,7 +69,7 @@ public function generate(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index c54268a6d..f4a24f19a 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -131,7 +131,7 @@ public function add() { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -441,7 +441,7 @@ public function edit(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -900,7 +900,7 @@ public function view($id = null) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/GroupNestings/fields.inc b/app/templates/GroupNestings/fields.inc index f913a1f21..673e5b005 100644 --- a/app/templates/GroupNestings/fields.inc +++ b/app/templates/GroupNestings/fields.inc @@ -26,22 +26,47 @@ */ if($vv_action == 'add') { - print $this->Field->control('target_group_id'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'target_group_id', + ] + ]); } elseif($vv_action == 'edit') { + $link = [ + 'url' => [ + 'controller' => 'groups', + 'action' => 'edit', + $vv_obj->target_group_id] + ]; // The target group can't be changed after adding - print $this->Field->statusControl('target_group_id', - $vv_obj->target_group->name, - ['url' => ['controller' => 'groups', - 'action' => 'edit', - $vv_obj->target_group_id]]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'target_group_id', + 'status' => $vv_obj->target_group->name, + 'link' => $link, + ] + ]); } if($vv_action == 'add' || $vv_action == 'edit') { - print $this->Field->statusControl('group_id', - $vv_bc_parent_obj->name, - ['url' => ['controller' => 'groups', - 'action' => 'edit', - $vv_bc_parent_obj->id]]); - - print $this->Field->control('negate'); + $link = [ + 'url' => [ + 'controller' => 'groups', + 'action' => 'edit', + $vv_bc_parent_obj->id] + ]; + // 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 From 8e73da0d2709662a617bdcc545b9db4f9520f114 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 27 Apr 2024 21:48:47 +0300 Subject: [PATCH 23/35] GroupMembers --- app/templates/GroupMembers/fields.inc | 74 ++++++++++--------- app/templates/element/form/fieldDiv.php | 4 + .../element/form/infoDiv/autocomplete.php | 59 +++++++++++++++ .../element/form/infoDiv/groupMember.php | 41 ++++++++++ app/templates/element/form/listItem.php | 4 + app/templates/element/form/nameDiv.php | 1 - 6 files changed, 149 insertions(+), 34 deletions(-) create mode 100644 app/templates/element/form/infoDiv/autocomplete.php create mode 100644 app/templates/element/form/infoDiv/groupMember.php diff --git a/app/templates/GroupMembers/fields.inc b/app/templates/GroupMembers/fields.inc index 4775a33b5..5a2308c09 100644 --- a/app/templates/GroupMembers/fields.inc +++ b/app/templates/GroupMembers/fields.inc @@ -28,46 +28,54 @@ if($vv_action == 'add') { if(!empty($vv_selected_person)) { // The person has been preselected. Created a hidden field, and present information about the person. - print $this->Form->hidden('person_id', ['value' => $vv_selected_person['id']]); + $hidden = [ + 'person_id' => $vv_selected_person['id'] + ]; - // Present the person information in the view: -?> -
  • -
    -
    -
    - -
    -
    -
    - - - - - () - -
    -
    -
  • -element('form/listItem', [ + 'arguments' => [ + 'fieldName' => '', + 'labelText' => __d('field','name'), + 'groupmember' => $vv_selected_person + ] + ]); } else { // Produce the autocomplete people selector on 'add' - print $this->Field->peopleAutocompleteControl('person_id', [ - 'for' => 'GroupMembers', - 'action' => $vv_action, - 'groupId' => $this->getRequest()?->getQuery('group_id') - ]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'person_id', + 'options' => [ + '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') + ] + ] + ] + ]); } - - // XXX As a temporary hack for development, we accept a manually entered Person ID - // XXX leave here temporarily. - //print $this->Field->control('person_id', ['type' => 'text']); } else { - print $this->Form->hidden('person_id'); + $hidden = [ + 'person_id' => $vv_obj->person_id + ]; } -print $this->Field->dateControl('valid_from'); +print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'valid_from', + ] +]); -print $this->Field->dateControl('valid_through'); +print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'valid_through', + ] +]); // XXX RFE: Add links to EIS or Nesting info \ No newline at end of file diff --git a/app/templates/element/form/fieldDiv.php b/app/templates/element/form/fieldDiv.php index bc3b63bc5..ecec7e2e4 100644 --- a/app/templates/element/form/fieldDiv.php +++ b/app/templates/element/form/fieldDiv.php @@ -45,6 +45,10 @@ print $this->element('form/infoDiv/source'); } elseif(isset($vv_field_arguments['check']) && $vv_field_arguments['check']) { print $this->element('form/infoDiv/check'); + } elseif(isset($vv_field_arguments['groupmember'])) { + print $this->element('form/infoDiv/groupMember'); + } elseif(isset($vv_field_arguments['autocomplete'])) { + print $this->element('form/infoDiv/autocomplete'); } else { print $this->element('form/infoDiv/default'); } diff --git a/app/templates/element/form/infoDiv/autocomplete.php b/app/templates/element/form/infoDiv/autocomplete.php new file mode 100644 index 000000000..02477afab --- /dev/null +++ b/app/templates/element/form/infoDiv/autocomplete.php @@ -0,0 +1,59 @@ +Form->unlockField($fieldName); +$this->Form->unlockField($autoCompleteFieldName); + +$autocompleteArgs = [ + 'type' => 'field', + 'fieldName' => $fieldName, + 'personType' => 'person', + 'htmlId' => $autoCompleteFieldName, + 'viewConfigParameters' => $vv_field_arguments['autocomplete']['configuration'] +]; + +?> + + +Form->hidden($fieldName, $vv_field_arguments['options']) . $this->element('peopleAutocomplete', $autocompleteArgs); +?> +
    + info + +
    diff --git a/app/templates/element/form/infoDiv/groupMember.php b/app/templates/element/form/infoDiv/groupMember.php new file mode 100644 index 000000000..8d4b6069e --- /dev/null +++ b/app/templates/element/form/infoDiv/groupMember.php @@ -0,0 +1,41 @@ + + + + + + + + () + + diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index c14ba9e6e..0d95d0355 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -48,6 +48,10 @@ default => '' }; +if(isset($arguments['autocomplete'])) { + $classes = 'fields-people-autocomplete '; +} + ?>
  • diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index 028709d6e..8cc7a49f9 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -66,7 +66,6 @@ ?>
    -
    Date: Sun, 28 Apr 2024 08:34:52 +0300 Subject: [PATCH 24/35] rename field parameters. Added prefix field. --- .../src/Model/Table/FileProvisionersTable.php | 2 +- .../src/Model/Table/FileSourcesTable.php | 4 ++-- app/src/Controller/ApiUsersController.php | 3 ++- app/src/Controller/StandardController.php | 9 ++++++--- app/templates/Addresses/fields.inc | 2 +- app/templates/ApiUsers/fields.inc | 2 +- app/templates/CoSettings/fields.inc | 14 ++++++-------- app/templates/Cous/fields.inc | 3 +-- app/templates/EmailAddresses/fields.inc | 4 ++-- app/templates/ExternalIdentityRoles/fields.inc | 6 +++--- app/templates/ExternalIdentitySources/fields.inc | 2 +- app/templates/GroupMembers/fields.inc | 4 ++-- app/templates/Groups/fields.inc | 4 ++-- app/templates/HistoryRecords/fields.inc | 2 +- app/templates/IdentifierAssignments/fields.inc | 6 +++--- app/templates/Identifiers/fields.inc | 2 +- app/templates/Jobs/fields.inc | 2 +- app/templates/Names/fields.inc | 4 ++-- app/templates/People/fields.inc | 4 ++-- app/templates/PersonRoles/fields.inc | 9 +++------ app/templates/Pipelines/fields.inc | 2 +- app/templates/Pronouns/fields.inc | 2 +- app/templates/ProvisioningTargets/fields.inc | 4 ++-- app/templates/TelephoneNumbers/fields.inc | 2 +- app/templates/Types/fields.inc | 2 +- app/templates/Urls/fields.inc | 2 +- app/templates/element/form/fieldDiv.php | 2 +- app/templates/element/form/infoDiv/withPrefix.php | 2 +- app/templates/element/form/nameDiv.php | 4 ++-- 29 files changed, 54 insertions(+), 56 deletions(-) diff --git a/app/availableplugins/FileConnector/src/Model/Table/FileProvisionersTable.php b/app/availableplugins/FileConnector/src/Model/Table/FileProvisionersTable.php index 3a0aff846..b4ec46ea8 100644 --- a/app/availableplugins/FileConnector/src/Model/Table/FileProvisionersTable.php +++ b/app/availableplugins/FileConnector/src/Model/Table/FileProvisionersTable.php @@ -34,7 +34,7 @@ use Cake\Validation\Validator; use App\Lib\Enum\ProvisioningEligibilityEnum; use App\Lib\Enum\ProvisioningStatusEnum; -use \FileConnector\Model\Entity\FileProvisioner; +use \FileProvisioner\Model\Entity\FileProvisioner; class FileProvisionersTable extends Table { use \App\Lib\Traits\ChangelogBehaviorTrait; diff --git a/app/availableplugins/FileConnector/src/Model/Table/FileSourcesTable.php b/app/availableplugins/FileConnector/src/Model/Table/FileSourcesTable.php index c170e3ebb..82be14a59 100644 --- a/app/availableplugins/FileConnector/src/Model/Table/FileSourcesTable.php +++ b/app/availableplugins/FileConnector/src/Model/Table/FileSourcesTable.php @@ -349,7 +349,7 @@ protected function resultToEntityData(array $result): array { */ public function retrieve( - \App\Model\Entity\ExternalIdentitySource $source, + \App\Model\Entity\ExternalIdentitySource $source, string $source_key ): array { // Read the field configuration (for resultToEntity) @@ -423,7 +423,7 @@ public function ruleIsFileReadable($entity, array $options): string|bool { */ public function search( - \App\Model\Entity\ExternalIdentitySource $source, + \App\Model\Entity\ExternalIdentitySource $source, array $searchAttrs ): array { // Read the field configuration (for resultToEntity) diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 6b39a7b69..0d5859078 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -69,7 +69,8 @@ public function generate(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', + 'GroupMembers' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index f4a24f19a..921da8d7c 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -131,7 +131,8 @@ public function add() { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', + 'GroupMembers' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -441,7 +442,8 @@ public function edit(string $id) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', + 'GroupMembers' ]) ) { $this->render('/Standard/add-edit-view-new'); @@ -900,7 +902,8 @@ public function view($id = null) { 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings' + 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', + 'GroupMembers' ]) ) { $this->render('/Standard/add-edit-view-new'); diff --git a/app/templates/Addresses/fields.inc b/app/templates/Addresses/fields.inc index 7433c3c60..4c23a1b46 100644 --- a/app/templates/Addresses/fields.inc +++ b/app/templates/Addresses/fields.inc @@ -44,7 +44,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_type ] ]]); diff --git a/app/templates/ApiUsers/fields.inc b/app/templates/ApiUsers/fields.inc index f5390c24e..349916d8a 100644 --- a/app/templates/ApiUsers/fields.inc +++ b/app/templates/ApiUsers/fields.inc @@ -35,7 +35,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'username', // string - 'prefix' => 'co_' . $vv_cur_co->id . '.' + 'fieldPrefix' => 'co_' . $vv_cur_co->id . '.' ] ]); diff --git a/app/templates/CoSettings/fields.inc b/app/templates/CoSettings/fields.inc index 3410d0171..b7ff8281e 100644 --- a/app/templates/CoSettings/fields.inc +++ b/app/templates/CoSettings/fields.inc @@ -31,7 +31,7 @@ if($vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'required_fields_address', - 'options' => ['empty' => false] + 'fieldOptions' => ['empty' => false] ]]); print $this->element('form/listItem', [ @@ -57,13 +57,13 @@ if($vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'permitted_fields_name', - 'options' => ['empty' => false] + 'fieldOptions' => ['empty' => false] ]]); print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'required_fields_name', - 'options' => ['empty' => false] + 'fieldOptions' => ['empty' => false] ]]); print $this->element('form/listItem', [ @@ -79,7 +79,7 @@ if($vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'permitted_fields_telephone_number', - 'options' => ['empty' => false] + 'fieldOptions' => ['empty' => false] ]]); print $this->element('form/listItem', [ @@ -103,14 +103,12 @@ if($vv_action == 'edit') { 'groupedControls' => [ // each key is the fieldName of the control we are going to create 'person_picker_email_address_type_id' => [ - 'options' => [ - 'empty' => true, + 'fieldOptions' => [ 'label' => __d('field', 'mail'), ], ], 'person_picker_identifier_type_id' => [ - 'options' => [ - 'empty' => true, + 'fieldOptions' => [ 'label' => __d('field', 'identifier'), ], ], diff --git a/app/templates/Cous/fields.inc b/app/templates/Cous/fields.inc index bdce4df30..60089c412 100644 --- a/app/templates/Cous/fields.inc +++ b/app/templates/Cous/fields.inc @@ -38,8 +38,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'parent_id', - 'options' => ['empty' => true], - 'labelText' => __d('field', 'parent_id') + 'fieldLabel' => __d('field', 'parent_id') ] ]); } diff --git a/app/templates/EmailAddresses/fields.inc b/app/templates/EmailAddresses/fields.inc index fcc811108..3c4d5065c 100644 --- a/app/templates/EmailAddresses/fields.inc +++ b/app/templates/EmailAddresses/fields.inc @@ -34,7 +34,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_type ] ]]); @@ -48,7 +48,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'verified', - 'options' => [ + 'fieldOptions' => [ 'readonly' => true ] ]]); diff --git a/app/templates/ExternalIdentityRoles/fields.inc b/app/templates/ExternalIdentityRoles/fields.inc index 3e1c11af2..33b5aef1a 100644 --- a/app/templates/ExternalIdentityRoles/fields.inc +++ b/app/templates/ExternalIdentityRoles/fields.inc @@ -29,7 +29,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'affiliation_type_id', - 'labelText' => __d('field', 'affiliation') + 'fieldLabel' => __d('field', 'affiliation') ] ]); @@ -57,13 +57,13 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'sponsor_identifier', - 'labelText' => __d('field', 'sponsor') + 'fieldLabel' => __d('field', 'sponsor') ] ]); print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'manager_identifier', - 'labelText' => __d('field', 'manager') + 'fieldLabel' => __d('field', 'manager') ] ]); diff --git a/app/templates/ExternalIdentitySources/fields.inc b/app/templates/ExternalIdentitySources/fields.inc index 85a746c38..12d631fd0 100644 --- a/app/templates/ExternalIdentitySources/fields.inc +++ b/app/templates/ExternalIdentitySources/fields.inc @@ -41,7 +41,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { ] ]; if($field == 'status') { - $params['arguments']['options'] = [ + $params['arguments']['fieldOptions'] = [ 'default' => \App\Lib\Enum\SyncModeEnum::Disabled ]; } diff --git a/app/templates/GroupMembers/fields.inc b/app/templates/GroupMembers/fields.inc index 5a2308c09..f88c6b510 100644 --- a/app/templates/GroupMembers/fields.inc +++ b/app/templates/GroupMembers/fields.inc @@ -36,7 +36,7 @@ if($vv_action == 'add') { $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => '', - 'labelText' => __d('field','name'), + 'fieldLabel' => __d('field','name'), 'groupmember' => $vv_selected_person ] ]); @@ -45,7 +45,7 @@ if($vv_action == 'add') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'person_id', - 'options' => [ + 'fieldOptions' => [ 'class' => 'form-control people-autocomplete', 'placeholder' => __d('operation','autocomplete.people.placeholder'), 'id' => 'person_id', diff --git a/app/templates/Groups/fields.inc b/app/templates/Groups/fields.inc index fb6282ef2..fb408df14 100644 --- a/app/templates/Groups/fields.inc +++ b/app/templates/Groups/fields.inc @@ -39,7 +39,7 @@ foreach(['name', print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => $field, - 'options' => $options + 'fieldOptions' => $options ] ]); } @@ -54,7 +54,7 @@ if($vv_action != 'add') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'group_type', - 'options' => [ + 'fieldOptions' => [ 'readonly' => true ] ] diff --git a/app/templates/HistoryRecords/fields.inc b/app/templates/HistoryRecords/fields.inc index df320b062..2bc8d628c 100644 --- a/app/templates/HistoryRecords/fields.inc +++ b/app/templates/HistoryRecords/fields.inc @@ -151,7 +151,7 @@ if($vv_action == 'add' || $vv_action == 'view') { 'fieldName' => 'actor_person_id', 'status' => $vv_obj->actor_person->names[0]->full_name, 'link' => $viewLink, - 'labelText' => __d('field', 'actor') + 'fieldLabel' => __d('field', 'actor') ] ]); } diff --git a/app/templates/IdentifierAssignments/fields.inc b/app/templates/IdentifierAssignments/fields.inc index 7dfcb6d43..93ca8e381 100644 --- a/app/templates/IdentifierAssignments/fields.inc +++ b/app/templates/IdentifierAssignments/fields.inc @@ -85,7 +85,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'context', - 'options' => [ + 'fieldOptions' => [ 'onChange' => 'updateGadgets()' ] ] @@ -94,7 +94,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'identifier_type_id', - 'options' => [ + 'fieldOptions' => [ 'onChange' => 'resetType("email-address-type-id")' ] ] @@ -109,7 +109,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'email_address_type_id', - 'options' => [ + 'fieldOptions' => [ 'onChange' => 'resetType("identifier-type-id")' ] ] diff --git a/app/templates/Identifiers/fields.inc b/app/templates/Identifiers/fields.inc index eb5e9c6d2..5d0b03a34 100644 --- a/app/templates/Identifiers/fields.inc +++ b/app/templates/Identifiers/fields.inc @@ -34,7 +34,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_type ] ]]); diff --git a/app/templates/Jobs/fields.inc b/app/templates/Jobs/fields.inc index 769b51c27..bd6d9f1a7 100644 --- a/app/templates/Jobs/fields.inc +++ b/app/templates/Jobs/fields.inc @@ -30,7 +30,7 @@ if($vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'plugin', - 'labelText' => __d('controller', 'Jobs', [1]) + 'fieldLabel' => __d('controller', 'Jobs', [1]) ] ]); diff --git a/app/templates/Names/fields.inc b/app/templates/Names/fields.inc index 112e65923..f4a19b41d 100644 --- a/app/templates/Names/fields.inc +++ b/app/templates/Names/fields.inc @@ -41,7 +41,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_type ] ]]); @@ -63,7 +63,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'description', - 'options' => [ + 'fieldOptions' => [ 'readonly' => $vv_obj->primary_name ] ]]); diff --git a/app/templates/People/fields.inc b/app/templates/People/fields.inc index d16a99e31..016c50412 100644 --- a/app/templates/People/fields.inc +++ b/app/templates/People/fields.inc @@ -36,7 +36,7 @@ if($vv_action == 'add') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'names.0.'.$f, - 'options' => [ + 'fieldOptions' => [ 'required' => in_array($f, $vv_required_name_fields) ], 'fieldType' => 'string' @@ -47,7 +47,7 @@ if($vv_action == 'add') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'names.0.type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_name_type ], 'fieldType' => 'string' diff --git a/app/templates/PersonRoles/fields.inc b/app/templates/PersonRoles/fields.inc index 7265f1031..3a103add4 100644 --- a/app/templates/PersonRoles/fields.inc +++ b/app/templates/PersonRoles/fields.inc @@ -35,16 +35,13 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' =>'affiliation_type_id', - 'labelText' => __d('field', 'affiliation') + 'fieldLabel' => __d('field', 'affiliation') ] ]); print $this->element('form/listItem', [ 'arguments' => [ - 'fieldName' =>'status', - 'options' => [ - 'empty' => false - ] + 'fieldName' =>'status' ] ]); @@ -77,7 +74,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { 'fieldName' => $f.'_person_id', 'status' => $fname, 'link' => $flink, - 'labelText' => __d('field', $f) + 'fieldLabel' => __d('field', $f) ] ]); } diff --git a/app/templates/Pipelines/fields.inc b/app/templates/Pipelines/fields.inc index a9ee9794f..58a956008 100644 --- a/app/templates/Pipelines/fields.inc +++ b/app/templates/Pipelines/fields.inc @@ -66,7 +66,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'match_strategy', - 'options' => [ + 'fieldOptions' => [ 'onChange' => 'updateGadgets()' ], 'fieldType' => 'select' diff --git a/app/templates/Pronouns/fields.inc b/app/templates/Pronouns/fields.inc index aa57d4a69..0104a3b7f 100644 --- a/app/templates/Pronouns/fields.inc +++ b/app/templates/Pronouns/fields.inc @@ -34,7 +34,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_type ] ]]); diff --git a/app/templates/ProvisioningTargets/fields.inc b/app/templates/ProvisioningTargets/fields.inc index 0162116d2..682bbd11e 100644 --- a/app/templates/ProvisioningTargets/fields.inc +++ b/app/templates/ProvisioningTargets/fields.inc @@ -57,7 +57,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'description', - 'options' => [ + 'fieldOptions' => [ 'onChange' => 'updateGadgets()', 'default' => \App\Lib\Enum\ProvisionerModeEnum::QueueOnError ] @@ -66,7 +66,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'description', - 'options' => [ + 'fieldOptions' => [ 'default' => 900 ] ]]); diff --git a/app/templates/TelephoneNumbers/fields.inc b/app/templates/TelephoneNumbers/fields.inc index 7161577a5..fe47db851 100644 --- a/app/templates/TelephoneNumbers/fields.inc +++ b/app/templates/TelephoneNumbers/fields.inc @@ -41,7 +41,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_type ] ]]); diff --git a/app/templates/Types/fields.inc b/app/templates/Types/fields.inc index 476167f6e..d235049c1 100644 --- a/app/templates/Types/fields.inc +++ b/app/templates/Types/fields.inc @@ -51,7 +51,7 @@ if($vv_action == 'add' || $vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'attribute', - 'options' => [ + 'fieldOptions' => [ 'onChange' => 'updateGadgets()', 'readonly' => $vv_action == 'edit' ] diff --git a/app/templates/Urls/fields.inc b/app/templates/Urls/fields.inc index 4e45ab386..4d48a815a 100644 --- a/app/templates/Urls/fields.inc +++ b/app/templates/Urls/fields.inc @@ -34,7 +34,7 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { print $this->element('form/listItem', [ 'arguments' => [ 'fieldName' => 'type_id', - 'options' => [ + 'fieldOptions' => [ 'default' => $vv_default_type ] ]]); diff --git a/app/templates/element/form/fieldDiv.php b/app/templates/element/form/fieldDiv.php index ecec7e2e4..2f383ca68 100644 --- a/app/templates/element/form/fieldDiv.php +++ b/app/templates/element/form/fieldDiv.php @@ -35,7 +35,7 @@ print $this->element('form/nameDiv'); // Info Div - if(isset($vv_field_arguments['prefix'])) { + if(isset($vv_field_arguments['fieldPrefix'])) { print $this->element('form/infoDiv/withPrefix'); } elseif(isset($vv_field_arguments['status'])) { print $this->element('form/infoDiv/status'); diff --git a/app/templates/element/form/infoDiv/withPrefix.php b/app/templates/element/form/infoDiv/withPrefix.php index c5a80d0a7..0881534b5 100644 --- a/app/templates/element/form/infoDiv/withPrefix.php +++ b/app/templates/element/form/infoDiv/withPrefix.php @@ -31,7 +31,7 @@
    - +
    Fieeld->formField(...$vv_field_arguments)?>
    diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index 8cc7a49f9..daa8295c7 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -29,7 +29,7 @@ /* * Parameters * string $fieldName - * string $labelText + * string $fieldLabel * bool $labelIsTextOnly */ @@ -57,7 +57,7 @@ } [$label, $desc] = $this->Fieeld->calculateLabelAndDescription($fn); -$label = $vv_field_arguments['labelText'] ?? $label; +$label = $vv_field_arguments['fieldLabel'] ?? $label; // Extra class required for the grouped controls elements if(isset($groupedControls)) { From 75f4f88f5f0c9aa1259832ad316fcde3a5091a90 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sun, 28 Apr 2024 09:33:11 +0300 Subject: [PATCH 25/35] Available plugins.Alert to element. --- .../src/Model/Table/ApiSourcesTable.php | 6 +- .../templates/ApiSources/fields.inc | 11 +++- .../templates/FileProvisioners/fields.inc | 6 +- .../templates/FileSources/fields.inc | 22 ++++--- .../templates/SqlProvisioners/fields.inc | 17 ++++- app/src/View/Helper/AlertHelper.php | 53 ++------------- app/src/View/Helper/FieeldHelper.php | 34 +++++----- app/templates/ApiUsers/fields.inc | 2 +- app/templates/Cos/select.php | 2 +- app/templates/Dashboards/configuration.php | 6 +- app/templates/Dashboards/search.php | 4 +- .../ExtIdentitySourceRecords/fields.inc | 5 +- app/templates/ExternalIdentities/fields.inc | 8 ++- .../ExternalIdentitySources/retrieve.php | 3 +- .../ExternalIdentitySources/search.php | 5 +- app/templates/ProvisioningTargets/status.php | 4 +- .../element/filter/dateTimeFilters.php | 4 +- app/templates/element/flash.php | 4 +- app/templates/element/flash/default.php | 2 +- app/templates/element/flash/error.php | 6 +- app/templates/element/flash/information.php | 6 +- app/templates/element/flash/success.php | 6 +- .../element/form/infoDiv/autocomplete.php | 2 +- app/templates/element/menuPanel.php | 6 +- app/templates/element/notify/alert.php | 65 +++++++++++++++++++ app/templates/element/{ => notify}/banner.php | 2 +- app/templates/element/notify/closeButton.php | 35 ++++++++++ 27 files changed, 221 insertions(+), 105 deletions(-) create mode 100644 app/templates/element/notify/alert.php rename app/templates/element/{ => notify}/banner.php (95%) create mode 100644 app/templates/element/notify/closeButton.php diff --git a/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php b/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php index fd4b255e4..cf4fd5866 100644 --- a/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php +++ b/app/availableplugins/ApiConnector/src/Model/Table/ApiSourcesTable.php @@ -189,7 +189,7 @@ protected function mapApiToRegistry(string $model, array $attributes): array { */ public function remove( - \App\Model\Entity\ExternalIdentitySource $source, + \App\Model\Entity\ExternalIdentitySource $source, string $sorId ): array { // We call this remove() so as not to interfere with the default table::delete(). @@ -293,7 +293,7 @@ protected function resultToEntityData(array $result): array { */ public function retrieve( - \App\Model\Entity\ExternalIdentitySource $source, + \App\Model\Entity\ExternalIdentitySource $source, string $source_key ): array { $ret = [ @@ -328,7 +328,7 @@ public function retrieve( */ public function search( - \App\Model\Entity\ExternalIdentitySource $source, + \App\Model\Entity\ExternalIdentitySource $source, array $searchAttrs ): array { $ret = []; diff --git a/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc b/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc index 6eb871263..8bd3e6ec6 100644 --- a/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc +++ b/app/availableplugins/ApiConnector/templates/ApiSources/fields.inc @@ -30,8 +30,15 @@ if($vv_action == 'add' || $vv_action == 'edit') { print '
  • ' . __d('api_connector', 'field.ApiSources.push_mode') . '

  • '; - print $this->Field->banner(__d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])); + print $this->element('banner', [ + 'info' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint]) + ]); - print $this->Field->control('api_user_id'); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'api_user_id', + ] + ]); } diff --git a/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc b/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc index 4980a687a..d5e5c8353 100644 --- a/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc +++ b/app/availableplugins/FileConnector/templates/FileProvisioners/fields.inc @@ -27,5 +27,9 @@ // This view does currently not support read-only if($vv_action == 'add' || $vv_action == 'edit') { - print $this->Field->control('filename'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'filename', + ] + ]); } diff --git a/app/availableplugins/FileConnector/templates/FileSources/fields.inc b/app/availableplugins/FileConnector/templates/FileSources/fields.inc index 2380fe7bb..e9e7ae621 100644 --- a/app/availableplugins/FileConnector/templates/FileSources/fields.inc +++ b/app/availableplugins/FileConnector/templates/FileSources/fields.inc @@ -27,13 +27,17 @@ // This view does currently not support read-only if($vv_action == 'add' || $vv_action == 'edit') { - print $this->Field->control('filename'); - - print $this->Field->control('format'); - - print $this->Field->control('archivedir'); - - print $this->Field->control('threshold_warn'); - - print $this->Field->control('threshold_override'); + foreach([ + 'filename', + 'format', + 'archivedir', + 'threshold_warn', + 'threshold_override', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + ] + ]); + } } diff --git a/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc b/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc index 2b23c2634..ff3da2816 100644 --- a/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc +++ b/app/availableplugins/SqlConnector/templates/SqlProvisioners/fields.inc @@ -27,7 +27,18 @@ // This view does currently not support read-only if($vv_action == 'add' || $vv_action == 'edit') { - print $this->Field->control('server_id'); - - print $this->Field->control('table_prefix', ['default' => 'sp_']); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'server_id', + ] + ]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'table_prefix', + 'options' => [ + 'default' => 'sp_' + ] + ] + ]); } diff --git a/app/src/View/Helper/AlertHelper.php b/app/src/View/Helper/AlertHelper.php index d653759df..b4b083af5 100644 --- a/app/src/View/Helper/AlertHelper.php +++ b/app/src/View/Helper/AlertHelper.php @@ -45,52 +45,13 @@ * @since COmanage Registry v5.0.0 */ class AlertHelper extends Helper { - - public $helpers = ['Html']; - - public function alert( - string $message, - string $type = 'warning', - bool $dismissable = false, - string $title = null ) { - - $closeButton = ''; - $dismissableClass = ''; - if($dismissable) { - $closeButton = ' - - - - '; - $dismissableClass = ' alert-dismissible'; - } - - $titleMarkup = ''; - if(!empty($title)) { - $titleMarkup = '' . $title . ''; - } - - return ' - - '; - } - - public function getAlertIcon(string $type) { - switch($type) { - case('success'): return 'check_circle'; - case('information'): return 'info'; - default: return 'report_problem'; - } + public function getAlertIcon(string $type): string + { + return match($type) { + 'success' => 'check_circle', + 'information' => 'info', + default => 'report_problem' + }; } } \ No newline at end of file diff --git a/app/src/View/Helper/FieeldHelper.php b/app/src/View/Helper/FieeldHelper.php index 21e69ed2e..29acdff70 100644 --- a/app/src/View/Helper/FieeldHelper.php +++ b/app/src/View/Helper/FieeldHelper.php @@ -273,39 +273,39 @@ public function dateField(string $fieldName, /** * Create the actual Form element * - * @param string $fieldName Form field - * @param array|null $options FormHelper control options - * @param string|null $labelText - * @param string $prefix Field prefix - used for API Usernames - * @param string|null $fieldType + * @param string $fieldName Form field + * @param array|null $fieldOptions The second parameter of the Form->control helper. List of element options + * @param string|null $fieldLabel Custom label thext + * @param string $fieldPrefix If the field has a specil prefix provide the value + * @param string|null $fieldType Field type to override the one calculated from the schema * * @return string HTML element * @since COmanage Registry v5.0.0 */ public function formField(string $fieldName, - array $options = null, - string $labelText = null, - string $prefix = '', // api user + array $fieldOptions = null, + string $fieldLabel = null, + string $fieldPrefix = '', string $fieldType = null): string { - $fieldArgs = $options ?? []; - $fieldArgs['label'] = $options['label'] ?? false; + $fieldArgs = $fieldOptions ?? []; + $fieldArgs['label'] = $fieldOptions['label'] ?? false; $fieldArgs['readonly'] = !$this->editable - || (isset($options['readonly']) && $options['readonly']) + || (isset($fieldOptions['readonly']) && $fieldOptions['readonly']) || ($fieldName == 'plugin' && $this->action == 'edit'); // Selects, Checkboxes, and Radio Buttons use "disabled" $fieldArgs['disabled'] = $fieldArgs['readonly']; - $fieldArgs['required'] = (bool)$this->isReqField($fieldName); + $fieldArgs['required'] = $this->isReqField($fieldName); // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') $fieldType = $fieldType ?? $this->getFieldType($fieldName); // Remove prefix from field value - if(!empty($prefix) && !empty($this->getEntity()->$fieldName)) { + if(!empty($fieldPrefix) && !empty($this->getEntity()->$fieldName)) { $vv_obj = $this->getView()->get('vv_obj'); $fieldValue = $vv_obj->$fieldName; - $fieldValueTemp = str_replace($prefix, '', $fieldValue); + $fieldValueTemp = str_replace($fieldPrefix, '', $fieldValue); $vv_obj->$fieldName = $fieldValueTemp; $this->getView()->set('vv_obj', $vv_obj); } @@ -315,8 +315,8 @@ public function formField(string $fieldName, // Note this will be ignored for non-select controls. if(\in_array($fieldName, ['status', 'sync_status_on_delete'], true)) { $fieldArgs['empty'] = false; - } elseif(isset($options['empty'])) { - $fieldArgs['empty'] = $options['empty']; + } elseif(isset($fieldOptions['empty'])) { + $fieldArgs['empty'] = $fieldOptions['empty']; } else { $fieldArgs['empty'] = true; } @@ -324,7 +324,7 @@ public function formField(string $fieldName, // A boolean field is a checkbox. Set the label and class to improve rendering // and accessibility. if($fieldType === 'boolean') { - $fieldArgs['label'] = $labelText; + $fieldArgs['label'] = $fieldLabel; $fieldArgs['class'] = 'form-check-input'; } elseif($fieldType === 'date') { return $this->dateField($fieldName, DateTypeEnum::DateOnly); diff --git a/app/templates/ApiUsers/fields.inc b/app/templates/ApiUsers/fields.inc index 349916d8a..e8cba5cac 100644 --- a/app/templates/ApiUsers/fields.inc +++ b/app/templates/ApiUsers/fields.inc @@ -28,7 +28,7 @@ // This view does not support read-only if($vv_action == 'add' || $vv_action == 'edit') { if($vv_cur_co->id == 1) { - print $this->element('banner', __d('information', 'api.cmp')); + print $this->element('banner', ['info' => __d('information', 'api.cmp')]); } // AR-ApiUser-3 For namespacing purposes, API Users are named with a prefix consisting of the string "co_#.". diff --git a/app/templates/Cos/select.php b/app/templates/Cos/select.php index b62bb20a5..b18e1833b 100644 --- a/app/templates/Cos/select.php +++ b/app/templates/Cos/select.php @@ -35,7 +35,7 @@
    - Alert->alert(__d('information','cos.none'), 'warning') ?> + element('notify/alert', ['message' => __d('information','cos.none')]) ?>

    diff --git a/app/templates/Dashboards/configuration.php b/app/templates/Dashboards/configuration.php index 10c307cb7..1ecc290c9 100644 --- a/app/templates/Dashboards/configuration.php +++ b/app/templates/Dashboards/configuration.php @@ -145,6 +145,10 @@ ]; ?>
    - Alert->alert(__d('information','cmp.config.notice', $noticeUrls), 'information', true) ?> + element('notify/alert', [ + 'message' => __d('information','cmp.config.notice', $noticeUrls), + 'type' => 'information', + 'dismissible' => true + ]) ?>
    \ No newline at end of file diff --git a/app/templates/Dashboards/search.php b/app/templates/Dashboards/search.php index 3481f9fd2..e39f29d6b 100644 --- a/app/templates/Dashboards/search.php +++ b/app/templates/Dashboards/search.php @@ -59,13 +59,13 @@ - Alert->alert($b, 'warning') ?> + element('notify/alert', ['message' => $b]) ?> - Alert->alert($b, 'warning') ?> + element('notify/alert', ['message' => $b]) ?>
    diff --git a/app/templates/ExtIdentitySourceRecords/fields.inc b/app/templates/ExtIdentitySourceRecords/fields.inc index b1eb8aa5f..47df19b92 100644 --- a/app/templates/ExtIdentitySourceRecords/fields.inc +++ b/app/templates/ExtIdentitySourceRecords/fields.inc @@ -42,7 +42,10 @@ $noticeText = __d( ] ); -print $this->Alert->alert($noticeText, 'information', false); +print $this->element('notify/alert', [ + 'message' => $noticeText, + 'type' => 'information' +]); // This view does not support add or edit if($vv_action == 'view') { diff --git a/app/templates/ExternalIdentities/fields.inc b/app/templates/ExternalIdentities/fields.inc index 8741f75ad..4f5eeaff2 100644 --- a/app/templates/ExternalIdentities/fields.inc +++ b/app/templates/ExternalIdentities/fields.inc @@ -43,8 +43,12 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') { ) ] ); - - print $this->Alert->alert($noticeText, 'information', false); + + $this->element('notify/alert', [ + 'message' => $noticeText, + 'type' => 'information' + ]); + } print $this->element('form/listItem', [ diff --git a/app/templates/ExternalIdentitySources/retrieve.php b/app/templates/ExternalIdentitySources/retrieve.php index b50364847..f0925635d 100644 --- a/app/templates/ExternalIdentitySources/retrieve.php +++ b/app/templates/ExternalIdentitySources/retrieve.php @@ -105,8 +105,7 @@ ); } ?> -Alert->alert($noticeText, 'information', false) ?> - +element('notify/alert', ['message' => $noticeText,'type' => 'information']) ?>

    diff --git a/app/templates/ExternalIdentitySources/search.php b/app/templates/ExternalIdentitySources/search.php index a7b841cec..65c166613 100644 --- a/app/templates/ExternalIdentitySources/search.php +++ b/app/templates/ExternalIdentitySources/search.php @@ -42,7 +42,10 @@
    - Alert->alert(__d('information', 'ExternalIdentitySources.search.attrs.none'), 'information', false) ?> + element('notify/alert', [ + 'message' => __d('information', 'ExternalIdentitySources.search.attrs.none'), + 'type' => 'information' + ]) ?> - Alert->alert($b, 'warning') ?> + element('notify/alert', ['message' => $b]) ?> - Alert->alert($b, 'warning') ?> + element('notify/alert', ['message' => $b]) ?>
    diff --git a/app/templates/element/filter/dateTimeFilters.php b/app/templates/element/filter/dateTimeFilters.php index 4c7440dba..a3ad78d2f 100644 --- a/app/templates/element/filter/dateTimeFilters.php +++ b/app/templates/element/filter/dateTimeFilters.php @@ -42,7 +42,7 @@ Form->label("{$key}_starts_at", __d('field', 'starts_at'), ['class' => 'filter-datepicker-lbl']); - print $this->Field->dateField("{$key}_starts_at", DateTypeEnum::DateOnly, $query)['controlCode']; + print $this->Fieeld->dateField("{$key}_starts_at", DateTypeEnum::DateOnly, $query); ?>
    @@ -50,7 +50,7 @@ Form->label("{$key}_ends_at", __d('field','ends_at'), ['class' => 'filter-datepicker-lbl']); - print $this->Field->dateField("{$key}_ends_at", DateTypeEnum::DateOnly, $query)['controlCode']; + print $this->Fieeld->dateField("{$key}_ends_at", DateTypeEnum::DateOnly, $query); ?>
    diff --git a/app/templates/element/flash.php b/app/templates/element/flash.php index 5c6a91f26..3809206e3 100644 --- a/app/templates/element/flash.php +++ b/app/templates/element/flash.php @@ -32,13 +32,13 @@ - Alert->alert($b, 'warning') ?> + element('notify/alert', ['message' => $b]) ?> - Alert->alert($b, 'warning') ?> + element('notify/alert', ['message' => $b]) ?>
    \ No newline at end of file diff --git a/app/templates/element/flash/default.php b/app/templates/element/flash/default.php index 325e35513..7484ee14a 100644 --- a/app/templates/element/flash/default.php +++ b/app/templates/element/flash/default.php @@ -8,6 +8,6 @@ - Alert->alert($message, 'warning', true) ?> + element('notify/alert', ['message' => $message]) ?> diff --git a/app/templates/element/flash/error.php b/app/templates/element/flash/error.php index 8069a15da..c77a0eac9 100644 --- a/app/templates/element/flash/error.php +++ b/app/templates/element/flash/error.php @@ -8,5 +8,9 @@ - Alert->alert($message, 'danger', true) ?> + element('notify/alert', [ + 'message' => $message, + 'type' => 'danger', + 'dismissible' => true + ]) ?> diff --git a/app/templates/element/flash/information.php b/app/templates/element/flash/information.php index 26dc52329..c7b7b83b1 100644 --- a/app/templates/element/flash/information.php +++ b/app/templates/element/flash/information.php @@ -8,5 +8,9 @@ - Alert->alert($message, 'information', true) ?> + element('notify/alert', [ + 'message' => $message, + 'type' => 'information', + 'dismissible' => true + ]) ?> \ No newline at end of file diff --git a/app/templates/element/flash/success.php b/app/templates/element/flash/success.php index 6f0671bb0..17c7469d5 100644 --- a/app/templates/element/flash/success.php +++ b/app/templates/element/flash/success.php @@ -8,5 +8,9 @@ - Alert->alert($message, 'success', true) ?> + element('notify/alert', [ + 'message' => $message, + 'type' => 'success', + 'dismissible' => true + ]) ?> \ No newline at end of file diff --git a/app/templates/element/form/infoDiv/autocomplete.php b/app/templates/element/form/infoDiv/autocomplete.php index 02477afab..787a54c1a 100644 --- a/app/templates/element/form/infoDiv/autocomplete.php +++ b/app/templates/element/form/infoDiv/autocomplete.php @@ -51,7 +51,7 @@ Form->hidden($fieldName, $vv_field_arguments['options']) . $this->element('peopleAutocomplete', $autocompleteArgs); + print $this->Form->hidden($fieldName, $vv_field_arguments['fieldOptions']) . $this->element('peopleAutocomplete', $autocompleteArgs); ?>
    info diff --git a/app/templates/element/menuPanel.php b/app/templates/element/menuPanel.php index d4065b255..8790380c3 100644 --- a/app/templates/element/menuPanel.php +++ b/app/templates/element/menuPanel.php @@ -485,7 +485,11 @@ ]; ?>
    - Alert->alert(__d('information','cmp.config.notice', $noticeUrls), 'information', true) ?> + element('notify/alert', [ + 'message' => __d('information','cmp.config.notice', $noticeUrls), + 'type' => 'information', + 'dismissible' => true + ]) ?>
    diff --git a/app/templates/element/notify/alert.php b/app/templates/element/notify/alert.php new file mode 100644 index 000000000..2d316f8ea --- /dev/null +++ b/app/templates/element/notify/alert.php @@ -0,0 +1,65 @@ + + + diff --git a/app/templates/element/banner.php b/app/templates/element/notify/banner.php similarity index 95% rename from app/templates/element/banner.php rename to app/templates/element/notify/banner.php index c0393c6c1..27bfdfbaa 100644 --- a/app/templates/element/banner.php +++ b/app/templates/element/notify/banner.php @@ -35,5 +35,5 @@
  • - Alert->alert($info, 'warning') ?> + element('notify/alert', ['message' => $info]) ?>
  • diff --git a/app/templates/element/notify/closeButton.php b/app/templates/element/notify/closeButton.php new file mode 100644 index 000000000..b7f5efa99 --- /dev/null +++ b/app/templates/element/notify/closeButton.php @@ -0,0 +1,35 @@ + + + + + \ No newline at end of file From 53ca43dbb2961329733267ab056c235ed0ca9230 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sun, 28 Apr 2024 09:52:58 +0300 Subject: [PATCH 26/35] required field fix for nameDiv and infoDiv. Take fieldOptions into consideration. --- app/src/View/Helper/FieeldHelper.php | 4 ++-- app/templates/element/form/nameDiv.php | 9 ++++++++- app/templates/element/notify/banner.php | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/View/Helper/FieeldHelper.php b/app/src/View/Helper/FieeldHelper.php index 29acdff70..e829b839e 100644 --- a/app/src/View/Helper/FieeldHelper.php +++ b/app/src/View/Helper/FieeldHelper.php @@ -291,12 +291,12 @@ public function formField(string $fieldName, $fieldArgs = $fieldOptions ?? []; $fieldArgs['label'] = $fieldOptions['label'] ?? false; $fieldArgs['readonly'] = !$this->editable - || (isset($fieldOptions['readonly']) && $fieldOptions['readonly']) + || \boolval($fieldOptions['readonly']) || ($fieldName == 'plugin' && $this->action == 'edit'); // Selects, Checkboxes, and Radio Buttons use "disabled" $fieldArgs['disabled'] = $fieldArgs['readonly']; - $fieldArgs['required'] = $this->isReqField($fieldName); + $fieldArgs['required'] = $this->isReqField($fieldName) ?? boolval($fieldOptions['required']); // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') $fieldType = $fieldType ?? $this->getFieldType($fieldName); diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index daa8295c7..45e80d0e6 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -59,6 +59,10 @@ [$label, $desc] = $this->Fieeld->calculateLabelAndDescription($fn); $label = $vv_field_arguments['fieldLabel'] ?? $label; +// Override the default required behavior is the field has the required +// option set +$optionsRequired = boolval($vv_field_arguments['fieldOptions']['required']); + // Extra class required for the grouped controls elements if(isset($groupedControls)) { $classes .= 'align-top '; @@ -78,7 +82,10 @@ Fieeld->isEditable() && $this->Fieeld->isReqField($fn)) { + if($this->Fieeld->isEditable() + && + ($this->Fieeld->isReqField($fn) || $optionsRequired) + ) { print $this->element('form/requiredSpan'); } ?> diff --git a/app/templates/element/notify/banner.php b/app/templates/element/notify/banner.php index 27bfdfbaa..927e7fc0f 100644 --- a/app/templates/element/notify/banner.php +++ b/app/templates/element/notify/banner.php @@ -28,8 +28,8 @@ declare(strict_types = 1); -// Params required: -// $info +// Parameters: +// $info: String, required ?> From d69bb7c947249a96962bc00f4c2bd8d42b134b08 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sun, 28 Apr 2024 11:04:29 +0300 Subject: [PATCH 27/35] cleanup --- app/src/View/Helper/AlertHelper.php | 19 ++++----- app/src/View/Helper/FieeldHelper.php | 52 ++++++++++++------------- app/templates/element/form/listItem.php | 10 ++++- app/templates/element/form/nameDiv.php | 3 +- app/templates/element/notify/alert.php | 1 + app/webroot/js/comanage/comanage.js | 2 +- 6 files changed, 43 insertions(+), 44 deletions(-) diff --git a/app/src/View/Helper/AlertHelper.php b/app/src/View/Helper/AlertHelper.php index b4b083af5..0c3d1ef68 100644 --- a/app/src/View/Helper/AlertHelper.php +++ b/app/src/View/Helper/AlertHelper.php @@ -32,19 +32,14 @@ use \Cake\View\Helper; use phpDocumentor\Reflection\Types\Boolean; -/** - * Helper which will produce Bootstrap based alert - * - * @param string $message Alert message - * @param string $type Define the type of Alert. The value should be one of - * [success,warning,danger,info]. Defaults to 'warning' - * @param boolean $dismissable Can the Alert be dismissed? Defaults to false. - * @param string|null $title Title to display (typically "Success", "Error", or "Warning"). Defaults to null. - * @param boolean $dis_text_dark Disable dark-text fonts for light|info color mode. - * @return mixed - a constructed HTML block - * @since COmanage Registry v5.0.0 - */ class AlertHelper extends Helper { + /** + * Map Alert Type to Icon + * + * @param string $type + * + * @return string + */ public function getAlertIcon(string $type): string { return match($type) { diff --git a/app/src/View/Helper/FieeldHelper.php b/app/src/View/Helper/FieeldHelper.php index e829b839e..39288877f 100644 --- a/app/src/View/Helper/FieeldHelper.php +++ b/app/src/View/Helper/FieeldHelper.php @@ -291,15 +291,19 @@ public function formField(string $fieldName, $fieldArgs = $fieldOptions ?? []; $fieldArgs['label'] = $fieldOptions['label'] ?? false; $fieldArgs['readonly'] = !$this->editable - || \boolval($fieldOptions['readonly']) + || (isset($fieldOptions['readonly']) && $fieldOptions['readonly']) || ($fieldName == 'plugin' && $this->action == 'edit'); // Selects, Checkboxes, and Radio Buttons use "disabled" $fieldArgs['disabled'] = $fieldArgs['readonly']; - $fieldArgs['required'] = $this->isReqField($fieldName) ?? boolval($fieldOptions['required']); + $fieldArgs['required'] = $this->isReqField($fieldName) + || (isset($fieldOptions['required']) && $fieldOptions['required']); - // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') - $fieldType = $fieldType ?? $this->getFieldType($fieldName); + // Cause any select (except status) to render with a blank option, even + // if the field is required. This makes it clear when a value needs to be set. + // Note this will be ignored for non-select controls. + $fieldArgs['empty'] = !\in_array($fieldName, ['status', 'sync_status_on_delete'], true) + || (isset($fieldOptions['empty']) && $fieldOptions['empty']); // Remove prefix from field value if(!empty($fieldPrefix) && !empty($this->getEntity()->$fieldName)) { @@ -310,31 +314,23 @@ public function formField(string $fieldName, $this->getView()->set('vv_obj', $vv_obj); } - // Cause any select (except status) to render with a blank option, even - // if the field is required. This makes it clear when a value needs to be set. - // Note this will be ignored for non-select controls. - if(\in_array($fieldName, ['status', 'sync_status_on_delete'], true)) { - $fieldArgs['empty'] = false; - } elseif(isset($fieldOptions['empty'])) { - $fieldArgs['empty'] = $fieldOptions['empty']; - } else { - $fieldArgs['empty'] = true; - } - - // A boolean field is a checkbox. Set the label and class to improve rendering - // and accessibility. - if($fieldType === 'boolean') { - $fieldArgs['label'] = $fieldLabel; - $fieldArgs['class'] = 'form-check-input'; - } elseif($fieldType === 'date') { - return $this->dateField($fieldName, DateTypeEnum::DateOnly); - } elseif($fieldType == 'datetime' || $fieldType == 'timestamp') { - return $this->dateField($fieldName); - } - + // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') + $fieldType = $fieldType ?? $this->getFieldType($fieldName); // Generate the form control or pass along the markup generated in a wrapper function - return $this->Form->control($fieldName, $fieldArgs); - + return match($fieldType) { + // A boolean field is a checkbox. Set the label and class to improve rendering + // and accessibility. + 'boolean' => $this->Form->control($fieldName, [ + // First import and then overwrite + ...$fieldArgs, + 'label' => $fieldLabel, + 'class' => 'form-check-input', + ]), + 'date' => $this->dateField($fieldName, DateTypeEnum::DateOnly), + 'datetime', + 'timestamp' => $this->dateField($fieldName), + default => $this->Form->control($fieldName, $fieldArgs) + }; } /** diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index 0d95d0355..a68337709 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -37,19 +37,25 @@ $this->set('fieldName', $arguments['fieldName']); $this->set('vv_field_arguments', $arguments); -// Additional classes calculation +// Class calculation by field Type $classes = match ($this->Fieeld->getFieldType($arguments['fieldName'])) { 'date', 'datetime', 'timestamp' => 'fields-datepicker ', + default => '' +}; + +// Class calculation by field name +$classes .= match ($arguments['fieldName']) { 'source_record' => 'source-record ', 'retry_interval', 'login' => 'subfield ', default => '' }; +// Class calculation by type of Info Div if(isset($arguments['autocomplete'])) { - $classes = 'fields-people-autocomplete '; + $classes .= 'fields-people-autocomplete '; } ?> diff --git a/app/templates/element/form/nameDiv.php b/app/templates/element/form/nameDiv.php index 45e80d0e6..e049384fe 100644 --- a/app/templates/element/form/nameDiv.php +++ b/app/templates/element/form/nameDiv.php @@ -61,7 +61,8 @@ // Override the default required behavior is the field has the required // option set -$optionsRequired = boolval($vv_field_arguments['fieldOptions']['required']); +$optionsRequired = isset($vv_field_arguments['fieldOptions']['required']) + && $vv_field_arguments['fieldOptions']['required']; // Extra class required for the grouped controls elements if(isset($groupedControls)) { diff --git a/app/templates/element/notify/alert.php b/app/templates/element/notify/alert.php index 2d316f8ea..d0e0af67a 100644 --- a/app/templates/element/notify/alert.php +++ b/app/templates/element/notify/alert.php @@ -39,6 +39,7 @@ $alertClass = "alert-{$type}"; $showButton = false; + if(isset($dismissible) && $dismissible) { $alertClass .= ' alert-dismissible'; $showButton = true; diff --git a/app/webroot/js/comanage/comanage.js b/app/webroot/js/comanage/comanage.js index f0d8b71fa..2d599837c 100644 --- a/app/webroot/js/comanage/comanage.js +++ b/app/webroot/js/comanage/comanage.js @@ -64,7 +64,7 @@ function showFields(fields, isPageLoad) { $('#' + field).closest('li').addClass('collapse show'); } else { $('#' + field).closest('li').collapse('show'); - } + } } } From 73c07557fb830a344903a2b86eff61043e367d8f Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sun, 28 Apr 2024 11:34:43 +0300 Subject: [PATCH 28/35] Add frozen and plugin configuration handling --- app/templates/element/form/listItem.php | 45 +++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index a68337709..ce97436a4 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -35,10 +35,11 @@ // - wrap them in an array. // We choose the latter. $this->set('fieldName', $arguments['fieldName']); +$fieldName = $arguments['fieldName']; $this->set('vv_field_arguments', $arguments); // Class calculation by field Type -$classes = match ($this->Fieeld->getFieldType($arguments['fieldName'])) { +$classes = match ($this->Fieeld->getFieldType($fieldName)) { 'date', 'datetime', 'timestamp' => 'fields-datepicker ', @@ -46,7 +47,7 @@ }; // Class calculation by field name -$classes .= match ($arguments['fieldName']) { +$classes .= match ($fieldName) { 'source_record' => 'source-record ', 'retry_interval', 'login' => 'subfield ', @@ -58,6 +59,46 @@ $classes .= 'fields-people-autocomplete '; } + +// If an attribute is frozen, inject a special link to unfreeze it, since +// the attribute is read-only and the admin can't simply uncheck the setting +if($fieldName == 'frozen' && $this->Fieeld->getEntity()->frozen) { + $url = [ + 'label' => __d('operation', 'unfreeze'), + 'url' => [ + 'plugin' => null, + 'controller' => \App\Lib\Util\StringUtilities::entityToClassname($this->Fieeld->getEntity()), + 'action' => 'unfreeze', + $this->Fieeld->getEntity()->id + ] + ]; + $arguments = [ + ...$arguments, + 'status' => __d('field', 'frozen'), + 'link' => $url, + ]; + $this->set('vv_field_arguments', $arguments); +} + +// If an attribute is a plugin, return the link to its configuration +if($fieldName == 'plugin' && $vv_action == 'edit') { + $url = [ + 'label' => __d('operation', 'configure.plugin'), + 'url' => [ + 'plugin' => null, + 'controller' => \App\Lib\Util\StringUtilities::entityToClassname($this->Fieeld->getEntity()), + 'action' => 'configure', + $this->Fieeld->getEntity()->id + ] + ]; + $arguments = [ + ...$arguments, + 'status' => $this->Fieeld->getEntity()->$fieldName, + 'link' => $url, + ]; + $this->set('vv_field_arguments', $arguments); +} + ?>
  • From b0f4163de2e754e4f5d393c770325afbb0067195 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sun, 28 Apr 2024 11:59:50 +0300 Subject: [PATCH 29/35] remove temp helper files --- app/src/Controller/ApiUsersController.php | 15 +- app/src/Controller/StandardController.php | 48 +- app/src/View/Helper/FieeldHelper.php | 450 --------- app/src/View/Helper/FieldHelper.php | 902 +++++------------- app/templates/Standard/add-edit-view-new.php | 219 ----- app/templates/Standard/add-edit-view.php | 57 +- .../element/filter/dateTimeFilters.php | 4 +- app/templates/element/filter/filter.php | 2 +- app/templates/element/form/infoDiv/check.php | 2 +- .../element/form/infoDiv/default.php | 2 +- .../element/form/infoDiv/grouped.php | 2 +- app/templates/element/form/infoDiv/source.php | 2 +- .../element/form/infoDiv/withPrefix.php | 2 +- app/templates/element/form/listItem.php | 14 +- app/templates/element/form/nameDiv.php | 10 +- app/templates/element/form/submit.php | 2 +- 16 files changed, 272 insertions(+), 1461 deletions(-) delete mode 100644 app/src/View/Helper/FieeldHelper.php delete mode 100644 app/templates/Standard/add-edit-view-new.php diff --git a/app/src/Controller/ApiUsersController.php b/app/src/Controller/ApiUsersController.php index 0d5859078..aa871b09b 100644 --- a/app/src/Controller/ApiUsersController.php +++ b/app/src/Controller/ApiUsersController.php @@ -64,19 +64,6 @@ public function generate(string $id) { $this->set('vv_title', $title); // Let the view render - if(in_array($this->name, [ - 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', - 'GroupMembers' - ]) - ) { - $this->render('/Standard/add-edit-view-new'); - } else { - // Let the view render - $this->render('/Standard/add-edit-view'); - } + $this->render('/Standard/add-edit-view'); } } \ No newline at end of file diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 921da8d7c..79085fed4 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -126,20 +126,7 @@ public function add() { $this->set('vv_subtitle', $subtitle); // Let the view render - if(in_array($this->name, [ - 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', - 'GroupMembers' - ]) - ) { - $this->render('/Standard/add-edit-view-new'); - } else { - // Let the view render - $this->render('/Standard/add-edit-view'); - } + $this->render('/Standard/add-edit-view'); } /** @@ -437,20 +424,8 @@ public function edit(string $id) { $this->set('vv_supertitle', $supertitle); $this->set('vv_subtitle', $subtitle); - if(in_array($this->name, [ - 'Cous', 'CoSettings', 'ApiUsers', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', - 'GroupMembers' - ]) - ) { - $this->render('/Standard/add-edit-view-new'); - } else { - // Let the view render - $this->render('/Standard/add-edit-view'); - } + // Let the view render + $this->render('/Standard/add-edit-view'); } /** @@ -895,21 +870,8 @@ public function view($id = null) { $this->set('vv_title', $title); $this->set('vv_supertitle', $supertitle); $this->set('vv_subtitle', $subtitle); - + // Let the view render - if(in_array($this->name, [ - 'Cous', 'ApiUsers', 'CoSettings', 'Cos', 'Addresses', 'EmailAddresses', - 'Groups', 'Servers', 'Types', 'Urls', 'Identifiers', 'HistoryRecords', - 'TelephoneNumbers', 'Names', 'AdHocAttributes', 'PersonRoles', 'ExternalIdentities', - 'ExternalIdentityRoles', 'ExternalIdentitySources', 'ExternalIdentitySourceRecords', - 'IdentifierAssignments', 'Jobs', 'JobHistoryRecords', 'People', 'GroupNestings', - 'GroupMembers' - ]) - ) { - $this->render('/Standard/add-edit-view-new'); - } else { - // Let the view render - $this->render('/Standard/add-edit-view'); - } + $this->render('/Standard/add-edit-view'); } } \ No newline at end of file diff --git a/app/src/View/Helper/FieeldHelper.php b/app/src/View/Helper/FieeldHelper.php deleted file mode 100644 index 39288877f..000000000 --- a/app/src/View/Helper/FieeldHelper.php +++ /dev/null @@ -1,450 +0,0 @@ -reqFields = $this->getView()->get('vv_required_fields'); - $this->modelName = $this->getView()->getName(); - $this->action = $this->getView()->get('vv_action'); - $this->editable = \in_array($this->action, ['add', 'edit']); - $this->pluginName = $this->getView()->getPlugin(); - $this->entity = $this->getView()->get('vv_obj'); - $this->fieldTypes = $this->getView()->get('vv_field_types'); - } - - /** - * We autogenerate field labels and descriptions from the field name. - * - * @param string $fieldName - * - * @return array - */ - public function calculateLabelAndDescription(string $fieldName): array - { - $desc = null; - $label = null; - - // First, try to autogenerate the field label (if we weren't given one). - $pluginDomain = (!empty($this->getPluginName()) - ? Inflector::underscore($this->getPluginName()) - : null); - - $modelName = $this->getModelName(); - // We try to automagically determine if a description for the field exists by - // looking for the corresponding .desc language translation. - // We autogenerate field labels and descriptions from the field name. - - // We loop over the field generation logic twice, first for a plugin - // context (if set) and then generally (if no plugin localization was found). - - // We use $core as the variable for this loop, so the rest of the code - // is easier to read (!$core = plugin) - for($core = 0;$core < 2;$core++) { - if(!$core && empty($this->pluginName)) { - // No plugin set, go to the core field checks - continue; - } - - // Is there a model specific key? For plugins, this will be in field.Model.Field - - $key = (!$core ? 'field.' : '') . "$modelName.$fieldName"; - $label = __d(($core ? 'field' : $pluginDomain), $key); - - if($label === $key) { - // Model-specific label isn't found, try again for a general label - - $f = null; - - if(preg_match('/^(.*?)_id$/', $fieldName, $f)) { - // Map foreign keys (foo_id) to the controller label - $key = (!$core ? 'controller.' : '') . Inflector::camelize(Inflector::pluralize($f[1])); - $label = __d(($core ? 'controller' : $pluginDomain), $key, [1]); - - if($key !== $label) { - break; - } - } - - // Look up the key - $key = (!$core ? 'field.' : '') . $fieldName; - $label = __d(($core ? 'field' : $pluginDomain), $key); - - if($key !== $label) { - break; - } - } else { - // If we found a key, break the loop - break; - } - } - // We try to automagically determine if a description for the field exists by - // looking for the corresponding .desc language translation. - - for($core = 0;$core < 2;$core++) { - if(!$core && empty($this->pluginName)) { - // No plugin set, just go to the core field checks - continue; - } - - $key = (!$core ? 'field.' : '') . "$modelName.$fieldName.desc"; - $desc = __d(($core ? 'field' : $pluginDomain), $key); - - // If the description is the literal key we just generated, there is no description - if($desc === $key) { - $desc = null; - } else { - break; - } - } - - return [$label, $desc]; - } - - /** - * Emit a date/time form control. - * This is a wrapper function for $this->control() - * - * @param string $fieldName Form field - * @param string $dateType Standard, DateOnly, FromTime, ThroughTime - * @param array|null $queryParams Request Query parameters used by the filtering Blocks to get the date values - * @param string|null $label - * - * @return string HTML element - * @since COmanage Registry v5.0.0 - */ - - public function dateField(string $fieldName, - string $dateType=DateTypeEnum::Standard, - array $queryParams=null, - string $label=null): string - { - // Initialize - $dateFormat = $dateType === DateTypeEnum::DateOnly ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'; - $dateTitle = $dateType === DateTypeEnum::DateOnly ? 'datepicker.enterDate' : 'datepicker.enterDateTime'; - $datePattern = $dateType === DateTypeEnum::DateOnly ? '\d{4}-\d{2}-\d{2}' : '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'; - $date_object = null; - - if(isset($queryParams)) { - if(!empty($queryParams[$fieldName])) { - $date_object = FrozenTime::parse($queryParams[$fieldName]); - } - } else { - // This is an entity view. We are getting the data from the object - $entity = $this->getView()->get('vv_obj'); - $date_object = $entity->$fieldName; - } - - // Create the options array for the (text input) form control - $coptions = []; - - // A datetime field will be rendered as a plain text input with adjacent date and time pickers - // that will interact with the field value. Allowing direct access to the input field is for - // accessibility purposes. - - // ACTION VIEW - if($this->action == 'view') { - // return the date as plaintext - $element = $this->getView()->element('form/notSetDiv'); - if ($date_object !== null) { - // Adjust the time back to the user's timezone - $element = ''; - } - - // Return this to the generic control() function - return $element; - } - - // Special-case the very common "valid_from" and "valid_through" fields, so we won't need - // to specify their types in fields.inc. - $pickerType = match ($fieldName) { - 'valid_from' => DateTypeEnum::FromTime, - 'valid_through' => DateTypeEnum::ThroughTime, - default => $dateType - }; - - // Append the timezone to the label - $coptions['class'] = 'form-control datepicker'; - $coptions['placeholder'] = $dateFormat; - if(!empty($label)) { - $coptions['label'] = $label; - } - $coptions['pattern'] = $datePattern; - $coptions['title'] = __d('field', $dateTitle); - - $coptions['id'] = str_replace('_', '-', $fieldName); - - - // Default the picker date to today - $now = FrozenTime::now(); - $pickerDate = $now->i18nFormat($dateFormat); - - // Get the existing values, if present - if($date_object !== null) { - // Adjust the time back to the user's timezone - $coptions['value'] = $date_object->i18nFormat($dateFormat); - $pickerDate = $date_object->i18nFormat($dateFormat); - } - - // Set the date picker floor year value (-100 years)() - $pickerDateFT = new FrozenTime($pickerDate); - $pickerDateFT = $pickerDateFT->subYears(100); - $pickerFloor = $pickerDateFT->i18nFormat($dateFormat); - - $date_picker_args = [ - 'fieldName' => $fieldName, - 'pickerDate' => $pickerDate, - 'pickerType' => $pickerType, - 'pickerFloor' => $pickerFloor, - ]; - - // Create a text field to hold our value and call the datePicker - return $this->Form->text($fieldName, $coptions) . $this->getView()->element('datePicker', $date_picker_args); - } - - /** - * Create the actual Form element - * - * @param string $fieldName Form field - * @param array|null $fieldOptions The second parameter of the Form->control helper. List of element options - * @param string|null $fieldLabel Custom label thext - * @param string $fieldPrefix If the field has a specil prefix provide the value - * @param string|null $fieldType Field type to override the one calculated from the schema - * - * @return string HTML element - * @since COmanage Registry v5.0.0 - */ - public function formField(string $fieldName, - array $fieldOptions = null, - string $fieldLabel = null, - string $fieldPrefix = '', - string $fieldType = null): string - { - $fieldArgs = $fieldOptions ?? []; - $fieldArgs['label'] = $fieldOptions['label'] ?? false; - $fieldArgs['readonly'] = !$this->editable - || (isset($fieldOptions['readonly']) && $fieldOptions['readonly']) - || ($fieldName == 'plugin' && $this->action == 'edit'); - - // Selects, Checkboxes, and Radio Buttons use "disabled" - $fieldArgs['disabled'] = $fieldArgs['readonly']; - $fieldArgs['required'] = $this->isReqField($fieldName) - || (isset($fieldOptions['required']) && $fieldOptions['required']); - - // Cause any select (except status) to render with a blank option, even - // if the field is required. This makes it clear when a value needs to be set. - // Note this will be ignored for non-select controls. - $fieldArgs['empty'] = !\in_array($fieldName, ['status', 'sync_status_on_delete'], true) - || (isset($fieldOptions['empty']) && $fieldOptions['empty']); - - // Remove prefix from field value - if(!empty($fieldPrefix) && !empty($this->getEntity()->$fieldName)) { - $vv_obj = $this->getView()->get('vv_obj'); - $fieldValue = $vv_obj->$fieldName; - $fieldValueTemp = str_replace($fieldPrefix, '', $fieldValue); - $vv_obj->$fieldName = $fieldValueTemp; - $this->getView()->set('vv_obj', $vv_obj); - } - - // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') - $fieldType = $fieldType ?? $this->getFieldType($fieldName); - // Generate the form control or pass along the markup generated in a wrapper function - return match($fieldType) { - // A boolean field is a checkbox. Set the label and class to improve rendering - // and accessibility. - 'boolean' => $this->Form->control($fieldName, [ - // First import and then overwrite - ...$fieldArgs, - 'label' => $fieldLabel, - 'class' => 'form-check-input', - ]), - 'date' => $this->dateField($fieldName, DateTypeEnum::DateOnly), - 'datetime', - 'timestamp' => $this->dateField($fieldName), - default => $this->Form->control($fieldName, $fieldArgs) - }; - } - - /** - * Emit a source control for an MVEA that has a source_foo_id field pointing - * to an External Identity attribute. - * - * @param Entity $entity Entity to emit control for - * - * @return string Source Link - * @since COmanage Registry v5.0.0 - */ - public function sourceLink($entity): string - { - // eg: Identifiers - // eg: source_identifier_id, or source_external_identity_role_id - $sourceFK = $this->getView()->get('vv_source_fk'); - // e.g.: source_identifier - we need to construct this from the $sourceFK - $sourceEntityName = substr($sourceFK, 0, strlen($sourceFK) - 3); - // In most cases, $sourceModelName = $modelName, but not for PersonRoles - $sourceModelName = substr(StringUtilities::foreignKeyToClassName($sourceFK), 6); - - $link = ''; - if (!empty($entity->$sourceFK)) { - $link .= $this->Html->Link( - title: __d('controller', $sourceModelName, [1]), - url: [ - 'controller' => $sourceModelName, - 'action' => 'view', - $entity->$sourceFK - ] - ); - } - - if (!empty($entity->$sourceEntityName)) { - $link .= ', ' . $this->Html->Link( - title: __d('controller', 'ExternalIdentities', [1]), - url: [ - 'controller' => 'external_identities', - 'action' => 'view', - $entity->$sourceEntityName->external_identity_id - ] - ); - } - return $link; - } - - /** - * @return bool - */ - public function isEditable(): bool - { - return $this->editable; - } - - /** - * @return string|null - */ - public function getPluginName(): ?string - { - return $this->pluginName; - } - - /** - * @return string|null - */ - public function getModelName(): ?string - { - return $this->modelName; - } - - /** - * @return object|null - */ - public function getEntity(): ?object - { - return $this->entity; - } - - /** - * @return array - */ - public function getReqFields(): array - { - return $this->reqFields; - } - - /** - * @param string $field - * - * @return bool - */ - public function isReqField(string $field): bool - { - return \in_array($field, $this->reqFields, true); - } - - - /** - * @return array - */ - public function getFieldTypes(): array - { - return $this->fieldTypes; - } - - /** - * @param string $field - * - * @return string|null - */ - public function getFieldType(string $field): ?string - { - return $this->fieldTypes[$field] ?? null; - } - - -} \ No newline at end of file diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index 1b26ac583..d74b45af1 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -38,172 +38,154 @@ class FieldHelper extends Helper { public $helpers = ['Form', 'Html', 'Url', 'Alert']; - + // Is this read-only or read-write? - protected $editable = true; + protected bool $editable = true; // Our current model name - protected $modelName = null; + protected ?string $modelName = null; // The plugin we are rendering within, if set - protected $pluginName = null; - + protected ?string $pluginName = null; + // The list of required fields - protected $reqFields = []; - + protected array $reqFields = []; + + // The field types + protected array $fieldTypes = []; + // The current entity, if edit or view - protected $entity = null; + protected ?object $entity = null; // The current action - protected $action = null; + protected ?string $action = null; + /** - * Emit an informational banner. + * Constructor hook method. * - * @since COmanage Registry v6.0.0 - * @param string $info Information string - * @return string HTML for banner + * @param array $config The configuration settings provided to this helper. + * + * @return void */ - - public function banner(string $info): string { - return '
  • ' . - $this->Alert->alert($info, 'warning') - . '
  • '; + public function initialize(array $config): void + { + parent::initialize($config); + + $this->reqFields = $this->getView()->get('vv_required_fields'); + $this->modelName = $this->getView()->getName(); + $this->action = $this->getView()->get('vv_action'); + $this->editable = \in_array($this->action, ['add', 'edit']); + $this->pluginName = $this->getView()->getPlugin(); + $this->entity = $this->getView()->get('vv_obj'); + $this->fieldTypes = $this->getView()->get('vv_field_types'); } /** - * Emit a form control. + * We autogenerate field labels and descriptions from the field name. * - * @param string $fieldName Form field - * @param array $options FormHelper control options - * @param string|null $labelText Label text (fieldName language key used by default) - * @param string|null $ctrlCode Control code passed in from wrapper functions - * @param string $cssClass Start li css class passed in from wrapper functions - * @param string $beforeField Markup to be placed before/above the field - * @param string $afterField Markup to be placed after/below the field - * @param string $prefix Field prefix - used for API Usernames - * @param bool $labelIsTextOnly For fields that should not include
    \n"; + return $this->Form->text($fieldName, $coptions) . $this->getView()->element('datePicker', $date_picker_args); } /** * Create the actual Form element * - * @param string $fieldName Form field - * @param array $options FormHelper control options - * By setting the options you are requesting a select field - * @param string|null $labelText Label text (fieldName language key used by default) - * @param string|null $ctrlCode Control code passed in from wrapper functions - * @param string $prefix Field prefix - used for API Usernames - * @param string|null $controlType + * @param string $fieldName Form field + * @param array|null $fieldOptions The second parameter of the Form->control helper. List of element options + * @param string|null $fieldLabel Custom label thext + * @param string $fieldPrefix If the field has a specil prefix provide the value + * @param string|null $fieldType Field type to override the one calculated from the schema * - * @return string HTML for control + * @return string HTML element * @since COmanage Registry v5.0.0 */ - protected function formControl(string $fieldName, - array $options = [], - string $labelText = null, - string $ctrlCode = null, - string $prefix = '', - string $controlType = null): string { - $coptions = $options; - $coptions['label'] = $options['label'] ?? false; - $coptions['readonly'] = - !$this->editable - || (isset($options['readonly']) && $options['readonly']) - // Plugins can't be changed after the parent object is instantiated - || ($fieldName == 'plugin' && $this->action == 'edit'); + public function formField(string $fieldName, + array $fieldOptions = null, + string $fieldLabel = null, + string $fieldPrefix = '', + string $fieldType = null): string + { + $fieldArgs = $fieldOptions ?? []; + $fieldArgs['label'] = $fieldOptions['label'] ?? false; + $fieldArgs['readonly'] = !$this->editable + || (isset($fieldOptions['readonly']) && $fieldOptions['readonly']) + || ($fieldName == 'plugin' && $this->action == 'edit'); + // Selects, Checkboxes, and Radio Buttons use "disabled" - $coptions['disabled'] = $coptions['readonly']; + $fieldArgs['disabled'] = $fieldArgs['readonly']; + $fieldArgs['required'] = $this->isReqField($fieldName) + || (isset($fieldOptions['required']) && $fieldOptions['required']); - // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') - $fieldMap = $this->getView()->get('vv_field_types'); - $fieldType = $controlType ?: $fieldMap[$fieldName]; + // Cause any select (except status) to render with a blank option, even + // if the field is required. This makes it clear when a value needs to be set. + // Note this will be ignored for non-select controls. + $fieldArgs['empty'] = !\in_array($fieldName, ['status', 'sync_status_on_delete'], true) + || (isset($fieldOptions['empty']) && $fieldOptions['empty']); // Remove prefix from field value - if(!empty($prefix) && !empty($this->getView()->get('vv_obj')->$fieldName)) { + if(!empty($fieldPrefix) && !empty($this->getEntity()->$fieldName)) { $vv_obj = $this->getView()->get('vv_obj'); $fieldValue = $vv_obj->$fieldName; - $fieldValueTemp = str_replace($prefix, '', $fieldValue); + $fieldValueTemp = str_replace($fieldPrefix, '', $fieldValue); $vv_obj->$fieldName = $fieldValueTemp; $this->getView()->set('vv_obj', $vv_obj); } - if($fieldName != 'status' - && !isset($options['empty']) - && (!isset($options['suppressBlank']) || !$options['suppressBlank'])) { - // Cause any select (except status) to render with a blank option, even - // if the field is required. This makes it clear when a value need to be set. - // Note this will be ignored for non-select controls. - $coptions['empty'] = true; - } - - // A boolean field is a checkbox. Set the label and class to improve rendering - // and accessibility. - if($fieldType == 'boolean') { - $coptions['label'] = $labelText; - $coptions['class'] = 'form-check-input'; - } - + // Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp') + $fieldType = $fieldType ?? $this->getFieldType($fieldName); // Generate the form control or pass along the markup generated in a wrapper function - return empty($ctrlCode) ? $this->Form->control($fieldName, $coptions) : $ctrlCode; - - } - - /** - * Generate a form info (control, value) box. - * - * @since COmanage Registry v5.0.0 - * @param string $content Content HTML - * @param string $beforeField Markup to be placed before/above the field - * @param string $afterField Markup to be placed after/below the field - * @return string Form Info HTML - */ - - protected function formInfoDiv(string $content, - string $beforeField = '', - string $afterField = ''): string { - $div = '
    ' . PHP_EOL; - if(!empty($beforeField)) { - $div .= $beforeField . PHP_EOL; - } - $div .= $content . PHP_EOL; - if(!empty($afterField)) { - $div .= $afterField . PHP_EOL; - } - $div .= '
    ' . PHP_EOL; - - return $div; + return match($fieldType) { + // A boolean field is a checkbox. Set the label and class to improve rendering + // and accessibility. + 'boolean' => $this->Form->control($fieldName, [ + // First import and then overwrite + ...$fieldArgs, + 'label' => $fieldLabel, + 'class' => 'form-check-input', + ]), + 'date' => $this->dateField($fieldName, DateTypeEnum::DateOnly), + 'datetime', + 'timestamp' => $this->dateField($fieldName), + default => $this->Form->control($fieldName, $fieldArgs) + }; } /** - * Create grouped control elements. By default, the elements will be placed one after the other, inline, - * with a direction left to right. For that need to occupy the whole row we defined the 'singleRowItem' - * configuration property that will add an inline Bootstrap css rule. The rule will override the default - * behavior + * Emit a source control for an MVEA that has a source_foo_id field pointing + * to an External Identity attribute. * - * @param array $fields - * @param string $pseudoFieldName - * @param string $beforeField Markup to be placed before/above the field - * @param string $afterField Markup to be placed after/below the field + * @param Entity $entity Entity to emit control for * - * @return string Form Info HTML + * @return string Source Link * @since COmanage Registry v5.0.0 */ + public function sourceLink($entity): string + { + // eg: Identifiers + // eg: source_identifier_id, or source_external_identity_role_id + $sourceFK = $this->getView()->get('vv_source_fk'); + // e.g.: source_identifier - we need to construct this from the $sourceFK + $sourceEntityName = substr($sourceFK, 0, strlen($sourceFK) - 3); + // In most cases, $sourceModelName = $modelName, but not for PersonRoles + $sourceModelName = substr(StringUtilities::foreignKeyToClassName($sourceFK), 6); - public function groupedControls(array $fields, - string $pseudoFieldName, - string $beforeField = '', - string $afterField = ''): string { - $content = ''; - foreach ($fields as $fieldName => $fieldOptions) { - $dblock = isset($fieldOptions['singleRowItem']) && $fieldOptions['singleRowItem'] ? 'd-block' : ''; - $content .= "
    " . PHP_EOL; - $content .= '
    ' . PHP_EOL; - $content .= $this->formControl($fieldName, $fieldOptions['options'] ?? []) . PHP_EOL; - $content .= '
    ' . PHP_EOL; - $content .= '
    ' . PHP_EOL; + $link = ''; + if (!empty($entity->$sourceFK)) { + $link .= $this->Html->Link( + title: __d('controller', $sourceModelName, [1]), + url: [ + 'controller' => $sourceModelName, + 'action' => 'view', + $entity->$sourceFK + ] + ); } - $mn = $this->modelName; - - return $this->startLine() - . $this->formNameDiv( - fieldName: $pseudoFieldName, - labelText: __d('field', $mn . '.' . $pseudoFieldName), - fieldType: 'string', - fieldNameClasses: 'field-name align-top' - ) - . $this->formInfoDiv($content, $beforeField, $afterField) - . $this->endLine(); - } - /** - * Generate a form info (control, value) box with a non editable prefix. - * - * @since COmanage Registry v5.0.0 - * @param string $content Content HTML - * @param string $prefix Prefix value - * @param string $beforeField Markup to be placed before/above the field - * @param string $afterField Markup to be placed after/below the field - * @return string Form Info HTML - */ - - protected function formInfoWithPrefixDiv(string $context, - string $prefix, - string $beforeField = '', - string $afterField = ''): string { - $div = '
    ' . PHP_EOL; - if(!empty($beforeField)) { - $div .= $beforeField . PHP_EOL; - } - $div .= '
    ' . PHP_EOL; - $div .= '
    ' . PHP_EOL; - $div .= '' . $prefix . ''; - $div .= '
    ' . PHP_EOL; - $div .= $context; - $div .= '
    '; - if(!empty($afterField)) { - $div .= $afterField . PHP_EOL; + if (!empty($entity->$sourceEntityName)) { + $link .= ', ' . $this->Html->Link( + title: __d('controller', 'ExternalIdentities', [1]), + url: [ + 'controller' => 'external_identities', + 'action' => 'view', + $entity->$sourceEntityName->external_identity_id + ] + ); } - $div .= '
    '; - - return $div; + return $link; } /** - * Generate a form name (label, description) box. - * - * @param string $fieldName Form field - * @param string|null $labelText Label text (fieldName language key used by default) - * @param string $fieldType Type of field (string, boolean, timestamp, etc.) - * @param boolean $labelIsTextOnly True if label should be text only. Otherwise, false. - * @param string|null $fieldNameClasses Override the field-name classes - * @param string|null $fieldTitleClasses Override the field-title classes - * @param string|null $fieldDescClasses Override the field-description classes - * - * @return string Form Name HTML - * @since COmanage Registry v5.0.0 - */ - - protected function formNameDiv(string $fieldName, - ?string $labelText, - string $fieldType, - bool $labelIsTextOnly = false, - ?string $fieldNameClasses = null, - ?string $fieldTitleClasses = null, - ?string $fieldDescClasses = null - ): string { - $label = $labelText; - $desc = null; - - // We'll accept a fieldName of the form other_models.0.foo for forms that - // request associated data. Note, however, that model names for language - // keys are OtherModel, so we'll need to inflect. - - $mn = $this->modelName; - $fn = $fieldName; - - if(str_contains($fieldName, '.')) { - // othermodels.0.field - - $bits = explode('.', $fieldName, 3); - $mn = Inflector::classify($bits[0]); - $fn = $bits[2]; - } - - // First try to autogenerate the field label (if we weren't given one). - - $pluginDomain = (!empty($this->pluginName) - ? Inflector::underscore($this->pluginName) - : null); - - if(!$label) { - // We autogenerate field labels and descriptions from the field name. - - // We loop over the field generation logic twice, first for a plugin - // context (if set) and then generally (if no plugin localization was found). - - // We use $core as the variable for this loop, so the rest of the code - // is easier to read (!$core = plugin) - for($core = 0;$core < 2;$core++) { - if(!$core && empty($this->pluginName)) { - // No plugin set, just go to the core field checks - continue; - } - - // Is there a model specific key? For plugins, this will be in field.Model.Field - - $key = (!$core ? 'field.' : '') . "$mn.$fn"; - $label = __d(($core ? 'field' : $pluginDomain), $key); - - if($label == $key) { - // Model specific label not found, try again for a general label - - $f = null; - - if(preg_match('/^(.*?)_id$/', $fn, $f)) { - // Map foreign keys (foo_id) to the controller label - $key = (!$core ? 'controller.' : '') . Inflector::camelize(Inflector::pluralize($f[1])); - $label = __d(($core ? 'controller' : $pluginDomain), $key, [1]); - - if($key != $label) { - break; - } - } - - // Just look up the key - $key = (!$core ? 'field.' : '') . $fn; - $label = __d(($core ? 'field' : $pluginDomain), $key); - - if($key != $label) { - break; - } - } else { - // If we found a key, break the loop - break; - } - } - } - - // We try to automagically determine if a description for the field exists by - // looking for the corresponding .desc language translation. - - for($core = 0;$core < 2;$core++) { - if(!$core && empty($this->pluginName)) { - // No plugin set, just go to the core field checks - continue; - } - - $key = (!$core ? "field." : "") . "$mn.$fn.desc"; - $desc = __d(($core ? 'field' : $pluginDomain), $key); - - // If the description is the literal key we just generated, there is no description - if($desc == $key) { - $desc = null; - } else { - break; - } - } - - return '
    ' - . '
    ' - // Form Label - . (!($labelIsTextOnly) && ($fieldType != 'boolean') ? $this->Form->label($fn, $label) : $label) - . ($this->editable && in_array($fn, $this->reqFields) ? $this->requiredSpanElement() : '') - . '
    ' // field-title div - // Description element - . ($desc ? '
    ' . $desc . '
    ' : '') .' -
    '; - } - - /** - * Emit a People Autocomplete (PrimeVue) control for selecting a person - * - * @param string $fieldName Field name of input field - * @param array $viewConfigParameters - * @param string $personType Type of person autocomplete to use (XXX should be an enum, and a default should be set) - * - * @return string Source HTML - * @since COmanage Registry v5.0.0 - * + * @return bool */ - - public function peopleAutocompleteControl(string $fieldName, array $viewConfigParameters = [], string $personType = 'coperson'): string { - if($this->action == 'view') { - // return the member name value as plaintext - $coptions = ['type' => 'text']; - $entity = $this->getView()->get('vv_obj'); - $controlCode = $entity->$fieldName; - - // Return this to the generic control() function - return $this->control($fieldName, $coptions, ctrlCode: $controlCode, labelIsTextOnly: true); - - } else { - // Create the options array for the (text input) form control - $coptions = []; - $coptions['class'] = 'form-control people-autocomplete'; - $coptions['placeholder'] = __d('operation','autocomplete.people.placeholder'); - $coptions['id'] = $fieldName; - $coptions['value'] = ''; - - $entity = $this->getView()->get('vv_obj'); - - // Get the existing values, if present - if(!empty($entity->$fieldName)) { - $coptions['value'] = ''; // XXX put the ID here. - } - - // Create a field name for the autocomplete input - $autoCompleteFieldName = 'cm_autocomplete_' . $fieldName; - - // Because we use JavaScript to set the value of the hidden field, - // disable form-tamper checking for the autocomplete fields. - // XXX We ought not have to do this for the hidden field ($fieldName) at least - $this->Form->unlockField($fieldName); - $this->Form->unlockField($autoCompleteFieldName); - - $autocompleteArgs = [ - 'type' => 'field', - 'fieldName' => $fieldName, - 'personType' => $personType, - 'htmlId' => $autoCompleteFieldName, - 'viewConfigParameters' => $viewConfigParameters - ]; - - // Create a hidden field to hold our value and emit the autocomplete widget - $controlCode = $this->Form->hidden($fieldName, $coptions) - . $this->getView()->element('peopleAutocomplete', $autocompleteArgs); - - // XXX the numeric value passed to 'autocomplete.people.desc' should be derived from config; it is the minLength value for starting autocomplete. - $autoCompleteDesc = '
    info ' . __d('operation','autocomplete.people.desc',['2']) . '
    '; - - // Specify a class on the
  • form control wrapper - $liClass = 'fields-people-autocomplete'; - - // Pass everything to the generic control() function - return $this->control( - $fieldName, - $coptions, - ctrlCode: $controlCode, - cssClass: $liClass, - afterField: $autoCompleteDesc, - labelIsTextOnly: true - ); - } + public function isEditable(): bool + { + return $this->editable; } /** - * Static required Span Element - * - * @return string - * @since COmanage Registry v5.0.0 + * @return string|null */ - protected function requiredSpanElement(): string + public function getPluginName(): ?string { - return "" - . "{__d('field', 'required')}"; + return $this->pluginName; } /** - * Static Not Set Div Element - * - * @return string - * @since COmanage Registry v5.0.0 + * @return string|null */ - - protected function notSetElement(): string + public function getModelName(): ?string { - return '
    ' . __d('information', 'notset') . '
    '; + return $this->modelName; } /** - * Emit a source control for an MVEA that has a source_foo_id field pointing - * to an External Identity attribute. - * - * @since COmanage Registry v5.0.0 - * @param Entity $entity Entity to emit control for - * @return string Source HTML + * @return object|null */ - - public function sourceControl($entity): string { - // eg: Identifiers - $modelName = StringUtilities::entityToClassName($entity); - // eg: source_identifier_id, or source_external_identity_role_id - $sourceFK = $this->getView()->get('vv_source_fk'); - // eg: source_identifier - we need to construct this from the $sourceFK - $sourceEntityName = substr($sourceFK, 0, strlen($sourceFK)-3); - // In most cases $sourceModelName = $modelName, but not for PersonRoles - $sourceModelName = substr(StringUtilities::foreignKeyToClassName($sourceFK), 6); - - $linkHtml = '
    '; - - if(!empty($entity->$sourceFK)) { - $linkHtml .= $this->Html->Link( - title: __d('controller', $sourceModelName, [1]), - url: [ - 'controller' => $sourceModelName, - 'action' => 'view', - $entity->$sourceFK - ] - ); - } - - if(!empty($entity->$sourceEntityName)) { - $linkHtml .= ', ' . $this->Html->Link( - title: __d('controller', 'ExternalIdentities', [1]), - url: [ - 'controller' => 'external_identities', - 'action' => 'view', - $entity->$sourceEntityName->external_identity_id - ] - ); - } - - $linkHtml .= '
    '; - - return $this->startLine() - . $this->formNameDiv( - fieldName: $sourceFK, - labelText: __d('field', 'source'), - fieldType: 'string' - ) - . $linkHtml - . $this->endLine(); + public function getEntity(): ?object + { + return $this->entity; } /** - * Generate a status control (a read only status with an optional link button). - * - * @param string $fieldName Form field - * @param string $status Status text - * @param array $link Link information, including 'url', 'label', 'class', 'confirm' - * @param string|null $labelText Label text (fieldName language key used by default) - * @param boolean $labelIsTextOnly true if
  • @@ -50,7 +50,7 @@ Form->label("{$key}_ends_at", __d('field','ends_at'), ['class' => 'filter-datepicker-lbl']); - print $this->Fieeld->dateField("{$key}_ends_at", DateTypeEnum::DateOnly, $query); + print $this->Field->dateField("{$key}_ends_at", DateTypeEnum::DateOnly, $query); ?>
    diff --git a/app/templates/element/filter/filter.php b/app/templates/element/filter/filter.php index ca534135b..f0df46ea6 100644 --- a/app/templates/element/filter/filter.php +++ b/app/templates/element/filter/filter.php @@ -129,7 +129,7 @@ print '
    '; print $this->Form->label($key, $label); print '
    '; - print $this->Field->dateField($key, DateTypeEnum::DateOnly, $query)['controlCode']; + print $this->Field->dateField($key, DateTypeEnum::DateOnly, $query); print '
    '; print '
    '; } else { diff --git a/app/templates/element/form/infoDiv/check.php b/app/templates/element/form/infoDiv/check.php index d70790494..237eeac66 100644 --- a/app/templates/element/form/infoDiv/check.php +++ b/app/templates/element/form/infoDiv/check.php @@ -37,7 +37,7 @@ - Fieeld->formField(...$vv_field_arguments) ?> + Field->formField(...$vv_field_arguments) ?>