summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets/model_field_selector.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-02-10 18:41:06 +0100
committerChristophe Simonis <chs@odoo.com>2017-02-10 18:41:06 +0100
commita282d4ae7f27869a0b828e8562f8efd901e02799 (patch)
tree1fa369ee7526a0a7ccee075f0d8232d2f4fac870 /addons/web/static/src/js/widgets/model_field_selector.js
parentb229e9cb8c1fdc83a1aa5abd51141e32aea59bcd (diff)
parentbe9dfb331f90bd0352728c78e115bc3647f472e9 (diff)
[MERGE] forward port branch saas-14 up to be9dfb331f9
Diffstat (limited to 'addons/web/static/src/js/widgets/model_field_selector.js')
-rw-r--r--addons/web/static/src/js/widgets/model_field_selector.js39
1 files changed, 13 insertions, 26 deletions
diff --git a/addons/web/static/src/js/widgets/model_field_selector.js b/addons/web/static/src/js/widgets/model_field_selector.js
index 6d65108b7dc..99528e3e74e 100644
--- a/addons/web/static/src/js/widgets/model_field_selector.js
+++ b/addons/web/static/src/js/widgets/model_field_selector.js
@@ -12,32 +12,14 @@ var ModelFieldSelector = Widget.extend({
template: "FieldSelector",
events: {
// Handle popover opening and closing
- "focusin input, .o_field_selector_popover": function (e) {
- if (this._hidePopoverTimeout !== undefined) {
- clearTimeout(this._hidePopoverTimeout);
- this._hidePopoverTimeout = undefined;
- return;
- }
- if (this.$input.is(e.currentTarget)) {
- this.showPopover();
- }
- },
- "focusout input, .o_field_selector_popover": function () {
- if (this._hidePopoverTimeout !== undefined) {
- return;
- }
- this._hidePopoverTimeout = setTimeout((function () {
- this.hidePopover();
- this._hidePopoverTimeout = undefined;
- }).bind(this), 100);
+ "focusin": function () {
+ clearTimeout(this._hidePopoverTimeout);
+ this.showPopover();
},
- "click .o_field_selector_close": function () {
- if (this._hidePopoverTimeout !== undefined) {
- clearTimeout(this._hidePopoverTimeout);
- this._hidePopoverTimeout = undefined;
- }
- this.hidePopover();
+ "focusout": function () {
+ this._hidePopoverTimeout = _.defer(this.hidePopover.bind(this));
},
+ "click .o_field_selector_close": "hidePopover",
// Handle popover field navigation
"click .o_field_selector_prev_page": "goToPrevPage",
@@ -190,6 +172,7 @@ var ModelFieldSelector = Widget.extend({
},
/// The removeChainNode method removes the last field name at the end of the current field chain.
removeChainNode: function () {
+ this.dirty = true;
this.setChain(this.chain.substring(0, this.chain.lastIndexOf(".")));
},
/// The validate method toggles the valid status of the widget and display the error message if it
@@ -200,16 +183,20 @@ var ModelFieldSelector = Widget.extend({
this.valid = valid;
},
/// The showPopover method shows the popover to select the field chain. It prepares the popover pages
- /// before actually showing it.
+ /// before actually showing it. (if already open, does nothing)
showPopover: function () {
+ if (this._isOpen) return;
+ this._isOpen = true;
this._prefill().then((function () {
this.displayPage();
this.$popover.removeClass("hidden");
}).bind(this));
},
/// The hidePopover method closes the popover and mark the field as selected. If the field chain changed,
- /// it notifies its parents.
+ /// it notifies its parents. (if not open, does nothing)
hidePopover: function () {
+ if (!this._isOpen) return;
+ this._isOpen = false;
this.$popover.addClass("hidden");
this.isSelected = true;
if (this.dirty) {