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

View file

@ -2,23 +2,23 @@
<div class="input">
<el-select
v-if="renderMultipleSelect(setting.type)"
:value="rewritePolicyValue"
:value="inputValue"
:data-search="setting.key"
multiple
filterable
class="input"
@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
v-if="setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown'))"
:value="data.value"
:value="inputValue"
:data-search="setting.key || setting.group"
clearable
class="input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)">
<el-option
v-for="(option, index) in authenticatorOptions(setting.suggestions)"
v-for="(option, index) in options(setting.suggestions)"
:value="option.value"
:label="option.label"
:key="index"/>
@ -50,18 +50,42 @@ export default {
}
},
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() {
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: {
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 => {
const label = element.split('Pleroma.Web.Auth.')[1]
? element.split('Pleroma.Web.Auth.')[1]
const label = element.split(prefix)[1]
? element.split(prefix)[1]
: element
return { value: element, label }
})