From 9c6acae0cf233715e53d80cb863fa3e274c1e2e2 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 6 May 2020 19:38:02 +0300 Subject: [PATCH 1/4] Use boolean values if value equals 'true' or 'false' --- src/store/modules/normalizers.js | 9 +++++++++ src/views/settings/components/Inputs.vue | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 6eecebca..c146d60e 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -1,5 +1,14 @@ import _ from 'lodash' +export const getBooleanValue = value => { + if (value === 'true') { + return true + } else if (value === 'false') { + return false + } + return value +} + export const checkPartialUpdate = (settings, updatedSettings, description) => { return Object.keys(updatedSettings).reduce((acc, group) => { acc[group] = Object.keys(updatedSettings[group]).reduce((acc, key) => { diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index c0d62c6d..a756037b 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -132,7 +132,7 @@ import { RateLimitInput, RegInvitesInput, SelectInputWithReducedLabels } from './inputComponents' -import { processNested } from '@/store/modules/normalizers' +import { getBooleanValue, processNested } from '@/store/modules/normalizers' import _ from 'lodash' import marked from 'marked' @@ -332,9 +332,10 @@ export default { ) }, update(value, group, key, parents, input, type, nested) { + const updatedValue = getBooleanValue(value) nested - ? this.processNestedData(value, group, key, parents) - : this.updateSetting(value, group, key, input, type) + ? this.processNestedData(updatedValue, group, key, parents) + : this.updateSetting(updatedValue, group, key, input, type) }, updateSetting(value, group, key, input, type) { this.$store.dispatch('UpdateSettings', { group, key, input, value, type }) From 4404e87e3d2354f48769cee28b44484e401ad981 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 6 May 2020 20:06:30 +0300 Subject: [PATCH 2/4] Rename component for specific multiple select, remove ability to create custom values in those selects --- src/views/settings/components/Inputs.vue | 10 +++++----- .../{MultipleSelect.vue => SpecificMultipleSelect.vue} | 6 +----- src/views/settings/components/inputComponents/index.js | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) rename src/views/settings/components/inputComponents/{MultipleSelect.vue => SpecificMultipleSelect.vue} (94%) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index a756037b..4e45ddae 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -99,12 +99,12 @@ - + @@ -126,12 +126,12 @@ import { EditableKeywordInput, IconsInput, MascotsInput, - MultipleSelect, ProxyUrlInput, PruneInput, RateLimitInput, RegInvitesInput, - SelectInputWithReducedLabels } from './inputComponents' + SelectInputWithReducedLabels, + SpecificMultipleSelect } from './inputComponents' import { getBooleanValue, processNested } from '@/store/modules/normalizers' import _ from 'lodash' import marked from 'marked' @@ -144,12 +144,12 @@ export default { EditableKeywordInput, IconsInput, MascotsInput, - MultipleSelect, ProxyUrlInput, PruneInput, RateLimitInput, RegInvitesInput, - SelectInputWithReducedLabels + SelectInputWithReducedLabels, + SpecificMultipleSelect }, props: { customLabelWidth: { diff --git a/src/views/settings/components/inputComponents/MultipleSelect.vue b/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue similarity index 94% rename from src/views/settings/components/inputComponents/MultipleSelect.vue rename to src/views/settings/components/inputComponents/SpecificMultipleSelect.vue index 66b3aa75..25df11a7 100644 --- a/src/views/settings/components/inputComponents/MultipleSelect.vue +++ b/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue @@ -5,8 +5,6 @@ :value="data.value" :data-search="setting.key || setting.group" multiple - filterable - allow-create class="input" @change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)"> @@ -18,8 +16,6 @@ :value="data[setting.key]" :data-search="setting.key || setting.group" multiple - filterable - allow-create class="input" @change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)"> @@ -31,7 +27,7 @@