-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: refactoring of configuration-popup.vue and adding ExportSett… #691
Changes from 2 commits
3ad663f
86ac456
04832a4
a7fcb0f
4cc9a23
0b53b88
5daa746
42130a7
3e91fe2
baed608
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,42 @@ | |
<div | ||
v-if="itemInstance.name" | ||
> | ||
<!-- https://github.com/vuejs/core/issues/2279#issuecomment-701266701--> | ||
<component | ||
:is="componentConfig.component" | ||
:label="componentConfig.label" | ||
v-bind="componentConfig.bind" | ||
v-on="componentConfig.on" | ||
<wt-switcher | ||
v-if="specificControls.defaultBooleanConfig" | ||
:label="$t('reusable.state')" | ||
:v="v$.itemInstance.value" | ||
:value="itemInstance.value" | ||
required | ||
@change="(event) => this.setItemProp({ prop: 'value', value: event })" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а чого саме стрілка тут потрібна? |
||
/> | ||
<wt-input | ||
v-if="specificControls.defaultNumberConfig" | ||
:label="$tc('vocabulary.values', 1)" | ||
:v="v$.itemInstance.value" | ||
:value="itemInstance.value" | ||
required | ||
type="number" | ||
@input="(event) => this.setItemProp({ prop: 'value', value: +event })" | ||
/> | ||
<div v-if="specificControls.defaultSelectConfig"> | ||
<wt-select | ||
:clearable="false" | ||
:label="$t('objects.configuration.configurationPopup.format')" | ||
:options="exportSettingOptions" | ||
:v="v$.itemInstance.format" | ||
:value="itemInstance.format" | ||
required | ||
@input="selectHandler" | ||
/> | ||
<wt-input | ||
v-if="itemInstance.format?.value === exportSettingsEnum.XLS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. краще у компьютед) |
||
:label="$t('objects.configuration.configurationPopup.separator')" | ||
:v="v$.itemInstance.separator" | ||
:value="itemInstance.separator" | ||
required | ||
@input="inputHandler" | ||
/> | ||
</div> | ||
</div> | ||
</form> | ||
</template> | ||
|
@@ -60,6 +89,8 @@ import openedObjectMixin from '../../../../../app/mixins/objectPagesMixins/opene | |
import openedTabComponentMixin | ||
from '../../../../../app/mixins/objectPagesMixins/openedObjectTabMixin/openedTabComponentMixin'; | ||
import ConfigurationAPI from '../api/configuration'; | ||
import exportSettingsEnum from '../enum/exportSettings.enum.js'; | ||
import ConfigurationTypeLookup from '../lookups/ConfigurationType.lookup.js'; | ||
import ConfigurationValueTypes from '../utils/configurationValueTypes'; | ||
|
||
export default { | ||
|
@@ -76,66 +107,81 @@ export default { | |
setup: () => ({ | ||
v$: useVuelidate(), | ||
}), | ||
validations: { | ||
itemInstance: { | ||
name: { required }, | ||
value: { | ||
required, | ||
minValue: minValue(0), | ||
validations() { | ||
const defaults = { | ||
itemInstance: { | ||
name: { required }, | ||
}, | ||
}, | ||
}; | ||
const defaultBooleanConfig = { | ||
itemInstance:{ | ||
value: { | ||
required, | ||
}, | ||
} | ||
} | ||
const defaultNumberConfig = { | ||
itemInstance:{ | ||
value: { | ||
required, | ||
minValue: minValue(0), | ||
}, | ||
} | ||
} | ||
const defaultSelectConfig = { | ||
itemInstance: { | ||
format: { required }, | ||
separator: { required }, | ||
}, | ||
} | ||
|
||
switch (this.itemInstance.name) { | ||
case EngineSystemSettingName.EnableOmnichannel: | ||
return deepmerge(defaults, defaultBooleanConfig); | ||
case EngineSystemSettingName.AmdCancelNotHuman: | ||
return deepmerge(defaults, defaultBooleanConfig); | ||
case EngineSystemSettingName.Enable2fa: | ||
return deepmerge(defaults, defaultBooleanConfig); | ||
case EngineSystemSettingName.MemberChunkSize: | ||
return deepmerge(defaults, defaultNumberConfig); | ||
case EngineSystemSettingName.SchemeVersionLimit: | ||
return deepmerge(defaults, defaultNumberConfig); | ||
case EngineSystemSettingName.SearchNumberLength: | ||
return deepmerge(defaults, defaultNumberConfig); | ||
case EngineSystemSettingName.ExportSettings: | ||
if (this.itemInstance.format === exportSettingsEnum.XLS) { | ||
return deepmerge(defaults, defaultSelectConfig); | ||
} else { | ||
return deepmerge(defaults, { | ||
itemInstance: { | ||
format: { required }, | ||
}, | ||
}); | ||
} | ||
default: | ||
return defaults; | ||
} | ||
}, | ||
|
||
data() { | ||
return { | ||
exportSettingsEnum, | ||
}; | ||
}, | ||
computed: { | ||
exportSettingOptions() { | ||
return Object.keys(exportSettingsEnum) | ||
.map(key => ({ name: exportSettingsEnum[key], value: exportSettingsEnum[key], id: exportSettingsEnum[key] })); | ||
}, | ||
valueType() { | ||
return ConfigurationValueTypes[this.itemInstance.name]; | ||
}, | ||
componentConfig() { | ||
const defaultConfig = { | ||
bind: { | ||
value: this.itemInstance.value, | ||
v: this.v$.itemInstance.value, | ||
required: true, | ||
}, | ||
}; | ||
|
||
const defaultBooleanConfig = deepmerge(defaultConfig, { | ||
component: 'wt-switcher', | ||
label: this.$t('reusable.state'), | ||
on: { | ||
change: (event) => this.setItemProp({ prop: 'value', value: event }), | ||
}, | ||
}); | ||
const defaultNumberConfig = deepmerge(defaultConfig, { | ||
component: 'wt-input', | ||
label: this.$tc('vocabulary.values', 1), | ||
bind: { | ||
type: 'number', | ||
}, | ||
on: { | ||
input: (event) => this.setItemProp({ prop: 'value', value: +event }), | ||
}, | ||
}); | ||
|
||
switch (this.itemInstance.name) { | ||
case EngineSystemSettingName.EnableOmnichannel: { | ||
return defaultBooleanConfig; | ||
} | ||
case EngineSystemSettingName.AmdCancelNotHuman: { | ||
return defaultBooleanConfig; | ||
} | ||
case EngineSystemSettingName.Enable2fa: { | ||
return defaultBooleanConfig; | ||
} | ||
case EngineSystemSettingName.MemberChunkSize: { | ||
return defaultNumberConfig; | ||
} | ||
case EngineSystemSettingName.SchemeVersionLimit: { | ||
return defaultNumberConfig; | ||
} | ||
default: { | ||
return {}; | ||
} | ||
} | ||
specificControls() { | ||
return ConfigurationTypeLookup[this.itemInstance.name].controls | ||
.reduce((controls, control) => ({ | ||
...controls, | ||
[control]: true, | ||
}), {}); | ||
}, | ||
}, | ||
methods: { | ||
|
@@ -160,6 +206,23 @@ export default { | |
close() { | ||
this.$emit('close'); | ||
}, | ||
selectHandler(selectedValue) { | ||
this.itemInstance.format = selectedValue; | ||
if (this.itemInstance.format?.value !== exportSettingsEnum.XLS) { | ||
delete this.itemInstance.separator; | ||
} | ||
this.handleDefaultSelectConfigInput(); | ||
}, | ||
inputHandler(inputValue) { | ||
this.itemInstance.separator = inputValue; | ||
this.handleDefaultSelectConfigInput(); | ||
}, | ||
handleDefaultSelectConfigInput() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. чисто попридиратись( |
||
this.setItemProp({ | ||
prop: 'value', | ||
value: { format: this.itemInstance.format.name, separator: this.itemInstance.separator }, | ||
}); | ||
}, | ||
async loadParameterList(params) { | ||
return await ConfigurationAPI.getObjectsList({ ...params, size: 5000 }); | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default Object.freeze({ | ||
CSV: 'csv', | ||
XLS: 'xls', | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { EngineSystemSettingName } from 'webitel-sdk'; | ||
|
||
const ConfigurationTypeLookup = Object.freeze({ | ||
[EngineSystemSettingName.EnableOmnichannel]: { | ||
controls: [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а це вірно що значення в масиві сховані? |
||
'defaultBooleanConfig', | ||
], | ||
}, | ||
[EngineSystemSettingName.AmdCancelNotHuman]: { | ||
controls: [ | ||
'defaultBooleanConfig', | ||
], | ||
}, | ||
[EngineSystemSettingName.Enable2fa]: { | ||
controls: [ | ||
'defaultBooleanConfig', | ||
], | ||
}, | ||
[EngineSystemSettingName.MemberChunkSize]: { | ||
controls: [ | ||
'defaultNumberConfig', | ||
], | ||
}, | ||
[EngineSystemSettingName.SearchNumberLength]: { | ||
controls: [ | ||
'defaultNumberConfig', | ||
], | ||
}, | ||
[EngineSystemSettingName.SchemeVersionLimit]: { | ||
controls: [ | ||
'defaultNumberConfig', | ||
], | ||
}, | ||
[EngineSystemSettingName.ExportSettings]: { | ||
controls: [ | ||
'defaultSelectConfig', | ||
], | ||
}, | ||
}); | ||
|
||
export default ConfigurationTypeLookup; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а цих локалей нема в лібі?