[IMP]Implement shortcut functionality.
bzr revid: vme@tinyerp.com-20110808111616-2qi3d6hfebix0uho
This commit is contained in:
parent
dad68b79a7
commit
9ad05c699b
|
@ -259,9 +259,9 @@ 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 sorted(req.session.model('ir.ui.view_sc').get_sc(req.session._uid, "ir.ui.menu",
|
||||
req.session.eval_context(req.context)), key=lambda k: k['id'])
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def get_lang_list(self, req):
|
||||
try:
|
||||
|
|
|
@ -1180,3 +1180,57 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
|
|||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
/* Shortcuts*/
|
||||
#shortcut_add_remove {
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
width: 24px;
|
||||
cursor: pointer;
|
||||
display: inline; /*IE7 */
|
||||
display: inline-block;
|
||||
}
|
||||
.shortcut-add {
|
||||
background: url(../img/add-shortcut.png) no-repeat;
|
||||
background-position: bottom;
|
||||
}
|
||||
.shortcut-remove{
|
||||
background: url(../img/remove-shortcut.png) no-repeat;
|
||||
background-position: bottom;
|
||||
}
|
||||
/* ================ */
|
||||
#shortcuts {
|
||||
position: absolute;
|
||||
|
||||
margin: 0;
|
||||
padding: 6px 5px;
|
||||
top: 37px;
|
||||
left: 197px;
|
||||
right: 0;
|
||||
height: 17px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
#shortcuts ul {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
list-style: none;
|
||||
white-space: nowrap;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
#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-left: 4px;
|
||||
font-size: 90%;
|
||||
font-weight: normal;
|
||||
}
|
||||
#shortcuts li:first-child,
|
||||
#shortcuts li.first {
|
||||
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 |
|
@ -25,6 +25,9 @@ openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Sessi
|
|||
this.module_list = [];
|
||||
this.module_loaded = {"base": true};
|
||||
this.context = {};
|
||||
this.sc_list ={};
|
||||
this.active_id = "";
|
||||
this.active_menu_name = "";
|
||||
},
|
||||
start: function() {
|
||||
this.session_restore();
|
||||
|
@ -858,8 +861,36 @@ openerp.base.Header = openerp.base.Widget.extend({
|
|||
do_update: function() {
|
||||
this.$element.html(QWeb.render("Header", this));
|
||||
this.$element.find(".logout").click(this.on_logout);
|
||||
this.shortcut_load();
|
||||
},
|
||||
shortcut_load :function(){
|
||||
var self = this;
|
||||
this.rpc('/base/session/sc_list', {}, function(sc_list_data){
|
||||
self.session.sc_list = sc_list_data
|
||||
self.$element.find('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': sc_list_data}));
|
||||
self.shortcut_menu_load();
|
||||
});
|
||||
},
|
||||
|
||||
shortcut_menu_load :function(){
|
||||
var self = this
|
||||
this.$element.find('#shortcuts ul li').click(function(ev, id){
|
||||
self.session.active_id = this.id;
|
||||
self.rpc('/base/menu/action', {'menu_id':this.id},function(ir_menu_data){
|
||||
if (ir_menu_data.action.length){
|
||||
this.action_manager = new openerp.base.ActionManager(self, "oe_app");
|
||||
this.action_manager.do_action(ir_menu_data.action[0][2]);
|
||||
self.session.active_menu_name = ir_menu_data.action[0][2]['name'];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
on_logout: function() {
|
||||
this.remove();
|
||||
},
|
||||
remove:function(){
|
||||
this.$element.find('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': {}}));
|
||||
},
|
||||
on_logout: function() {}
|
||||
});
|
||||
|
||||
openerp.base.Menu = openerp.base.Widget.extend({
|
||||
|
@ -921,6 +952,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);
|
||||
}
|
||||
|
@ -935,6 +967,7 @@ openerp.base.Menu = openerp.base.Widget.extend({
|
|||
on_menu_action_loaded: function(data) {
|
||||
var self = this;
|
||||
if (data.action.length) {
|
||||
this.session.active_menu_name = data.action[0][2]['name'];
|
||||
var action = data.action[0][2];
|
||||
self.on_action(action);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ openerp.base.SearchView = openerp.base.Widget.extend({
|
|||
$.when.apply(null, widget_starts).then(function () {
|
||||
self.ready.resolve();
|
||||
});
|
||||
|
||||
this.shortcut_check();
|
||||
this.reload_managed_filters();
|
||||
},
|
||||
reload_managed_filters: function() {
|
||||
|
@ -344,7 +344,34 @@ openerp.base.SearchView = openerp.base.Widget.extend({
|
|||
// triggers refresh
|
||||
this.$element.find('form').submit();
|
||||
}
|
||||
}
|
||||
},
|
||||
shortcut_check: function(){
|
||||
var img = "shortcut-add";
|
||||
for(var list_shortcut=0; list_shortcut<this.session.sc_list.length; list_shortcut++){
|
||||
if (this.session.sc_list[list_shortcut]['res_id'] == this.session.active_id)
|
||||
{img = "shortcut-remove"}}
|
||||
$('#shortcut_add_remove').addClass(img);
|
||||
this.shortcut_add_remove();
|
||||
},
|
||||
shortcut_add_remove : function(session){
|
||||
var self = this;
|
||||
var shortcut_selector =$('#shortcut_add_remove');
|
||||
var dataset_shortcut = new openerp.base.DataSet(this, 'ir.ui.view_sc');
|
||||
shortcut_selector.click(function(ev,id){
|
||||
if(shortcut_selector.hasClass("shortcut-remove")){
|
||||
var unlink_id = $("li[id="+self.session.active_id+"]").attr('shortcut-id');
|
||||
dataset_shortcut.unlink([parseInt(unlink_id)]);
|
||||
shortcut_selector.removeClass("shortcut-remove");
|
||||
shortcut_selector.addClass("shortcut-add"); }
|
||||
else {
|
||||
var data = {'user_id': self.uid, 'res_id': self.session.active_id, 'resource': 'ir.ui.menu', 'name': self.session.active_menu_name};
|
||||
dataset_shortcut.create(data);
|
||||
shortcut_selector.removeClass("shortcut-add");
|
||||
shortcut_selector.addClass("shortcut-remove"); }
|
||||
this.header = new openerp.base.Header(self, "oe_header");
|
||||
this.header.shortcut_load();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
/** @namespace */
|
||||
|
@ -482,7 +509,6 @@ openerp.base.search.Group = openerp.base.search.Widget.extend({
|
|||
return $.when.apply(null, widget_starts);
|
||||
}
|
||||
});
|
||||
|
||||
openerp.base.search.Input = openerp.base.search.Widget.extend( /** @lends openerp.base.search.Input# */{
|
||||
/**
|
||||
* @constructs
|
||||
|
|
|
@ -360,6 +360,15 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<div id="shortcuts" class="header_title">
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="Shortcuts">
|
||||
<ul class="first">
|
||||
<li t-foreach="shortcuts_pass" t-as="sc" t-att-id="sc.res_id" t-att-shortcut-id = "sc.id" >
|
||||
<a><t t-esc="sc.name"/></a>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
<t t-name="Menu">
|
||||
<table align="center">
|
||||
|
@ -867,7 +876,7 @@
|
|||
</button>
|
||||
</t>
|
||||
<t t-name="SearchView">
|
||||
<h2 class="oe_view_title"><t t-esc="view.attrs['string']"/></h2>
|
||||
<h2 class="oe_view_title"> <a id = "shortcut_add_remove" title="Add / Remove Shortcut..."> </a><t t-esc="view.attrs['string']"/></h2>
|
||||
<form class="oe_forms">
|
||||
<t t-call="SearchView.render_lines"/>
|
||||
<div class="oe_search-view-buttons" style="text-align: right;">
|
||||
|
|
Loading…
Reference in New Issue