forked from extern/egroupware
Merge pull request 8feac04979
#108 from Alexandros into the master
This commit is contained in:
parent
59a6a3c717
commit
13e717ce68
@ -50,6 +50,22 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "more",
|
"default": "more",
|
||||||
"description": "Define a style for list header (more ...), which can get short 3dots with no caption or bigger button with caption more ..."
|
"description": "Define a style for list header (more ...), which can get short 3dots with no caption or bigger button with caption more ..."
|
||||||
|
},
|
||||||
|
"preference_id": {
|
||||||
|
"name": "Preference id",
|
||||||
|
"type": "string",
|
||||||
|
"default": false,
|
||||||
|
"description": "Define a custom preference id for saving the toolbar preferences." +
|
||||||
|
"This is useful when you have the same toolbar and you use it in a pop up but also in a tab, which have different dom ids" +
|
||||||
|
"When not set it defaults to the dom id of the form."
|
||||||
|
},
|
||||||
|
"preference_app": {
|
||||||
|
"name": "Preference application",
|
||||||
|
"type": "string",
|
||||||
|
"default": false,
|
||||||
|
"description": "Define a custom preference application for saving the toolbar preferences." +
|
||||||
|
"This is useful when you have the same toolbar and you use it in a pop up but also in a tab, wich have different application names" +
|
||||||
|
"When not set it defaults to the result of this.egw().app_name();"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,6 +110,13 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
// Set proper id and dom_id for the widget
|
// Set proper id and dom_id for the widget
|
||||||
this.set_id(this.id);
|
this.set_id(this.id);
|
||||||
|
|
||||||
|
if(!this.options.preference_id){
|
||||||
|
this.options.preference_id = this.dom_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.options.preference_app){
|
||||||
|
this.options.preference_app = this.egw().app_name();
|
||||||
|
}
|
||||||
|
|
||||||
this.actionbox = jQuery(document.createElement('div'))
|
this.actionbox = jQuery(document.createElement('div'))
|
||||||
.addClass("et2_toolbar_more")
|
.addClass("et2_toolbar_more")
|
||||||
@ -232,7 +255,7 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
{
|
{
|
||||||
this.actionbox.find('.toolbar-admin-pref').click(function(e){
|
this.actionbox.find('.toolbar-admin-pref').click(function(e){
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
egw.json('EGroupware\\Api\\Etemplate\\Widget\\Toolbar::ajax_get_default_prefs', [egw.app_name(), that.dom_id], function(_prefs){
|
egw.json('EGroupware\\Api\\Etemplate\\Widget\\Toolbar::ajax_get_default_prefs', [that.options.preference_app, that.options.preference_id], function(_prefs){
|
||||||
let prefs = [];
|
let prefs = [];
|
||||||
for (let p in _prefs)
|
for (let p in _prefs)
|
||||||
{
|
{
|
||||||
@ -242,7 +265,8 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
}).sendRequest(true);
|
}).sendRequest(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let pref = (!egwIsMobile())? egw.preference(this.dom_id, this.egw().app_name()): undefined;
|
|
||||||
|
let pref = (!egwIsMobile())? egw.preference(this.options.preference_id, this.options.preference_app): undefined;
|
||||||
if (pref && !jQuery.isArray(pref)) this.preference = pref;
|
if (pref && !jQuery.isArray(pref)) this.preference = pref;
|
||||||
|
|
||||||
//Set the default actions for the first time
|
//Set the default actions for the first time
|
||||||
@ -461,7 +485,7 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
if (that.actionlist.find(".ui-draggable").length == 0)
|
if (that.actionlist.find(".ui-draggable").length == 0)
|
||||||
{
|
{
|
||||||
that.preference = {};
|
that.preference = {};
|
||||||
egw.set_preference(that.egw().app_name(),that.dom_id,that.preference);
|
egw.set_preference(that.options.preference_app,that.options.preference_id,that.preference);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tolerance:"touch"
|
tolerance:"touch"
|
||||||
@ -525,7 +549,7 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
{
|
{
|
||||||
this.preference[_action] = _state;
|
this.preference[_action] = _state;
|
||||||
if (egwIsMobile()) return;
|
if (egwIsMobile()) return;
|
||||||
egw.set_preference(this.egw().app_name(),this.dom_id,this.preference);
|
egw.set_preference(this.options.preference_app,this.options.preference_id,this.preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -537,7 +561,7 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
{
|
{
|
||||||
let button_options = {
|
let button_options = {
|
||||||
};
|
};
|
||||||
let button = jQuery(document.createElement('button'))
|
let button = jQuery(document.createElement('button'))
|
||||||
.addClass("et2_button et2_button_text et2_button_with_image")
|
.addClass("et2_button et2_button_text et2_button_with_image")
|
||||||
.attr('id', this.id+'-'+action.id)
|
.attr('id', this.id+'-'+action.id)
|
||||||
.attr('type', 'button')
|
.attr('type', 'button')
|
||||||
@ -773,7 +797,7 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
id:child,
|
id:child,
|
||||||
value: child,
|
value: child,
|
||||||
label: _actions[key]['children'][child]['caption'],
|
label: _actions[key]['children'][child]['caption'],
|
||||||
app: egw.app_name(),
|
app: self.options.preference_app,
|
||||||
icon: _actions[key]['children'][child]['iconUrl']
|
icon: _actions[key]['children'][child]['iconUrl']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -784,7 +808,7 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
id:key,
|
id:key,
|
||||||
value: key,
|
value: key,
|
||||||
label: _actions[key]['caption'],
|
label: _actions[key]['caption'],
|
||||||
app: egw.app_name(),
|
app: self.options.preference_app,
|
||||||
icon: _actions[key]['iconUrl']
|
icon: _actions[key]['iconUrl']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -808,12 +832,12 @@ export class et2_toolbar extends et2_DOMWidget implements et2_IInput
|
|||||||
_value.actions = pref;
|
_value.actions = pref;
|
||||||
}
|
}
|
||||||
egw.json('EGroupware\\Api\\Etemplate\\Widget\\Toolbar::ajax_setAdminSettings',
|
egw.json('EGroupware\\Api\\Etemplate\\Widget\\Toolbar::ajax_setAdminSettings',
|
||||||
[_value, self.dom_id, egw.app_name()],function(_result){
|
[_value, self.options.preference_id, self.options.preference_app],function(_result){
|
||||||
egw.message(_result);
|
egw.message(_result);
|
||||||
}).sendRequest(true);
|
}).sendRequest(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: egw.lang('admin settings for %1', this.dom_id),
|
title: egw.lang('admin settings for %1', this.options.preference_id),
|
||||||
buttons: buttons,
|
buttons: buttons,
|
||||||
minWidth: 600,
|
minWidth: 600,
|
||||||
minHeight: 300,
|
minHeight: 300,
|
||||||
|
Loading…
Reference in New Issue
Block a user