Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into feat/implement-redirect-to-serv…
Browse files Browse the repository at this point in the history
…ice-catalog-page

# Conflicts:
#	package-lock.json
#	package.json
  • Loading branch information
stanislav-kozak committed Dec 20, 2024
2 parents 1abe10c + 5a27c62 commit f2a5953
Show file tree
Hide file tree
Showing 18 changed files with 449 additions and 115 deletions.
16 changes: 8 additions & 8 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 @@ -15,7 +15,7 @@
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
"@vueuse/core": "^11.0.3",
"@webitel/ui-sdk": "^24.12.21",
"@webitel/ui-sdk": "^24.12.28",
"axios": "^1.7.7",
"deep-equal": "^2.2.1",
"dompurify": "^3.1.2",
Expand Down
2 changes: 2 additions & 0 deletions src/app/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export default {
slas: {
slas: 'SLA | SLAs',
conditions: 'Condition | Conditions',
editCondition: 'Edit condition',
addCondition: 'Add condition',
reactionTime: 'Reaction time',
resolutionTime: 'Resolution time',
validFrom: 'Valid from',
Expand Down
2 changes: 2 additions & 0 deletions src/app/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export default {
slas: {
slas: 'SLA | SLAs',
conditions: 'Условие | Условия',
editCondition: 'Редактировать условие',
addCondition: 'Добавить условие',
reactionTime: 'Плановое время реакции',
resolutionTime: 'Плановое время решения',
validFrom: 'Действителен с',
Expand Down
2 changes: 2 additions & 0 deletions src/app/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export default {
slas: {
slas: 'SLA | SLAs',
conditions: 'Умова | Умови',
editCondition: 'Редагувати умову',
addCondition: 'Додати умову',
reactionTime: 'Плановий час реакції',
resolutionTime: 'Плановий час вирішення',
validFrom: 'Дійсний з',
Expand Down
14 changes: 8 additions & 6 deletions src/modules/configuration/components/the-configuration.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<template>
<wt-navigation-menu
:nav="nav"
:icons="icons"/>
:icons="icons"
/>
</template>

<script setup>
import { useI18n } from 'vue-i18n';
import { computed, reactive } from 'vue';
import lookupsIcon from '../../../app/assets/icons/sprite/crm-lookups.svg';
import CrmSections from '@webitel/ui-sdk/src/enums/WebitelApplications/CrmSections.enum.js';
const { t } = useI18n();
const icons = [lookupsIcon];
const nav = [
const nav = reactive([
{
value: 'lookups',
name: t('lookups.lookups'),
name: computed(() => t('lookups.lookups')),
subNav: [
{
value: CrmSections.SOURCES,
name: t('lookups.sources.sources', 2),
name: computed(() => t('lookups.sources.sources', 2)),
route: 'lookups/sources',
},
{
value: CrmSections.SLAS,
name: t('lookups.slas.slas', 2),
name: computed(() => t('lookups.slas.slas', 2)),
route: 'lookups/slas',
},
{
Expand All @@ -35,7 +37,7 @@ const nav = [
},
],
},
];
]);
</script>

<style lang="scss" scoped>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import {
getDefaultGetListResponse,
getDefaultGetParams,
getDefaultInstance,
getDefaultOpenAPIConfig,
} from '@webitel/ui-sdk/src/api/defaults/index.js';
import applyTransform, {
camelToSnake,
merge,
mergeEach,
notify,
sanitize,
snakeToCamel,
starToSearch,
} from '@webitel/ui-sdk/src/api/transformers/index.js';
import { GroupsApiFactory } from 'webitel-sdk';
import {
generatePermissionsApi,
} from '@webitel/ui-sdk/src/api/clients/_shared/generatePermissionsApi.js';

const instance = getDefaultInstance();
const configuration = getDefaultOpenAPIConfig();

const contactGroupsService = new GroupsApiFactory(configuration, '', instance);

const baseUrl = '/contacts/groups';

const fieldsToSend = [
'name',
'description',
'enabled',
'type',
'default_group',
];

const getContactGroupsList = async (params) => {
const fieldsToSend = ['page', 'size', 'q', 'sort', 'fields', 'type'];
const defaultObject = {
enabled: false,
};

const listResponseHandler = (items) => {
return items.map((item) => {
if (item.type) {
item.type = item.type.toLowerCase();
}
return item;
});
};

const {
page,
size,
fields,
sort,
id,
q,
} = applyTransform(params, [
merge(getDefaultGetParams()),
starToSearch('search'),
(params) => ({ ...params, q: params.search }),
sanitize(fieldsToSend),
camelToSnake(),
]);

try {
const response = await contactGroupsService.listGroups(
page,
size,
fields,
sort,
id,
q,
);
const { items, next } = applyTransform(response.data, [
merge(getDefaultGetListResponse()),
]);
return {
items: applyTransform(items, [
mergeEach(defaultObject),
listResponseHandler,
]),
next,
};
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const getContactGroup = async ({ itemId: id }) => {
const itemResponseHandler = (item) => {
if (item.group.type) {
item.group.type = item.group.type.toLowerCase();
}
return item.group;
};

try {
const response = await contactGroupsService.locateGroup(id, fieldsToSend);
return applyTransform(response.data, [
snakeToCamel(),
itemResponseHandler,
]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const preRequestHandler = (item) => {
return {
...item,
type: item.type.toUpperCase(),
};
};

const addStaticContactGroup = async ({ itemInstance }) => {

const item = applyTransform(itemInstance, [
preRequestHandler,
camelToSnake(),
sanitize(fieldsToSend),
]);
try {
const response = await contactGroupsService.createGroup(item);
return applyTransform(response.data, [
snakeToCamel(),
]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const updateStaticContactGroup = async ({ itemInstance, itemId: id }) => {
const item = applyTransform(itemInstance, [
camelToSnake(),
sanitize(fieldsToSend),
]);

try {
const response = await contactGroupsService.updateGroup(id, item);
return applyTransform(response.data, [snakeToCamel()]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const patchStaticContactGroup = async ({ id, changes }) => {
const item = applyTransform(changes, [
camelToSnake(),
sanitize(fieldsToSend),
]);

try {
const response = await contactGroupsService.updateGroup2(id, item);
return applyTransform(response.data, [snakeToCamel()]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const deleteStaticContactGroup = async ({ id }) => {
try {
const response = await contactGroupsService.deleteGroup(id);
return applyTransform(response.data, []);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const getLookup = (params) => getContactGroupsList({
...params,
fields: params.fields || ['id', 'name'],
});

const ContactGroupsAPI = {
getList: getContactGroupsList,
get: getContactGroup,
add: addStaticContactGroup,
update: updateStaticContactGroup,
patch: patchStaticContactGroup,
delete: deleteStaticContactGroup,
getLookup,

...generatePermissionsApi(baseUrl),

};

export default ContactGroupsAPI;
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {
getDefaultInstance, getDefaultOpenAPIConfig,
} from '@webitel/ui-sdk/src/api/defaults/index.js';
import applyTransform, {
camelToSnake,
notify,
sanitize,
snakeToCamel,
} from '@webitel/ui-sdk/src/api/transformers/index.js';
import { DynamicGroupsApiFactory } from 'webitel-sdk';

const instance = getDefaultInstance();
const configuration = getDefaultOpenAPIConfig();

const dynamicContactGroupsService = new DynamicGroupsApiFactory(configuration, '', instance);

const fieldsToSend = ['name', 'description', 'enabled', 'type', 'default_group_id'];

const preRequestHandler = (item) => {
return {
...item,
type: item.type.toUpperCase(),
defaultGroupId: item.defaultGroup.id,
}
};

const addDynamicContactGroup = async (itemInstance) => {
const item = applyTransform(itemInstance, [
preRequestHandler,
camelToSnake(),
sanitize(fieldsToSend),
]);

try {
const response = await dynamicContactGroupsService.createDynamicGroup(item);
return applyTransform(response.data, [
snakeToCamel()
]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const updateDynamicContactGroup = async ({ itemInstance, itemId: id }) => {
const item = applyTransform(itemInstance, [preRequestHandler, camelToSnake(), sanitize(fieldsToSend)]);

try {
const response = await dynamicContactGroupsService.updateDynamicGroup(id, item);
return applyTransform(response.data, [snakeToCamel()]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const dynamicContactGroupsAPI = {
add: addDynamicContactGroup,
update: updateDynamicContactGroup,
}

export default dynamicContactGroupsAPI;
Loading

0 comments on commit f2a5953

Please sign in to comment.