Preferences: Add a preference for if select multiple dropdowns stay open or closes immediately after selection

This commit is contained in:
nathan 2023-04-17 09:28:27 -06:00
parent b557eb7b83
commit 358cc70d66
4 changed files with 112 additions and 81 deletions

View File

@ -244,12 +244,22 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
*/
private _block_change_event = false;
/**
* Close the dropdown after user selects an option.
* Only applies when multiple="true". We initialize it in constructor to the common preference "select_multiple_close"
* @type {boolean}
* @private
*/
private _close_on_select : boolean;
constructor(...args : any[])
{
super();
// We want this on more often than off
this.hoist = true;
this._close_on_select = this.egw().preference("select_multiple_close") == "close";
this._triggerChange = this._triggerChange.bind(this);
this._doResize = this._doResize.bind(this);
this._handleMouseWheel = this._handleMouseWheel.bind(this);
@ -683,8 +693,8 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
}
/**
* Always close the dropdown if an option is clicked, even if multiple=true. This differs from SlSelect,
* which leaves the dropdown open for multiple=true
* Apply the user preference to close the dropdown if an option is clicked, even if multiple=true.
* The default (from SlSelect) leaves the dropdown open for multiple=true
*
* @param {MouseEvent} event
* @private
@ -696,6 +706,8 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
// Don't hide dropdown when clicking on select. That can close it after user opens it.
return;
}
if(this._close_on_select)
{
this.dropdown.hide().then(() =>
{
if(typeof this.handleMenuHide == "function")
@ -705,6 +717,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
}
});
}
}
/**
* Always close the dropdown if an option is clicked, even if multiple=true. This differs from SlSelect,

View File

@ -83,6 +83,10 @@ export class Et2SelectEmail extends Et2Select
constructor(...args : any[])
{
super(...args);
// Always off for select email, per ticket #79694
this._close_on_select = true;
this.search = true;
this.searchUrl = "EGroupware\\Api\\Etemplate\\Widget\\Taglist::ajax_email";
this.allowFreeEntries = true;

View File

@ -25,6 +25,10 @@ class preferences_hooks
*/
static public function settings($hook_data)
{
$select_multiple_close = array(
'open' => lang('Stay open'),
'close' => lang('Close after selection')
);
$navbar_format = array(
'icons' => lang('Icons only'),
'icons_and_text' => lang('Icons and text'),
@ -258,6 +262,14 @@ class preferences_hooks
'admin' => False,
'forced' => 'icons',
),
'select_multiple_close' => array(
'type' => 'select',
'label' => 'Keep list open for selecting multiple',
'name' => 'select_multiple_close',
'values' => $select_multiple_close,
'help' => 'When you can select multiple options, should the option list stay open until you close it, or close after you pick an option.',
'default' => 'open'
),
'link_list_thumbnail' => array(
'type' => 'select',
'label' => 'Display thumbnails for linked images',

View File

@ -104,6 +104,7 @@ interface/template selection preferences en Interface | Template
it sets content size (text only) according to selected size. preferences en It sets content size (text only) according to selected size.
just clicking on the line, like a checkbox preferences en just clicking on the line, like a checkbox
kama theme preferences en Kama theme
keep list open for selecting multiple preferences en Keep list open for selecting multiple
language preferences en Language
look & feel preferences en Look & feel
lowercase letters preferences en lowercase letters
@ -194,6 +195,7 @@ unit of displayed font sizes: either "px" as used eg. for web-pages or "pt" as u
uppercase letters preferences en uppercase letters
use default preferences en Use default
users choice preferences en Users choice
when you can select multiple options, should the option list stay open until you close it, or close after you pick an option. preferences en When you can select multiple options, should the option list stay open until you close it, or close after you pick an option.
when you say yes the home and logout buttons are presented as applications in the main top applcation bar. preferences en Show Home and Logout buttons as applications in the top bar.
which charset should be used for the csv export. the system default is the charset of this egroupware installation. addressbook en Select character set for the CSV Import|Export.
which currency symbol or name should be used in egroupware. preferences en Currency symbol or name.