Fix processing nested data for dispatch setting
This commit is contained in:
parent
1814e67adb
commit
1c7a7cc906
4 changed files with 17 additions and 13 deletions
|
@ -134,18 +134,18 @@ export const partialUpdate = (group, key) => {
|
|||
|
||||
export const processNested = (valueForState, valueForUpdatedSettings, group, parentKey, parents, settings, updatedSettings) => {
|
||||
const [{ key, type }, ...otherParents] = parents
|
||||
const path = [group, parentKey, ...parents.reverse().map(parent => parent.key)]
|
||||
const path = [group, parentKey, ...parents.reverse().map(parent => parent.key).slice(0, -1)]
|
||||
|
||||
const updatedValueForState = valueExists(settings, path)
|
||||
? { ...getCurrentValue(settings[group][parentKey], parents.map(el => el.key).slice(0, -1)),
|
||||
...{ [key]: valueForState }}
|
||||
: { [key]: valueForState }
|
||||
const updatedValueForUpdatedSettings = valueExists(updatedSettings, path)
|
||||
? { ...getCurrentValue(settings[group][parentKey], parents.map(el => el.key).slice(0, -1)),
|
||||
? { ...getCurrentValue(updatedSettings[group][parentKey], parents.map(el => el.key).slice(0, -1))[1],
|
||||
...{ [key]: [type, valueForUpdatedSettings] }}
|
||||
: { [key]: [type, valueForUpdatedSettings] }
|
||||
|
||||
// if (group === ':mime' && key === ':types') {
|
||||
// if (group === ':mime' && key === ':types') {
|
||||
// updatedValueForState = { ...settings[group][key].value, ...updatedValueForState }
|
||||
// updatedValueForUpdatedSettings = {
|
||||
// ...Object.keys(settings[group][key].value)
|
||||
|
@ -197,8 +197,10 @@ const wrapValues = (settings, currentState) => {
|
|||
return { 'tuple': [setting, wrapValues(value, currentState)] }
|
||||
} else if (type === 'atom' && value.length > 0) {
|
||||
return { 'tuple': [setting, `:${value}`] }
|
||||
} else if (type.includes('tuple') && (type.includes('string') || type.includes('list') || type.includes('atom'))) {
|
||||
} else if (type.includes('tuple') && (type.includes('string') || type.includes('atom'))) {
|
||||
return { 'tuple': [setting, { 'tuple': value }] }
|
||||
} else if (type.includes('tuple') && type.includes('list')) {
|
||||
return { 'tuple': [setting, value] }
|
||||
} else if (type === 'map') {
|
||||
const mapValue = Object.keys(value).reduce((acc, key) => {
|
||||
acc[key] = setting === ':match_actor' ? value[key] : value[key][1]
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<div v-for="subSetting in setting.children" :key="subSetting.key">
|
||||
<inputs
|
||||
:setting-group="settingGroup"
|
||||
:setting-parent="[...settingParent, setting, subSetting]"
|
||||
:setting-parent="[...settingParent, subSetting]"
|
||||
:setting="subSetting"
|
||||
:data="data[setting.key]"
|
||||
:custom-label-width="'100px'"
|
||||
|
@ -164,7 +164,7 @@ export default {
|
|||
return this.data[this.setting.key] ? this.data[this.setting.key][0] : ''
|
||||
},
|
||||
set: function(value) {
|
||||
this.processNestedData([value], this.settingGroup.group, this.settingGroup.key, this.settingParent[0].key, this.settingParent[0].type)
|
||||
this.processNestedData([value], this.settingGroup.group, this.settingGroup.key, this.settingParent)
|
||||
}
|
||||
},
|
||||
inputValue() {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div v-for="subSetting in setting.children" :key="subSetting.key">
|
||||
<inputs
|
||||
:setting-group="settingGroup"
|
||||
:setting-parent="[setting]"
|
||||
:setting-parent="[setting, subSetting]"
|
||||
:setting="subSetting"
|
||||
:data="data[setting.key]"
|
||||
:nested="true"/>
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
<el-tab-pane :label="$t('settings.mailer')" lazy>
|
||||
<mailer/>
|
||||
</el-tab-pane>
|
||||
<!-- <el-tab-pane :label="$t('settings.mediaProxy')" lazy>
|
||||
<media-proxy/>
|
||||
</el-tab-pane> -->
|
||||
<el-tab-pane :label="$t('settings.metadata')" lazy>
|
||||
<metadata/>
|
||||
</el-tab-pane>
|
||||
|
@ -59,18 +62,17 @@
|
|||
<el-tab-pane :label="$t('settings.relays')" lazy>
|
||||
<relays/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('settings.webPush')" lazy>
|
||||
<web-push/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('settings.other')" lazy>
|
||||
<other/>
|
||||
</el-tab-pane>
|
||||
<!-- <el-tab-pane :label="$t('settings.mediaProxy')" lazy>
|
||||
<media-proxy/>
|
||||
</el-tab-pane>
|
||||
<!--
|
||||
<el-tab-pane :label="$t('settings.upload')" lazy>
|
||||
<upload/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('settings.webPush')" lazy>
|
||||
<web-push/>
|
||||
</el-tab-pane> -->
|
||||
-->
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Reference in a new issue