Unify rendering :replace settings as keyword with strings

This commit is contained in:
Angelina Filippova 2020-07-10 03:40:17 +03:00
parent f34157b1db
commit 0323053fee
3 changed files with 13 additions and 17 deletions

View file

@ -283,8 +283,7 @@ export default {
}, },
methods: { methods: {
editableKeyword(key, type) { editableKeyword(key, type) {
return key === ':replace' || return type === 'map' ||
type === 'map' ||
(Array.isArray(type) && type.includes('keyword') && type.includes('integer')) || (Array.isArray(type) && type.includes('keyword') && type.includes('integer')) ||
(Array.isArray(type) && type.includes('keyword') && type.includes('string')) || (Array.isArray(type) && type.includes('keyword') && type.includes('string')) ||
(Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1) (Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1)
@ -334,7 +333,7 @@ export default {
type.includes('module') || type.includes('module') ||
(type.includes('list') && type.includes('string')) || (type.includes('list') && type.includes('string')) ||
(type.includes('list') && type.includes('atom')) || (type.includes('list') && type.includes('atom')) ||
(type.includes('regex') && type.includes('string')) (!type.includes('keyword') && type.includes('regex') && type.includes('string'))
) )
}, },
renderSingleSelect(type) { renderSingleSelect(type) {

View file

@ -121,8 +121,7 @@ export default {
compound({ type, key, children }) { compound({ type, key, children }) {
return type === 'keyword' || return type === 'keyword' ||
type === 'map' || type === 'map' ||
type.includes('keyword') || type.includes('keyword')
key === ':replace'
}, },
divideSetting(key) { divideSetting(key) {
return [':sslopts', ':tlsopts', ':adapter', ':poll_limits', ':queues', ':styling', ':invalidation', ':multi_factor_authentication'].includes(key) return [':sslopts', ':tlsopts', ':adapter', ':poll_limits', ':queues', ':styling', ':invalidation', ':multi_factor_authentication'].includes(key)

View file

@ -1,14 +1,6 @@
<template> <template>
<div class="editable-keyword-container"> <div class="editable-keyword-container">
<div v-if="setting.key === ':replace'" :data-search="setting.key || setting.group"> <div v-if="editableKeywordWithInteger" :data-search="setting.key || setting.group">
<div v-for="element in data" :key="getId(element)" class="setting-input">
<el-input :value="getKey(element)" placeholder="pattern" class="name-input" @input="parseEditableKeyword($event, 'key', element)"/> :
<el-input :value="getValue(element)" placeholder="replacement" class="value-input" @input="parseEditableKeyword($event, 'value', element)"/>
<el-button :size="isDesktop ? 'medium' : 'mini'" class="icon-minus-button" icon="el-icon-minus" circle @click="deleteEditableKeywordRow(element)"/>
</div>
<el-button :size="isDesktop ? 'medium' : 'mini'" icon="el-icon-plus" circle @click="addRowToEditableKeyword"/>
</div>
<div v-else-if="editableKeywordWithInteger" :data-search="setting.key || setting.group">
<div v-for="element in data" :key="getId(element)" class="setting-input"> <div v-for="element in data" :key="getId(element)" class="setting-input">
<el-input :value="getKey(element)" placeholder="key" class="name-input" @input="parseEditableKeyword($event, 'key', element)"/> : <el-input :value="getKey(element)" placeholder="key" class="name-input" @input="parseEditableKeyword($event, 'key', element)"/> :
<el-input-number :value="getValue(element)" :min="0" size="large" class="value-input" @change="parseEditableKeyword($event, 'value', element)"/> <el-input-number :value="getValue(element)" :min="0" size="large" class="value-input" @change="parseEditableKeyword($event, 'value', element)"/>
@ -16,10 +8,10 @@
</div> </div>
<el-button :size="isDesktop ? 'medium' : 'mini'" icon="el-icon-plus" circle @click="addRowToEditableKeyword"/> <el-button :size="isDesktop ? 'medium' : 'mini'" icon="el-icon-plus" circle @click="addRowToEditableKeyword"/>
</div> </div>
<div v-if="editableKeywordWithString" :data-search="setting.key || setting.group"> <div v-else-if="editableKeywordWithString" :data-search="setting.key || setting.group">
<div v-for="element in data" :key="getId(element)" class="setting-input"> <div v-for="element in data" :key="getId(element)" class="setting-input">
<el-input :value="getKey(element)" placeholder="key" class="name-input" @input="parseEditableKeyword($event, 'key', element)"/> : <el-input :value="getKey(element)" :placeholder="keyPlaceholder" class="name-input" @input="parseEditableKeyword($event, 'key', element)"/> :
<el-input :value="getValue(element)" placeholder="value" class="value-input" @input="parseEditableKeyword($event, 'value', element)"/> <el-input :value="getValue(element)" :placeholder="valuePlaceholder" class="value-input" @input="parseEditableKeyword($event, 'value', element)"/>
<el-button :size="isDesktop ? 'medium' : 'mini'" class="icon-minus-button" icon="el-icon-minus" circle @click="deleteEditableKeywordRow(element)"/> <el-button :size="isDesktop ? 'medium' : 'mini'" class="icon-minus-button" icon="el-icon-minus" circle @click="deleteEditableKeywordRow(element)"/>
</div> </div>
<el-button :size="isDesktop ? 'medium' : 'mini'" icon="el-icon-plus" circle @click="addRowToEditableKeyword"/> <el-button :size="isDesktop ? 'medium' : 'mini'" icon="el-icon-plus" circle @click="addRowToEditableKeyword"/>
@ -77,11 +69,17 @@ export default {
isDesktop() { isDesktop() {
return this.$store.state.app.device === 'desktop' return this.$store.state.app.device === 'desktop'
}, },
keyPlaceholder() {
return this.setting.key === ':replace' ? 'pattern' : 'key'
},
settings() { settings() {
return this.$store.state.settings.settings return this.$store.state.settings.settings
}, },
updatedSettings() { updatedSettings() {
return this.$store.state.settings.updatedSettings return this.$store.state.settings.updatedSettings
},
valuePlaceholder() {
return this.setting.key === ':replace' ? 'replacement' : 'value'
} }
}, },
methods: { methods: {