[IMP]checked that shortcut are from either ir.ui.menu or it is tree view
bzr revid: vme@tinyerp.com-20110812071248-y9oqa8t1wx61xciu
This commit is contained in:
parent
9ad05c699b
commit
f17f4bbd48
|
@ -259,7 +259,7 @@ class Session(openerpweb.Controller):
|
|||
|
||||
@openerpweb.jsonrequest
|
||||
def sc_list(self, req):
|
||||
return sorted(req.session.model('ir.ui.view_sc').get_sc(req.session._uid, "ir.ui.menu",
|
||||
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
|
||||
|
|
|
@ -1190,11 +1190,11 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
|
|||
display: inline-block;
|
||||
}
|
||||
.shortcut-add {
|
||||
background: url(../img/add-shortcut.png) no-repeat;
|
||||
background: url(/base/static/src/img/add-shortcut.png) no-repeat;
|
||||
background-position: bottom;
|
||||
}
|
||||
.shortcut-remove{
|
||||
background: url(../img/remove-shortcut.png) no-repeat;
|
||||
background: url(/base/static/src/img/remove-shortcut.png) no-repeat;
|
||||
background-position: bottom;
|
||||
}
|
||||
/* ================ */
|
||||
|
|
|
@ -27,7 +27,6 @@ openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Sessi
|
|||
this.context = {};
|
||||
this.sc_list ={};
|
||||
this.active_id = "";
|
||||
this.active_menu_name = "";
|
||||
},
|
||||
start: function() {
|
||||
this.session_restore();
|
||||
|
@ -860,37 +859,37 @@ 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();
|
||||
this.shortcut_menu_load();
|
||||
this.$element.find(".logout").click(this.on_logout);
|
||||
},
|
||||
shortcut_load :function(){
|
||||
var self = this;
|
||||
this.rpc('/base/session/sc_list', {}, function(sc_list_data){
|
||||
self.session.sc_list = 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
|
||||
var self = this;
|
||||
this.$element.find('#shortcuts ul li').click(function(ev, id){
|
||||
self.session.active_id = this.id;
|
||||
self.active_shortcut = "ir.ui.menu";
|
||||
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'];
|
||||
self.on_action(ir_menu_data.action[0][2]);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
on_action: function(action) {
|
||||
},
|
||||
|
||||
on_logout: function() {
|
||||
this.remove();
|
||||
},
|
||||
remove:function(){
|
||||
this.$element.find('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': {}}));
|
||||
},
|
||||
this.$element.find('#shortcuts ul li').remove();
|
||||
}
|
||||
});
|
||||
|
||||
openerp.base.Menu = openerp.base.Widget.extend({
|
||||
|
@ -953,6 +952,7 @@ openerp.base.Menu = openerp.base.Widget.extend({
|
|||
|
||||
if (id) {
|
||||
this.session.active_id = id;
|
||||
this.active_shortcut = "ir.ui.menu";
|
||||
this.rpc('/base/menu/action', {'menu_id': id},
|
||||
this.on_menu_action_loaded);
|
||||
}
|
||||
|
@ -967,7 +967,6 @@ 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);
|
||||
}
|
||||
|
@ -1014,6 +1013,8 @@ 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() {
|
||||
|
|
|
@ -144,7 +144,6 @@ 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() {
|
||||
|
@ -345,33 +344,6 @@ openerp.base.SearchView = openerp.base.Widget.extend({
|
|||
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 */
|
||||
|
|
|
@ -15,6 +15,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
|
|||
// Will use parent to find it when implementation will be done.
|
||||
this.session.action_manager = this;
|
||||
},
|
||||
|
||||
do_action: function(action, on_closed) {
|
||||
action.flags = _.extend({
|
||||
sidebar : action.target != 'new',
|
||||
|
@ -87,7 +88,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
|
|||
this.current_dialog.stop();
|
||||
this.current_dialog = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
openerp.base.ActionDialog = openerp.base.Dialog.extend({
|
||||
|
@ -143,6 +144,7 @@ openerp.base.ViewManager = openerp.base.Widget.extend({
|
|||
}
|
||||
// switch to the first one in sequence
|
||||
return this.on_mode_switch(this.views_src[0].view_type);
|
||||
|
||||
},
|
||||
stop: function() {
|
||||
},
|
||||
|
@ -157,6 +159,7 @@ openerp.base.ViewManager = openerp.base.Widget.extend({
|
|||
view_promise;
|
||||
this.active_view = view_type;
|
||||
var view = this.views[view_type];
|
||||
this.shortcut_check(view.view_id,view_type);
|
||||
if (!view.controller) {
|
||||
// Lazy loading of views
|
||||
var controllerclass = this.registry.get_object(view_type);
|
||||
|
@ -268,6 +271,51 @@ openerp.base.ViewManager = openerp.base.Widget.extend({
|
|||
*/
|
||||
contexts: function () {
|
||||
return [];
|
||||
},
|
||||
shortcut_check: function(view_id,view_type){
|
||||
var self = this;
|
||||
$('#shortcut_add_remove').show();
|
||||
if (view_type == "tree" || typeof view_id != "boolean" && this.views_src[0].view_id == view_id
|
||||
//to check view is either from menu or it is tree view...
|
||||
{
|
||||
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);
|
||||
}
|
||||
else {
|
||||
$('#shortcut_add_remove').hide();
|
||||
}
|
||||
this.shortcut_add_remove();
|
||||
},
|
||||
shortcut_add_remove : function(){
|
||||
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.action.name};
|
||||
|
||||
dataset_shortcut.create(data);
|
||||
shortcut_selector.removeClass("shortcut-add");
|
||||
shortcut_selector.addClass("shortcut-remove");
|
||||
|
||||
}
|
||||
self.rpc('/base/session/sc_list', {}, function(sc_list_data){
|
||||
self.session.sc_list = sc_list_data;
|
||||
$('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': sc_list_data}));
|
||||
});
|
||||
});
|
||||
//$('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': {}}));
|
||||
//self.session.sc_list = sc_list_data;
|
||||
//self.$element.find('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': sc_list_data}));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -326,6 +374,7 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
|
|||
.then(this.searchview.do_search);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
stop: function() {
|
||||
// should be replaced by automatic destruction implemented in Widget
|
||||
|
@ -352,7 +401,7 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
|
|||
return [];
|
||||
}
|
||||
return [this.action.context];
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
openerp.base.Sidebar = openerp.base.Widget.extend({
|
||||
|
|
|
@ -366,10 +366,11 @@
|
|||
<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>
|
||||
<a ><t t-esc="sc.name"/></a>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
|
||||
<t t-name="Menu">
|
||||
<table align="center">
|
||||
<tr>
|
||||
|
@ -419,6 +420,9 @@
|
|||
<tr>
|
||||
<td class="view-manager-main-content">
|
||||
<!-- TODO prefix id with the element_id of the controller t-attf-id="#{prefix}_localid" -->
|
||||
<t t-if="view.view_type != form" t-foreach="views" t-as="view">
|
||||
<a id = "shortcut_add_remove" title="Add / Remove Shortcut..." href="javascript: void(0)"> </a>
|
||||
</t>
|
||||
<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">
|
||||
|
@ -876,7 +880,7 @@
|
|||
</button>
|
||||
</t>
|
||||
<t t-name="SearchView">
|
||||
<h2 class="oe_view_title"> <a id = "shortcut_add_remove" title="Add / Remove Shortcut..."> </a><t t-esc="view.attrs['string']"/></h2>
|
||||
<h2 class="oe_view_title"> <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