Add label and description to children settings of ssl-option

This commit is contained in:
Angelina Filippova 2019-12-25 00:28:22 +03:00
parent 51a2b72793
commit 82c077112f

View file

@ -1,15 +1,18 @@
<template>
<div>
<div v-for="subSetting in setting.children" :key="subSetting.key">
<el-select
v-if="subSetting.type.includes('list') && subSetting.type.includes('atom')"
:value="data[setting.key][subSetting.key]"
multiple
filterable
allow-create
@change="update($event, subSetting.key)">
<el-option v-for="(option, index) in subSetting.suggestions" :key="index" :value="option"/>
</el-select>
<el-form-item :label="subSetting.label" :label-width="customLabelWidth">
<el-select
v-if="subSetting.type.includes('list') && subSetting.type.includes('atom')"
:value="data[setting.key][subSetting.key]"
multiple
filterable
allow-create
@change="update($event, subSetting.key)">
<el-option v-for="(option, index) in subSetting.suggestions" :key="index" :value="option"/>
</el-select>
<p class="expl">{{ subSetting.description }}</p>
</el-form-item>
</div>
</div>
</template>
@ -61,11 +64,21 @@ export default {
inputValue(key) {
return this.data[this.setting.key][key]
},
update(value, key) {
const updatedState = { ...this.data, [this.setting.key]: { ...this.data[this.setting.key], [key]: value }}
update(value, childKey) {
const [group, key, parentKey, input] = [this.settingGroup.group, this.settingGroup.key, this.setting.key, this.settingParent.key]
const { updatedSettings, description } = this.$store.state.settings
const type = description
.find(element => element.group === group && element.key === key).children
.find(child => child.key === ':adapter').children.find(child => child.key === ':ssl_options').children
.find(child => child.key === childKey).type
this.$store.dispatch('UpdateSettings', { group: this.settingGroup.group, key: this.settingGroup.key, input: this.settingParent.key, value: updatedState, type: this.settingParent.type })
this.$store.dispatch('UpdateState', { group: this.settingGroup.group, key: this.settingGroup.key, input: this.settingParent.key, value: updatedState })
const updatedState = { ...this.data, [parentKey]: { ...this.data[parentKey], [childKey]: value }}
const updatedSetting = !updatedSettings[group] || !updatedSettings[group][key]
? { [parentKey]: ['keyword', { [childKey]: [type, value] }] }
: { ...updatedSettings[group][key][parentKey], [parentKey]: { ...updatedSettings[group][key][parentKey], [childKey]: [type, value] }}
this.$store.dispatch('UpdateSettings', { group, key, input, value: updatedSetting, type: this.settingParent.type })
this.$store.dispatch('UpdateState', { group, key, input, value: updatedState })
}
}
}