-
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 #649 from webitel/feature/team-schemas
Feature/team schemas [WTEL-4354]
- Loading branch information
Showing
14 changed files
with
488 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
167 changes: 167 additions & 0 deletions
167
src/modules/contact-center/modules/teams/modules/flow/api/teamFlows.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,167 @@ | ||
import { TeamTriggerServiceApi } from 'webitel-sdk'; | ||
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; |
88 changes: 88 additions & 0 deletions
88
src/modules/contact-center/modules/teams/modules/flow/components/opened-team-flow-popup.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,88 @@ | ||
<template> | ||
<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> |
Oops, something went wrong.