mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
Merge pull request #108 from asig2016/21.1_toolbar
Added preference_id and preference_app attributes to toolbar widget, …
This commit is contained in:
commit
8feac04979
@ -67,6 +67,12 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
.addClass('et2_toolbar ui-widget-header ui-corner-all');
|
.addClass('et2_toolbar ui-widget-header ui-corner-all');
|
||||||
// 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")
|
||||||
.attr('id', _this.id + '-' + 'actionbox');
|
.attr('id', _this.id + '-' + 'actionbox');
|
||||||
@ -180,7 +186,7 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
if (this.options.is_admin) {
|
if (this.options.is_admin) {
|
||||||
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) {
|
||||||
var prefs = [];
|
var prefs = [];
|
||||||
for (var p in _prefs) {
|
for (var p in _prefs) {
|
||||||
if (_prefs[p] === false)
|
if (_prefs[p] === false)
|
||||||
@ -190,7 +196,7 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
}).sendRequest(true);
|
}).sendRequest(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var pref = (!egwIsMobile()) ? egw.preference(this.dom_id, this.egw().app_name()) : undefined;
|
var pref = (!egwIsMobile()) ? egw.preference(this.options.preference_id, this.options.preference_app) : undefined;
|
||||||
if (pref && !jQuery.isArray(pref))
|
if (pref && !jQuery.isArray(pref))
|
||||||
this.preference = pref;
|
this.preference = pref;
|
||||||
//Set the default actions for the first time
|
//Set the default actions for the first time
|
||||||
@ -366,7 +372,7 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
ui.draggable.appendTo(menulist);
|
ui.draggable.appendTo(menulist);
|
||||||
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"
|
||||||
@ -424,7 +430,7 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
this.preference[_action] = _state;
|
this.preference[_action] = _state;
|
||||||
if (egwIsMobile())
|
if (egwIsMobile())
|
||||||
return;
|
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);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Make a button based on the given action
|
* Make a button based on the given action
|
||||||
@ -623,7 +629,7 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
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']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -633,7 +639,7 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
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']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -654,12 +660,12 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
_value.actions = pref;
|
_value.actions = pref;
|
||||||
}
|
}
|
||||||
egw.json('EGroupware\\Api\\Etemplate\\Widget\\Toolbar::ajax_setAdminSettings', [_value, self.dom_id, egw.app_name()], function (_result) {
|
egw.json('EGroupware\\Api\\Etemplate\\Widget\\Toolbar::ajax_setAdminSettings', [_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,
|
||||||
@ -686,6 +692,22 @@ var et2_toolbar = /** @class */ (function (_super) {
|
|||||||
"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();"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +48,22 @@ 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();"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -92,6 +108,13 @@ 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")
|
||||||
@ -230,7 +253,7 @@ 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)
|
||||||
{
|
{
|
||||||
@ -240,7 +263,8 @@ 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
|
||||||
@ -459,7 +483,7 @@ 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"
|
||||||
@ -523,7 +547,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -771,7 +795,7 @@ 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']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -782,7 +806,7 @@ 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']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -806,12 +830,12 @@ 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