Skip to content

Commit

Permalink
Merge pull request #649 from webitel/feature/team-schemas
Browse files Browse the repository at this point in the history
Feature/team schemas [WTEL-4354]
  • Loading branch information
liza-pohranichna authored Apr 19, 2024
2 parents 29ae457 + 63af419 commit 0bb5959
Show file tree
Hide file tree
Showing 14 changed files with 488 additions and 31 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/app/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default {
back: 'Back',
change: 'Change',
name: 'Name',
title: 'Title',
description: 'Description',
user: 'User',
users: 'Users',
Expand Down Expand Up @@ -717,6 +718,10 @@ export default {
agentStatus: 'Agent status changed',
}
},
flows: {
addFlowSchema: 'Add flow schema',
editFlowSchema: 'Edit flow schema',
},
},

members: {
Expand Down
5 changes: 5 additions & 0 deletions src/app/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default {
back: 'Назад',
change: 'Заменить',
name: 'Имя',
title: 'Название',
description: 'Описание',
user: 'Пользователь',
users: 'Пользователи',
Expand Down Expand Up @@ -715,6 +716,10 @@ export default {
agentStatus: 'Изменение статуса оператора',
}
},
flows: {
addFlowSchema: 'Добавить схему',
editFlowSchema: 'Редактировать схему',
},
},

members: {
Expand Down
7 changes: 6 additions & 1 deletion src/app/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default {
back: 'Назад',
change: 'Замінити',
name: 'Ім\'я',
title: 'Назва',
description: 'Опис',
user: 'Користувач',
users: 'Користувачі',
Expand Down Expand Up @@ -692,7 +693,7 @@ export default {
},

teams: {
teams: 'Команда| Команди',
teams: 'Команда | Команди',
allTeams: 'Всі команди',
strategy: 'Стратегія',
parameters: 'Параметри',
Expand All @@ -717,6 +718,10 @@ export default {
agentStatus: 'Зміна статуту оператора',
}
},
flows: {
addFlowSchema: 'Додати схему',
editFlowSchema: 'Редагувати схему',
},
},

members: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -52,6 +53,7 @@ export default {
Agents,
Parameters,
Hooks,
Flows,
},
mixins: [openedObjectMixin],
Expand Down Expand Up @@ -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',
}
];
Expand Down
167 changes: 167 additions & 0 deletions src/modules/contact-center/modules/teams/modules/flow/api/teamFlows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { TeamTriggerServiceApi } from 'webitel-sdk';

Check failure on line 1 in src/modules/contact-center/modules/teams/modules/flow/api/teamFlows.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: Install the 'eslint' package
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<template>

Check failure on line 1 in src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flow-popup.vue

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: Install the 'eslint' package
<wt-popup
min-width="480"
overflow
@close="close"
>
<template #title>
{{ popupTitle }}
</template>
<template #main>
<form>
<wt-input
:label="$t('objects.name')"
:v="v$.itemInstance.name"
:value="itemInstance.name"
required
@input="setItemProp({ prop: 'name', value: $event })"
/>
<wt-select
:clearable="false"
:label="$tc('objects.routing.flow.flow', 1)"
:search-method="loadFlowOptions"
:v="v$.itemInstance.schema"
:value="itemInstance.schema"
required
@input="setItemProp({ prop: 'schema', value: $event })"
/>
</form>
</template>
<template #actions>
<wt-button
:disabled="disabledSave"
@click="save"
>
{{ $t('objects.save') }}
</wt-button>
<wt-button
color="secondary"
@click="close"
>
{{ $t('objects.close') }}
</wt-button>
</template>
</wt-popup>
</template>

<script>
import { EngineRoutingSchemaType } from 'webitel-sdk';
import { useVuelidate } from '@vuelidate/core';
import { required } from '@vuelidate/validators';
import nestedObjectMixin from '../../../../../../../app/mixins/objectPagesMixins/openedObjectMixin/nestedObjectMixin';
import FlowsAPI from '../../../../../../routing/modules/flow/api/flow';
export default {
name: 'OpenedTeamFlowPopup',
mixins: [nestedObjectMixin],
setup: () => ({
v$: useVuelidate(),
}),
data: () => ({
namespace: 'ccenter/teams/flow',
}),
validations: {
itemInstance: {
name: { required },
schema: { required },
},
},
computed: {
popupTitle() {
return this.itemInstance.id
? this.$tc('objects.ccenter.teams.flows.editFlowSchema')
: this.$tc('objects.ccenter.teams.flows.addFlowSchema')
}
},
methods: {
loadFlowOptions(params) {
return FlowsAPI.getLookup({ ...params, type: [EngineRoutingSchemaType.Service] });
},
},
};
</script>

<style lang="scss" scoped>
</style>
Loading

0 comments on commit 0bb5959

Please sign in to comment.