Do not render deactivated actions in completion

The disabled attribute is not enough to prevent the click event.
So it is simpler to not render the action that are not supported like tryton
does.

Closes #12470
This commit is contained in:
Cédric Krier committed 2023-08-14 09:56:36 +02:00
1 parent 51b032442d
commit 23a718ab1d
2 files changed
+23 -30

No files matched your search

+10 -9
View File
@@ -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(
+13 -21
View File
@@ -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('<div/>', {
@@ -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('<div/>', {
@@ -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('<button/>', {