Commit 9f3c246d authored by Domeshow Emmanuel's avatar Domeshow Emmanuel Committed by Adrien Mbuya Maloba
Browse files

[ENH] Better UX for selecting multiple group names

parent 412d1587
Pipeline #755468793 passed with stages
in 8 minutes and 53 seconds
......@@ -354,8 +354,8 @@ class Services_Tracker_Controller
'editable_by' => 'groupname',
]
);
$visibleBy = $input->asArray('visible_by', ',');
$editableBy = $input->asArray('editable_by', ',');
$visibleBy = $input->asArray('visible_by', false);
$editableBy = $input->asArray('editable_by', false);
$options = $this->utilities->buildOptions(new JitFilter($input->option), $typeInfo);
......@@ -505,6 +505,10 @@ class Services_Tracker_Controller
$validation_types['remotelock'] = tr('Remote Lock');
}
$userlib = TikiLib::lib('user');
$groups = $userlib->list_all_groups();
$field['all_groups'] = $groups;
return [
'title' => tr('Edit') . " " . tr('%0', $field['name']),
'field' => $field,
......
......@@ -27,7 +27,9 @@ function wikiplugin_group_info()
Example:') . ' <code>Admins|Developers</code>',
'since' => '1',
'filter' => 'groupname',
'default' => ''
'default' => '',
'separator' => '|',
'profile_reference' => 'group',
],
'notgroups' => [
'required' => false,
......@@ -35,7 +37,9 @@ function wikiplugin_group_info()
'description' => tra('Pipe-separated list of groups not allowed to view the block.'),
'since' => '1',
'filter' => 'groupname',
'default' => ''
'default' => '',
'separator' => '|',
'profile_reference' => 'group',
],
'friends' => [
'required' => false,
......@@ -53,7 +57,9 @@ function wikiplugin_group_info()
list of groups) is outstanding.'),
'since' => '13.0',
'filter' => 'groupname',
'default' => ''
'default' => '',
'separator' => '|',
'profile_reference' => 'group',
],
'notpending' => [
'required' => false,
......@@ -62,7 +68,9 @@ function wikiplugin_group_info()
groups) is not pending.'),
'since' => '13.0',
'filter' => 'groupname',
'default' => ''
'default' => '',
'separator' => '|',
'profile_reference' => 'group',
],
],
];
......@@ -84,10 +92,10 @@ function wikiplugin_group($data, $params)
}
if (! empty($params['groups'])) {
$groups = explode('|', $params['groups']);
$groups = $params['groups'];
}
if (! empty($params['notgroups'])) {
$notgroups = explode('|', $params['notgroups']);
$notgroups = $params['notgroups'];
}
$userPending = [];
if (! empty($params['pending']) || ! empty($params['notpending'])) {
......@@ -95,7 +103,7 @@ function wikiplugin_group($data, $params)
$attributes = $attributelib->get_attributes('user', $user);
$userlib = TikiLib::lib('user');
if (! empty($params['pending'])) {
$pending = explode('|', $params['pending']);
$pending = $params['pending'];
foreach ($pending as $pgrp) {
$grpinfo = $userlib->get_group_info($pgrp);
$attname = 'tiki.memberextend.' . $grpinfo['id'];
......@@ -105,7 +113,7 @@ function wikiplugin_group($data, $params)
}
}
if (! empty($params['notpending'])) {
$notpending = explode('|', $params['notpending']);
$notpending = $params['notpending'];
foreach ($notpending as $npgrp) {
$grpinfo = $userlib->get_group_info($npgrp);
$attname = 'tiki.memberextend.' . $grpinfo['id'];
......
......@@ -158,8 +158,9 @@
<div class="mb-3 row mx-0">
<label for="visible_by" class="groupselector col-form-label">{tr}Visible by{/tr}</label>
<input type="text" name="visible_by" id="visible_by" value="{foreach from=$field.visibleBy item=group}{$group|escape}, {/foreach}" class="form-control">
{autocomplete element='#visible_by' type='groupname' options="multiple:true,multipleSeparator:','"}{* note, multiple doesn't work in jquery-ui 1.8 *}
<select multiple name="visible_by[]" id="visible_by" class="form-select">
{foreach from=$field.all_groups item=group}<option value="{$group|escape}" {if in_array($group, $field.visibleBy)}selected="selected"{/if}>{$group|escape}</option> {/foreach}
</select>
<div class="form-text">
{tr}List of Group names with permission to see this field{/tr}. {tr}Separated by comma (,){/tr}
</div>
......@@ -167,8 +168,9 @@
<div class="mb-3 row mx-0">
<label for="editable_by" class="groupselector col-form-label">{tr}Editable by{/tr}</label>
<input type="text" name="editable_by" id="editable_by" value="{foreach from=$field.editableBy item=group}{$group|escape}, {/foreach}" class="form-control">
{autocomplete element='#editable_by' type='groupname' options="multiple:true,multipleSeparator:','"}{* note, multiple doesn't work in jquery-ui 1.8 *}
<select multiple name="editable_by[]" id="editable_by" class="form-select">
{foreach from=$field.all_groups item=group}<option value="{$group|escape}" {if in_array($group, $field.editableBy)}selected="selected"{/if}>{$group|escape}</option> {/foreach}
</select>
<div class="form-text">
{tr}List of Group names with permission to edit this field{/tr}. {tr}Separated by comma (,){/tr}
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment