diff options
| author | Christophe Matthieu <chm@openerp.com> | 2012-10-26 16:04:12 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2012-10-26 16:04:12 +0200 |
| commit | 415f519cd86ad5ad7085c5ba6f2cb4bd7c353e01 (patch) | |
| tree | 986f0f842c51b52a4dcb16533b8dd52af5a454d3 /addons/web/static/src/js | |
| parent | 00bfec86ab5222ee8d46f50e57c3003b9a5d1c72 (diff) | |
| parent | 08db8bbf0f015fd710e1ce79a55fb8faf143f6d5 (diff) | |
[MERGE] from trunk
bzr revid: chm@openerp.com-20121026140412-wfwl9ze4s8pzs9sg
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 1 | ||||
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 119 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 11 |
5 files changed, 64 insertions, 75 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 3cb4437d1c3..6cf35a14e92 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1128,6 +1128,7 @@ instance.web.WebClient = instance.web.Client.extend({ } return $.when(self.action_manager.do_action(action, { 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/coresetup.js b/addons/web/static/src/js/coresetup.js index 1f1112df2f2..220b9b63d5c 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -530,7 +530,8 @@ instance.web.qweb.default_dict['__debug__'] = instance.session.debug; // Which o instance.web.qweb.debug = instance.session.debug; instance.web.qweb.default_dict = { '_' : _, - '_t' : instance.web._t + '_t' : instance.web._t, + 'JSON': JSON, }; instance.web.qweb.preprocess_node = function() { // Note that 'this' is the Qweb Node diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 79b7a2cba52..2819be453fb 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1590,37 +1590,6 @@ instance.web.form.DefaultFieldManager = instance.web.Widget.extend({ }, }); -instance.web.form.FormDialog = instance.web.Dialog.extend({ - init: function(parent, options, view_id, dataset) { - this._super(parent, options); - this.dataset = dataset; - this.view_id = view_id; - return this; - }, - start: function() { - var self = this; - this._super(); - this.form = new instance.web.FormView(this, this.dataset, this.view_id, { - pager: false - }); - this.form.appendTo(this.$el); - this.form.on('record_created', self, this.on_form_dialog_saved); - this.form.on('record_saved', this, this.on_form_dialog_saved); - return this; - }, - select_id: function(id) { - if (this.form.dataset.select_id(id)) { - return this.form.do_show(); - } else { - this.do_warn("Could not find id in dataset"); - return $.Deferred().reject(); - } - }, - on_form_dialog_saved: function(r) { - this.close(); - } -}); - instance.web.form.compute_domain = function(expr, fields) { if (! (expr instanceof Array)) return !! expr; @@ -3141,7 +3110,6 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc type: 'ir.actions.act_window', res_model: self.field.relation, res_id: self.get("value"), - context: self.build_context(), views: [[false, 'form']], target: 'current' }); @@ -3987,9 +3955,12 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in }, }); -/* - * TODO niv: clean those deferred stuff, it could be better - */ +/** + widget options: + - reload_on_button: Reload the whole form view if click on a button in a list view. + If you see this options, do not use it, it's basically a dirty hack to make one + precise o2m to behave the way we want. +*/ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({ multi_selection: false, disable_utility_classes: true, @@ -4118,7 +4089,20 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in readonly: this.getParent().get("effective_readonly") }); pop.on('write_completed', self, self.reload_content); - } + }, + do_button_action: function(name, id, callback) { + var self = this; + var _sup = _.bind(this._super, this); + if (! this.m2m_field.options.reload_on_button) { + return _sup(name, id, callback); + } else { + return this.m2m_field.view.save().pipe(function() { + return _sup(name, id, function() { + self.m2m_field.view.reload(); + }); + }); + } + }, }); instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(instance.web.form.CompletionFieldMixin, { @@ -4551,6 +4535,10 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend self.select_elements(self.selected_ids); self.destroy(); }); + var $cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-create"); + $cbutton.click(function() { + self.new_object(); + }); }); }); this.searchview.appendTo($(".oe_popup_search", self.$el)); @@ -4605,16 +4593,6 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan this._super(field_manager, node); this.reference_ready = true; }, - on_nop: function() { - }, - on_selection_changed: function() { - if (this.reference_ready) { - var sel = this.selection.get_value(); - this.m2o.field.relation = sel; - this.m2o.set_value(false); - this.m2o.$el.toggle(sel !== false); - } - }, destroy_content: function() { if (this.fm) { this.fm.destroy(); @@ -4655,33 +4633,38 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan .on('focused', null, function () {self.trigger('focused')}) .on('blurred', null, function () {self.trigger('blurred')}); }, - is_false: function() { - return typeof(this.get_value()) !== 'string'; + on_selection_changed: function() { + if (this.reference_ready) { + this.internal_set_value([this.selection.get_value(), false]); + this.render_value(); + } + }, + data_changed: function() { + if (this.reference_ready) { + this.internal_set_value([this.selection.get_value(), this.m2o.get_value()]); + } + }, + set_value: function(val) { + if (val) { + val = val.split(','); + val[0] = val[0] || false; + val[1] = val[0] ? (val[1] ? parseInt(val[1], 10) : val[1]) : false; + } + this._super(val || [false, false]); + }, + get_value: function() { + return this.get('value')[0] && this.get('value')[1] ? (this.get('value')[0] + ',' + this.get('value')[1]) : false; }, render_value: function() { this.reference_ready = false; - var vals = [], sel_val, m2o_val; - if (typeof(this.get('value')) === 'string') { - vals = this.get('value').split(','); - } - sel_val = vals[0] || false; - m2o_val = vals[1] ? parseInt(vals[1], 10) : vals[1]; if (!this.get("effective_readonly")) { - this.selection.set_value(sel_val); + this.selection.set_value(this.get('value')[0]); } - this.m2o.field.relation = sel_val; - this.m2o.set_value(m2o_val); + this.m2o.field.relation = this.get('value')[0]; + this.m2o.set_value(this.get('value')[1]); + this.m2o.$el.toggle(!!this.get('value')[0]); this.reference_ready = true; }, - data_changed: function() { - var model = this.selection.get_value(), - id = this.m2o.get_value(); - if (typeof(model) === 'string' && typeof(id) === 'number') { - this.internal_set_value(model + ',' + id); - } else { - this.internal_set_value(false); - } - }, }); instance.web.form.FieldBinary = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { @@ -4750,8 +4733,6 @@ instance.web.form.FieldBinary = instance.web.form.AbstractField.extend(instance. } this.$el.find('.oe_form_binary_progress').hide(); this.$el.find('.oe_form_binary').show(); - - console.log("upload ok"); }, on_file_uploaded_and_valid: function(size, name, content_type, file_base64) { }, @@ -4906,7 +4887,7 @@ instance.web.form.FieldOne2ManyBinaryMultiFiles = instance.web.form.AbstractFiel this.field_manager = field_manager; this.node = node; if(this.field.type != "one2many" || this.field.relation != 'ir.attachment') { - console.log("The type of the field '"+this.field.string+"' must be a one2many field with a relation to 'ir.attachment' model."); + throw "The type of the field '"+this.field.string+"' must be a one2many field with a relation to 'ir.attachment' model."; } this.ds_file = new instance.web.DataSetSearch(this, 'ir.attachment'); this.fileupload_id = _.uniqueId('oe_fileupload_temp'); diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 75bf6c2f586..5546105e901 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -374,7 +374,10 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi var total = dataset.size(); var limit = this.limit() || total; - this.$pager.toggle(total !== 0); + if (total == 0) + this.$pager.hide(); + else + this.$pager.css("display", ""); this.$pager.toggleClass('oe_list_pager_single_page', (total <= limit)); var spager = '-'; if (total) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index d373adf514e..ebc7c326724 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -174,6 +174,9 @@ instance.web.ActionManager = instance.web.Widget.extend({ if(this.inner_action.type == 'ir.actions.act_window') { state['model'] = this.inner_action.res_model; } + if (this.inner_action.menu_id) { + state['menu_id'] = this.inner_action.menu_id; + } if (this.inner_action.id) { state['action'] = this.inner_action.id; } else if (this.inner_action.type == 'ir.actions.client') { @@ -241,6 +244,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ clear_breadcrumbs: false, on_reverse_breadcrumb: function() {}, on_close: function() {}, + action_menu_id: null, }); if (_.isString(action) && instance.web.client_actions.contains(action)) { var action_client = { type: "ir.actions.client", tag: action }; @@ -266,6 +270,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ pager : !popup && !inline, display_title : !popup }, action.flags || {}); + action.menu_id = options.action_menu_id; if (!(type in this)) { console.error("Action manager can't handle action of type " + action.type, action); return $.Deferred().reject(); @@ -1276,11 +1281,9 @@ instance.web.View = instance.web.Widget.extend({ }, /** * Switches to a specific view type - * - * @param {String} view view type to switch to */ - do_switch_view: function(view) { - this.trigger('switch_mode',view); + do_switch_view: function() { + this.trigger.apply(this, ['switch_mode'].concat(_.toArray(arguments))); }, /** * Cancels the switch to the current view, switches to the previous one |
