[FIX] Fixed on_loaded in all different views.
bzr revid: vta@openerp.com-20121018114950-svqy0gje04vw2ysc
This commit is contained in:
parent
8b4580ea86
commit
1e70837161
|
@ -127,6 +127,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
self.init_pager();
|
||||
});
|
||||
self.on("load_record", self, self.load_record);
|
||||
this.on('view_loaded', self, self.load_form);
|
||||
instance.web.bus.on('clear_uncommitted_changes', this, function(e) {
|
||||
if (!this.can_be_discarded()) {
|
||||
e.preventDefault();
|
||||
|
@ -143,13 +144,13 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
}
|
||||
this._super();
|
||||
},
|
||||
on_loaded: function(data) {
|
||||
load_form: function(data) {
|
||||
var self = this;
|
||||
if (!data) {
|
||||
throw new Error("No data provided.");
|
||||
}
|
||||
if (this.arch) {
|
||||
throw "Form view does not support multiple calls to on_loaded";
|
||||
throw "Form view does not support multiple calls to load_form";
|
||||
}
|
||||
this.fields_order = [];
|
||||
this.fields_view = data;
|
||||
|
@ -213,7 +214,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
this._super.apply(this, arguments);
|
||||
this.trigger('form_view_loaded', data);
|
||||
return $.when();
|
||||
},
|
||||
widgetFocused: function() {
|
||||
|
@ -3802,7 +3803,7 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({
|
|||
|
||||
instance.web.form.One2ManyFormView = instance.web.FormView.extend({
|
||||
form_template: 'One2Many.formview',
|
||||
on_loaded: function(data) {
|
||||
load_form: function(data) {
|
||||
this._super(data);
|
||||
var self = this;
|
||||
this.$buttons.find('button.oe_form_button_create').click(function() {
|
||||
|
@ -4012,7 +4013,7 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({
|
|||
}
|
||||
this.list_view.m2m_field = this;
|
||||
var loaded = $.Deferred();
|
||||
this.list_view.on("view_loaded",self,function() {
|
||||
this.list_view.on("list_view_loaded", self, function() {
|
||||
self.initial_is_loaded.resolve();
|
||||
loaded.resolve();
|
||||
});
|
||||
|
@ -4132,7 +4133,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
|
|||
}
|
||||
this.kanban_view.m2m = this;
|
||||
var loaded = $.Deferred();
|
||||
this.kanban_view.on("view_loaded",self,function() {
|
||||
this.kanban_view.on("kanban_view_loaded",self,function() {
|
||||
self.initial_is_loaded.resolve();
|
||||
loaded.resolve();
|
||||
});
|
||||
|
@ -4356,7 +4357,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
|
|||
this.view_form.set_embedded_view(this.options.alternative_form_view);
|
||||
}
|
||||
this.view_form.appendTo(this.$el.find(".oe_popup_form"));
|
||||
this.view_form.on("view_loaded",self,function() {
|
||||
this.view_form.on("form_view_loaded", self, function() {
|
||||
var multi_select = self.row_id === null && ! self.options.disable_multiple_selection;
|
||||
self.$buttonpane.html(QWeb.render("AbstractFormPopup.buttons", {
|
||||
multi_select: multi_select,
|
||||
|
@ -4493,7 +4494,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
|
|||
}).pipe(function() {
|
||||
self.searchview.do_search();
|
||||
});
|
||||
self.view_list.on("view_loaded",self,function() {
|
||||
self.view_list.on("list_view_loaded", self, function() {
|
||||
self.$buttonpane.html(QWeb.render("SelectCreatePopup.search.buttons", {widget:self}));
|
||||
var $cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-close");
|
||||
$cbutton.click(function() {
|
||||
|
|
|
@ -83,6 +83,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
});
|
||||
|
||||
this.no_leaf = false;
|
||||
this.on('view_load', self, self.load_list);
|
||||
},
|
||||
set_default_options: function (options) {
|
||||
this._super(options);
|
||||
|
@ -218,7 +219,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
* @param {Object} data.fields_view.arch current list view descriptor
|
||||
* @param {Boolean} grouped Is the list view grouped
|
||||
*/
|
||||
on_loaded: function(data, grouped) {
|
||||
load_list: function(data, grouped) {
|
||||
var self = this;
|
||||
this.fields_view = data;
|
||||
this.name = "" + this.fields_view.arch.attrs.string;
|
||||
|
@ -358,7 +359,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
this.sidebar.add_toolbar(this.fields_view.toolbar);
|
||||
this.sidebar.$el.hide();
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
this.trigger('list_view_loaded', data, grouped);
|
||||
},
|
||||
/**
|
||||
* Configures the ListView pager based on the provided dataset's information
|
||||
|
@ -469,7 +470,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
reload_view: function (grouped, context, initial) {
|
||||
var self = this;
|
||||
var callback = function (field_view_get) {
|
||||
self.on_loaded(field_view_get, grouped);
|
||||
self.load_list(field_view_get, grouped);
|
||||
};
|
||||
if (this.embedded_view) {
|
||||
return $.Deferred().then(callback).resolve(this.embedded_view);
|
||||
|
|
|
@ -1135,11 +1135,13 @@ instance.web.View = instance.web.Widget.extend({
|
|||
return this.load_view();
|
||||
},
|
||||
load_view: function() {
|
||||
var self = this;
|
||||
if (this.embedded_view) {
|
||||
var def = $.Deferred();
|
||||
var self = this;
|
||||
$.async_when().then(function() {def.resolve(self.embedded_view);});
|
||||
return def.pipe(this.on_loaded);
|
||||
return def.pipe(function(r) {
|
||||
self.trigger('view_loaded', r);
|
||||
});
|
||||
} else {
|
||||
var context = new instance.web.CompoundContext(this.dataset.get_context());
|
||||
if (! this.view_type)
|
||||
|
@ -1150,16 +1152,11 @@ instance.web.View = instance.web.Widget.extend({
|
|||
"view_type": this.view_type,
|
||||
toolbar: !!this.options.$sidebar,
|
||||
context: context
|
||||
}).pipe(this.on_loaded);
|
||||
}).pipe(function(r) {
|
||||
self.trigger('view_loaded', r);
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Called after a successful call to fields_view_get.
|
||||
* Must return a promise.
|
||||
*/
|
||||
on_loaded: function(fields_view_get) {
|
||||
this.trigger("view_loaded");
|
||||
},
|
||||
set_default_options: function(options) {
|
||||
this.options = options || {};
|
||||
_.defaults(this.options, {
|
||||
|
|
|
@ -12,6 +12,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
|
|||
display_name: _lt('Calendar'),
|
||||
// Dhtmlx scheduler ?
|
||||
init: function(parent, dataset, view_id, options) {
|
||||
var self = this;
|
||||
this._super(parent);
|
||||
this.ready = $.Deferred();
|
||||
this.set_default_options(options);
|
||||
|
@ -38,6 +39,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
|
|||
this.range_stop = null;
|
||||
this.update_range_dates(Date.today());
|
||||
this.selected_filters = [];
|
||||
this.on('view_loaded', self, self.load_calendar);
|
||||
},
|
||||
start: function() {
|
||||
this._super();
|
||||
|
@ -47,7 +49,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
|
|||
scheduler.clearAll();
|
||||
this._super();
|
||||
},
|
||||
on_loaded: function(data) {
|
||||
load_calendar: function(data) {
|
||||
this.fields_view = data;
|
||||
this.$el.addClass(this.fields_view.arch.attrs['class']);
|
||||
this.calendar_fields = {};
|
||||
|
@ -106,7 +108,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
|
|||
this.sidebar = new instance.web_calendar.Sidebar(this);
|
||||
this.has_been_loaded.pipe(this.sidebar.appendTo(this.$el.find('.oe_calendar_sidebar_container')));
|
||||
}
|
||||
|
||||
this.trigger('calendar_view_loaded', data);
|
||||
return this.has_been_loaded.resolve();
|
||||
},
|
||||
init_scheduler: function() {
|
||||
|
|
|
@ -11,6 +11,7 @@ instance.web.DiagramView = instance.web.View.extend({
|
|||
display_name: _lt('Diagram'),
|
||||
searchable: false,
|
||||
init: function(parent, dataset, view_id, options) {
|
||||
var self = this;
|
||||
this._super(parent);
|
||||
this.set_default_options(options);
|
||||
this.view_manager = parent;
|
||||
|
@ -20,17 +21,20 @@ instance.web.DiagramView = instance.web.View.extend({
|
|||
this.domain = this.dataset._domain || [];
|
||||
this.context = {};
|
||||
this.ids = this.dataset.ids;
|
||||
this.on('view_loaded', self, self.load_diagram);
|
||||
},
|
||||
start: function() {
|
||||
return this.rpc("/web_diagram/diagram/load", {"model": this.model, "view_id": this.view_id}, this.on_loaded);
|
||||
var self = this;
|
||||
return this.rpc("/web_diagram/diagram/load", {"model": this.model, "view_id": this.view_id}).then(function(r) {
|
||||
self.load_diagram(r);
|
||||
});
|
||||
},
|
||||
|
||||
toTitleCase: function(str) {
|
||||
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
|
||||
},
|
||||
|
||||
on_loaded: function(result) {
|
||||
|
||||
load_diagram: function(result) {
|
||||
var self = this;
|
||||
if(this.ids && this.ids.length) {
|
||||
this.id = this.ids[self.dataset.index || 0];
|
||||
|
@ -47,7 +51,7 @@ instance.web.DiagramView = instance.web.View.extend({
|
|||
return label.tag == "label";
|
||||
});
|
||||
|
||||
this.$el.html(QWeb.render("DiagramView", {'widget': this}));
|
||||
this.$el.html(QWeb.render("DiagramView", {'widget': self}));
|
||||
this.$el.addClass(this.fields_view.arch.attrs['class']);
|
||||
|
||||
_.each(self.labels,function(label){
|
||||
|
@ -68,7 +72,7 @@ instance.web.DiagramView = instance.web.View.extend({
|
|||
if(this.id) {
|
||||
self.get_diagram_info();
|
||||
}
|
||||
|
||||
this.trigger('diagram_view_loaded', result);
|
||||
},
|
||||
|
||||
get_diagram_info: function() {
|
||||
|
|
|
@ -12,11 +12,13 @@ instance.web_gantt.GanttView = instance.web.View.extend({
|
|||
template: "GanttView",
|
||||
view_type: "gantt",
|
||||
init: function() {
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
this.has_been_loaded = $.Deferred();
|
||||
this.chart_id = _.uniqueId();
|
||||
this.on('view_loaded', self, self.load_gantt);
|
||||
},
|
||||
on_loaded: function(fields_view_get, fields_get) {
|
||||
load_gantt: function(fields_view_get, fields_get) {
|
||||
var self = this;
|
||||
this.fields_view = fields_view_get;
|
||||
this.$el.addClass(this.fields_view.arch.attrs['class']);
|
||||
|
|
|
@ -23,6 +23,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
|||
view_type: "graph",
|
||||
|
||||
init: function(parent, dataset, view_id, options) {
|
||||
var self = this;
|
||||
this._super(parent);
|
||||
this.set_default_options(options);
|
||||
this.dataset = dataset;
|
||||
|
@ -41,6 +42,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
|||
this.group_by = [];
|
||||
|
||||
this.graph = null;
|
||||
this.on('view_loaded', self, self.load_graph);
|
||||
},
|
||||
destroy: function () {
|
||||
if (this.graph) {
|
||||
|
@ -49,7 +51,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
|||
this._super();
|
||||
},
|
||||
|
||||
on_loaded: function(fields_view_get) {
|
||||
load_graph: function(fields_view_get) {
|
||||
// TODO: move to load_view and document
|
||||
var self = this;
|
||||
this.fields_view = fields_view_get;
|
||||
|
@ -98,7 +100,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
|||
self.forcehtml = false;
|
||||
});
|
||||
});
|
||||
return this._super();
|
||||
this.trigger('graph_view_loaded', fields_view_get);
|
||||
},
|
||||
|
||||
get_format: function (options) {
|
||||
|
|
|
@ -14,6 +14,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||
number_of_color_schemes: 10,
|
||||
init: function (parent, dataset, view_id, options) {
|
||||
this._super(parent, dataset, view_id, options);
|
||||
var self = this;
|
||||
_.defaults(this.options, {
|
||||
"quick_creatable": true,
|
||||
"creatable": true,
|
||||
|
@ -41,6 +42,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||
this.currently_dragging = {};
|
||||
this.limit = options.limit || 40;
|
||||
this.add_group_mutex = new $.Mutex();
|
||||
this.on('view_loaded', self, self.load_kanban);
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
@ -55,7 +57,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||
this._super.apply(this, arguments);
|
||||
$('html').off('click.kanban');
|
||||
},
|
||||
on_loaded: function(data) {
|
||||
load_kanban: function(data) {
|
||||
this.fields_view = data;
|
||||
this.$el.addClass(this.fields_view.arch.attrs['class']);
|
||||
this.$buttons = $(QWeb.render("KanbanView.buttons", {'widget': this}));
|
||||
|
@ -71,7 +73,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||
this.fields_keys = _.keys(this.fields_view.fields);
|
||||
this.add_qweb_template();
|
||||
this.has_been_loaded.resolve();
|
||||
this._super.apply(this, arguments);
|
||||
this.trigger('kanban_view_loaded', data);
|
||||
return $.when();
|
||||
},
|
||||
_is_quick_create_enabled: function() {
|
||||
|
|
Loading…
Reference in New Issue