From 994356628d25e0c09454506f6207c0cd866c3164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Fri, 9 Jun 2023 14:42:35 +0200 Subject: [PATCH] [v-autocomplete] Fix for special characters --- .../plugins/tm@_mixins/autocomplete.mixin.ts | 17 ++++++ .../projects/_components/a-project-filter.vue | 8 +-- .../tasks/_components/a-tasks-filter.vue | 52 +++++++------------ .../tm@modal/_components/read-only/z-team.vue | 20 ++++++- .../tm@modal/blocker/z-blocker-modal.vue | 47 +++++++++-------- .../master-task/_mixins/selects.mixin.ts | 20 ++++++- .../master-task/z-master-task-modal.vue | 49 +++++++++++------ .../plugins/tm@modal/task/z-task-modal.vue | 9 ++-- .../plugins/tm@modal/team/z-team-modal.vue | 4 +- .../_components/z-tasks-search.vue | 4 +- 10 files changed, 147 insertions(+), 83 deletions(-) create mode 100644 app/src/plugins/tm@_mixins/autocomplete.mixin.ts diff --git a/app/src/plugins/tm@_mixins/autocomplete.mixin.ts b/app/src/plugins/tm@_mixins/autocomplete.mixin.ts new file mode 100644 index 0000000..9347da4 --- /dev/null +++ b/app/src/plugins/tm@_mixins/autocomplete.mixin.ts @@ -0,0 +1,17 @@ +export default { + methods: { + customFilter(item, input) { + // Replace accented characters with non-accented equivalents + const normalizedItem = item.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); + const normalizedInput = input.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); + + // Remove any character that is not a letter, number, or space from both the item and the input + const pattern = /[^a-zA-Z0-9 ]/g; + const cleanedItem = normalizedItem.replace(pattern, ''); + const cleanedInput = normalizedInput.replace(pattern, ''); + + // Check if the cleaned item starts with the cleaned input + return cleanedItem.toLowerCase().startsWith(cleanedInput.toLowerCase()); + } + } +} \ No newline at end of file diff --git a/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue b/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue index b55184d..5829e07 100644 --- a/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue +++ b/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue @@ -1,12 +1,12 @@