[IMP] lot of small improvements to better detect when a view has finished loading
bzr revid: nicolas.vanhoren@openerp.com-20121213140914-8d1u01h17r2x4fpu
This commit is contained in:
parent
5bc1a17026
commit
906ceba948
|
@ -1122,6 +1122,8 @@ instance.web.WebClient = instance.web.Client.extend({
|
|||
init: function(parent) {
|
||||
this._super(parent);
|
||||
this._current_state = null;
|
||||
this.menu_dm = new instance.web.DropMisordered();
|
||||
this.action_mutex = new $.Mutex();
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
@ -1287,8 +1289,9 @@ instance.web.WebClient = instance.web.Client.extend({
|
|||
},
|
||||
on_menu_action: function(options) {
|
||||
var self = this;
|
||||
return this.rpc("/web/action/load", { action_id: options.action_id })
|
||||
return this.menu_dm.add(this.rpc("/web/action/load", { action_id: options.action_id }))
|
||||
.then(function (result) {
|
||||
return self.action_mutex.exec(function() {
|
||||
if (options.needaction) {
|
||||
result.context = new instance.web.CompoundContext(
|
||||
result.context,
|
||||
|
@ -1301,6 +1304,7 @@ instance.web.WebClient = instance.web.Client.extend({
|
|||
self.menu.open_menu(options.previous_menu_id);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
set_content_full_screen: function(fullscreen) {
|
||||
if (fullscreen) {
|
||||
|
|
|
@ -640,7 +640,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
|||
.then(this.proxy('setup_default_query'));
|
||||
|
||||
return $.when(drawer_started, defaults_fetched)
|
||||
.done(function () {
|
||||
.then(function () {
|
||||
self.trigger("search_view_loaded", data);
|
||||
self.ready.resolve();
|
||||
});
|
||||
|
|
|
@ -128,13 +128,15 @@ 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();
|
||||
}
|
||||
});
|
||||
},
|
||||
view_loading: function(r) {
|
||||
return this.load_form(r);
|
||||
},
|
||||
destroy: function() {
|
||||
_.each(this.get_widgets(), function(w) {
|
||||
w.off('focused blurred');
|
||||
|
|
|
@ -90,7 +90,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
|
||||
this.no_leaf = false;
|
||||
this.grouped = false;
|
||||
this.on('view_loaded', self, self.load_list);
|
||||
},
|
||||
view_loading: function(r) {
|
||||
return this.load_list(r);
|
||||
},
|
||||
set_default_options: function (options) {
|
||||
this._super(options);
|
||||
|
|
|
@ -37,7 +37,10 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
|
|||
this.options = _.extend({}, this.defaults, options || {});
|
||||
|
||||
_.bindAll(this, 'color_for');
|
||||
this.on('view_loaded', this, this.load_tree);
|
||||
},
|
||||
|
||||
view_loading: function(r) {
|
||||
return this.load_tree(r);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1186,31 +1186,35 @@ instance.web.View = instance.web.Widget.extend({
|
|||
},
|
||||
load_view: function(context) {
|
||||
var self = this;
|
||||
var view_loaded;
|
||||
var view_loaded_def;
|
||||
if (this.embedded_view) {
|
||||
view_loaded = $.Deferred();
|
||||
view_loaded_def = $.Deferred();
|
||||
$.async_when().done(function() {
|
||||
view_loaded.resolve(self.embedded_view);
|
||||
view_loaded_def.resolve(self.embedded_view);
|
||||
});
|
||||
} else {
|
||||
if (! this.view_type)
|
||||
console.warn("view_type is not defined", this);
|
||||
view_loaded = instance.web.fields_view_get({
|
||||
view_loaded_def = instance.web.fields_view_get({
|
||||
"model": this.dataset._model,
|
||||
"view_id": this.view_id,
|
||||
"view_type": this.view_type,
|
||||
"toolbar": !!this.options.$sidebar,
|
||||
});
|
||||
}
|
||||
return view_loaded.then(function(r) {
|
||||
return view_loaded_def.then(function(r) {
|
||||
self.fields_view = r;
|
||||
self.trigger('view_loaded', r);
|
||||
// add css classes that reflect the (absence of) access rights
|
||||
self.$el.addClass('oe_view')
|
||||
.toggleClass('oe_cannot_create', !self.is_action_enabled('create'))
|
||||
.toggleClass('oe_cannot_edit', !self.is_action_enabled('edit'))
|
||||
.toggleClass('oe_cannot_delete', !self.is_action_enabled('delete'));
|
||||
return $.when(self.view_loading(r)).then(function() {
|
||||
self.trigger('view_loaded', r);
|
||||
});
|
||||
});
|
||||
},
|
||||
view_loading: function(r) {
|
||||
},
|
||||
set_default_options: function(options) {
|
||||
this.options = options || {};
|
||||
|
|
|
@ -49,7 +49,9 @@ 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);
|
||||
},
|
||||
view_loading: function(r) {
|
||||
return this.load_calendar(r);
|
||||
},
|
||||
destroy: function() {
|
||||
scheduler.clearAll();
|
||||
|
|
|
@ -22,10 +22,13 @@ 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);
|
||||
this.on('pager_action_executed', self, self.pager_action_trigger);
|
||||
},
|
||||
|
||||
view_loading: function(r) {
|
||||
return this.load_diagram(r);
|
||||
},
|
||||
|
||||
toTitleCase: function(str) {
|
||||
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
|
||||
},
|
||||
|
|
|
@ -16,7 +16,9 @@ instance.web_gantt.GanttView = instance.web.View.extend({
|
|||
this._super.apply(this, arguments);
|
||||
this.has_been_loaded = $.Deferred();
|
||||
this.chart_id = _.uniqueId();
|
||||
this.on('view_loaded', self, self.load_gantt);
|
||||
},
|
||||
view_loading: function(r) {
|
||||
return this.load_gantt(r);
|
||||
},
|
||||
load_gantt: function(fields_view_get, fields_get) {
|
||||
var self = this;
|
||||
|
|
|
@ -42,7 +42,9 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
|||
this.group_by = [];
|
||||
|
||||
this.graph = null;
|
||||
this.on('view_loaded', self, self.load_graph);
|
||||
},
|
||||
view_loading: function(r) {
|
||||
return this.load_graph(r);
|
||||
},
|
||||
destroy: function () {
|
||||
if (this.graph) {
|
||||
|
|
|
@ -43,7 +43,9 @@ 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);
|
||||
},
|
||||
view_loading: function(r) {
|
||||
return this.load_kanban(r);
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
|
Loading…
Reference in New Issue