summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js31
-rw-r--r--addons/web/static/src/js/search.js2
-rw-r--r--addons/web/static/src/js/view_form.js13
-rw-r--r--addons/web/static/src/js/view_list.js4
-rw-r--r--addons/web/static/src/js/view_tree.js5
-rw-r--r--addons/web/static/src/js/views.js25
6 files changed, 55 insertions, 25 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index a6f75a5de6c..e3d5c9452f4 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -1139,6 +1139,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;
@@ -1190,6 +1192,7 @@ instance.web.WebClient = instance.web.Client.extend({
show_application: function() {
var self = this;
self.toggle_bars(true);
+ self.update_logo();
self.menu = new instance.web.Menu(self);
self.menu.replace(this.$el.find('.oe_menu_placeholder'));
self.menu.on('menu_click', this, this.on_menu_action);
@@ -1201,6 +1204,10 @@ instance.web.WebClient = instance.web.Client.extend({
self.set_title();
self.check_timezone();
},
+ update_logo: function() {
+ var img = this.session.url('/web/binary/company_logo');
+ this.$el.find('.oe_logo img').attr('src', '').attr('src', img);
+ },
check_timezone: function() {
var self = this;
return new instance.web.Model('res.users').call('read', [[this.session.uid], ['tz_offset']]).then(function(result) {
@@ -1304,18 +1311,20 @@ 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) {
- if (options.needaction) {
- result.context = new instance.web.CompoundContext(
- result.context,
- {search_default_message_unread: true});
- }
- return $.when(self.action_manager.do_action(result, {
- clear_breadcrumbs: true,
- action_menu_id: self.menu.current_menu,
- })).fail(function() {
- self.menu.open_menu(options.previous_menu_id);
+ return self.action_mutex.exec(function() {
+ if (options.needaction) {
+ result.context = new instance.web.CompoundContext(
+ result.context,
+ {search_default_message_unread: true});
+ }
+ return $.when(self.action_manager.do_action(result, {
+ clear_breadcrumbs: true,
+ action_menu_id: self.menu.current_menu,
+ })).fail(function() {
+ self.menu.open_menu(options.previous_menu_id);
+ });
});
});
},
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js
index eea8bba726d..34ab101fea7 100644
--- a/addons/web/static/src/js/search.js
+++ b/addons/web/static/src/js/search.js
@@ -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();
});
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 3f6952e5da4..cfc8be391b4 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -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');
@@ -2542,6 +2544,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
initialize_content: function() {
var self = this;
this.$textarea = this.$el.find('textarea');
+ this.auto_sized = false;
this.default_height = this.$textarea.css('height');
if (this.get("effective_readonly")) {
this.$textarea.attr('disabled', 'disabled');
@@ -2561,13 +2564,17 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
}
},
render_value: function() {
- $(window).resize();
var show_value = instance.web.format_value(this.get('value'), this, '');
if (show_value === '') {
this.$textarea.css('height', parseInt(this.default_height)+"px");
}
this.$textarea.val(show_value);
- this.$textarea.autosize();
+ if (! this.auto_sized) {
+ this.auto_sized = true;
+ this.$textarea.autosize();
+ } else {
+ this.$textarea.trigger("autosize");
+ }
},
is_syntax_valid: function() {
if (!this.get("effective_readonly") && this.$textarea) {
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 04ff8b48923..f6794bd435c 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -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);
diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js
index acac93f1842..2f9efad9171 100644
--- a/addons/web/static/src/js/view_tree.js
+++ b/addons/web/static/src/js/view_tree.js
@@ -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);
},
/**
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index c949762a5f6..92f66849fec 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -467,6 +467,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
this.flags = flags || {};
this.registry = instance.web.views;
this.views_history = [];
+ this.view_completely_inited = $.Deferred();
},
/**
* @returns {jQuery.Deferred} initial view loading promise
@@ -586,6 +587,8 @@ instance.web.ViewManager = instance.web.Widget.extend({
&& self.flags.auto_search
&& view.controller.searchable !== false) {
self.searchview.ready.done(self.searchview.do_search);
+ } else {
+ self.view_completely_inited.resolve();
}
self.trigger("controller_inited",view_type,controller);
});
@@ -700,7 +703,9 @@ instance.web.ViewManager = instance.web.Widget.extend({
if (_.isString(groupby)) {
groupby = [groupby];
}
- controller.do_search(results.domain, results.context, groupby || []);
+ $.when(controller.do_search(results.domain, results.context, groupby || [])).then(function() {
+ self.view_completely_inited.resolve();
+ });
});
},
/**
@@ -782,7 +787,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
var main_view_loaded = this._super();
- var manager_ready = $.when(searchview_loaded, main_view_loaded);
+ var manager_ready = $.when(searchview_loaded, main_view_loaded, this.view_completely_inited);
this.$el.find('.oe_debug_view').change(this.on_debug_changed);
this.$el.addClass("oe_view_manager_" + (this.action.target || 'current'));
@@ -1186,32 +1191,36 @@ 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 || {};
_.defaults(this.options, {