-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure CoreEnroller for top-level form generation (CFM-218) (#355)
- Loading branch information
Showing
9 changed files
with
237 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?php | ||
| /** | ||
| * COmanage Registry Field Div Element for CoreEnroller | ||
| * | ||
| * Portions licensed to the University Corporation for Advanced Internet | ||
| * Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * UCAID licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at: | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * @link https://www.internet2.edu/comanage COmanage Project | ||
| * @package registry | ||
| * @since COmanage Registry v5.0.0 | ||
| * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
| */ | ||
|
|
||
|
|
||
| declare(strict_types = 1); | ||
| ?> | ||
|
|
||
| <div class="field"> | ||
| <?php | ||
| // Name Div | ||
| print $this->element('form/nameDiv'); | ||
|
|
||
| // This configuration isn't necessary anymore. | ||
| if(isset($vv_field_arguments['fieldDescription'])) { | ||
| unset($vv_field_arguments['fieldDescription']); | ||
| $this->set('vv_field_arguments', $vv_field_arguments); | ||
| } | ||
|
|
||
| // Info Div | ||
| ?> | ||
| <div class="field-info"> | ||
| <?php | ||
| // Insert the beforeField supplement: | ||
| if(!empty($vv_before_field)) { | ||
| print $vv_before_field; | ||
| } | ||
|
|
||
| // Include the correct sub-element based on the field configuration | ||
| if(isset($vv_field_arguments['fieldPrefix'])) { | ||
| print $this->element('form/infoDiv/withPrefix'); | ||
| } elseif(isset($vv_field_arguments['autocomplete'])) { | ||
| print $this->element('form/infoDiv/autocomplete'); | ||
| } elseif(isset($vv_field_arguments['status'])) { | ||
| 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'); | ||
| } elseif(isset($vv_field_arguments['groupmember'])) { | ||
| print $this->element('form/infoDiv/groupMember'); | ||
| } else { | ||
| print $this->element('form/infoDiv/default'); | ||
| } | ||
|
|
||
| // Insert the afterField supplement: | ||
| if(!empty($vv_after_field)) { | ||
| print $vv_after_field; | ||
| } | ||
| ?> | ||
| </div> | ||
| </div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <?php | ||
| /** | ||
| * COmanage Registry Unordered List Element for CoreEnroller | ||
| * | ||
| * Portions licensed to the University Corporation for Advanced Internet | ||
| * Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * UCAID licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at: | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * @link https://www.internet2.edu/comanage COmanage Project | ||
| * @package registry | ||
| * @since COmanage Registry v5.2.0 | ||
| * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
| */ | ||
|
|
||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| // Make the element configuration available downstream | ||
| // XXX Unfortunately CAKEPHP doe not create a viewvar space for the element | ||
| // parameters. As a result we do not know which one is which unless we: | ||
| // - add a prefix and create a namespace | ||
| // - wrap them in an array. | ||
| // We choose the latter. | ||
| $this->set('fieldName', $arguments['fieldName']); | ||
| $fieldName = $arguments['fieldName']; | ||
| $this->set('vv_field_arguments', $arguments); | ||
|
|
||
| // Pass along the field supplements if they are configured. | ||
| $this->set('vv_before_field', $beforeField ?? ''); | ||
| $this->set('vv_after_field', $afterField ?? ''); | ||
|
|
||
| // 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->Field->getEntity()->frozen) { | ||
| $url = [ | ||
| 'label' => __d('operation', 'unfreeze'), | ||
| 'url' => [ | ||
| 'plugin' => null, | ||
| 'controller' => \App\Lib\Util\StringUtilities::entityToClassname($this->Field->getEntity()), | ||
| 'action' => 'unfreeze', | ||
| $this->Field->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->Field->getEntity()), | ||
| 'action' => 'configure', | ||
| $this->Field->getEntity()->id | ||
| ] | ||
| ]; | ||
| $arguments = [ | ||
| ...$arguments, | ||
| 'status' => $this->Field->getEntity()->$fieldName, | ||
| 'link' => $url, | ||
| ]; | ||
| $this->set('vv_field_arguments', $arguments); | ||
| } | ||
|
|
||
| ?> | ||
|
|
||
| <li class="<?= trim($this->Field->calculateLiClasses()) ?>"> | ||
| <?= $this->element('CoreEnroller.fieldDiv')?> | ||
| </li> |
68 changes: 68 additions & 0 deletions
68
app/plugins/CoreEnroller/templates/element/unorderedList.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <?php | ||
| /** | ||
| * COmanage Registry Unordered List Element for CoreEnroller | ||
| * | ||
| * Portions licensed to the University Corporation for Advanced Internet | ||
| * Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * UCAID licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at: | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * @link https://www.internet2.edu/comanage COmanage Project | ||
| * @package registry | ||
| * @since COmanage Registry v5.2.0 | ||
| * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
| */ | ||
|
|
||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| // View vars | ||
| // $vv_obj | ||
| // $vv_required_fields | ||
| // $vv_action | ||
| // $vv_fields_inc | ||
| // $vv_template_path | ||
| // $vv_field_types | ||
| // $vv_submit_button_label | ||
|
|
||
| ?> | ||
| <ul id="<?= $vv_action . '_' . $this->name ?>" class="fields form-list"> | ||
| <?php | ||
| // We allow the fields.inc file to be specified for Controllers that have more | ||
| // complicated/non-default actions. | ||
| // XXX Each fields.inc file will calculate and provide the hidden controls. | ||
| $fieldsFile = $vv_fields_inc ?? 'dispatch.inc'; | ||
| // The controller will calculate the template path for us, since it could be | ||
| // in one of several paths if we are in a plugin context. | ||
| // The include files will contain the listItem elements | ||
| include($vv_template_path . DS . $fieldsFile); | ||
|
|
||
| if(!isset($suppress_submit) || !$suppress_submit) { | ||
| // The Submit element will be printed only if we are adding or updating, and if not | ||
| // suppressed by the field configuration | ||
| $vv_submit_button_label = $vv_submit_button_label ?? __d('operation', 'save'); | ||
| print $this->element('form/submit', ['label' => $vv_submit_button_label]); | ||
| } | ||
| ?> | ||
| </ul> | ||
|
|
||
| <?php | ||
| // 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]); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters