[REV] Reverted changes about sidebar as we now have
a widget to handle things like selection in a list view. bzr revid: tde@openerp.com-20140415132528-0spzmcb2xmphxpwn
This commit is contained in:
parent
654700fb36
commit
33ebae745d
|
@ -1117,12 +1117,10 @@ instance.web.Sidebar = instance.web.Widget.extend({
|
|||
this._super(parent);
|
||||
var view = this.getParent();
|
||||
this.sections = [
|
||||
{ 'name': 'buttons', 'label': _t('Button'), },
|
||||
{ 'name' : 'print', 'label' : _t('Print'), },
|
||||
{ 'name' : 'other', 'label' : _t('More'), }
|
||||
];
|
||||
this.items = {
|
||||
'buttons': [],
|
||||
'print' : [],
|
||||
'other' : []
|
||||
};
|
||||
|
@ -1134,24 +1132,22 @@ instance.web.Sidebar = instance.web.Widget.extend({
|
|||
});
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
this._super(this);
|
||||
this.redraw();
|
||||
this.$el.on('click', 'button.oe_sidebar_button', this.on_item_click);
|
||||
this.$el.on('click','.oe_dropdown_menu li a', this.on_item_click);
|
||||
},
|
||||
on_item_click: function (event) {
|
||||
var self = this;
|
||||
var section = $(event.currentTarget).data('section');
|
||||
var index = $(event.currentTarget).data('index');
|
||||
var item = self.items[section][index];
|
||||
if (item.callback) {
|
||||
item.callback.apply(self, [item]);
|
||||
} else if (item.action) {
|
||||
self.on_item_action_clicked(item);
|
||||
} else if (item.url) {
|
||||
return true;
|
||||
}
|
||||
event.preventDefault();
|
||||
this.$el.on('click','.oe_dropdown_menu li a', function(event) {
|
||||
var section = $(this).data('section');
|
||||
var index = $(this).data('index');
|
||||
var item = self.items[section][index];
|
||||
if (item.callback) {
|
||||
item.callback.apply(self, [item]);
|
||||
} else if (item.action) {
|
||||
self.on_item_action_clicked(item);
|
||||
} else if (item.url) {
|
||||
return true;
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
},
|
||||
redraw: function() {
|
||||
var self = this;
|
||||
|
@ -1201,26 +1197,17 @@ instance.web.Sidebar = instance.web.Widget.extend({
|
|||
},
|
||||
add_toolbar: function(toolbar) {
|
||||
var self = this;
|
||||
var context = self.getParent().dataset.context; // not sure this is the correct way to find the context
|
||||
var highlighted_act_ids = context['view_manager_highlight'] || [];
|
||||
_.each(['print','action','relate'], function(type) {
|
||||
var items = toolbar[type];
|
||||
if (items) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var section_code = 'other';
|
||||
if (highlighted_act_ids && _.indexOf(highlighted_act_ids, items[i]['id']) != -1) {
|
||||
section_code = 'buttons';
|
||||
}
|
||||
else if (type == 'print') {
|
||||
section_code = 'print';
|
||||
}
|
||||
items[i] = {
|
||||
label: items[i]['name'],
|
||||
action: items[i],
|
||||
classname: 'oe_sidebar_' + type
|
||||
};
|
||||
self.add_items(section_code, [items[i]]);
|
||||
}
|
||||
self.add_items(type=='print' ? 'print' : 'other', items);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -1531,7 +1518,7 @@ instance.web.View = instance.web.Widget.extend({
|
|||
new instance.web.DataExport(this, this.dataset).open();
|
||||
},
|
||||
sidebar_eval_context: function () {
|
||||
return $.when(new instance.web.CompoundContext(this.dataset.get_context()));
|
||||
return $.when({});
|
||||
},
|
||||
/**
|
||||
* Asks the view to reload itself, if the reloading is asynchronous should
|
||||
|
|
Loading…
Reference in New Issue