diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 4fbfecae..c9dbc850 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -12,6 +12,10 @@ export const parseTuples = (tuples, key) => { accum[item.tuple[0]] = item.tuple[1] } else if (key === ':mascots') { accum[item.tuple[0]] = { ...item.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` } + } else if (item.tuple[0] === ':groups') { + accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { + return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] + }, []) } else if ((item.tuple[0] === ':sslopts' && item.tuple[1].length === 0) || // should be removed (item.tuple[0] === ':tlsopts' && item.tuple[1].length === 0)) { accum[item.tuple[0]] = {} diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index b1624e5d..024b4b7a 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -55,30 +55,6 @@ @input="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"> -
-
- : - - -
- -
-
-
- : - - -
- -
-
-
- : - - -
- -
Disabled @@ -137,8 +113,9 @@ @input="updateSetting($event, settingGroup.group, settingGroup.key, setting.key)"/>
- - + + +
@@ -165,13 +142,14 @@ import AceEditor from 'vue2-ace-editor' import 'brace/mode/elixir' import 'default-passive-events' -import { AutoLinkerInput, MascotsInput } from './inputComponents' +import { AutoLinkerInput, EditableKeyword, MascotsInput } from './inputComponents' export default { name: 'Inputs', components: { editor: AceEditor, AutoLinkerInput, + EditableKeyword, MascotsInput }, props: { @@ -183,7 +161,7 @@ export default { required: false }, data: { - type: Object || Array, + type: [Object, Array], default: function() { return {} } @@ -287,43 +265,12 @@ export default { methods: { addIconToIcons() {}, addValueToIcons() {}, - addRowToEditableKeyword() { - const updatedValue = this.editableKeywordData(this.data).reduce((acc, el, i) => { - return { ...acc, [el[0]]: el[1] } - }, {}) - this.updateSetting({ ...updatedValue, '': [] }, this.settingGroup.group, this.settingGroup.key, this.setting.key) - }, - deleteEditableKeywordRow(index) { - const filteredValues = this.editableKeywordData(this.data).filter((el, i) => index !== i) - const updatedValue = filteredValues.reduce((acc, el, i) => { - return { ...acc, [el[0]]: el[1] } - }, {}) - this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key) - }, deleteIcondRow(index) {}, - editableKeywordWithInput(key) { - return key === ':replace' - }, - editableKeywordWithInteger(type) { - return Array.isArray(type) - ? type.includes('keyword') && type.includes('integer') - : false - }, - editableKeywordWithSelect(type) { - return type === 'map' || - (Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1) - }, - editableKeywordData(data) { - return Object.keys(data).map(key => [key, data[key]]) - }, - parseEditableKeyword(value, inputType, index) { - const updatedValue = this.editableKeywordData(this.data).reduce((acc, el, i) => { - if (index === i) { - return inputType === 'key' ? { ...acc, [value]: el[1] } : { ...acc, [el[0]]: value } - } - return { ...acc, [el[0]]: el[1] } - }, {}) - this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key) + editableKeyword(key, type) { + return key === ':replace' || + (Array.isArray(type) && type.includes('keyword') && type.includes('integer')) || + type === 'map' || + (Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1) }, parseIcons(value, inputType, index) {}, parseRateLimiter(value, input, typeOfInput, typeOfLimit, currentValue) { diff --git a/src/views/settings/components/inputComponents/EditableKeyword.vue b/src/views/settings/components/inputComponents/EditableKeyword.vue new file mode 100644 index 00000000..f1f106cd --- /dev/null +++ b/src/views/settings/components/inputComponents/EditableKeyword.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/src/views/settings/components/inputComponents/index.js b/src/views/settings/components/inputComponents/index.js index eb2d7b83..922dea1b 100644 --- a/src/views/settings/components/inputComponents/index.js +++ b/src/views/settings/components/inputComponents/index.js @@ -1,2 +1,3 @@ export { default as AutoLinkerInput } from './AutoLinkerInput' export { default as MascotsInput } from './MascotsInput' +export { default as EditableKeyword } from './EditableKeyword'