forked from extern/egroupware
Fix some bugs with static options being repeated
- Select Tab options being sent from server & cached - Static options not properly set for all selects
This commit is contained in:
parent
e3bed10045
commit
1a2e691cbb
@ -241,11 +241,15 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
||||
|
||||
set_value(val : string | string[] | number | number[])
|
||||
{
|
||||
if (typeof val === 'number')
|
||||
if(typeof val === 'string' && val.indexOf(',') !== -1)
|
||||
{
|
||||
val = val.split(',');
|
||||
}
|
||||
if(typeof val === 'number')
|
||||
{
|
||||
val = val.toString();
|
||||
}
|
||||
if (Array.isArray(val))
|
||||
if(Array.isArray(val))
|
||||
{
|
||||
val = val.map(v => typeof v === 'number' ? v.toString() : v || '');
|
||||
}
|
||||
@ -561,18 +565,27 @@ export class Et2SelectTab extends Et2SelectApp
|
||||
|
||||
set value(new_value)
|
||||
{
|
||||
if(!new_value)
|
||||
{
|
||||
super.value = new_value;
|
||||
return;
|
||||
}
|
||||
const values = Array.isArray(new_value) ? new_value : [new_value];
|
||||
const options = this.select_options;
|
||||
values.forEach(value => {
|
||||
if (!options.filter(option => option.value == value).length)
|
||||
values.forEach(value =>
|
||||
{
|
||||
if(!options.filter(option => option.value == value).length)
|
||||
{
|
||||
const matches = value.match(/^([a-z0-9]+)\-/i);
|
||||
let option : SelectOption = {value: value, label: value};
|
||||
if (matches)
|
||||
if(matches)
|
||||
{
|
||||
option = options.filter(option => option.value == matches[1])[0] || {value: value, label: egw.lang(matches[1])};
|
||||
option = options.filter(option => option.value == matches[1])[0] || {
|
||||
value: value,
|
||||
label: this.egw().lang(matches[1])
|
||||
};
|
||||
option.value = value;
|
||||
option.label += ' '+egw.lang('Tab');
|
||||
option.label += ' ' + this.egw().lang('Tab');
|
||||
}
|
||||
try {
|
||||
const app = opener?.framework.getApplicationByName(value);
|
||||
|
@ -57,6 +57,11 @@ export class Et2SelectCategory extends Et2StaticSelectMixin(Et2Select)
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
so.cat(this).then(options =>
|
||||
{
|
||||
this.static_options = options
|
||||
this.requestUpdate("select_options");
|
||||
});
|
||||
}
|
||||
|
||||
async connectedCallback()
|
||||
@ -75,11 +80,7 @@ export class Et2SelectCategory extends Et2StaticSelectMixin(Et2Select)
|
||||
await this.updateComplete;
|
||||
if(this.select_options.length == 0)
|
||||
{
|
||||
so.cat(this).then(options =>
|
||||
{
|
||||
this.static_options = options
|
||||
this.requestUpdate("select_options");
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,12 @@ export const Et2StaticSelectMixin = <T extends Constructor<Et2WidgetWithSelect>>
|
||||
// @ts-ignore IDE doesn't recognise property
|
||||
super.select_options = new_options;
|
||||
}
|
||||
|
||||
set_static_options(new_static_options)
|
||||
{
|
||||
this.static_options = new_static_options;
|
||||
this.requestUpdate("select_options");
|
||||
}
|
||||
}
|
||||
|
||||
return Et2StaticSelectOptions;
|
||||
|
@ -39,6 +39,7 @@ class Select extends Etemplate\Widget
|
||||
public static $cached_types = array(
|
||||
'select-account',
|
||||
'select-app',
|
||||
'select-tab',
|
||||
'select-bool',
|
||||
'select-cat',
|
||||
'select-country',
|
||||
|
@ -66,23 +66,23 @@ $GLOBALS['settings'] = array(
|
||||
'forced' => false,
|
||||
),
|
||||
'open_tabs' => array(
|
||||
'type' => 'select-tabs',
|
||||
'label' => 'Open application tabs',
|
||||
'name' => 'open_tabs',
|
||||
'values' => $apps,
|
||||
'help' => 'Allows to set a default or force the open application tabs.',
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'type' => 'select-tabs',
|
||||
'label' => 'Open application tabs',
|
||||
'name' => 'open_tabs',
|
||||
'values' => $no_navbar_apps,
|
||||
'help' => 'Allows to set a default or force the open application tabs.',
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'default' => 'addressbook,calendar,mail,filemanager,infolog,rocketchat',
|
||||
),
|
||||
'active_tab' => array(
|
||||
'type' => 'select-tab',
|
||||
'label' => 'Active application tab',
|
||||
'name' => 'active_tab',
|
||||
'values' => $apps,
|
||||
'help' => 'Allows to set a default or force the active application tab for new logins.',
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'type' => 'select-tab',
|
||||
'label' => 'Active application tab',
|
||||
'name' => 'active_tab',
|
||||
'values' => $no_navbar_apps,
|
||||
'help' => 'Allows to set a default or force the active application tab for new logins.',
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'default' => 'calendar',
|
||||
),
|
||||
'template_color' => array(
|
||||
|
Loading…
Reference in New Issue
Block a user