Skip to content

Commit

Permalink
fix: SettingValueTypes object and setting-popup component[WTEl-3818]
Browse files Browse the repository at this point in the history
  • Loading branch information
Lera24 committed Oct 18, 2023
1 parent e29bb0e commit 1043f08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/app/router/_internals/RouteNames.enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default Object.freeze({

// SYSTEM
CHANGELOGS: 'changelogs',
SETTINGS: 'adm-settings',
SETTINGS: 'admin-settings',

SETTINGS_PAGE: 'settings',
PAGE_403: 'access-denied',
Expand Down
36 changes: 14 additions & 22 deletions src/modules/system/modules/settings/components/setting-popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@
:track-by="null"
:disabled="id"
required
@input="setItemProp({ prop: 'name', value: $event })"
@input="setDefaultValue"
></wt-select>
<div
v-if="itemInstance.name"
>
<wt-switcher
v-if="valueType === 'boolean'"
<component
:is="`wt-${componentType}`"
:value="itemInstance.value"
:v="v$.itemInstance.value"
:required="componentType === 'input'"
:label="$tc('vocabulary.values', 1)"
@change="setItemProp({ prop: 'value', value: $event })"
></wt-switcher>
<wt-input
v-else
:value="itemInstance.value"
:v="v$.itemInstance.value"
:type="valueType === 'number' && 'number'"
:label="$tc('vocabulary.values', 1)"
@change="setItemProp({ prop: 'value', value: $event })"
@input="setItemProp({ prop: 'value', value: $event })"
required
></wt-input>
></component>
</div>
</form>
</template>
Expand Down Expand Up @@ -92,7 +86,10 @@ export default {
},
computed: {
valueType() {
return SettingsValueTypes.find((setting) => setting.name === this.itemInstance.name).type;
return SettingsValueTypes[this.itemInstance.name];
},
componentType() {
return this.valueType === 'boolean' ? 'switcher' : 'input';
},
},
methods: {
Expand Down Expand Up @@ -126,15 +123,10 @@ export default {
));
return response;
},
},
watch: {
'itemInstance.name': {
handler() {
if (!this.id) {
if (this.valueType === 'boolean') this.setItemProp({ prop: 'value', value: false });
if (this.valueType === 'number') this.setItemProp({ prop: 'value', value: 0 });
};
},
setDefaultValue(event) {
this.setItemProp({ prop: 'name', value: event });
if (this.valueType === 'boolean') this.setItemProp({ prop: 'value', value: false });
if (this.valueType === 'number') this.setItemProp({ prop: 'value', value: 0 });
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { EngineSystemSettingName } from 'webitel-sdk';

const SettingsValueTypes = Object.freeze([
{ name: EngineSystemSettingName.EnableOmnichannel, type: 'boolean' },
{ name: EngineSystemSettingName.MemberChunkSize, type: 'number' },
]);
const SettingsValueTypes = Object.freeze({
[EngineSystemSettingName.EnableOmnichannel]: 'boolean',
[EngineSystemSettingName.MemberChunkSize]: 'number',
},
);

export default SettingsValueTypes;

0 comments on commit 1043f08

Please sign in to comment.