From 5e8549ebfd2247b734f4074d56acd7ce97b8656f Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Mon, 14 Oct 2024 09:08:29 +0530 Subject: [PATCH 1/9] WEBUI-1504: Tags fix mixed case entry --- ui/widgets/nuxeo-selectivity.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 02c10b81f..7d16e7351 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -2422,6 +2422,10 @@ typedArrayTags[weakMapTag] = false; * term - The search term for which the results are displayed. */ showResults(results, options) { + if(options && options.term){ + options.term = options.term.toLowerCase(); + } + console.log(results); const searchText = options && options.term && options.term.trim(); if (options.add) { removeElement(this.$('.selectivity-loading')); @@ -7194,6 +7198,7 @@ typedArrayTags[weakMapTag] = false; } options.query = (query) => { + query.term= query.term.toLowerCase(); if (query.term.length < this.minChars) { query.error(this.i18n('selectivity.minChars', this.minChars)); return; From 518ac28a8c64346419668622e6a27e3edc0f658e Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Mon, 14 Oct 2024 11:17:31 +0530 Subject: [PATCH 2/9] Removing console --- ui/widgets/nuxeo-selectivity.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 7d16e7351..2adb6ada5 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -2425,7 +2425,6 @@ typedArrayTags[weakMapTag] = false; if(options && options.term){ options.term = options.term.toLowerCase(); } - console.log(results); const searchText = options && options.term && options.term.trim(); if (options.add) { removeElement(this.$('.selectivity-loading')); From c4ed9dbd5e5e8b6eed7cd49412fd0875bf2365af Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Mon, 14 Oct 2024 12:19:48 +0530 Subject: [PATCH 3/9] WEBUI-1504: Tags fix mixed case entry fix 2 --- ui/widgets/nuxeo-selectivity.js | 1 - ui/widgets/nuxeo-tag-suggestion.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 2adb6ada5..03ad92cbd 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -7197,7 +7197,6 @@ typedArrayTags[weakMapTag] = false; } options.query = (query) => { - query.term= query.term.toLowerCase(); if (query.term.length < this.minChars) { query.error(this.i18n('selectivity.minChars', this.minChars)); return; diff --git a/ui/widgets/nuxeo-tag-suggestion.js b/ui/widgets/nuxeo-tag-suggestion.js index 63070d193..987d69dd7 100644 --- a/ui/widgets/nuxeo-tag-suggestion.js +++ b/ui/widgets/nuxeo-tag-suggestion.js @@ -237,7 +237,7 @@ import { escapeHTML } from './nuxeo-selectivity.js'; } _newEntryFormatter(term) { - return { id: term, displayLabel: term, newTag: true }; + return { id: term, displayLabel: term.toLowerCase(), newTag: true }; } _addedTagHandler(entry) { From 559eed67eabe1f82802f3fe200bbb176658a235f Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Mon, 14 Oct 2024 12:30:42 +0530 Subject: [PATCH 4/9] WEBUI-1504: Tags fix mixed case entry fix 3 --- ui/widgets/nuxeo-selectivity.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 03ad92cbd..4966df7b7 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -2422,9 +2422,6 @@ typedArrayTags[weakMapTag] = false; * term - The search term for which the results are displayed. */ showResults(results, options) { - if(options && options.term){ - options.term = options.term.toLowerCase(); - } const searchText = options && options.term && options.term.trim(); if (options.add) { removeElement(this.$('.selectivity-loading')); @@ -2438,7 +2435,7 @@ typedArrayTags[weakMapTag] = false; let resultsHtml = isFilteredResultNotEmpty ? this.renderItems(filteredResults) : ''; if (options.hasMore) { resultsHtml += this.selectivity.template('loadMore'); - } else if (value && Array.isArray(value) && value.includes(options.term)) { + } else if (value && Array.isArray(value) && value.includes(options.term.toLowerCase())) { resultsHtml = this.selectivity.template('tagExists'); } else if (!resultsHtml && !options.add) { resultsHtml = this.selectivity.template('noResults', { term: options.term }); From 22451d079276732f5a2b0ad5d7389e3606abb766 Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Mon, 14 Oct 2024 12:41:54 +0530 Subject: [PATCH 5/9] making id and value in sync --- ui/widgets/nuxeo-tag-suggestion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/widgets/nuxeo-tag-suggestion.js b/ui/widgets/nuxeo-tag-suggestion.js index 987d69dd7..b5f7bba54 100644 --- a/ui/widgets/nuxeo-tag-suggestion.js +++ b/ui/widgets/nuxeo-tag-suggestion.js @@ -237,7 +237,7 @@ import { escapeHTML } from './nuxeo-selectivity.js'; } _newEntryFormatter(term) { - return { id: term, displayLabel: term.toLowerCase(), newTag: true }; + return { id: term.toLowerCase(), displayLabel: term.toLowerCase(), newTag: true }; } _addedTagHandler(entry) { From c914d0880619c1f337b4167422f46b878fc26387 Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Mon, 14 Oct 2024 17:58:44 +0530 Subject: [PATCH 6/9] optimized code --- ui/widgets/nuxeo-tag-suggestion.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/widgets/nuxeo-tag-suggestion.js b/ui/widgets/nuxeo-tag-suggestion.js index b5f7bba54..adba42d92 100644 --- a/ui/widgets/nuxeo-tag-suggestion.js +++ b/ui/widgets/nuxeo-tag-suggestion.js @@ -237,7 +237,8 @@ import { escapeHTML } from './nuxeo-selectivity.js'; } _newEntryFormatter(term) { - return { id: term.toLowerCase(), displayLabel: term.toLowerCase(), newTag: true }; + term = term.toLowerCase(); + return { id: term, displayLabel: term, newTag: true }; } _addedTagHandler(entry) { From 871cfe742aee7c7ee434cd8c3345c1fc3a6bfe33 Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Tue, 15 Oct 2024 23:47:57 +0530 Subject: [PATCH 7/9] Review comments incorporated --- ui/widgets/nuxeo-selectivity.js | 2 +- ui/widgets/nuxeo-tag-suggestion.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 4966df7b7..32f72722a 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -2435,7 +2435,7 @@ typedArrayTags[weakMapTag] = false; let resultsHtml = isFilteredResultNotEmpty ? this.renderItems(filteredResults) : ''; if (options.hasMore) { resultsHtml += this.selectivity.template('loadMore'); - } else if (value && Array.isArray(value) && value.includes(options.term.toLowerCase())) { + } else if (value && Array.isArray(value) && value.includes(options?.term?.toLowerCase())) { resultsHtml = this.selectivity.template('tagExists'); } else if (!resultsHtml && !options.add) { resultsHtml = this.selectivity.template('noResults', { term: options.term }); diff --git a/ui/widgets/nuxeo-tag-suggestion.js b/ui/widgets/nuxeo-tag-suggestion.js index adba42d92..5b1294fbb 100644 --- a/ui/widgets/nuxeo-tag-suggestion.js +++ b/ui/widgets/nuxeo-tag-suggestion.js @@ -237,7 +237,7 @@ import { escapeHTML } from './nuxeo-selectivity.js'; } _newEntryFormatter(term) { - term = term.toLowerCase(); + term = term?.toLowerCase(); return { id: term, displayLabel: term, newTag: true }; } From 53d97c0b5c2811aba29fb13fc5204e366c1d1eef Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Wed, 16 Oct 2024 11:13:23 +0530 Subject: [PATCH 8/9] fix optional chaining issue --- ui/widgets/nuxeo-selectivity.js | 6 +++++- ui/widgets/nuxeo-tag-suggestion.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 32f72722a..00f8d4a6f 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -2435,7 +2435,11 @@ typedArrayTags[weakMapTag] = false; let resultsHtml = isFilteredResultNotEmpty ? this.renderItems(filteredResults) : ''; if (options.hasMore) { resultsHtml += this.selectivity.template('loadMore'); - } else if (value && Array.isArray(value) && value.includes(options?.term?.toLowerCase())) { + } else if ( + value && + Array.isArray(value) && + value.includes(options && options.term ? options.term.toLowerCase() : options.term) + ) { resultsHtml = this.selectivity.template('tagExists'); } else if (!resultsHtml && !options.add) { resultsHtml = this.selectivity.template('noResults', { term: options.term }); diff --git a/ui/widgets/nuxeo-tag-suggestion.js b/ui/widgets/nuxeo-tag-suggestion.js index 5b1294fbb..3b9444321 100644 --- a/ui/widgets/nuxeo-tag-suggestion.js +++ b/ui/widgets/nuxeo-tag-suggestion.js @@ -237,7 +237,7 @@ import { escapeHTML } from './nuxeo-selectivity.js'; } _newEntryFormatter(term) { - term = term?.toLowerCase(); + term = term ? term.toLowerCase() : term; return { id: term, displayLabel: term, newTag: true }; } From bc8f12648832cf2da5c7cc6aa3b32e1f43097e82 Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Wed, 16 Oct 2024 11:18:46 +0530 Subject: [PATCH 9/9] adding null fix --- ui/widgets/nuxeo-selectivity.js | 2 +- ui/widgets/nuxeo-tag-suggestion.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 00f8d4a6f..2437874c0 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -2438,7 +2438,7 @@ typedArrayTags[weakMapTag] = false; } else if ( value && Array.isArray(value) && - value.includes(options && options.term ? options.term.toLowerCase() : options.term) + value.includes(options && options.term ? options.term.toLowerCase() : null) ) { resultsHtml = this.selectivity.template('tagExists'); } else if (!resultsHtml && !options.add) { diff --git a/ui/widgets/nuxeo-tag-suggestion.js b/ui/widgets/nuxeo-tag-suggestion.js index 3b9444321..f3c4e8b1a 100644 --- a/ui/widgets/nuxeo-tag-suggestion.js +++ b/ui/widgets/nuxeo-tag-suggestion.js @@ -237,7 +237,7 @@ import { escapeHTML } from './nuxeo-selectivity.js'; } _newEntryFormatter(term) { - term = term ? term.toLowerCase() : term; + term = term ? term.toLowerCase() : null; return { id: term, displayLabel: term, newTag: true }; }