[IMP] Sidebar wip
bzr revid: nicolas.vanhoren@openerp.com-20110404160813-kxfvmj5bn6giuwei
This commit is contained in:
parent
661972d764
commit
26951a725e
|
@ -48,6 +48,10 @@ openerp.base.FormView = openerp.base.Controller.extend(
|
|||
|
||||
// this.dataset.on_active_id.add(this.on_record_loaded);
|
||||
// this.dataset.active_id(fields of the form, this.on_record_loaded);
|
||||
|
||||
// sidebar stuff
|
||||
if (this.view_manager.sidebar)
|
||||
this.view_manager.sidebar.load_multi_actions();
|
||||
},
|
||||
on_next: function() {
|
||||
// this.dataset.next();
|
||||
|
|
|
@ -69,12 +69,8 @@ openerp.base.ListView = openerp.base.Controller.extend({
|
|||
}).trigger('resize');
|
||||
|
||||
// sidebar stuff
|
||||
this.rpc("/base/sidebar/get_actions",
|
||||
{"model": this.model}, function(result) {
|
||||
self.view_manager.sidebar.sections.push({elements:
|
||||
_.map(result, function(x) {return {text:x[2].name, action:x}; })});
|
||||
self.view_manager.sidebar.refresh();
|
||||
});
|
||||
if (this.view_manager.sidebar)
|
||||
this.view_manager.sidebar.load_multi_actions();
|
||||
},
|
||||
do_fill_table: function(records) {
|
||||
this.log("do_fill_table");
|
||||
|
|
|
@ -20,7 +20,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
|||
if (this.viewmanager) {
|
||||
this.viewmanager.stop();
|
||||
}
|
||||
this.viewmanager = new openerp.base.ViewManager(this.session,this.element_id);
|
||||
this.viewmanager = new openerp.base.ViewManager(this.session,this.element_id, false);
|
||||
this.viewmanager.do_action_window(action);
|
||||
this.viewmanager.start();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
|||
openerp.base.views = new openerp.base.Registry();
|
||||
openerp.base.ViewManager = openerp.base.Controller.extend({
|
||||
// This will be ViewManager Abstract/Common
|
||||
init: function(session, element_id) {
|
||||
init: function(session, element_id, desactivate_sidebar) {
|
||||
this._super(session, element_id);
|
||||
this.action = null;
|
||||
this.dataset = null;
|
||||
|
@ -41,15 +41,22 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
|
|||
this.active_view = null;
|
||||
// this.views = { "list": { "view_id":1234, "controller": instance} }
|
||||
this.views = {};
|
||||
this.sidebar = new openerp.base.Sidebar(null);
|
||||
if (desactivate_sidebar)
|
||||
this.sidebar = null;
|
||||
else
|
||||
this.sidebar = new openerp.base.Sidebar(null, this);
|
||||
},
|
||||
start: function() {
|
||||
this.$element.find('.view-manager-main-sidebar').html(this.sidebar.render());
|
||||
this.sidebar.start();
|
||||
if (this.sidebar) {
|
||||
this.$element.find('.view-manager-main-sidebar').html(this.sidebar.render());
|
||||
this.sidebar.start();
|
||||
}
|
||||
},
|
||||
stop: function() {
|
||||
// should be replaced by automatic destruction implemented in BaseWidget
|
||||
this.sidebar.stop();
|
||||
if (this.sidebar) {
|
||||
this.sidebar.stop();
|
||||
}
|
||||
this._super();
|
||||
},
|
||||
/**
|
||||
|
@ -189,13 +196,14 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
|
|||
*/
|
||||
identifier_prefix: 'generic-identifier',
|
||||
/**
|
||||
* Base class for widgets. Handle rendering (based on a QWeb template), identifier
|
||||
* generation, parenting and destruction of the widget.
|
||||
* Base class for widgets. Handle rendering (based on a QWeb template), identifier
|
||||
* generation, parenting and destruction of the widget.
|
||||
* Contructor. Also initialize the identifier.
|
||||
*
|
||||
* @params {openerp.base.search.BaseWidget} parent The parent widget.
|
||||
*/
|
||||
init: function (parent) {
|
||||
init: function (parent, session) {
|
||||
this._super(session);
|
||||
this.children = [];
|
||||
this.parent = null;
|
||||
this.set_parent(parent);
|
||||
|
@ -265,10 +273,22 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
|
|||
|
||||
openerp.base.Sidebar = openerp.base.BaseWidget.extend({
|
||||
template: "ViewManager.sidebar",
|
||||
init: function(parent) {
|
||||
this._super(parent);
|
||||
init: function(parent, view_manager) {
|
||||
this._super(parent, view_manager.session);
|
||||
this.view_manager = view_manager;
|
||||
this.sections = [];
|
||||
},
|
||||
load_multi_actions: function() {
|
||||
if (_.detect(this.sections, function(x) {return x.type=="multi_actions";}) != undefined)
|
||||
return;
|
||||
var self = this;
|
||||
this.rpc("/base/sidebar/get_actions",
|
||||
{"model": this.view_manager.dataset.model}, function(result) {
|
||||
self.sections.push({type: "multi_actions", elements:
|
||||
_.map(result, function(x) {return {text:x[2].name, action:x}; })});
|
||||
self.refresh();
|
||||
});
|
||||
},
|
||||
refresh: function() {
|
||||
this.$element.html(QWeb.render("ViewManager.sidebar.internal", this));
|
||||
var self = this;
|
||||
|
|
Loading…
Reference in New Issue