[FIX] web_shortcuts: remove server-side eval, move all logic to js
bzr revid: xmo@openerp.com-20121127161913-46ita3emgjan7diu
This commit is contained in:
parent
a698e32152
commit
6a3b91e6d5
|
@ -17,6 +17,5 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import controllers
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import main
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,11 +0,0 @@
|
|||
import openerp
|
||||
|
||||
class Shortcuts(openerp.addons.web.http.Controller):
|
||||
_cp_path = "/web/shortcuts"
|
||||
|
||||
@openerp.addons.web.http.jsonrequest
|
||||
def 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))
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -33,7 +33,7 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
|
|||
this.on('display', this, this.display);
|
||||
this.on('remove', this, this.remove);
|
||||
this.on('click', this, this.click);
|
||||
this.dataset = new instance.web.DataSet(this, 'ir.ui.view_sc');
|
||||
this.model = new instance.web.Model('ir.ui.view_sc');
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
@ -46,7 +46,11 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
|
|||
load: function() {
|
||||
var self = this;
|
||||
this.$el.find('.oe_systray_shortcuts_items').empty();
|
||||
return this.rpc('/web/shortcuts/list', {}).done(function(shortcuts) {
|
||||
return this.model.call('get_sc', [
|
||||
instance.session.uid,
|
||||
'ir.ui.menu',
|
||||
instance.web.pyeval.eval('context', {})
|
||||
]).done(function(shortcuts) {
|
||||
_.each(shortcuts, function(sc) {
|
||||
self.trigger('display', sc);
|
||||
});
|
||||
|
@ -54,7 +58,7 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
|
|||
},
|
||||
add: function (sc) {
|
||||
var self = this;
|
||||
this.dataset.create(sc).then(function(out){
|
||||
this.model.call('create', [sc]).then(function(out){
|
||||
self.trigger('load');
|
||||
});
|
||||
},
|
||||
|
@ -69,7 +73,7 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
|
|||
var $shortcut = this.$el.find('.oe_systray_shortcuts_items li a[data-id=' + menu_id + ']');
|
||||
var shortcut_id = $shortcut.data('shortcut-id');
|
||||
$shortcut.remove();
|
||||
this.dataset.unlink([shortcut_id]);
|
||||
this.model.call('unlink', [shortcut_id]);
|
||||
},
|
||||
click: function($link) {
|
||||
var self = this,
|
||||
|
|
Loading…
Reference in New Issue