-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #784 from webitel/feature/add-working-conditions-page
feature: add working conditions page[WTEL-5078]
- Loading branch information
Showing
16 changed files
with
624 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/modules/lookups/modules/working-conditions/api/workingConditions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
115 changes: 115 additions & 0 deletions
115
...odules/lookups/modules/working-conditions/components/opened-working-condition-general.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.