W.I.P. of toolbar admin default prefs:

- Add admin settings button
- Add dialog
This commit is contained in:
Hadi Nategh 2018-08-16 12:29:21 +02:00
parent bbe551d4cc
commit bf151cff7b
4 changed files with 94 additions and 3 deletions

View File

@ -152,7 +152,7 @@ var et2_toolbar = (function(){ "use strict"; return et2_DOMWidget.extend([et2_II
this.div.empty(); this.div.empty();
this.actionbox.empty(); this.actionbox.empty();
this.actionlist.empty(); this.actionlist.empty();
var admin_setting = this.options.is_admin ? '<span class="toolbar-admin-pref">admin</span>': ''; var admin_setting = this.options.is_admin ? '<span class="toolbar-admin-pref" title="'+egw.lang('Admin settings')+' ..."></span>': '';
this.actionbox.append('<h class="ui-toolbar-menulistHeader">'+egw.lang('more')+' ...'+admin_setting+'</h>'); this.actionbox.append('<h class="ui-toolbar-menulistHeader">'+egw.lang('more')+' ...'+admin_setting+'</h>');
this.actionbox.append('<div id="' + this.id + '-menulist' +'" class="ui-toolbar-menulist" ></div>'); this.actionbox.append('<div id="' + this.id + '-menulist' +'" class="ui-toolbar-menulist" ></div>');
var that = this; var that = this;
@ -160,7 +160,7 @@ var et2_toolbar = (function(){ "use strict"; return et2_DOMWidget.extend([et2_II
{ {
this.actionbox.find('.toolbar-admin-pref').click(function(e){ this.actionbox.find('.toolbar-admin-pref').click(function(e){
e.stopImmediatePropagation(); e.stopImmediatePropagation();
// TODO that._admin_settings_dialog.call(that, actions);
}); });
} }
var pref = (!egwIsMobile())? egw.preference(this.dom_id,this.egw().getAppName()): undefined; var pref = (!egwIsMobile())? egw.preference(this.dom_id,this.egw().getAppName()): undefined;
@ -691,6 +691,46 @@ var et2_toolbar = (function(){ "use strict"; return et2_DOMWidget.extend([et2_II
{ {
this._super.apply(this, arguments); this._super.apply(this, arguments);
return false; return false;
},
/**
* Builds dialog for possible admin settings (e.g. default actions pref)
*
* @param {type} _actions
*/
_admin_settings_dialog: function (_actions)
{
var buttons = [
{text: egw.lang("Close"), id:"close"},
{text: egw.lang("Save"), id:"save"},
];
var sel_options = {actions:[]};
for (var key in _actions)
{
sel_options.actions.push({id:key, value: key, label: _actions[key]['caption'], app: egw.app_name(), icon: _actions[key]['iconUrl']});
}
var content = {actions:''};
et2_createWidget("dialog",
{
callback: function(_button_id, _value)
{
if (_button_id == 'save' && _value)
{
egw.json('EGroupware\\Api\\Etemplate\\Widget\\Toolbar::ajax_setAdminSettings',
[_value],function(_result){
egw.message(_result);
}).sendRequest(true);
}
},
title: egw.lang('admin settings for %1', this.dom_id),
buttons: buttons,
minWidth: 500,
minHeight: 300,
value:{content: content, sel_options: sel_options},
template: egw.webserverUrl+'/api/templates/default/toolbarAdminSettings.xet?1',
resizable: false
}, et2_dialog._create_parent('api'));
} }
});}).call(this); });}).call(this);
et2_register_widget(et2_toolbar, ["toolbar"]); et2_register_widget(et2_toolbar, ["toolbar"]);

View File

@ -56,4 +56,21 @@ class Toolbar extends Etemplate\Widget
$value['is_admin'] = true; $value['is_admin'] = true;
} }
} }
/**
* Set admin settings
*
* @param array $settings array of settings to be processed
*/
public static function ajax_setAdminSettings ($settings)
{
$response = \EGroupware\Api\Json\Response::get();
// None admin users are not allowed to access
if (!$GLOBALS['egw_info']['user']['apps']['admin'])
{
$response->data(Lang('Permission denied! This is an administration only feature.'));
exit();
}
}
} }

View File

@ -1975,6 +1975,21 @@ div.ui-dialog div.ui-dialog-content > div[id] {
margin: 0 !important; margin: 0 !important;
padding: 0 !important; padding: 0 !important;
} }
.et2_toolbar .et2_toolbar_more h .toolbar-admin-pref {
background-image: url(../../../pixelegg/images/gear.png);
background-repeat: no-repeat;
background-size: 12px;
width: 20px;
height: 100%;
display: inline-block;
position: absolute;
right: 0px;
top: 0px;
background-position: center;
}
.et2_toolbar .et2_toolbar_more h .toolbar-admin-pref:hover {
background-color: #ffd555;
}
.et2_toolbar .et2_toolbar_actionlist span[data-group]:not(:first-child) > button.et2_button:first-child { .et2_toolbar .et2_toolbar_actionlist span[data-group]:not(:first-child) > button.et2_button:first-child {
margin-left: 7px; margin-left: 7px;
} }
@ -2224,7 +2239,7 @@ div.et2_toolbar_more .ui-accordion-header-active {
color:black; color:black;
} }
div.et2_toolbar_more h.ui-accordion-header { div.et2_toolbar_more h.ui-accordion-header {
padding: 4px 14px 3px 25px !important; padding: 4px 30px 3px 25px !important;
margin:1px; margin:1px;
} }
.et2_toolbar_actionlist{ .et2_toolbar_actionlist{

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="api.toolbarAdminSettings" template="" lang="" group="0" version="1.9.001">
<grid width="100%">
<columns>
<column width="100px"/>
<column width="300px"/>
</columns>
<rows>
<row>
<description value="default visible actions" label="%s:"/>
<taglist id="actions" editModeEnabled="false" allowFreeEntries="false" autocomplete_url=' ' class="et2_fullWidth"/>
</row>
</rows>
</grid>
</template>
</overlay>