[imp] nivified list view

bzr revid: nicolas.vanhoren@openerp.com-20110914143028-bwjnpw8vbubjc90k
This commit is contained in:
niv-openerp 2011-09-14 16:30:28 +02:00
parent f460118f42
commit 4e033738d0
4 changed files with 15 additions and 11 deletions

View File

@ -10,20 +10,19 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
* view should be displayed (if there is one active).
*/
searchable: false,
template: "FormView",
template: "EmptyComponent",
/**
* @constructs openerp.web.FormView
* @extends openerp.web.View
*
* @param {openerp.web.Session} session the current openerp session
* @param {String} element_id this view's root element id
* @param {openerp.web.DataSet} dataset the dataset this view will work with
* @param {String} view_id the identifier of the OpenERP view object
*
* @property {openerp.web.Registry} registry=openerp.web.form.widgets widgets registry for this form view instance
*/
init: function(parent, element_id, dataset, view_id, options) {
this._super(parent, element_id);
init: function(parent, dataset, view_id, options) {
this._super(parent);
this.set_default_options(options);
this.dataset = dataset;
this.model = dataset.model;
@ -45,6 +44,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
_.defaults(this.options, {"always_show_new_button": true});
},
start: function() {
this._super();
if (this.embedded_view) {
var def = $.Deferred().then(this.on_loaded);
var self = this;
@ -75,7 +75,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
this.fields_view = data;
var frame = new (this.registry.get_object('frame'))(this, this.fields_view.arch);
this.$element.html(QWeb.render(this.template, { 'frame': frame, 'view': this }));
this.$element.html(QWeb.render("FormView", { 'frame': frame, 'view': this }));
_.each(this.widgets, function(w) {
w.start();
});

View File

@ -2,6 +2,7 @@ openerp.web.list = function (openerp) {
var QWeb = openerp.web.qweb;
openerp.web.views.add('list', 'openerp.web.ListView');
openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# */ {
template: "EmptyComponent",
defaults: {
// records can be selected one by one
'selectable': true,
@ -31,7 +32,6 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
* @extends openerp.web.View
*
* @param parent parent object
* @param element_id the id of the DOM elements this view should link itself to
* @param {openerp.web.DataSet} dataset the dataset the view should work with
* @param {String} view_id the listview's identifier, if any
* @param {Object} options A set of options used to configure the view
@ -42,9 +42,9 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
* @param {Boolean} [options.sortable=true] is it possible to sort the table by clicking on column headers
* @param {Boolean} [options.reorderable=true] is it possible to reorder list rows
*/
init: function(parent, element_id, dataset, view_id, options) {
init: function(parent, dataset, view_id, options) {
var self = this;
this._super(parent, element_id);
this._super(parent);
this.set_default_options(_.extend({}, this.defaults, options || {}));
this.dataset = dataset;
this.model = dataset.model;
@ -128,6 +128,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
* @returns {$.Deferred} loading promise
*/
start: function() {
this._super();
this.$element.addClass('oe-listview');
return this.reload_view(null, null, true);
},

View File

@ -208,8 +208,7 @@ openerp.web.ViewManager = openerp.web.Widget.extend(/** @lends openerp.web.View
if (!view.controller) {
// Lazy loading of views
var controllerclass = this.registry.get_object(view_type);
var controller = new controllerclass(this, this.element_id + '_view_' + view_type,
this.dataset, view.view_id, view.options);
var controller = new controllerclass(this, this.dataset, view.view_id, view.options);
if (view.embedded_view) {
controller.set_embedded_view(view.embedded_view);
}
@ -228,7 +227,8 @@ openerp.web.ViewManager = openerp.web.Widget.extend(/** @lends openerp.web.View
unique: true
});
}
view_promise = controller.start();
var container = $("#" + this.element_id + '_view_' + view_type);
view_promise = controller.appendTo(container);
$.when(view_promise).then(function() {
self.on_controller_inited(view_type, controller);
});

View File

@ -1422,4 +1422,7 @@
</t>
</ul>
</t>
<t t-name="EmptyComponent">
<div></div>
</t>
</templates>