Skip to content

Commit

Permalink
Merge pull request #782 from webitel/fix/small-refactor-shift-templat…
Browse files Browse the repository at this point in the history
…e-page

fix: small refactor shift page[WTEL-5079]
  • Loading branch information
Lera24 authored Sep 27, 2024
2 parents f63b9ca + 7c21173 commit 3839c07
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/app/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ export default {
},
shiftTemplates: {
shiftTemplates: 'Shift template | Shift templates',
duration: 'Duration (hh:mm)',
},
},
routing: {
Expand Down
1 change: 1 addition & 0 deletions src/app/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ export default {
},
shiftTemplates: {
shiftTemplates: 'Шаблон смен | Шаблоны смен',
duration: 'Длительность (чч:мм)',
},
},
routing: {
Expand Down
1 change: 1 addition & 0 deletions src/app/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ export default {
},
shiftTemplates: {
shiftTemplates: 'Шаблон змін | Шаблони змін',
duration: 'Тривалість (гг:хх)',
},
},
routing: {
Expand Down
5 changes: 2 additions & 3 deletions src/app/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ 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 ShiftTemplates
from '../../modules/lookups/modules/shift-templates/router/shift-templates.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";
Expand Down Expand Up @@ -109,7 +108,7 @@ const router = createRouter({
...CommunicationsRoutes,
...RegionsRoutes,
...AgentPauseCauseRoutes,
...ShiftTemplates,
...ShiftTemplatesRoutes,
// ----------LOOKUPS END------------

// --------------CONTACT CENTER-------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<template #actions="{ item, index }">
<wt-icon-action
action="delete"
@click="deleteTime(index)"
@click="removeTime(index)"
/>
</template>
</wt-table>
Expand All @@ -65,10 +65,9 @@
</template>

<script>
import { mapActions } from 'vuex';
import openedTabComponentMixin from '../../../../../app/mixins/objectPagesMixins/openedObjectTabMixin/openedTabComponentMixin';
const DEFAULT_TIME = { start: 9 * 60, end: 20 * 60, duration: 11 * 60 };
export default {
name: 'OpenedShiftTemplateTimes',
mixins: [openedTabComponentMixin],
Expand All @@ -85,34 +84,31 @@ export default {
},
{
value: 'duration',
text: this.$t('objects.ccenter.queues.logs.duration'),
text: this.$t('objects.lookups.shiftTemplates.duration'),
},
];
},
},
methods: {
...mapActions({
addTime(dispatch, payload) {
dispatch(`${this.namespace}/ADD_TIME`, payload);
},
setTime(dispatch, payload) {
dispatch(`${this.namespace}/SET_TIME`, payload);
},
removeTime(dispatch, payload) {
dispatch(`${this.namespace}/REMOVE_TIME`, payload);
},
}),
minToSec(min) {
return min * 60;
},
secToMin(sec) {
return sec / 60;
},
addTime() {
const array = [...this.itemInstance.times];
array.push(DEFAULT_TIME);
this.setItemProp({ prop: 'times', value: array });
},
deleteTime(index) {
const array = [...this.itemInstance.times];
array.splice(index, 1);
this.setItemProp({ prop: 'times', value: array });
},
setTime({ prop, index, value }) {
const array = [...this.itemInstance.times];
array[index][prop] = value;
this.setItemProp({ prop: 'times', value: array });
},
setStartTime({ index, value }) {
this.setTime({ prop: 'start', index, value });
this.setTime({ prop: 'duration', index, value: this.itemInstance.times[index].end - this.itemInstance.times[index].start });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
<section class="main-section__wrapper">
<header class="content-header">
<h3 class="content-title">
{{ $tc('objects.lookups.shiftTemplates.shiftTemplates',2) }}
{{
$t(
'objects.all',
{ entity: $tc('objects.routing.chatGateways.templates.templates', 2) },
)
}}
</h3>
<div class="content-header__actions-wrap">
<wt-search-bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,28 @@ const resettableState = {
},
};

const actions = {
ADD_TIME: (context) => {
const array = [...context.state.itemInstance.times];
const defaultTimes = { start: 9 * 60, end: 20 * 60, duration: 11 * 60 }
array.push(defaultTimes);
context.dispatch('SET_ITEM_PROPERTY', { path: 'times', value: array });
},
SET_TIME: (context, { prop, index, value }) => {
const array = [...context.state.itemInstance.times];
array[index][prop] = value;
context.dispatch('SET_ITEM_PROPERTY', { path: 'times', value: array });
},
REMOVE_TIME: (context, index) => {
const array = [...context.state.itemInstance.times];
array.splice(index, 1);
context.dispatch('SET_ITEM_PROPERTY', { path: 'times', value: array });
},
}

const shiftTemplates = new ObjectStoreModule({ resettableState, headers })
.attachAPIModule(ShiftTemplatesAPI)
.generateAPIActions()
.getModule();
.getModule({actions});

export default shiftTemplates;

0 comments on commit 3839c07

Please sign in to comment.