Skip to content

Commit

Permalink
Allow picker email/identifier all or 1 type
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Aug 23, 2024
1 parent a13b802 commit 8ec25db
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/operation.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ msgstr "Apply Database Schema"
msgid "assign"
msgstr "Assign"

msgid "all"
msgstr "All"

msgid "any"
msgstr "Any"

Expand Down
22 changes: 21 additions & 1 deletion app/src/View/Helper/FieldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,27 @@ public function formField(string $fieldName,
// 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']);
|| (isset($fieldOptions['empty']) && !empty($fieldOptions['empty']));

// Check if the empty option comes with a value
if($fieldArgs['empty']
&& !empty($fieldOptions['empty'])
&& \is_string($fieldOptions['empty'])) {
$fieldArgs['empty'] = $fieldOptions['empty'];
}

if(!empty($fieldOptions['all'])) {
$optionName = lcfirst(StringUtilities::foreignKeyToClassName($fieldName));
$optionValues = $this->getView()->get($optionName);
$optionValues = [
'-1' => $fieldOptions['all'],
...$optionValues
];
$this->getView()->set($optionName, $optionValues);
}

// Is this a multiple select
$fieldArgs['multiple'] = !empty($fieldOptions['multiple']);

// Manipulate the vv_object for the hasPrefix use case
$this->handlePrefix($fieldPrefix, $fieldName);
Expand Down
4 changes: 4 additions & 0 deletions app/templates/CoSettings/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ if($vv_action == 'edit') {
'person_picker_email_address_type_id' => [
'fieldOptions' => [
'label' => __d('field', 'mail'),
'empty' => '(' . __d('operation', 'all') . ')',
// 'all' => '(' . __d('operation', 'all') . ')'
],
],
'person_picker_identifier_type_id' => [
'fieldOptions' => [
'label' => __d('field', 'identifier'),
'empty' => '(' . __d('operation', 'all') . ')',
// 'all' => '(' . __d('operation', 'all') . ')',
],
],
'person_picker_display_types' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export default {
<div class="cm-ac-subitem cm-ac-email" v-if="slotProps.option.email">
<span class="cm-ac-label" v-if="slotProps.option.emailLabel">{{ slotProps.option.emailLabel }}</span>
<span class="cm-ac-value">
<ItemWithType
<ItemWithType
v-for="item in slotProps.option.email"
:item="item"
kind="email"
Expand Down

0 comments on commit 8ec25db

Please sign in to comment.