Skip to content

Commit

Permalink
GroupMembers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 27, 2024
1 parent 1bc7299 commit 2818eec
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 34 deletions.
74 changes: 41 additions & 33 deletions app/templates/GroupMembers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
?>
<li>
<div class="field">
<div class="field-name">
<div class="field-title">
<?= __d('field','name') ?>
</div>
</div>
<div class="field-info">
<span class="group-member-to-add-name">
<?= $vv_selected_person['name'] ?>
</span>
<span class="group-member-to-add-id">
(<?= __d('information', 'entity.id', [$vv_selected_person['id']]) ?>)
</span>
</div>
</div>
</li>
<?php
// Present the person information in the view
$this->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
4 changes: 4 additions & 0 deletions app/templates/element/form/fieldDiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
59 changes: 59 additions & 0 deletions app/templates/element/form/infoDiv/autocomplete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* COmanage Registry Autocomplete 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);

// 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' => 'person',
'htmlId' => $autoCompleteFieldName,
'viewConfigParameters' => $vv_field_arguments['autocomplete']['configuration']
];

?>


<?php
// Create a hidden field to hold our value and emit the autocomplete widget
print $this->Form->hidden($fieldName, $vv_field_arguments['options']) . $this->element('peopleAutocomplete', $autocompleteArgs);
?>
<div class="field-desc">
<span class="material-icons">info</span>
<?= __d('operation','autocomplete.people.desc',['2']) ?>
</div>
41 changes: 41 additions & 0 deletions app/templates/element/form/infoDiv/groupMember.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* COmanage Registry GroupMember Info Div 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);

// vv_selected_person parameter is set by the controller.
?>

<?php if(isset($vv_selected_person)): ?>
<span class="group-member-to-add-name">
<?= $vv_selected_person['name'] ?>
</span>
<span class="group-member-to-add-id">
(<?= __d('information', 'entity.id', [$vv_selected_person['id']]) ?>)
</span>
<?php endif; ?>
4 changes: 4 additions & 0 deletions app/templates/element/form/listItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
default => ''
};

if(isset($arguments['autocomplete'])) {
$classes = 'fields-people-autocomplete ';
}

?>

<li class="<?= trim($classes) ?>">
Expand Down
1 change: 0 additions & 1 deletion app/templates/element/form/nameDiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
?>

<div class="field-name <?= $classes ?>">

<div class="field-title">
<!-- Will this work for accessibility? -->
<?php if((isset($vv_field_arguments['labelIsTextOnly']) && !$vv_field_arguments['labelIsTextOnly'])
Expand Down

0 comments on commit 2818eec

Please sign in to comment.