From d2b0dbd06d63da2c2071d9c795a43706f803a0b1 Mon Sep 17 00:00:00 2001 From: lizacoma Date: Thu, 11 Apr 2024 22:07:18 +0300 Subject: [PATCH 1/8] feature:added new module to teams [WTEL-4354] --- .../modules/teams/components/opened-team.vue | 5 + .../teams/modules/schemes/api/teamSchemes.js | 129 ++++++++++++ .../components/opened-team-schemes-popup.vue | 72 +++++++ .../components/opened-team-schemes.vue | 185 ++++++++++++++++++ .../schemes/store/_internals/headers.js | 16 ++ .../modules/schemes/store/team-schemes.js | 17 ++ 6 files changed, 424 insertions(+) create mode 100644 src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js create mode 100644 src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes-popup.vue create mode 100644 src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue create mode 100644 src/modules/contact-center/modules/teams/modules/schemes/store/_internals/headers.js create mode 100644 src/modules/contact-center/modules/teams/modules/schemes/store/team-schemes.js diff --git a/src/modules/contact-center/modules/teams/components/opened-team.vue b/src/modules/contact-center/modules/teams/components/opened-team.vue index 961f7b596..78545ebcd 100644 --- a/src/modules/contact-center/modules/teams/components/opened-team.vue +++ b/src/modules/contact-center/modules/teams/components/opened-team.vue @@ -43,6 +43,7 @@ import Supervisors from '../modules/supervisors/components/opened-team-superviso import General from './opened-team-general.vue'; import Parameters from './opened-team-parameters.vue'; import Hooks from '../modules/hooks/components/opened-team-hooks.vue'; +import Schemes from '../modules/schemes/components/opened-team-schemes.vue'; export default { name: 'OpenedTeam', @@ -52,6 +53,7 @@ export default { Agents, Parameters, Hooks, + Schemes, }, mixins: [openedObjectMixin], @@ -92,6 +94,9 @@ export default { }, { text: this.$tc('objects.ccenter.queues.hooks.hooks', 2), value: 'hooks', + }, { + text: 'schemes', + value: 'schemes', } ]; diff --git a/src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js b/src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js new file mode 100644 index 000000000..6c684c644 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js @@ -0,0 +1,129 @@ +import { AgentServiceApiFactory } from 'webitel-sdk'; +import { + getDefaultGetListResponse, + getDefaultGetParams, +} from '@webitel/ui-sdk/src/api/defaults'; +import applyTransform, { + camelToSnake, + merge, mergeEach, + notify, + snakeToCamel, + starToSearch, +} from '@webitel/ui-sdk/src/api/transformers'; +import instance from '../../../../../../../app/api/instance'; +import configuration from '../../../../../../../app/api/openAPIConfig'; + +const agentService = new AgentServiceApiFactory(configuration, '', instance); + +const getTeamSchemesList = async (params) => { + const fields = ['id', 'name', 'status', 'supervisor', 'skills']; + + const defaultObject = { + name: '', + status: '', + supervisor: {}, + skills: [], + }; + + const { + parentId, + page = 1, + size = 10, + search, + sort, + } = applyTransform(params, [ + merge(getDefaultGetParams()), + starToSearch('search'), + ]); + + try { + const response = await agentService.searchAgent( + page, + size, + search, + sort, + fields, + undefined, + undefined, + undefined, + parentId, + ); + const { items, next } = applyTransform(response.data, [ + snakeToCamel(), + merge(getDefaultGetListResponse()), + ]); + return { + items: applyTransform(items, [ + mergeEach(defaultObject), + ]), + next, + }; + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const getTeamSchemes = async ({ itemId: id }) => { + const responseHandler = (agent) => ({ agent }); + + try { + const response = await agentService.readAgent(id); + return applyTransform(response.data, [ + snakeToCamel(), + responseHandler, + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const addTeamSchemes = ({ parentId, itemInstance }) => { + const { id } = itemInstance.agent; + const changes = { team: { id: parentId } }; + return patchAgent({ id, changes }); +}; + +const updateTeamSchemes = async ({ parentId, itemId, itemInstance }) => { + try { + await addTeamAgent({ parentId, itemInstance }); + await deleteTeamAgent({ id: itemId }); + } catch (err) { + throw err; + } +}; + +const patchSchemes = async ({ id, changes }) => { + const item = applyTransform(changes, [ + camelToSnake(), + ]); + try { + const response = await agentService.patchAgent(id, item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const deleteTeamSchemes = ({ id }) => { + const changes = { team: { id: null } }; + return patchAgent({ id, changes }); +}; + +const TeamAgentsAPI = { + getList: getTeamSchemesList, + get: getTeamSchemes, + add: addTeamSchemes, + update: updateTeamSchemes, + putch: patchSchemes, + delete: deleteTeamSchemes, +}; + +export default TeamAgentsAPI; diff --git a/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes-popup.vue b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes-popup.vue new file mode 100644 index 000000000..432c2479c --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes-popup.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue new file mode 100644 index 000000000..e355c0aa3 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue @@ -0,0 +1,185 @@ + + + + + diff --git a/src/modules/contact-center/modules/teams/modules/schemes/store/_internals/headers.js b/src/modules/contact-center/modules/teams/modules/schemes/store/_internals/headers.js new file mode 100644 index 000000000..be55f44b4 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/schemes/store/_internals/headers.js @@ -0,0 +1,16 @@ +import { SortSymbols } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters'; + +export default [ + { + value: 'name', + locale: 'objects.name', + field: 'name', + sort: SortSymbols.NONE, + }, + { + value: 'state', + locale: 'reusable.state', + // field: 'enabled', + sort: SortSymbols.NONE, + }, +]; diff --git a/src/modules/contact-center/modules/teams/modules/schemes/store/team-schemes.js b/src/modules/contact-center/modules/teams/modules/schemes/store/team-schemes.js new file mode 100644 index 000000000..b8b14793a --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/schemes/store/team-schemes.js @@ -0,0 +1,17 @@ +import NestedObjectStoreModule + from '../../../../../../../app/store/BaseStoreModules/StoreModules/NestedObjectStoreModule'; +import TeamSchemesAPI from '../api/teamSchemes'; +import headers from './_internals/headers'; + +const resettableItemState = { + itemInstance: { + agent: {}, + }, +}; + +const teamSchemes = new NestedObjectStoreModule({ resettableItemState, headers }) +.attachAPIModule(TeamSchemesAPI) +.generateAPIActions() +.getModule(); + +export default teamSchemes; From e597c1b4902a3317278569847eb9bd5aa5195409 Mon Sep 17 00:00:00 2001 From: lizacoma Date: Mon, 15 Apr 2024 23:16:01 +0300 Subject: [PATCH 2/8] feature: fixes in team scheme module [WTEL-4354] --- package-lock.json | 8 +- package.json | 2 +- src/app/locale/en/en.js | 5 + src/app/locale/ru/ru.js | 5 + src/app/locale/ua/ua.js | 5 + .../modules/teams/components/opened-team.vue | 2 +- .../components/opened-team-hooks-popup.vue | 2 +- .../teams/modules/schemes/api/teamSchemes.js | 111 ++++++++++++------ ...popup.vue => opened-team-scheme-popup.vue} | 39 +++--- .../components/opened-team-schemes.vue | 57 +++------ .../modules/schemes/store/team-schemes.js | 5 +- .../modules/teams/store/teams.js | 3 +- 12 files changed, 147 insertions(+), 97 deletions(-) rename src/modules/contact-center/modules/teams/modules/schemes/components/{opened-team-schemes-popup.vue => opened-team-scheme-popup.vue} (50%) diff --git a/package-lock.json b/package-lock.json index 861cd34fc..4e4a11943 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^24.2.3" + "webitel-sdk": "^24.02.06" }, "devDependencies": { "@vitejs/plugin-vue": "^4.4.0", @@ -8366,9 +8366,9 @@ } }, "node_modules/webitel-sdk": { - "version": "24.2.4", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.2.4.tgz", - "integrity": "sha512-7lg2CKR4iAdAQOOexi8A/5QqizK0mZ0JgV4E1x0L3hCZb6hP2UTapvwjUXx8Sie4WbJlq0wamIPuRVqoB/2r0Q==", + "version": "24.2.6", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.2.6.tgz", + "integrity": "sha512-pesFApYZJwKXSTAzxuFhkt/aVGqodEbOn0zUlDkALdj/6Za0/dZmAAZ4iBXar8YDUOeLxCnLRLrJxsQVAC7i1w==", "dependencies": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", diff --git a/package.json b/package.json index 3c5535c68..d16301d03 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^24.2.3" + "webitel-sdk": "^24.02.06" }, "devDependencies": { "@vitejs/plugin-vue": "^4.4.0", diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index cc8dac3fd..c79ec4b0f 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -709,6 +709,11 @@ export default { agentStatus: 'Agent status changed', } }, + scheme: { + scheme: 'Scheme | Schemes', + addScheme: 'Add scheme', + editScheme: 'Edit scheme', + }, }, members: { diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index 76c714d63..7137a0188 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -707,6 +707,11 @@ export default { agentStatus: 'Изменение статуса оператора', } }, + scheme: { + scheme: 'Схема | Схемы', + addScheme: 'Добавить схему', + editScheme: 'Редактировать схему', + }, }, members: { diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index 90232cbcd..81800dd7f 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -709,6 +709,11 @@ export default { agentStatus: 'Зміна статуту оператора', } }, + scheme: { + scheme: 'Схема | Схеми', + addScheme: 'Додати схему', + editScheme: 'Редагувати схему', + }, }, members: { diff --git a/src/modules/contact-center/modules/teams/components/opened-team.vue b/src/modules/contact-center/modules/teams/components/opened-team.vue index 78545ebcd..d8d2ed95d 100644 --- a/src/modules/contact-center/modules/teams/components/opened-team.vue +++ b/src/modules/contact-center/modules/teams/components/opened-team.vue @@ -95,7 +95,7 @@ export default { text: this.$tc('objects.ccenter.queues.hooks.hooks', 2), value: 'hooks', }, { - text: 'schemes', + text: this.$tc('objects.ccenter.teams.scheme.scheme', 2), value: 'schemes', } ]; diff --git a/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue b/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue index 5957fbb06..d6fa6f421 100644 --- a/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue +++ b/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue @@ -57,7 +57,7 @@ import FlowsAPI from '../../../../../../routing/modules/flow/api/flow'; import HookEvent from '../enum/HookTeamEvent.enum'; export default { - name: 'OpenedQueueHooksPopup', + name: 'OpenedTeamHooksPopup', mixins: [nestedObjectMixin], setup: () => ({ diff --git a/src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js b/src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js index 6c684c644..8d49600e6 100644 --- a/src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js +++ b/src/modules/contact-center/modules/teams/modules/schemes/api/teamSchemes.js @@ -1,4 +1,4 @@ -import { AgentServiceApiFactory } from 'webitel-sdk'; +import { TeamTriggerServiceApi } from 'webitel-sdk'; import { getDefaultGetListResponse, getDefaultGetParams, @@ -6,47 +6,51 @@ import { import applyTransform, { camelToSnake, merge, mergeEach, - notify, + notify, sanitize, snakeToCamel, starToSearch, } from '@webitel/ui-sdk/src/api/transformers'; import instance from '../../../../../../../app/api/instance'; import configuration from '../../../../../../../app/api/openAPIConfig'; -const agentService = new AgentServiceApiFactory(configuration, '', instance); +const schemeService = new TeamTriggerServiceApi(configuration, '', instance); -const getTeamSchemesList = async (params) => { - const fields = ['id', 'name', 'status', 'supervisor', 'skills']; +const fieldsToSend = ['name', 'schema', 'enabled', 'description']; + +const preRequestHandler = (parentId) => (item) => ({ + ...item, + teamId: parentId, +}); +const getTeamSchemesList = async (params) => { const defaultObject = { - name: '', - status: '', - supervisor: {}, - skills: [], + enabled: false, }; const { - parentId, - page = 1, - size = 10, + page, + size, search, sort, + fields, + id, + enabled, + parentId, } = applyTransform(params, [ merge(getDefaultGetParams()), starToSearch('search'), ]); try { - const response = await agentService.searchAgent( + const response = await schemeService.searchTeamTrigger( + parentId, page, size, search, sort, fields, - undefined, - undefined, - undefined, - parentId, + enabled, + id, ); const { items, next } = applyTransform(response.data, [ snakeToCamel(), @@ -65,14 +69,20 @@ const getTeamSchemesList = async (params) => { } }; -const getTeamSchemes = async ({ itemId: id }) => { - const responseHandler = (agent) => ({ agent }); +const getTeamSchemes = async ({ parentId, itemId: id }) => { + + const defaultObject = { + name: '', + description: '', + enabled: false, + schema: {}, + }; try { - const response = await agentService.readAgent(id); + const response = await schemeService.readTeamTrigger(parentId, id); return applyTransform(response.data, [ snakeToCamel(), - responseHandler, + merge(defaultObject), ]); } catch (err) { throw applyTransform(err, [ @@ -81,27 +91,50 @@ const getTeamSchemes = async ({ itemId: id }) => { } }; -const addTeamSchemes = ({ parentId, itemInstance }) => { - const { id } = itemInstance.agent; - const changes = { team: { id: parentId } }; - return patchAgent({ id, changes }); +const addTeamSchemes = async ({ parentId, itemInstance }) => { + const item = applyTransform(itemInstance, [ + preRequestHandler(parentId), + sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await schemeService.createTeamTrigger(parentId, item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } }; -const updateTeamSchemes = async ({ parentId, itemId, itemInstance }) => { +const patchTeamSchemes = async ({ changes, id, parentId }) => { + const body = applyTransform(changes, [ + sanitize(fieldsToSend), + camelToSnake(), + ]); + try { - await addTeamAgent({ parentId, itemInstance }); - await deleteTeamAgent({ id: itemId }); + const response = await schemeService.patchTeamTrigger(parentId, id, body); + return applyTransform(response.data, [ + snakeToCamel(), + ]); } catch (err) { - throw err; + throw applyTransform(err, [ + notify, + ]); } }; -const patchSchemes = async ({ id, changes }) => { - const item = applyTransform(changes, [ +const updateTeamSchemes = async ({ itemInstance, itemId: id, parentId }) => { + const item = applyTransform(itemInstance, [ + preRequestHandler(parentId), + sanitize(fieldsToSend), camelToSnake(), ]); try { - const response = await agentService.patchAgent(id, item); + const response = await schemeService.updateTeamTrigger(parentId, id, item); return applyTransform(response.data, [ snakeToCamel(), ]); @@ -112,9 +145,15 @@ const patchSchemes = async ({ id, changes }) => { } }; -const deleteTeamSchemes = ({ id }) => { - const changes = { team: { id: null } }; - return patchAgent({ id, changes }); +const deleteTeamSchemes = async ({ parentId, id }) => { + try { + const response = await schemeService.deleteTeamTrigger(parentId, id); + return applyTransform(response.data, []); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } }; const TeamAgentsAPI = { @@ -122,7 +161,7 @@ const TeamAgentsAPI = { get: getTeamSchemes, add: addTeamSchemes, update: updateTeamSchemes, - putch: patchSchemes, + patch: patchTeamSchemes, delete: deleteTeamSchemes, }; diff --git a/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes-popup.vue b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-scheme-popup.vue similarity index 50% rename from src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes-popup.vue rename to src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-scheme-popup.vue index 432c2479c..bc6747fd5 100644 --- a/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes-popup.vue +++ b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-scheme-popup.vue @@ -5,18 +5,27 @@ @close="close" > @@ -25,7 +34,7 @@ :disabled="disabledSave" @click="save" > - {{ $t('objects.add') }} + {{ $t('objects.save') }} diff --git a/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue index e355c0aa3..9f695fdfc 100644 --- a/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue +++ b/src/modules/contact-center/modules/teams/modules/schemes/components/opened-team-schemes.vue @@ -1,7 +1,7 @@