Skip to content

Commit

Permalink
Merge pull request #784 from webitel/feature/add-working-conditions-page
Browse files Browse the repository at this point in the history
feature: add working conditions page[WTEL-5078]
  • Loading branch information
Lera24 authored Oct 1, 2024
2 parents 651a294 + f65cc39 commit 8c18f6a
Show file tree
Hide file tree
Showing 16 changed files with 624 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/app/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,19 @@ export default {
duration: 'Duration (hh:mm)',
},
pauseTemplates: {
pauseTemplates: 'Pause templates',
pauseTemplates: 'Pause templates | Pause templates',
pauseReason: 'Pause reason',
duration: 'Duration (mm)',
},
workingConditions: {
workingConditions: 'Working Conditions',
workdayDuration: 'Workday duration (hrs)',
workdaysPerMonth: 'Workdays per month',
vacationDaysPerYear: 'Vacation days per year',
sickLeavesPerYear: 'Sick leaves per year',
daysOffPerYear: 'Days-off per year',
pauseDuration: 'Pause duration',
},
},
routing: {
routing: 'Routing',
Expand Down
11 changes: 10 additions & 1 deletion src/app/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,19 @@ export default {
duration: 'Длительность (чч:мм)',
},
pauseTemplates: {
pauseTemplates: 'Шаблоны пауз',
pauseTemplates: 'Шаблон пауз | Шаблоны пауз',
pauseReason: 'Причина паузы',
duration: 'Длительность (мм)',
},
workingConditions: {
workingConditions: 'Условия работы',
workdayDuration: 'Длительность рабочего дня (час.)',
workdaysPerMonth: 'Количество рабочих дней в месяц',
vacationDaysPerYear: 'Количество дней отпуска в год',
sickLeavesPerYear: 'Количество дней больничного в год',
daysOffPerYear: 'Количество выходных дней в год',
pauseDuration: 'Длительность перерыва',
},
},
routing: {
routing: 'Маршрутизация',
Expand Down
11 changes: 10 additions & 1 deletion src/app/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,19 @@ export default {
duration: 'Тривалість (гг:хх)',
},
pauseTemplates: {
pauseTemplates: 'Шаблони пауз',
pauseTemplates: 'Шаблон пауз | Шаблони пауз',
pauseReason: 'Причина паузи',
duration: 'Тривалість (хх)',
},
workingConditions: {
workingConditions: 'Умови роботи',
workdayDuration: 'Тривалість робочого дня (год.)',
workdaysPerMonth: 'Кількість робочих днів на місяць',
vacationDaysPerYear: 'Кількість днів відпустки на рік',
sickLeavesPerYear: 'Кількість днів лікарняного на рік',
daysOffPerYear: 'Кількість вихідних днів на рік',
pauseDuration: 'Тривалість перерви',
},
},
routing: {
routing: 'Маршрутизація',
Expand Down
5 changes: 5 additions & 0 deletions src/app/router/_internals/NavigationPages.lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ const nav = Object.freeze([
locale: `WebitelApplications.${WebitelApplications.ADMIN}.sections.${AdminSections.PAUSE_TEMPLATES}`,
route: 'pause-templates',
},
{
value: AdminSections.WORKING_CONDITIONS,
locale: `WebitelApplications.${WebitelApplications.ADMIN}.sections.${AdminSections.WORKING_CONDITIONS}`,
route: 'working-conditions',
},
],
},
{
Expand Down
1 change: 1 addition & 0 deletions src/app/router/_internals/RouteNames.enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default Object.freeze({
MEDIA: 'media',
SHIFT_TEMPLATES: 'shift-templates',
PAUSE_TEMPLATES: 'pause-templates',
WORKING_CONDITIONS: 'working-conditions',

// CONTACT-CENTER
AGENTS: 'agents',
Expand Down
6 changes: 4 additions & 2 deletions src/app/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import AgentSkillsRoutes from "../../modules/lookups/modules/agent-skills/router
import BucketsRoutes from "../../modules/lookups/modules/buckets/router/buckets.js";
import BlacklistsRoutes from "../../modules/lookups/modules/blacklists/router/blacklists.js";
import MediaRoutes from "../../modules/lookups/modules/media/router/media.js";
import ShiftTemplatesRoutes
from '../../modules/lookups/modules/shift-templates/router/shiftTemplates.js';
import ShiftTemplatesRoutes from "../../modules/lookups/modules/shift-templates/router/shiftTemplates.js";
import CalendarsRoutes from "../../modules/lookups/modules/calendars/router/calendars.js";
import CommunicationsRoutes from "../../modules/lookups/modules/communications/router/communications.js";
import RegionsRoutes from "../../modules/lookups/modules/regions/router/regions.js";
import AgentPauseCauseRoutes from "../../modules/lookups/modules/agent-pause-cause/router/agentPauseCause.js";
import PauseTemplatesRoutes from "../../modules/lookups/modules/pause-templates/router/pauseTemplates.js";
import WorkingConditionsRoutes
from '../../modules/lookups/modules/working-conditions/router/workingConditions.js';

const ApplicationHub = () => import('../../modules/application-hub/components/application-hub.vue');
const ModuleWrap = () => import('../../modules/_shared/object-wrap/the-object-wrap.vue');
Expand Down Expand Up @@ -112,6 +113,7 @@ const router = createRouter({
...AgentPauseCauseRoutes,
...ShiftTemplatesRoutes,
...PauseTemplatesRoutes,
...WorkingConditionsRoutes,
// ----------LOOKUPS END------------

// --------------CONTACT CENTER-------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default {
name: this.$t('objects.lookups.lookups'),
},
{
name: this.$t('objects.lookups.pauseTemplates.pauseTemplates'),
name: this.$tc('objects.lookups.pauseTemplates.pauseTemplates', 2),
route: '/lookups/pause-templates',
},
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import applyTransform, {
camelToSnake,
merge,
notify,
sanitize,
snakeToCamel,
} from '@webitel/ui-sdk/src/api/transformers/index.js';
import { WorkingConditionServiceApi } from 'webitel-sdk';
import {
getDefaultGetParams,
getDefaultGetListResponse
} from '@webitel/ui-sdk/src/api/defaults/index.js';

import instance from '../../../../../app/api/instance';
import configuration from '../../../../../app/api/openAPIConfig';

const workingConditionService = new WorkingConditionServiceApi(configuration, '', instance);

const getWorkingConditionList = async (params) => {
const { search: q, page, size, sort, fields } = applyTransform(params, [
merge(getDefaultGetParams()),
]);

try {
const response = await workingConditionService.searchWorkingCondition(q, page, size, sort, fields);
const { items, next } = applyTransform(response.data, [
snakeToCamel(),
merge(getDefaultGetListResponse()),
]);
return {
items,
next,
};
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const itemResponseHandler = (item) => {
return { ...item.item }
};

const getWorkingCondition = async ({ itemId: id }) => {

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

const fieldsToSend = ['name', 'description', 'workdayHours', 'workdayPerMonth', 'pauseDuration', 'vacation', 'pauseTemplate', 'sickLeaves', 'shiftTemplate', 'daysOff', 'createdAt', 'createdBy', 'domainId', 'id', 'updatedAt', 'updatedBy'];

const addWorkingCondition = async ({ itemInstance }) => {
const item = applyTransform(itemInstance, [sanitize(fieldsToSend), camelToSnake()]);
try {
const response = await workingConditionService.createWorkingCondition({ item: { ...item } });
return applyTransform(response.data, [snakeToCamel(), itemResponseHandler]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

const updateWorkingCondition = async ({ itemInstance, itemId: id }) => {
const item = applyTransform(itemInstance, [sanitize(fieldsToSend), camelToSnake()]);
try {
const response = await workingConditionService.updateWorkingCondition(id, { item: { ...item }});
return applyTransform(response.data, [snakeToCamel()]);
} catch (err) {
throw applyTransform(err, [notify]);
}
};

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

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

const WorkingConditionsAPI = {
getList: getWorkingConditionList,
get: getWorkingCondition,
add: addWorkingCondition,
update: updateWorkingCondition,
delete: deleteWorkingCondition,
getLookup: getWorkingConditionLookup,
}

export default WorkingConditionsAPI;
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<template>
<section>
<header class="content-header">
<h3 class="content-title">
{{ $t('objects.generalInfo') }}
</h3>
</header>
<div class="object-input-grid">
<wt-input
:disabled="disableUserInput"
:label="$t('objects.name')"
:v="v.itemInstance.name"
:value="itemInstance.name"
required
@input="setItemProp({ prop: 'name', value: $event })"
/>
<wt-input
:disabled="disableUserInput"
:value="itemInstance.workdayHours"
:v="v.itemInstance.workdayHours"
:label="$t('objects.lookups.workingConditions.workdayDuration')"
type="number"
required
@input="setItemProp({ prop: 'workdayHours', value: $event })"
/>
<wt-textarea
:disabled="disableUserInput"
:label="$t('objects.description')"
:value="itemInstance.description"
@input="setItemProp({ prop: 'description', value: $event })"
/>
<div>
<wt-input
:disabled="disableUserInput"
:value="itemInstance.workdayPerMonth"
:v="v.itemInstance.workdayPerMonth"
:label="$t('objects.lookups.workingConditions.workdaysPerMonth')"
type="number"
@input="setItemProp({ prop: 'workdayPerMonth', value: $event })"
/>

<wt-input
:disabled="disableUserInput"
:value="itemInstance.pauseDuration"
:v="v.itemInstance.pauseDuration"
:label="$t('objects.lookups.workingConditions.pauseDuration')"
type="number"
@input="setItemProp({ prop: 'pauseDuration', value: $event })"
/>
</div>
<wt-input
:disabled="disableUserInput"
:value="itemInstance.vacation"
:v="v.itemInstance.vacation"
:label="$t('objects.lookups.workingConditions.vacationDaysPerYear')"
type="number"
@input="setItemProp({ prop: 'vacation', value: $event })"
/>
<wt-select
:value="itemInstance.pauseTemplate"
:v="v.itemInstance.pauseTemplate"
:label="$tc('objects.lookups.pauseTemplates.pauseTemplates', 1)"
required
:search-method="loadPauseTemplate"
@input="setItemProp({ prop: 'pauseTemplate', value: $event })"
/>
<wt-input
:disabled="disableUserInput"
:value="itemInstance.sickLeaves"
:v="v.itemInstance.sickLeaves"
:label="$t('objects.lookups.workingConditions.sickLeavesPerYear')"
type="number"
@input="setItemProp({ prop: 'sickLeaves', value: $event })"
/>
<wt-select
:search-method="loadShiftTemplate"
:label="$tc('objects.lookups.shiftTemplates.shiftTemplates', 1)"
:value="itemInstance.shiftTemplate"
@input="setItemProp({ prop: 'shiftTemplate', value: $event })"
/>
<wt-input
:disabled="disableUserInput"
:value="itemInstance.daysOff"
:v="v.itemInstance.daysOff"
:label="$t('objects.lookups.workingConditions.daysOffPerYear')"
type="number"
@input="setItemProp({ prop: 'daysOff', value: $event })"
/>
</div>
</section>
</template>

<script>
import openedTabComponentMixin
from '../../../../../app/mixins/objectPagesMixins/openedObjectTabMixin/openedTabComponentMixin';
import PauseTemplatesAPI from '../../pause-templates/api/pauseTemplates.js';
import ShiftTemplatesAPI from '../../shift-templates/api/shiftTemplates.js';
export default {
name: 'OpenedWorkingConditionGeneral',
mixins: [openedTabComponentMixin],
methods: {
loadPauseTemplate(params) {
return PauseTemplatesAPI.getLookup(params);
},
loadShiftTemplate(params) {
return ShiftTemplatesAPI.getLookup(params);
},
},
};
</script>

<style scoped>
</style>
Loading

0 comments on commit 8c18f6a

Please sign in to comment.