diff options
| author | Frédéric van der Essen <fva@openerp.com> | 2012-09-19 11:15:22 +0200 |
|---|---|---|
| committer | Frédéric van der Essen <fva@openerp.com> | 2012-09-19 11:15:22 +0200 |
| commit | cf27013e63aeffbb33bad790c1436e87a655aba7 (patch) | |
| tree | eb145dfb7a0e5239fb6471ae99f027af6d7cf262 /addons/web/static/src | |
| parent | f139fc49ab799fdc57fe06611a84cc9aafee6c1d (diff) | |
| parent | cfa035e25a51fccbe4cd738d7e99526e01d9dbfa (diff) | |
[MERGE] from trunk
bzr revid: fva@openerp.com-20120919091522-20yc9992q5zfzwgb
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 13 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 45 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 13 |
3 files changed, 56 insertions, 15 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 3114aaf315f..9fdfb50307f 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -79,6 +79,9 @@ instance.web.Dialog = instance.web.Widget.extend({ } } if (options) { + if (options.buttons) { + this.params_buttons = true; + } _.extend(this.dialog_options, options); } }, @@ -123,7 +126,13 @@ instance.web.Dialog = instance.web.Widget.extend({ if (! this.dialog_inited) this.init_dialog(); var o = this.get_options(options); + if (! this.params_buttons) { + this.$buttons.appendTo($("body")); + } instance.web.dialog(this.$el, o).dialog('open'); + if (! this.params_buttons) { + this.$buttons.appendTo(this.$el.dialog("widget")); + } if (o.height === 'auto' && o.max_height) { this.$el.css({ 'max-height': o.max_height, 'overflow-y': 'auto' }); } @@ -133,6 +142,10 @@ instance.web.Dialog = instance.web.Widget.extend({ this.renderElement(); var o = this.get_options(options); instance.web.dialog(this.$el, o); + if (! this.params_buttons) { + this.$buttons = $('<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" />'); + this.$el.dialog("widget").append(this.$buttons); + } var res = this.start(); this.dialog_inited = true; return res; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d5eaf21c5e2..c188abc853e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2616,6 +2616,7 @@ instance.web.form.CompletionFieldMixin = { var dataset = new instance.web.DataSet(this, this.field.relation, self.build_context()); var blacklist = this.get_search_blacklist(); + this.last_query = search_val; return this.orderer.add(dataset.name_search( search_val, new instance.web.CompoundDomain(self.build_domain(), [["id", "not in", blacklist]]), @@ -2723,6 +2724,32 @@ instance.web.form.CompletionFieldMixin = { }, }; +instance.web.form.M2ODialog = instance.web.Dialog.extend({ + template: "M2ODialog", + init: function(parent) { + this._super(parent, { + title: _.str.sprintf(_t("Add %s"), parent.string), + width: 312, + }); + }, + start: function() { + var self = this; + this.$buttons.html(QWeb.render("M2ODialog.buttons")); + this.$("input").val(this.getParent().last_query); + this.$buttons.find(".oe_form_m2o_qc_button").click(function(){ + self.getParent()._quick_create(self.$("input").val()); + self.destroy(); + }); + this.$buttons.find(".oe_form_m2o_sc_button").click(function(){ + self.getParent()._search_create_popup("form", undefined, self.getParent()._create_context(self.$("input").val())); + self.destroy(); + }); + this.$buttons.find(".oe_form_m2o_cancel_button").click(function(){ + self.destroy(); + }); + }, +}); + instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instance.web.form.CompletionFieldMixin, instance.web.form.ReinitializeFieldMixin, { template: "FieldMany2One", init: function(field_manager, node) { @@ -2754,25 +2781,13 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.render_value(); }, init_error_displayer: function() { - this.$input.tipsy({ - title: function() { - return QWeb.render('Tipsy.alert', { - message: "No element was selected, you should create or select one from the dropdown list." - }); - }, - trigger:'manual', - fade: true, - gravity: 's', - html: true, - opacity: 1, - offset: 4, - }); + // nothing }, hide_error_displayer: function() { - this.$input.tipsy("hide"); + // doesn't work }, show_error_displayer: function() { - this.$input.tipsy("show"); + new instance.web.form.M2ODialog(this).open(); }, render_editable: function() { var self = this; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index aafac1019fd..232d4b618d7 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -919,6 +919,7 @@ t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" t-att-placeholder="widget.node.attrs.placeholder" + t-att-maxlength="widget.field.size" /><img class="oe_field_translate oe_input_icon" t-if="widget.field.translate" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"/> </t> </span> @@ -933,6 +934,7 @@ t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" t-att-placeholder="widget.node.attrs.placeholder" + t-att-maxlength="widget.field.size" /> </div> </t> @@ -951,6 +953,7 @@ t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" t-att-placeholder="! widget.get('effective_readonly') ? widget.node.attrs.placeholder : ''" + t-att-maxlength="widget.field.size" ></textarea><img class="oe_field_translate oe_input_icon" t-if="widget.field.translate and !widget.get('effective_readonly')" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0" @@ -1700,4 +1703,14 @@ <div class="oe_throbber_message" style="color:white"></div> </div> </t> +<t t-name="M2ODialog"> + <div> + Name: <input class="oe_form_m2o_input_name" type="text"/> + </div> +</t> +<t t-name="M2ODialog.buttons"> + <button class="oe_form_m2o_qc_button oe_button oe_highlight">Quick Add</button> + <button class="oe_form_m2o_sc_button oe_button">Add All Info...</button> + <button class="oe_form_m2o_cancel_button oe_button">Cancel</button> +</t> </templates> |
