Skip to content
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

Merged
merged 10 commits into from
Jun 24, 2024
Merged
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"vue-router": "^4.2.5",
"vue2-dropzone": "^3.6.0",
"vuex": "^4.1.0",
"webitel-sdk": "^24.2.12"
"webitel-sdk": "^24.4.7"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.4.0",
Expand Down
7 changes: 7 additions & 0 deletions src/app/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,13 @@ export default {
},
},

configuration: {
configurationPopup: {
format: 'Format',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а цих локалей нема в лібі?

separator: 'Separator',
},
},

integrations: {
integrations: 'Integrations',
emptyWorkspace: 'There are no profiles yet',
Expand Down
6 changes: 6 additions & 0 deletions src/app/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,12 @@ export default {
timerangeTo: 'До',
},
},
configuration: {
configurationPopup: {
format: 'Формат',
separator: 'Разделитель',
},
},
integrations: {
integrations: 'Интеграции',
emptyWorkspace: 'Профили в разделе еще не созданы',
Expand Down
6 changes: 6 additions & 0 deletions src/app/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,12 @@ export default {
timerangeTo: 'До',
},
},
configuration: {
configurationPopup: {
format: 'Формат',
separator: 'Розділювач',
},
},
integrations: {
integrations: 'Інтеграції',
emptyWorkspace: 'Профілі у розділі ще не створені',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })"
Copy link
Contributor

Choose a reason for hiding this comment

The 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"
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
Expand Down Expand Up @@ -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 {
Expand All @@ -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: {
Expand All @@ -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() {
Copy link
Contributor

Choose a reason for hiding this comment

The 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 });
},
Expand Down
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: [
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
Loading