forked from AkkomaGang/admin-fe
Add input for new type ['atom', 'boolean']
This commit is contained in:
parent
b36e8693b5
commit
4339a3a961
3 changed files with 43 additions and 14 deletions
|
@ -28,7 +28,7 @@ const getCurrentValue = (type, value, path) => {
|
|||
}
|
||||
|
||||
const getValueWithoutKey = (key, [type, value]) => {
|
||||
if (type === 'atom' && value.length > 1) {
|
||||
if (prependWithСolon(type, value)) {
|
||||
return `:${value}`
|
||||
} else if (key === ':backends') {
|
||||
const index = value.findIndex(el => el === ':ex_syslogger')
|
||||
|
@ -132,6 +132,11 @@ const parseProxyUrl = value => {
|
|||
return { socks5: false, host: null, port: null }
|
||||
}
|
||||
|
||||
const prependWithСolon = (type, value) => {
|
||||
return (type === 'atom' && value.length > 0) ||
|
||||
(Array.isArray(type) && type.includes('atom') && typeof value === 'string')
|
||||
}
|
||||
|
||||
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).slice(0, -1)]
|
||||
|
@ -216,7 +221,7 @@ const wrapValues = (settings, currentState) => {
|
|||
setting === ':replace'
|
||||
) {
|
||||
return { 'tuple': [setting, wrapValues(value, currentState)] }
|
||||
} else if (type === 'atom' && value.length > 0) {
|
||||
} else if (prependWithСolon(type, value)) {
|
||||
return { 'tuple': [setting, `:${value}`] }
|
||||
} else if (type.includes('tuple') && (type.includes('string') || type.includes('atom'))) {
|
||||
return typeof value === 'string'
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
<crontab-input v-if="setting.key === ':crontab'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting"/>
|
||||
<editable-keyword-input v-if="editableKeyword(setting.key, setting.type)" :data="keywordData" :setting-group="settingGroup" :setting="setting"/>
|
||||
<icons-input v-if="setting.key === ':icons'" :data="iconsData" :setting-group="settingGroup" :setting="setting"/>
|
||||
<link-formatter-input v-if="settingGroup.key === 'Pleroma.Formatter'" :data="data" :setting-group="settingGroup" :setting="setting"/>
|
||||
<link-formatter-input v-if="booleanCombinedInput" :data="data" :setting-group="settingGroup" :setting="setting"/>
|
||||
<mascots-input v-if="setting.key === ':mascots'" :data="keywordData" :setting-group="settingGroup" :setting="setting"/>
|
||||
<proxy-url-input v-if="setting.key === ':proxy_url'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting" :parents="settingParent"/>
|
||||
<prune-input v-if="setting.key === ':prune'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting"/>
|
||||
|
@ -216,6 +216,9 @@ export default {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
booleanCombinedInput() {
|
||||
return Array.isArray(this.setting.type) && this.setting.type.includes('boolean')
|
||||
},
|
||||
canBeDeleted() {
|
||||
const { group, key } = this.settingGroup
|
||||
return _.get(this.$store.state.settings.db, [group, key]) &&
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-if="setting.key === ':class' || setting.key === ':rel'" :data-search="setting.key || setting.group">
|
||||
<el-switch :value="autoLinkerBooleanValue(setting.key)" @change="processTwoTypeValue($event, setting.key)"/>
|
||||
<el-input v-if="autoLinkerBooleanValue(setting.key)" :value="autoLinkerStringValue(setting.key)" @input="processTwoTypeValue($event, setting.key)"/>
|
||||
<div v-if="setting.type.includes('string')" :data-search="setting.key || setting.group">
|
||||
<el-switch :value="autoLinkerBooleanValue" @change="processTwoTypeValue($event, setting.key)"/>
|
||||
<el-input
|
||||
v-if="autoLinkerBooleanValue"
|
||||
:value="autoLinkerStringValue"
|
||||
@input="processTwoTypeValue($event, setting.key)"/>
|
||||
</div>
|
||||
<div v-if="setting.key === ':truncate'" :data-search="setting.key || setting.group">
|
||||
<el-switch :value="autoLinkerBooleanValue(setting.key)" @change="processTwoTypeValue($event, setting.key)"/>
|
||||
<el-input-number v-if="autoLinkerBooleanValue(setting.key)" :value="autoLinkerIntegerValue(setting.key)" @input="processTwoTypeValue($event, setting.key)"/>
|
||||
<div v-if="setting.type.includes('integer')" :data-search="setting.key || setting.group">
|
||||
<el-switch :value="autoLinkerBooleanValue" @change="processTwoTypeValue($event, setting.key)"/>
|
||||
<el-input-number
|
||||
v-if="autoLinkerBooleanValue"
|
||||
:value="autoLinkerIntegerValue"
|
||||
@input="processTwoTypeValue($event, setting.key)"/>
|
||||
</div>
|
||||
<div v-if="setting.type.includes('atom')" :data-search="setting.key || setting.group">
|
||||
<el-switch :value="autoLinkerBooleanValue" @change="processTwoTypeValue($event, setting.key)"/>
|
||||
<el-input
|
||||
v-if="autoLinkerBooleanValue"
|
||||
:value="autoLinkerAtomValue"
|
||||
@input="processTwoTypeValue($event, setting.key)">
|
||||
<template slot="prepend">:</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -34,19 +49,25 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
autoLinkerBooleanValue(key) {
|
||||
computed: {
|
||||
autoLinkerAtomValue() {
|
||||
return this.data[this.setting.key] &&
|
||||
this.data[this.setting.key][0] === ':' ? this.data[this.setting.key].substr(1) : this.data[this.setting.key]
|
||||
},
|
||||
autoLinkerBooleanValue() {
|
||||
const value = this.data[this.setting.key]
|
||||
return typeof value === 'string' || typeof value === 'number'
|
||||
},
|
||||
autoLinkerIntegerValue(key) {
|
||||
autoLinkerIntegerValue() {
|
||||
const value = this.data[this.setting.key]
|
||||
return value || 0
|
||||
},
|
||||
autoLinkerStringValue(key) {
|
||||
autoLinkerStringValue() {
|
||||
const value = this.data[this.setting.key]
|
||||
return value || ''
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
processTwoTypeValue(value, input) {
|
||||
if (value === true) {
|
||||
const data = input === ':truncate' ? 0 : ''
|
||||
|
|
Loading…
Reference in a new issue