Reduce length of suggestions in Captcha method input

This commit is contained in:
Angelina Filippova 2020-04-25 22:38:30 +03:00
parent e488e3f852
commit 8937cf87d1
2 changed files with 37 additions and 13 deletions

View file

@ -55,7 +55,7 @@
:data-search="setting.key || setting.group" :data-search="setting.key || setting.group"
@change="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/> @change="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/>
<el-select <el-select
v-if="setting.key !== 'Pleroma.Web.Auth.Authenticator' && (setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown')))" v-if="!reducedSelects && (setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown')))"
:value="inputValue === false ? 'false' : inputValue" :value="inputValue === false ? 'false' : inputValue"
:data-search="setting.key || setting.group" :data-search="setting.key || setting.group"
clearable clearable
@ -67,7 +67,7 @@
:key="index"/> :key="index"/>
</el-select> </el-select>
<el-select <el-select
v-if="renderMultipleSelect(setting.type) && setting.key !== ':rewrite_policy'" v-if="renderMultipleSelect(setting.type) && !reducedSelects"
:value="inputValue" :value="inputValue"
:data-search="setting.key || setting.group" :data-search="setting.key || setting.group"
multiple multiple
@ -254,7 +254,7 @@ export default {
return Array.isArray(this.data) ? this.data : [] return Array.isArray(this.data) ? this.data : []
}, },
reducedSelects() { reducedSelects() {
return [':rewrite_policy', 'Pleroma.Web.Auth.Authenticator'].includes(this.setting.key) return [':method', ':rewrite_policy', 'Pleroma.Web.Auth.Authenticator'].includes(this.setting.key)
}, },
settings() { settings() {
return this.$store.state.settings.settings return this.$store.state.settings.settings

View file

@ -2,23 +2,23 @@
<div class="input"> <div class="input">
<el-select <el-select
v-if="renderMultipleSelect(setting.type)" v-if="renderMultipleSelect(setting.type)"
:value="rewritePolicyValue" :value="inputValue"
:data-search="setting.key" :data-search="setting.key"
multiple multiple
filterable filterable
class="input" class="input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)"> @change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)">
<el-option v-for="(option, index) in rewritePolicyOptions(setting.suggestions)" :key="index" :value="option.value" :label="option.label" /> <el-option v-for="(option, index) in options(setting.suggestions)" :key="index" :value="option.value" :label="option.label" />
</el-select> </el-select>
<el-select <el-select
v-if="setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown'))" v-if="setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown'))"
:value="data.value" :value="inputValue"
:data-search="setting.key || setting.group" :data-search="setting.key || setting.group"
clearable clearable
class="input" class="input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)"> @change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)">
<el-option <el-option
v-for="(option, index) in authenticatorOptions(setting.suggestions)" v-for="(option, index) in options(setting.suggestions)"
:value="option.value" :value="option.value"
:label="option.label" :label="option.label"
:key="index"/> :key="index"/>
@ -50,18 +50,42 @@ export default {
} }
}, },
computed: { computed: {
inputValue() {
if (this.setting.key === 'Pleroma.Web.Auth.Authenticator') {
return this.data.value
} else if (this.setting.key === ':rewrite_policy') {
return typeof this.data[this.setting.key] === 'string'
? [this.data[this.setting.key]]
: this.data[this.setting.key]
} else {
return this.data[this.setting.key]
}
},
isMobile() { isMobile() {
return this.$store.state.app.device === 'mobile' return this.$store.state.app.device === 'mobile'
},
rewritePolicyValue() {
return typeof this.data[this.setting.key] === 'string' ? [this.data[this.setting.key]] : this.data[this.setting.key]
} }
}, },
methods: { methods: {
authenticatorOptions(suggestions) { options(suggestions) {
let prefix
switch (this.setting.key) {
case ':rewrite_policy':
prefix = 'Pleroma.Web.ActivityPub.MRF.'
break
case 'Pleroma.Web.Auth.Authenticator':
prefix = 'Pleroma.Web.Auth.'
break
case ':method':
prefix = 'Pleroma.Captcha.'
break
default:
prefix = ''
}
return suggestions.map(element => { return suggestions.map(element => {
const label = element.split('Pleroma.Web.Auth.')[1] const label = element.split(prefix)[1]
? element.split('Pleroma.Web.Auth.')[1] ? element.split(prefix)[1]
: element : element
return { value: element, label } return { value: element, label }
}) })