diff --git a/package-lock.json b/package-lock.json index 21c4cb2bc..476f54153 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", @@ -8583,9 +8583,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 ceae35ab4..874927531 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 04627212c..fff9b80b6 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -124,6 +124,7 @@ export default { back: 'Back', change: 'Change', name: 'Name', + title: 'Title', description: 'Description', user: 'User', users: 'Users', @@ -717,6 +718,10 @@ export default { agentStatus: 'Agent status changed', } }, + flows: { + addFlowSchema: 'Add flow schema', + editFlowSchema: 'Edit flow schema', + }, }, members: { diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index 37b8c9444..61f5a01a6 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -124,6 +124,7 @@ export default { back: 'Назад', change: 'Заменить', name: 'Имя', + title: 'Название', description: 'Описание', user: 'Пользователь', users: 'Пользователи', @@ -715,6 +716,10 @@ export default { agentStatus: 'Изменение статуса оператора', } }, + flows: { + addFlowSchema: 'Добавить схему', + editFlowSchema: 'Редактировать схему', + }, }, members: { diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index 7feed490f..05fe22bb8 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -124,6 +124,7 @@ export default { back: 'Назад', change: 'Замінити', name: 'Ім\'я', + title: 'Назва', description: 'Опис', user: 'Користувач', users: 'Користувачі', @@ -692,7 +693,7 @@ export default { }, teams: { - teams: 'Команда| Команди', + teams: 'Команда | Команди', allTeams: 'Всі команди', strategy: 'Стратегія', parameters: 'Параметри', @@ -717,6 +718,10 @@ export default { agentStatus: 'Зміна статуту оператора', } }, + flows: { + addFlowSchema: 'Додати схему', + editFlowSchema: 'Редагувати схему', + }, }, 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 961f7b596..67188388d 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 Flows from '../modules/flow/components/opened-team-flows.vue'; export default { name: 'OpenedTeam', @@ -52,6 +53,7 @@ export default { Agents, Parameters, Hooks, + Flows, }, mixins: [openedObjectMixin], @@ -92,6 +94,9 @@ export default { }, { text: this.$tc('objects.ccenter.queues.hooks.hooks', 2), value: 'hooks', + }, { + text: this.$tc('objects.routing.flow.flow', 2), + value: 'flows', } ]; diff --git a/src/modules/contact-center/modules/teams/modules/flow/api/teamFlows.js b/src/modules/contact-center/modules/teams/modules/flow/api/teamFlows.js new file mode 100644 index 000000000..aff53b8d7 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/flow/api/teamFlows.js @@ -0,0 +1,167 @@ +import { TeamTriggerServiceApi } from 'webitel-sdk'; +import { + getDefaultGetListResponse, + getDefaultGetParams, +} from '@webitel/ui-sdk/src/api/defaults'; +import applyTransform, { + camelToSnake, + merge, mergeEach, + notify, sanitize, + snakeToCamel, + starToSearch, +} from '@webitel/ui-sdk/src/api/transformers'; +import instance from '../../../../../../../app/api/instance'; +import configuration from '../../../../../../../app/api/openAPIConfig'; + +const flowSchemaService = new TeamTriggerServiceApi(configuration, '', instance); + +const fieldsToSend = ['name', 'schema', 'enabled', 'description']; + +const preRequestHandler = (parentId) => (item) => ({ + ...item, + teamId: parentId, +}); + +const getTeamFlowSchemasList = async (params) => { + const defaultObject = { + enabled: false, + }; + + const { + page, + size, + search, + sort, + fields, + id, + enabled, + parentId, + } = applyTransform(params, [ + merge(getDefaultGetParams()), + starToSearch('search'), + ]); + + try { + const response = await flowSchemaService.searchTeamTrigger( + parentId, + page, + size, + search, + sort, + fields, + enabled, + id, + ); + const { items, next } = applyTransform(response.data, [ + snakeToCamel(), + merge(getDefaultGetListResponse()), + ]); + return { + items: applyTransform(items, [ + mergeEach(defaultObject), + ]), + next, + }; + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const getTeamFlowSchema = async ({ parentId, itemId: id }) => { + const defaultObject = { + name: '', + description: '', + enabled: false, + schema: {}, + }; + + try { + const response = await flowSchemaService.readTeamTrigger(parentId, id); + return applyTransform(response.data, [ + snakeToCamel(), + merge(defaultObject), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const addTeamFlowSchema = async ({ parentId, itemInstance }) => { + const item = applyTransform(itemInstance, [ + preRequestHandler(parentId), + sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await flowSchemaService.createTeamTrigger(parentId, item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const patchTeamFlowSchema = async ({ changes, id, parentId }) => { + const body = applyTransform(changes, [ + sanitize(fieldsToSend), + camelToSnake(), + ]); + + try { + const response = await flowSchemaService.patchTeamTrigger(parentId, id, body); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const updateTeamFlowSchema = async ({ itemInstance, itemId: id, parentId }) => { + const item = applyTransform(itemInstance, [ + preRequestHandler(parentId), + sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await flowSchemaService.updateTeamTrigger(parentId, id, item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const deleteTeamFlowSchema = async ({ parentId, id }) => { + try { + const response = await flowSchemaService.deleteTeamTrigger(parentId, id); + return applyTransform(response.data, []); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const TeamFlowsAPI = { + getList: getTeamFlowSchemasList, + get: getTeamFlowSchema, + add: addTeamFlowSchema, + update: updateTeamFlowSchema, + patch: patchTeamFlowSchema, + delete: deleteTeamFlowSchema, +}; + +export default TeamFlowsAPI; diff --git a/src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flow-popup.vue b/src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flow-popup.vue new file mode 100644 index 000000000..23ff512b7 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flow-popup.vue @@ -0,0 +1,88 @@ + + + + {{ popupTitle }} + + + + + + + + + + {{ $t('objects.save') }} + + + {{ $t('objects.close') }} + + + + + + + + diff --git a/src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flows.vue b/src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flows.vue new file mode 100644 index 000000000..ba52587f8 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flows.vue @@ -0,0 +1,167 @@ + + + + + + + + {{ $tc('objects.routing.flow.flow', 2) }} + + + + + deleteData(selectedRows), + })" + /> + + + + + + + + + + + + {{ item.name }} + + + + + + + + deleteData(item), + })" + /> + + + + + + + + + + diff --git a/src/modules/contact-center/modules/teams/modules/flow/store/_internals/headers.js b/src/modules/contact-center/modules/teams/modules/flow/store/_internals/headers.js new file mode 100644 index 000000000..0ce9f9e74 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/flow/store/_internals/headers.js @@ -0,0 +1,16 @@ +import { SortSymbols } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters'; + +export default [ + { + value: 'schema', + locale: 'objects.title', + 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/flow/store/team-flows.js b/src/modules/contact-center/modules/teams/modules/flow/store/team-flows.js new file mode 100644 index 000000000..2d763d528 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/flow/store/team-flows.js @@ -0,0 +1,20 @@ +import NestedObjectStoreModule + from '../../../../../../../app/store/BaseStoreModules/StoreModules/NestedObjectStoreModule'; +import TeamFlowsAPI from '../api/teamFlows'; +import headers from './_internals/headers'; + +const resettableItemState = { + itemInstance: { + name: '', + description: '', + enabled: true, + schema: {}, + }, +}; + +const teamFlows = new NestedObjectStoreModule({ resettableItemState, headers }) +.attachAPIModule(TeamFlowsAPI) +.generateAPIActions() +.getModule(); + +export default teamFlows; 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/store/teams.js b/src/modules/contact-center/modules/teams/store/teams.js index 01a9c4916..fdb6d8f73 100644 --- a/src/modules/contact-center/modules/teams/store/teams.js +++ b/src/modules/contact-center/modules/teams/store/teams.js @@ -6,6 +6,7 @@ import TeamsAPI from '../api/teams'; import agents from '../modules/agents/store/team-agents'; import supervisors from '../modules/supervisors/store/team-supervisors'; import hooks from '../modules/hooks/store/team-hooks'; +import flow from '../modules/flow/store/team-flows'; import headers from './_internals/headers'; const resettableState = { @@ -29,6 +30,7 @@ const actions = { context.dispatch('ccenter/teams/supervisors/RESET_STATE', {}, { root: true }); context.dispatch('ccenter/teams/agents/RESET_STATE', {}, { root: true }); context.dispatch('ccenter/teams/hooks/RESET_STATE', {}, { root: true }); + context.dispatch('ccenter/teams/flows/RESET_STATE', {}, { root: true }); }, }; @@ -40,7 +42,7 @@ const permissions = new PermissionsStoreModule() const teams = new ObjectStoreModule({ resettableState, headers }) .attachAPIModule(TeamsAPI) .generateAPIActions() -.setChildModules({ supervisors, agents, permissions, hooks }) +.setChildModules({ supervisors, agents, hooks, flow, permissions }) .getModule({ actions }); export default teams; diff --git a/src/modules/routing/modules/flow/modules/diagram/components/__tests__/opened-flow-diagram.spec.js b/src/modules/routing/modules/flow/modules/diagram/components/__tests__/opened-flow-diagram.spec.js deleted file mode 100644 index 62eed77c3..000000000 --- a/src/modules/routing/modules/flow/modules/diagram/components/__tests__/opened-flow-diagram.spec.js +++ /dev/null @@ -1,23 +0,0 @@ -import { shallowMount } from '@vue/test-utils'; -import deepmerge from 'deepmerge'; -import OpenedTabComponentMixinMock - from '../../../../../../../../../tests/unit/mocks/mixinMocks/openedTabComponentMixin.mock'; -import OpenedFlowDiagram from '../opened-flow-diagram.vue'; - -describe('OpenedFlowDiagram', () => { - const computed = { - itemInstance: () => ({}), - }; - - it('renders a component', () => { - vi.spyOn(OpenedFlowDiagram.methods, 'initDiagram') - .mockImplementationOnce(vi.fn()); - const wrapper = shallowMount(OpenedFlowDiagram, deepmerge.all([ - OpenedTabComponentMixinMock(), - { - computed, - }, - ])); - expect(wrapper.exists()).toBe(true); - }); -});