add collection and make kvp functional
This commit is contained in:
parent
4c20115705
commit
50badaef2b
|
@ -171,10 +171,19 @@
|
|||
"type": "drawer",
|
||||
"settings": [
|
||||
{
|
||||
"id": "kvp0",
|
||||
"type": "kvp",
|
||||
"text": "",
|
||||
"value": { "key": "kvpKey", "value": "kvpValue" }
|
||||
"id": "e2ekvps",
|
||||
"type": ["kvp"],
|
||||
"value": [
|
||||
{
|
||||
"id": "kvp0",
|
||||
"type": "kvp",
|
||||
"text": "",
|
||||
"value": {
|
||||
"key": "kvpKey",
|
||||
"value": "kvpValue"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import KeybindSetting from './types/keybind';
|
|||
import FileSetting from './types/file';
|
||||
import GuildSetting from './types/guild';
|
||||
import ArraySetting from './types/array';
|
||||
import CollectionSetting from './types/collection';
|
||||
import KvpSetting from './types/kvp';
|
||||
import CustomSetting from './types/custom';
|
||||
|
||||
|
@ -26,7 +27,7 @@ export default class Setting {
|
|||
|
||||
constructor(args, ...merge) {
|
||||
args = args.args || args;
|
||||
|
||||
if (args.type instanceof Array) return new CollectionSetting(args, ...merge);
|
||||
if (args.type === 'color') args.type = 'colour';
|
||||
|
||||
if (args.type === 'bool') return new BoolSetting(args, ...merge);
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* BetterDiscord Collection Setting Struct
|
||||
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
||||
* All rights reserved.
|
||||
* https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import BaseSetting from './basesetting';
|
||||
import Setting from '../setting';
|
||||
|
||||
export default class CollectionSetting extends BaseSetting {
|
||||
|
||||
constructor(args) {
|
||||
super(args);
|
||||
this.subtype = args.type[0];
|
||||
args.type = 'collection';
|
||||
this.sub = new Setting({ type: this.subtype });
|
||||
}
|
||||
|
||||
/**
|
||||
* The value to use when the setting doesn't have a value.
|
||||
*/
|
||||
get defaultValue() {
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -10,4 +10,5 @@ export { default as FileSetting } from './file';
|
|||
export { default as GuildSetting } from './guild';
|
||||
export { default as ArraySetting } from './array';
|
||||
export { default as KvpSetting } from './kvp';
|
||||
export { default as CollectionSetting } from './kvp';
|
||||
export { default as CustomSetting } from './custom';
|
||||
|
|
|
@ -16,6 +16,6 @@ export default class KvpSetting extends Setting {
|
|||
* The value to use when the setting doesn't have a value.
|
||||
*/
|
||||
get defaultValue() {
|
||||
return { key: 'Channel ID', value: 'Encryption Key' };
|
||||
return { key: 'Key', value: 'Value' };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* BetterDiscord Setting Bool Component
|
||||
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
||||
* All rights reserved.
|
||||
* https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
<template>
|
||||
<div class="bd-formCollection">
|
||||
<template v-for="s in setting.value">
|
||||
<KeyValuePair v-if="setting.subtype === 'kvp'" :setting="s" :key="s.id" />
|
||||
<Bool v-else-if="setting.subtype === 'bool'" :setting="s" :key="s.id" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import KeyValuePair from './KeyValuePair.vue';
|
||||
import Bool from './Bool.vue';
|
||||
export default {
|
||||
props: ['setting'],
|
||||
components: { KeyValuePair, Bool },
|
||||
mounted() { console.log('collection', this.setting) }
|
||||
}
|
||||
</script>
|
|
@ -12,12 +12,11 @@
|
|||
<div class="bd-formKvp">
|
||||
<div class="bd-formKvpDetails">
|
||||
<div class="bd-inputWrapper">
|
||||
<input type="text" class="bd-textInput" :value="setting.value.key" />
|
||||
<input type="text" class="bd-textInput" :value="setting.value.key" @keyup.stop @input="keyChange"/>
|
||||
</div>
|
||||
<div class="bd-inputWrapper">
|
||||
<input type="text" class="bd-textInput" :value="setting.value.value" />
|
||||
<input type="text" class="bd-textInput" :value="setting.value.value" @keyup.stop @input="valueChange"/>
|
||||
</div>
|
||||
<!-- using a text field is temporary -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -25,7 +24,13 @@
|
|||
<script>
|
||||
export default {
|
||||
props: ['setting'],
|
||||
methods: {},
|
||||
mounted() {console.log('setting', this.setting)}
|
||||
methods: {
|
||||
keyChange(e) {
|
||||
this.setting.value.key = e.target.value;
|
||||
},
|
||||
valueChange(e) {
|
||||
this.setting.value.value = e.target.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
<FileSetting v-if="setting.type === 'file'" :setting="setting" />
|
||||
<GuildSetting v-if="setting.type === 'guild'" :setting="setting" />
|
||||
<ArraySetting v-if="setting.type === 'array'" :setting="setting" />
|
||||
<KeyValuePair v-if="setting.type === 'kvp'" :setting="setting"/>
|
||||
<Collection v-if="setting.type === 'collection'" :setting="setting" />
|
||||
<KeyValuePair v-if="setting.type === 'kvp'" :setting="setting" />
|
||||
<CustomSetting v-if="setting.type === 'custom'" :setting="setting" />
|
||||
<div class="bd-form-divider"></div>
|
||||
</div>
|
||||
|
@ -42,6 +43,7 @@
|
|||
import FileSetting from './File.vue';
|
||||
import GuildSetting from './Guild.vue';
|
||||
import ArraySetting from './Array.vue';
|
||||
import Collection from './Collection.vue';
|
||||
import KeyValuePair from './KeyValuePair.vue';
|
||||
import CustomSetting from './Custom.vue';
|
||||
|
||||
|
@ -62,6 +64,7 @@
|
|||
FileSetting,
|
||||
GuildSetting,
|
||||
ArraySetting,
|
||||
Collection,
|
||||
KeyValuePair,
|
||||
CustomSetting
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue