[ADD] shortcuts menu in header, with toggle star next to titles
bzr revid: xmo@openerp.com-20110816143038-3fpx5esytlyuvkrw
This commit is contained in:
commit
ed9db7c2c7
|
@ -299,8 +299,8 @@ class Session(openerpweb.Controller):
|
|||
|
||||
@openerpweb.jsonrequest
|
||||
def sc_list(self, req):
|
||||
return req.session.model('ir.ui.view_sc').get_sc(req.session._uid, "ir.ui.menu",
|
||||
req.session.eval_context(req.context))
|
||||
return req.session.model('ir.ui.view_sc').get_sc(
|
||||
req.session._uid, "ir.ui.menu", req.session.eval_context(req.context))
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def get_lang_list(self, req):
|
||||
|
|
|
@ -264,7 +264,7 @@ label.error {
|
|||
background: -ms-linear-gradient(top, #bd5e54 0%,#90322a 60%); /* IE10+ */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#BD5E54', endColorstr='#90322A',GradientType=0 ); /* IE6-9 */
|
||||
background: linear-gradient(top, #bd5e54 0%,#90322a 60%); /* W3C */
|
||||
|
||||
|
||||
border: 1px solid #6E2A24;
|
||||
border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
|
@ -1054,14 +1054,14 @@ label.error {
|
|||
padding-right: 21px;
|
||||
height: 21px;
|
||||
|
||||
background: #ffffff; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #ffffff 0%, #ebe9e9 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#ebe9e9)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* IE10+ */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#EBE9E9',GradientType=0 ); /* IE6-9 */
|
||||
background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
|
||||
background: #ffffff; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #ffffff 0%, #ebe9e9 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#ebe9e9)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* IE10+ */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#EBE9E9',GradientType=0 ); /* IE6-9 */
|
||||
background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
|
||||
|
||||
border: 1px solid #D2CFCF;
|
||||
border-right-width: 0;
|
||||
|
@ -1170,6 +1170,7 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
|
|||
.parent_top {
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
.openerp .oe-dialog-warning p {
|
||||
padding-left: 1em;
|
||||
font-size: 1.2em;
|
||||
|
@ -1182,7 +1183,6 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
|
|||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.openerp .oe-treeview-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -1209,3 +1209,52 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
|
|||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
/* Shortcuts*/
|
||||
.oe-shortcut-toggle {
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
width: 24px;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
background: url(/base/static/src/img/add-shortcut.png) no-repeat bottom;
|
||||
float: left;
|
||||
}
|
||||
.oe-shortcut-remove{
|
||||
background: url(/base/static/src/img/remove-shortcut.png) no-repeat bottom;
|
||||
}
|
||||
/* ================ */
|
||||
.oe-shortcuts {
|
||||
position: absolute;
|
||||
|
||||
margin: 0;
|
||||
padding: 6px 5px;
|
||||
top: 37px;
|
||||
left: 197px;
|
||||
right: 0;
|
||||
height: 17px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.oe-shortcuts ul {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
list-style: none;
|
||||
white-space: nowrap;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.oe-shortcuts li {
|
||||
cursor: pointer;
|
||||
display: -moz-inline-stack;
|
||||
display: inline-block;
|
||||
display: inline; /*IE7 */
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
border-left: 1px solid #909090;
|
||||
padding: 4px;
|
||||
font-size: 90%;
|
||||
font-weight: normal;
|
||||
}
|
||||
.oe-shortcuts li:first-child {
|
||||
border-left: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 395 B |
Binary file not shown.
After Width: | Height: | Size: 559 B |
|
@ -573,13 +573,66 @@ openerp.base.Header = openerp.base.Widget.extend({
|
|||
this._super(parent, element_id);
|
||||
},
|
||||
start: function() {
|
||||
this.do_update();
|
||||
return this.do_update();
|
||||
},
|
||||
do_update: function() {
|
||||
do_update: function () {
|
||||
this.$element.html(QWeb.render("Header", this));
|
||||
this.$element.find(".logout").click(this.on_logout);
|
||||
return this.shortcut_load();
|
||||
},
|
||||
on_logout: function() {}
|
||||
shortcut_load :function(){
|
||||
var self = this,
|
||||
sc = self.session.shortcuts,
|
||||
shortcuts_ds = new openerp.base.DataSet(this, 'ir.ui.view_sc');
|
||||
// TODO: better way to communicate between sections.
|
||||
// sc.bindings, because jquery does not bind/trigger on arrays...
|
||||
if (!sc.binding) {
|
||||
sc.binding = {};
|
||||
$(sc.binding).bind({
|
||||
'add': function (e, attrs) {
|
||||
var $shortcut = $('<li>', {
|
||||
'data-id': attrs.res_id
|
||||
}).text(attrs.name)
|
||||
.appendTo(self.$element.find('.oe-shortcuts ul'));
|
||||
shortcuts_ds.create(attrs, function (out) {
|
||||
$shortcut.data('shortcut-id', out.result);
|
||||
});
|
||||
},
|
||||
'remove-current': function () {
|
||||
var menu_id = self.session.active_id;
|
||||
var $shortcut = self.$element
|
||||
.find('.oe-shortcuts li[data-id=' + menu_id + ']');
|
||||
var shortcut_id = $shortcut.data('shortcut-id');
|
||||
$shortcut.remove();
|
||||
shortcuts_ds.unlink([shortcut_id]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this.rpc('/base/session/sc_list', {}, function(shortcuts) {
|
||||
sc.splice(0, sc.length);
|
||||
sc.push.apply(sc, shortcuts);
|
||||
|
||||
self.$element.find('.oe-shortcuts')
|
||||
.html(QWeb.render('Shortcuts', {'shortcuts': shortcuts}))
|
||||
.undelegate('li', 'click')
|
||||
.delegate('li', 'click', function(e) {
|
||||
e.stopPropagation();
|
||||
var id = $(this).data('id');
|
||||
self.session.active_id = id;
|
||||
self.rpc('/base/menu/action', {'menu_id':id}, function(ir_menu_data) {
|
||||
if (ir_menu_data.action.length){
|
||||
self.on_action(ir_menu_data.action[0][2]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
on_action: function(action) {
|
||||
},
|
||||
|
||||
on_logout: function() {
|
||||
this.$element.find('.oe-shortcuts ul').empty();
|
||||
}
|
||||
});
|
||||
|
||||
openerp.base.Menu = openerp.base.Widget.extend({
|
||||
|
@ -641,6 +694,7 @@ openerp.base.Menu = openerp.base.Widget.extend({
|
|||
$secondary.show();
|
||||
|
||||
if (id) {
|
||||
this.session.active_id = id;
|
||||
this.rpc('/base/menu/action', {'menu_id': id},
|
||||
this.on_menu_action_loaded);
|
||||
}
|
||||
|
@ -699,7 +753,7 @@ openerp.base.WebClient = openerp.base.Widget.extend({
|
|||
|
||||
this.menu = new openerp.base.Menu(this, "oe_menu", "oe_secondary_menu");
|
||||
this.menu.on_action.add(this.on_menu_action);
|
||||
|
||||
this.header.on_action.add(this.on_menu_action);
|
||||
},
|
||||
start: function() {
|
||||
this.session.start();
|
||||
|
|
|
@ -635,6 +635,8 @@ openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.b
|
|||
this.module_list = [];
|
||||
this.module_loaded = {"base": true};
|
||||
this.context = {};
|
||||
this.shortcuts = [];
|
||||
this.active_id = null;
|
||||
},
|
||||
start: function() {
|
||||
this.session_restore();
|
||||
|
|
|
@ -92,7 +92,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
|
|||
ir_actions_client: function (action) {
|
||||
this.client_widget = openerp.base.client_actions.get_object(action.tag);
|
||||
new this.client_widget(this, this.element_id, action.params).start();
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
openerp.base.ViewManager = openerp.base.Widget.extend({
|
||||
|
@ -285,13 +285,53 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
|
|||
|
||||
var searchview_loaded = this.setup_search_view(
|
||||
searchview_id || false, search_defaults);
|
||||
|
||||
|
||||
// schedule auto_search
|
||||
if (searchview_loaded != null && this.action['auto_search']) {
|
||||
$.when(searchview_loaded, inital_view_loaded)
|
||||
.then(this.searchview.do_search);
|
||||
}
|
||||
}
|
||||
},
|
||||
on_mode_switch: function (view_type) {
|
||||
this._super(view_type);
|
||||
this.shortcut_check(this.views[view_type]);
|
||||
},
|
||||
shortcut_check : function(view) {
|
||||
var self = this;
|
||||
var grandparent = this.widget_parent && this.widget_parent.widget_parent;
|
||||
// display shortcuts if on the first view for the action
|
||||
var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
|
||||
if (!(grandparent instanceof openerp.base.WebClient) ||
|
||||
!(view.view_type === this.views_src[0].view_type
|
||||
&& view.view_id === this.views_src[0].view_id)) {
|
||||
$shortcut_toggle.hide();
|
||||
return;
|
||||
}
|
||||
$shortcut_toggle.removeClass('oe-shortcut-remove').show();
|
||||
if (_(this.session.shortcuts).detect(function (shortcut) {
|
||||
return shortcut.res_id === self.session.active_id; })) {
|
||||
$shortcut_toggle.addClass("oe-shortcut-remove");
|
||||
}
|
||||
this.shortcut_add_remove();
|
||||
},
|
||||
shortcut_add_remove: function() {
|
||||
var self = this;
|
||||
var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
|
||||
$shortcut_toggle.click(function() {
|
||||
if ($shortcut_toggle.hasClass("oe-shortcut-remove")) {
|
||||
$(self.session.shortcuts.binding).trigger('remove-current');
|
||||
$shortcut_toggle.removeClass("oe-shortcut-remove");
|
||||
} else {
|
||||
$(self.session.shortcuts.binding).trigger('add', {
|
||||
'user_id': self.session.uid,
|
||||
'res_id': self.session.active_id,
|
||||
'resource': 'ir.ui.menu',
|
||||
'name': self.action.name
|
||||
});
|
||||
$shortcut_toggle.addClass("oe-shortcut-remove");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -359,7 +359,15 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<div class="oe-shortcuts"> </div>
|
||||
</t>
|
||||
<ul t-name="Shortcuts">
|
||||
<li t-foreach="shortcuts" t-as="shortcut"
|
||||
t-att-data-id="shortcut.res_id"
|
||||
t-att-data-shortcut-id="shortcut.id"
|
||||
><t t-esc="shortcut.name"/></li>
|
||||
</ul>
|
||||
|
||||
<t t-name="Menu">
|
||||
<table align="center">
|
||||
<tr>
|
||||
|
@ -408,7 +416,8 @@
|
|||
<table class="view-manager-main-table">
|
||||
<tr>
|
||||
<td class="view-manager-main-content">
|
||||
<!-- TODO prefix id with the element_id of the controller t-attf-id="#{prefix}_localid" -->
|
||||
<a class="oe-shortcut-toggle" title="Add / Remove Shortcut..."
|
||||
href="javascript: void(0)"> </a>
|
||||
<div class="oe_vm_switch">
|
||||
<t t-if="views.length != 1" t-foreach="views" t-as="view">
|
||||
<button type="button" t-att-data-view-type="view.view_type">
|
||||
|
|
Loading…
Reference in New Issue