changeset 300dd3a6c593 in sao:default details: https://hg.tryton.org/sao?cmd=changeset&node=300dd3a6c593 description: Stop auto detecting on the first error
Use .every instead of .forEach as it stops if the callback returns false. issue11099 review393271002 diffstat: src/window.js | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diffs (37 lines): diff -r 2bd0d57d9c2a -r 300dd3a6c593 src/window.js --- a/src/window.js Mon Jan 03 22:55:50 2022 +0100 +++ b/src/window.js Tue Jan 04 22:25:53 2022 +0100 @@ -1422,14 +1422,14 @@ Sao.i18n.gettext("Detection failed")); }, complete: function(results) { - results.data[0].forEach(function(word) { + results.data[0].every(function(word) { if (!(word in this.fields_invert) && !(word in this.fields)) { var fields = this.fields_model; var prefix = ''; var parents = word.split('/').slice(0, -1); this._traverse(fields, prefix, parents, 0); } - this._auto_select(word); + return this._auto_select(word); }.bind(this)); }.bind(this) }); @@ -1449,7 +1449,7 @@ Sao.i18n.gettext( 'Error processing the file at field %1.', word), Sao.i18n.gettext('Error')); - return; + return false; } var node = jQuery('<li/>', { 'field': field @@ -1457,6 +1457,7 @@ node.addClass('bg-primary') .siblings().removeClass('bg-primary'); }).appendTo(this.fields_selected); + return true; }, _traverse: function(fields, prefix, parents, i) { var field, item;