summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/widgets')
-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) {