[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) {
|
init: function(parent) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this._current_state = null;
|
this._current_state = null;
|
||||||
|
this.menu_dm = new instance.web.DropMisordered();
|
||||||
|
this.action_mutex = new $.Mutex();
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -1287,18 +1289,20 @@ instance.web.WebClient = instance.web.Client.extend({
|
||||||
},
|
},
|
||||||
on_menu_action: function(options) {
|
on_menu_action: function(options) {
|
||||||
var self = this;
|
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) {
|
.then(function (result) {
|
||||||
if (options.needaction) {
|
return self.action_mutex.exec(function() {
|
||||||
result.context = new instance.web.CompoundContext(
|
if (options.needaction) {
|
||||||
result.context,
|
result.context = new instance.web.CompoundContext(
|
||||||
{search_default_message_unread: true});
|
result.context,
|
||||||
}
|
{search_default_message_unread: true});
|
||||||
return $.when(self.action_manager.do_action(result, {
|
}
|
||||||
clear_breadcrumbs: true,
|
return $.when(self.action_manager.do_action(result, {
|
||||||
action_menu_id: self.menu.current_menu,
|
clear_breadcrumbs: true,
|
||||||
})).fail(function() {
|
action_menu_id: self.menu.current_menu,
|
||||||
self.menu.open_menu(options.previous_menu_id);
|
})).fail(function() {
|
||||||
|
self.menu.open_menu(options.previous_menu_id);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -640,7 +640,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
.then(this.proxy('setup_default_query'));
|
.then(this.proxy('setup_default_query'));
|
||||||
|
|
||||||
return $.when(drawer_started, defaults_fetched)
|
return $.when(drawer_started, defaults_fetched)
|
||||||
.done(function () {
|
.then(function () {
|
||||||
self.trigger("search_view_loaded", data);
|
self.trigger("search_view_loaded", data);
|
||||||
self.ready.resolve();
|
self.ready.resolve();
|
||||||
});
|
});
|
||||||
|
|
|
@ -128,13 +128,15 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
self.init_pager();
|
self.init_pager();
|
||||||
});
|
});
|
||||||
self.on("load_record", self, self.load_record);
|
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) {
|
instance.web.bus.on('clear_uncommitted_changes', this, function(e) {
|
||||||
if (!this.can_be_discarded()) {
|
if (!this.can_be_discarded()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
view_loading: function(r) {
|
||||||
|
return this.load_form(r);
|
||||||
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
_.each(this.get_widgets(), function(w) {
|
_.each(this.get_widgets(), function(w) {
|
||||||
w.off('focused blurred');
|
w.off('focused blurred');
|
||||||
|
|
|
@ -90,7 +90,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
|
|
||||||
this.no_leaf = false;
|
this.no_leaf = false;
|
||||||
this.grouped = 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) {
|
set_default_options: function (options) {
|
||||||
this._super(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 || {});
|
this.options = _.extend({}, this.defaults, options || {});
|
||||||
|
|
||||||
_.bindAll(this, 'color_for');
|
_.bindAll(this, 'color_for');
|
||||||
this.on('view_loaded', this, this.load_tree);
|
},
|
||||||
|
|
||||||
|
view_loading: function(r) {
|
||||||
|
return this.load_tree(r);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1186,32 +1186,36 @@ instance.web.View = instance.web.Widget.extend({
|
||||||
},
|
},
|
||||||
load_view: function(context) {
|
load_view: function(context) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var view_loaded;
|
var view_loaded_def;
|
||||||
if (this.embedded_view) {
|
if (this.embedded_view) {
|
||||||
view_loaded = $.Deferred();
|
view_loaded_def = $.Deferred();
|
||||||
$.async_when().done(function() {
|
$.async_when().done(function() {
|
||||||
view_loaded.resolve(self.embedded_view);
|
view_loaded_def.resolve(self.embedded_view);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (! this.view_type)
|
if (! this.view_type)
|
||||||
console.warn("view_type is not defined", this);
|
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,
|
"model": this.dataset._model,
|
||||||
"view_id": this.view_id,
|
"view_id": this.view_id,
|
||||||
"view_type": this.view_type,
|
"view_type": this.view_type,
|
||||||
"toolbar": !!this.options.$sidebar,
|
"toolbar": !!this.options.$sidebar,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return view_loaded.then(function(r) {
|
return view_loaded_def.then(function(r) {
|
||||||
self.fields_view = r;
|
self.fields_view = r;
|
||||||
self.trigger('view_loaded', r);
|
|
||||||
// add css classes that reflect the (absence of) access rights
|
// add css classes that reflect the (absence of) access rights
|
||||||
self.$el.addClass('oe_view')
|
self.$el.addClass('oe_view')
|
||||||
.toggleClass('oe_cannot_create', !self.is_action_enabled('create'))
|
.toggleClass('oe_cannot_create', !self.is_action_enabled('create'))
|
||||||
.toggleClass('oe_cannot_edit', !self.is_action_enabled('edit'))
|
.toggleClass('oe_cannot_edit', !self.is_action_enabled('edit'))
|
||||||
.toggleClass('oe_cannot_delete', !self.is_action_enabled('delete'));
|
.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) {
|
set_default_options: function(options) {
|
||||||
this.options = options || {};
|
this.options = options || {};
|
||||||
_.defaults(this.options, {
|
_.defaults(this.options, {
|
||||||
|
|
|
@ -49,7 +49,9 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
|
||||||
this.range_stop = null;
|
this.range_stop = null;
|
||||||
this.update_range_dates(Date.today());
|
this.update_range_dates(Date.today());
|
||||||
this.selected_filters = [];
|
this.selected_filters = [];
|
||||||
this.on('view_loaded', self, self.load_calendar);
|
},
|
||||||
|
view_loading: function(r) {
|
||||||
|
return this.load_calendar(r);
|
||||||
},
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
scheduler.clearAll();
|
scheduler.clearAll();
|
||||||
|
|
|
@ -22,10 +22,13 @@ instance.web.DiagramView = instance.web.View.extend({
|
||||||
this.domain = this.dataset._domain || [];
|
this.domain = this.dataset._domain || [];
|
||||||
this.context = {};
|
this.context = {};
|
||||||
this.ids = this.dataset.ids;
|
this.ids = this.dataset.ids;
|
||||||
this.on('view_loaded', self, self.load_diagram);
|
|
||||||
this.on('pager_action_executed', self, self.pager_action_trigger);
|
this.on('pager_action_executed', self, self.pager_action_trigger);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
view_loading: function(r) {
|
||||||
|
return this.load_diagram(r);
|
||||||
|
},
|
||||||
|
|
||||||
toTitleCase: function(str) {
|
toTitleCase: function(str) {
|
||||||
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
|
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._super.apply(this, arguments);
|
||||||
this.has_been_loaded = $.Deferred();
|
this.has_been_loaded = $.Deferred();
|
||||||
this.chart_id = _.uniqueId();
|
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) {
|
load_gantt: function(fields_view_get, fields_get) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -42,7 +42,9 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
||||||
this.group_by = [];
|
this.group_by = [];
|
||||||
|
|
||||||
this.graph = null;
|
this.graph = null;
|
||||||
this.on('view_loaded', self, self.load_graph);
|
},
|
||||||
|
view_loading: function(r) {
|
||||||
|
return this.load_graph(r);
|
||||||
},
|
},
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
if (this.graph) {
|
if (this.graph) {
|
||||||
|
|
|
@ -43,7 +43,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||||
this.currently_dragging = {};
|
this.currently_dragging = {};
|
||||||
this.limit = options.limit || 40;
|
this.limit = options.limit || 40;
|
||||||
this.add_group_mutex = new $.Mutex();
|
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() {
|
start: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
Loading…
Reference in New Issue