diff --git a/sao/src/common.js b/sao/src/common.js index 49f741eb62..0d7160c294 100644 --- a/sao/src/common.js +++ b/sao/src/common.js @@ -3745,10 +3745,17 @@ Sao.common.set_overflow(this.input, 'show'); }); }, - set_actions: function(actions, action_activated) { + set_actions: function(action_activated, search, create) { if (action_activated !== undefined) { this.action_activated = action_activated; } + var actions = []; + if (search || search == undefined) { + actions.push(['search', Sao.i18n.gettext('Search...')]); + } + if (create || create == undefined) { + actions.push(['create', Sao.i18n.gettext('Create...')]); + } this.menu.find('li.action').remove(); if (jQuery.isEmptyObject(actions)) { this.separator.hide(); @@ -3845,15 +3852,9 @@ var completion = new Sao.common.InputCompletion( el, source, match_selected, format); if (action_activated) { - var actions = []; - if (search || search == undefined) { - actions.push(['search', Sao.i18n.gettext('Search...')]); - } - if (create || create == undefined) { - actions.push(['create', Sao.i18n.gettext('Create...')]); - } - completion.set_actions(actions, action_activated); + completion.set_actions(action_activated, search, create); } + return completion; }; Sao.common.update_completion = function( diff --git a/sao/src/view/form.js b/sao/src/view/form.js index 25f0371c38..6cdad76199 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -2471,11 +2471,10 @@ function eval_pyson(value){ this.entry.on('keydown', this.key_press.bind(this)); if (!attributes.completion || attributes.completion == "1") { - Sao.common.get_completion(group, + this.wid_completion = Sao.common.get_completion( + group, this._update_completion.bind(this), - this._completion_match_selected.bind(this), - this._completion_action_activated.bind(this)); - this.wid_completion = true; + this._completion_match_selected.bind(this)); } this.el.change(this.focus_out.bind(this)); this._readonly = false; @@ -2837,17 +2836,10 @@ function eval_pyson(value){ } }, _set_completion: function() { - var search = this.el.find('.action-search'); - if (this.read_access) { - search.removeClass('disabled'); - } else { - search.addClass('disabled'); - } - var create = this.el.find('.action-create'); - if (this.create_access) { - create.removeClass('disabled'); - } else { - create.addClass('disabled'); + if (this.wid_completion) { + this.wid_completion.set_actions( + this._completion_action_activated.bind(this), + this.read_access, this.create_access); } }, _update_completion: function(text) { @@ -3143,12 +3135,12 @@ function eval_pyson(value){ }).appendTo(group); if (!attributes.completion || attributes.completion == '1') { - Sao.common.get_completion(this.wid_text, + this.wid_completion = Sao.common.get_completion( + this.wid_text, this._update_completion.bind(this), this._completion_match_selected.bind(this), this._completion_action_activated.bind(this), this.read_access, this.create_access); - this.wid_completion = true; } buttons = jQuery('
', { @@ -3759,12 +3751,12 @@ function eval_pyson(value){ this.entry.on('keydown', this.key_press.bind(this)); if (!attributes.completion || attributes.completion == '1') { - Sao.common.get_completion(group, + this.wid_completion = Sao.common.get_completion( + group, this._update_completion.bind(this), this._completion_match_selected.bind(this), this._completion_action_activated.bind(this), this.read_access, this.create_access); - this.wid_completion = true; } var buttons = jQuery('
', { @@ -4707,10 +4699,10 @@ function eval_pyson(value){ }).appendTo(group); if (!attributes.completion || attributes.completion == '1') { - Sao.common.get_completion(group, + this.wid_completion = Sao.common.get_completion( + group, this._update_completion.bind(this), this._completion_match_selected.bind(this)); - this.wid_completion = true; } this.but_add = jQuery('