diff options
| author | vta vta@openerp.com <> | 2012-10-15 09:16:05 +0200 |
|---|---|---|
| committer | vta vta@openerp.com <> | 2012-10-15 09:16:05 +0200 |
| commit | c6dfd8afc114278345cf38ea8b96404f56d5958a (patch) | |
| tree | b2af9a32c7c6870436136b781742bf8471da0ccd /addons/web/static/src/js | |
| parent | 4112f2b3a76f2ad924fa35a2ddfc9c654d7ac8cd (diff) | |
| parent | e273ccce6394f0cc092aff81f9e33310b9bc6310 (diff) | |
[MERGE] Latest trunk.
bzr revid: vta@openerp.com-20121015071605-jgupguux9p1aavdm
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 25 | ||||
| -rw-r--r-- | addons/web/static/src/js/data.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 45 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list_editable.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 17 |
6 files changed, 50 insertions, 44 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index d7272d8d83f..c993f3e3ad1 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -70,7 +70,7 @@ instance.web.Dialog = instance.web.Widget.extend({ autoOpen: false, position: [false, 40], buttons: {}, - beforeClose: function () { self.on_close(); }, + beforeClose: function () { self.close(); }, resizeStop: this.on_resized }; for (var f in this) { @@ -150,16 +150,14 @@ instance.web.Dialog = instance.web.Widget.extend({ var res = this.start(); return res; }, - close: function() { - this.$el.dialog('close'); - }, - on_close: function() { + close: function() { if (this.__tmp_dialog_destroying) return; if (this.dialog_options.destroy_on_close) { this.__tmp_dialog_closing = true; this.destroy(); this.__tmp_dialog_closing = undefined; + this.trigger("dialog_close"); } }, on_resized: function() { @@ -879,8 +877,6 @@ instance.web.UserMenu = instance.web.Widget.extend({ }; this.update_promise = this.update_promise.pipe(fct, fct); }, - on_action: function() { - }, on_menu_logout: function() { this.trigger('user_logout'); }, @@ -899,8 +895,7 @@ instance.web.UserMenu = instance.web.Widget.extend({ var $help = $(QWeb.render("UserMenu.about", {version_info: res})); $help.find('a.oe_activate_debug_mode').click(function (e) { e.preventDefault(); - window.location = $.param.querystring( - window.location.href, 'debug'); + window.location = $.param.querystring( window.location.href, 'debug'); }); instance.web.dialog($help, {autoOpen: true, modal: true, width: 507, height: 290, resizable: false, title: _t("About")}); @@ -1021,15 +1016,13 @@ instance.web.WebClient = instance.web.Client.extend({ var state = $.bbq.getState(true); var action = { - 'type': 'ir.actions.client', - 'tag': 'login', - 'params': state + type: 'ir.actions.client', + tag: 'login', + _push_me: false, }; this.action_manager.do_action(action); this.action_manager.inner_widget.on('login_successful', this, function() { - this.do_push_state(state); - this._current_state = null; // ensure the state will be loaded this.show_application(); // will load the state we just pushed }); }, @@ -1041,8 +1034,7 @@ instance.web.WebClient = instance.web.Client.extend({ self.menu.on('menu_click', this, this.on_menu_action); self.user_menu = new instance.web.UserMenu(self); self.user_menu.replace(this.$el.find('.oe_user_menu_placeholder')); - self.user_menu.on('user_logout', self, this.proxy('on_logout')); - self.user_menu.on_action.add(this.proxy('on_menu_action')); + self.user_menu.on('user_logout', self, self.on_logout); self.user_menu.do_update(); self.bind_hashchange(); self.set_title(); @@ -1105,6 +1097,7 @@ instance.web.WebClient = instance.web.Client.extend({ }); }); } else { + state._push_me = false; // no need to push state back... this.action_manager.do_load_state(state, !!this._current_state); } } diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 1731f1effaa..48210007dcd 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -280,7 +280,8 @@ instance.web.Model = instance.web.Class.extend({ kwargs = args; args = []; } - return instance.session.rpc('/web/dataset/call_kw', { + var debug = instance.session.debug ? '/'+this.name+':'+method : ''; + return instance.session.rpc('/web/dataset/call_kw' + debug, { model: this.name, method: method, args: args, diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c3a94838cf6..67a36661b12 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -748,7 +748,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, on_button_save: function() { var self = this; - return this.do_save().then(function(result) { + return this.save().then(function(result) { + self.trigger("save"); self.to_view_mode(); }); }, @@ -825,11 +826,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM * record or saving an existing one depending on whether the record * already has an id property. * - * @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new + * @param {Boolean} [prepend_on_create=false] if ``save`` creates a new * record, should that record be inserted at the start of the dataset (by * default, records are added at the end) */ - do_save: function(prepend_on_create) { + save: function(prepend_on_create) { var self = this; return this.mutating_mutex.exec(function() { return self.is_initialized.pipe(function() { try { @@ -1001,7 +1002,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, recursive_save: function() { var self = this; - return $.when(this.do_save()).pipe(function(res) { + return $.when(this.save()).pipe(function(res) { if (self.dataset.parent_view) return self.dataset.parent_view.recursive_save(); }); @@ -1032,7 +1033,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return true; }, sidebar_context: function () { - return this.do_save().pipe(_.bind(function() {return this.get_fields_values();}, this)); + return this.save().pipe(_.bind(function() {return this.get_fields_values();}, this)); }, open_defaults_dialog: function () { var self = this; @@ -2379,7 +2380,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ this.$input = this.$el.find('input.oe_datepicker_master'); this.$input_picker = this.$el.find('input.oe_datepicker_container'); this.$input.change(function(){ - self.datetime_changed(); + self.change_datetime(); }); this.picker({ @@ -2449,7 +2450,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ format_client: function(v) { return instance.web.format_value(v, {"widget": this.type_of_date}); }, - datetime_changed: function() { + change_datetime: function() { if (this.is_valid_()) { this.set_value_from_ui_(); this.trigger("datetime_changed"); @@ -2880,7 +2881,7 @@ instance.web.form.CompletionFieldMixin = { self.build_domain(), new instance.web.CompoundContext(self.build_context(), context || {}) ); - pop.on("select_elements",self,function(element_ids) { + pop.on("elements_selected", self, function(element_ids) { self.add_id(element_ids[0]); self.focus(); }); @@ -3525,7 +3526,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ if (!view.is_initialized.isResolved()) { return false; } - var res = $.when(view.do_save()); + var res = $.when(view.save()); if (!res.isResolved() && !res.isRejected()) { console.warn("Asynchronous get_value() is not supported in form view."); } @@ -3599,7 +3600,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({ form_view_options: {'not_interactible_on_create':true}, readonly: self.o2m.get("effective_readonly") }); - pop.on("select_elements", self, function() { + pop.on("elements_selected", self, function() { self.o2m.reload_current_view(); }); }, @@ -3685,7 +3686,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ self.o2m.build_domain(), self.o2m.build_context() ); - pop.on("select_elements", self, function() { + pop.on("elements_selected", self, function() { self.o2m.reload_current_view(); }); } @@ -3721,7 +3722,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ var self = this; this.ensure_saved().pipe(function () { if (parent_form) - return parent_form.do_save(); + return parent_form.save(); else return $.when(); }).then(function () { @@ -3860,7 +3861,7 @@ instance.web.form.One2ManyFormView = instance.web.FormView.extend({ this._super(data); var self = this; this.$buttons.find('button.oe_form_button_create').click(function() { - self.do_save().then(self.on_button_new); + self.save().then(self.on_button_new); }); }, do_notify_change: function() { @@ -4122,7 +4123,7 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in this.m2m_field.build_context() ); var self = this; - pop.on("select_elements", self, function(element_ids) { + pop.on("elements_selected", self, function(element_ids) { _.each(element_ids, function(one_id) { if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); @@ -4237,7 +4238,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( new instance.web.CompoundDomain(this.build_domain(), ["!", ["id", "in", this.dataset.ids]]), this.build_context() ); - pop.on("select_elements", self, function(element_ids) { + pop.on("elements_selected", self, function(element_ids) { _.each(element_ids, function(one_id) { if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); @@ -4436,7 +4437,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ })); var $snbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save-new"); $snbutton.click(function() { - $.when(self.view_form.do_save()).then(function() { + $.when(self.view_form.save()).then(function() { self.view_form.reload_mutex.exec(function() { self.view_form.on_button_new(); }); @@ -4444,7 +4445,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ }); var $sbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save"); $sbutton.click(function() { - $.when(self.view_form.do_save()).then(function() { + $.when(self.view_form.save()).then(function() { self.view_form.reload_mutex.exec(function() { self.check_exit(); }); @@ -4457,12 +4458,12 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ self.view_form.do_show(); }); }, - elements_selected: function(element_ids) { - this.trigger("select_elements",element_ids); + select_elements: function(element_ids) { + this.trigger("elements_selected", element_ids); }, check_exit: function(no_destroy) { if (this.created_elements.length > 0) { - this.elements_selected(this.created_elements); + this.select_elements(this.created_elements); this.created_elements = []; } this.destroy(); @@ -4573,7 +4574,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend }); var $sbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-select"); $sbutton.click(function() { - self.elements_selected(self.selected_ids); + self.select_elements(self.selected_ids); self.destroy(); }); }); @@ -4615,7 +4616,7 @@ instance.web.form.SelectCreateListView = instance.web.ListView.extend({ this.popup.new_object(); }, select_record: function(index) { - this.popup.elements_selected([this.dataset.ids[index]]); + this.popup.select_elements([this.dataset.ids[index]]); this.popup.destroy(); }, do_select: function(ids, records) { diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 7457ca5ef67..88ee428fba4 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1321,7 +1321,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we } catch (e) { group_label = row_data[group_column.id].value; } - $group_column.text(_.str.sprintf("%s (%d)", + $group_column.html(_.str.sprintf("%s (%d)", group_label, group.length)); if (group.length && group.openable) { diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index fe0f525fe3f..4bf61895a09 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -724,7 +724,7 @@ openerp.web.list_editable = function (instance) { save: function () { var self = this; return this.form - .do_save(this.delegate.prepends_on_create()) + .save(this.delegate.prepends_on_create()) .pipe(function (result) { var created = result.created && !self.record.id; if (created) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 47a06e37ddc..b5bb3a7259d 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -164,6 +164,10 @@ instance.web.ActionManager = instance.web.Widget.extend({ state = state || {}; if (this.getParent() && this.getParent().do_push_state) { if (this.inner_action) { + if (this.inner_action._push_me === false) { + // this action has been explicitly marked as not pushable + return; + } state['title'] = this.inner_action.name; if(this.inner_action.type == 'ir.actions.act_window') { state['model'] = this.inner_action.res_model; @@ -172,7 +176,13 @@ instance.web.ActionManager = instance.web.Widget.extend({ state['action'] = this.inner_action.id; } else if (this.inner_action.type == 'ir.actions.client') { state['action'] = this.inner_action.tag; - //state = _.extend(this.inner_action.params || {}, state); + var params = {}; + _.each(this.inner_action.params, function(v, k) { + if(_.isString(v) || _.isNumber(v)) { + params[k] = v; + } + }); + state = _.extend(params || {}, state); } } if(!this.dialog) { @@ -286,8 +296,9 @@ instance.web.ActionManager = instance.web.Widget.extend({ buttons: { "Close": function() { $(this).dialog("close"); }}, dialogClass: executor.klass }); - if(on_close) - this.dialog.on_close.add(on_close); + if (on_close) { + this.dialog.on("dialog_close", this, on_close); + } } else { this.dialog_widget.destroy(); } |
