From 1a24de78fceca238f504c7927fa3a27b35c838b8 Mon Sep 17 00:00:00 2001 From: volodymyr Date: Fri, 20 Oct 2023 11:59:57 +0300 Subject: [PATCH 1/2] feature: variables search added to contacts list [WTEL-3888] --- src/app/locale/en/en.js | 3 ++ src/app/locale/ru/ru.js | 3 ++ src/app/locale/ua/ua.js | 3 ++ src/modules/contacts/api/ContactsAPI.js | 21 +++++++++---- .../filters/components/filter-search.vue | 31 +++++++++++++++++-- .../modules/filters/enums/SearchMode.enum.js | 1 + .../contacts/modules/filters/store/filters.js | 1 + .../validators/variableSearchValidator.js | 4 +++ 8 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 src/utils/validators/variableSearchValidator.js diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index 86918bef..e5a3e3f7 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -35,4 +35,7 @@ export default { [AccessMode.MANAGE]: 'Allow with delegation', }, }, + filters: { + variableSearchHint: 'Query format: "key=value"', + }, }; diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index fa991a27..9592eaeb 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -35,4 +35,7 @@ export default { [AccessMode.MANAGE]: 'Управление', }, }, + filters: { + variableSearchHint: 'Формат запроса: "ключ=значение"', + }, }; diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index ceead073..da1feba5 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -35,4 +35,7 @@ export default { [AccessMode.MANAGE]: 'Управління', }, }, + filters: { + variableSearchHint: 'Формат запиту: "ключ=значення"', + }, }; diff --git a/src/modules/contacts/api/ContactsAPI.js b/src/modules/contacts/api/ContactsAPI.js index acd02685..bfe22fb2 100644 --- a/src/modules/contacts/api/ContactsAPI.js +++ b/src/modules/contacts/api/ContactsAPI.js @@ -42,6 +42,9 @@ const getList = async (params) => { } else if (params[SearchMode.ABOUT]) { searchValue = params[SearchMode.ABOUT]; searchKey = SearchMode.ABOUT; + } else if (params[SearchMode.VARIABLE]) { + searchValue = params[SearchMode.VARIABLE]; + searchKey = 'variables'; } const changedParams = { @@ -50,6 +53,16 @@ const getList = async (params) => { qin: searchKey, }; + const transformations = [ + sanitize(fieldsToSend), + merge(getDefaultGetParams()), + camelToSnake(), + ]; + + if (searchKey !== 'variables') { + transformations.push(starToSearch('q')); + } + const { page, size, @@ -58,12 +71,8 @@ const getList = async (params) => { fields, id, qin, - } = applyTransform(changedParams, [ - sanitize(fieldsToSend), - merge(getDefaultGetParams()), - starToSearch('q'), - camelToSnake(), - ]); + } = applyTransform(changedParams, transformations); + try { const response = await service.searchContacts( page, diff --git a/src/modules/contacts/modules/filters/components/filter-search.vue b/src/modules/contacts/modules/filters/components/filter-search.vue index fe5ffa28..2d6e16f8 100644 --- a/src/modules/contacts/modules/filters/components/filter-search.vue +++ b/src/modules/contacts/modules/filters/components/filter-search.vue @@ -1,13 +1,16 @@