Ignore diacritics in autocomplete

Works for:
- Choice
- Choice List
- Reference
- Reference List

Co-Authored-By: Louis Delbosc <louis.delbosc.prestataire@anct.gouv.fr>
This commit is contained in:
Ronan Amicel
2022-08-09 15:43:44 +02:00
parent 103c795aa2
commit 2a05d04e35
6 changed files with 22 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
import {createGroup} from 'app/client/components/commands';
import {ACIndexImpl, ACItem, ACResults, buildHighlightedDom, HighlightFunc} from 'app/client/lib/ACIndex';
import {ACIndexImpl, ACItem, ACResults, buildHighlightedDom, cleanText as clean, HighlightFunc} from 'app/client/lib/ACIndex';
import {IAutocompleteOptions} from 'app/client/lib/autocomplete';
import {IToken, TokenField, tokenFieldStyles} from 'app/client/lib/TokenField';
import {colors, testId} from 'app/client/ui2018/cssVars';
@@ -16,7 +16,7 @@ import {choiceToken, cssChoiceACItem, cssChoiceToken} from 'app/client/widgets/C
import {icon} from 'app/client/ui2018/icons';
export class ChoiceItem implements ACItem, IToken {
public cleanText: string = this.label.toLowerCase().trim();
public cleanText: string = clean(this.label);
constructor(
public label: string,
public isInvalid: boolean, // If set, this token is not one of the valid choices.

View File

@@ -1,4 +1,4 @@
import { ACResults, buildHighlightedDom, HighlightFunc } from 'app/client/lib/ACIndex';
import { ACResults, buildHighlightedDom, cleanText as clean, HighlightFunc } from 'app/client/lib/ACIndex';
import { Autocomplete } from 'app/client/lib/autocomplete';
import { ICellItem } from 'app/client/models/ColumnACIndexes';
import { reportError } from 'app/client/models/errors';
@@ -115,7 +115,7 @@ export class ReferenceEditor extends NTextEditor {
this._showAddNew = false;
if (!this._enableAddNew || !text) { return result; }
const cleanText = text.trim().toLowerCase();
const cleanText = clean(text);
if (result.items.find((item) => item.cleanText === cleanText)) {
return result;
}

View File

@@ -1,5 +1,5 @@
import { createGroup } from 'app/client/components/commands';
import { ACItem, ACResults, HighlightFunc } from 'app/client/lib/ACIndex';
import { ACItem, ACResults, cleanText as clean, HighlightFunc } from 'app/client/lib/ACIndex';
import { IAutocompleteOptions } from 'app/client/lib/autocomplete';
import { IToken, TokenField, tokenFieldStyles } from 'app/client/lib/TokenField';
import { reportError } from 'app/client/models/errors';
@@ -26,7 +26,7 @@ class ReferenceItem implements IToken, ACItem {
* similar to getItemText() from IAutocompleteOptions.
*/
public label: string = typeof this.rowId === 'number' ? String(this.rowId) : this.text;
public cleanText: string = this.text.trim().toLowerCase();
public cleanText: string = clean(this.text);
constructor(
public text: string,
@@ -264,7 +264,7 @@ export class ReferenceListEditor extends NewBaseEditor {
this._showAddNew = false;
if (!this._enableAddNew || !text) { return result; }
const cleanText = text.trim().toLowerCase();
const cleanText = clean(text);
if (result.items.find((item) => item.cleanText === cleanText)) {
return result;
}