Parse and wrap atoms

This commit is contained in:
Angelina Filippova 2019-12-04 23:17:05 +09:00
parent bb2a78ae52
commit 191199a41c
2 changed files with 17 additions and 4 deletions

View file

@ -80,7 +80,9 @@ const wrapValues = settings => {
return Object.keys(settings).map(setting => {
const [type, value] = settings[setting]
if (type === 'keyword') {
return { 'tuple': [setting, wrapValues(setting, value)] }
return { 'tuple': [setting, wrapValues(value)] }
} else if (type === 'atom') {
return { 'tuple': [setting, `:${value}`] }
} else {
return { 'tuple': [setting, value] }
}

View file

@ -259,6 +259,8 @@ export default {
} else if ((this.settingGroup.group === ':logger' && this.setting.key === ':backends') ||
this.setting.key === 'Pleroma.Web.Auth.Authenticator') {
return this.data.value
} else if (this.setting.type === 'atom') {
return this.data[this.setting.key] && this.data[this.setting.key][0] === ':' ? this.data[this.setting.key].substr(1) : this.data[this.setting.key]
} else {
return this.data[this.setting.key]
}
@ -303,6 +305,12 @@ export default {
},
rewritePolicyValue() {
return typeof this.data[this.setting.key] === 'string' ? [this.data[this.setting.key]] : this.data[this.setting.key]
},
settings() {
return this.$store.state.settings.settings
},
updatedSettings() {
return this.$store.state.settings.updatedSettings
}
},
methods: {
@ -408,9 +416,12 @@ export default {
processAutoLinker(value, tab, inputName, childName) {
},
processNestedData(value, group, key, parentInput, parentType, childInput, childType) {
const updatedValueForState = { ...this.$store.state.settings.settings[group][key][parentInput], ...{ [childInput]: value }}
const updatedValue = this.$store.state.settings.updatedSettings[group]
? { ...this.$store.state.settings.updatedSettings[group][key][parentInput][1], ...{ [childInput]: [childType, value] }}
const valueExists = value => value[group] && value[group][key] && value[group][key][parentInput]
const updatedValueForState = valueExists(this.settings)
? { ...this.settings[group][key][parentInput], ...{ [childInput]: value }}
: { [childInput]: value }
const updatedValue = valueExists(this.updatedSettings)
? { ...this.updatedSettings[group][key][parentInput][1], ...{ [childInput]: [childType, value] }}
: { [childInput]: [childType, value] }
this.$store.dispatch('UpdateSettings', { group, key, input: parentInput, value: updatedValue, type: parentType })
this.$store.dispatch('UpdateState', { group, key, input: parentInput, value: updatedValueForState })