Skip to content

Commit

Permalink
CoSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 26, 2024
1 parent 1c6b6fb commit c1b8445
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 60 deletions.
8 changes: 3 additions & 5 deletions app/templates/ApiUsers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
*/

// 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' => [
'fieldName' => 'username', // string
'prefix' => 'co_' . $vv_cur_co->id . '.'
]
]);

// We link to the "Generate" button on edit only
$generateLink = [];
$labelIsTextOnly = false;
Expand Down Expand Up @@ -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
Expand Down
121 changes: 83 additions & 38 deletions app/templates/CoSettings/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,95 @@
<?php
// This view does not support add or read-only
if($vv_action == 'edit') {
print $this->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'
);
]]);
}
10 changes: 6 additions & 4 deletions app/templates/element/form/fieldDiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
<?php
// Name Div
print $this->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');
}
?>
</div>
File renamed without changes.
51 changes: 51 additions & 0 deletions app/templates/element/form/infoDiv/grouped.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* COmanage Registry Info Div Grouped Element
*
* 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);

$classes = '';


?>

<div class="field-info">
<?php foreach ($groupedControls as $fieldName => $fieldArguments): ?>
<?php
if(isset($fieldArguments['singleRowItem']) && $fieldArguments['singleRowItem']) {
$classes .= 'd-block ';
// This configuration is not needed for the control construction
unset($fieldArguments['singleRowItem']);
}
?>
<div class="subfield subfield-cols <?= $classes ?>">
<div class="field-col">
<?= $this->Fieeld->formField($fieldName, ...$fieldArguments) ?>
</div>
</div>
<?php endforeach; ?>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

if($link) {
// Construct HTML for the requested link

if(!empty($link['label'])) {
// Create a separate link after $status

Expand Down
9 changes: 8 additions & 1 deletion app/templates/element/form/listItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -43,6 +50,6 @@

?>

<li class="<?= $classes?>">
<li class="<?= $classes ?>">
<?= $this->element('form/fieldDiv')?>
</li>
21 changes: 10 additions & 11 deletions app/templates/element/form/nameDiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '.')) {
Expand All @@ -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 ';
}
?>

<div class="field-name">
<div class="field-name <?= $classes ?>">
<div class="field-title">
<!-- Will this work for accessibility? -->
<?php if((isset($labelIsTextOnly) && !$labelIsTextOnly)
&& $fieldType != 'boolean'): ?>
&& $this->Fieeld->getFieldType($fieldName) !== 'boolean'): ?>
<?= $this->Form->label($fn, $label) ?>
<?php else: ?>
<?= $label ?>
<?php endif; ?>
<?php
// Required Field
if($this->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');
}
?>
Expand Down

0 comments on commit c1b8445

Please sign in to comment.