-
{{category}}
-
+
+
+
+ {{category.category}} static with header
+
+
+
+ {{category.category}} drawer
+
+
+
@@ -44,8 +50,7 @@
return {
changed: false,
warnclose: false,
- configCache: [],
- categories: ['default']
+ configCache: []
}
},
components: {
@@ -54,29 +59,35 @@
},
methods: {
checkForChanges() {
- for (let cachedSetting of this.configCache) {
- if (this.plugin.pluginConfig.find(s => s.id === cachedSetting.id && s.value !== cachedSetting.value)) {
- return true;
+ for (let category of this.configCache) {
+ const cat = this.plugin.pluginConfig.find(c => c.category === category.category);
+ for (let setting of category.settings) {
+ if (cat.settings.find(s => s.id === setting.id).value !== setting.value) return true;
}
}
return false;
},
- textInputKd(settingId) {
- },
settingChange(settingId, newValue) {
- this.configCache.find(s => s.id === settingId).value = newValue;
+ for (let category of this.configCache) {
+ const found = category.settings.find(s => s.id === settingId);
+ if (found) {
+ found.value = newValue;
+ break;
+ }
+ }
this.changed = this.checkForChanges();
},
saveSettings() {
- this.plugin.saveSettings(this.configCache);
- this.configCache = JSON.parse(JSON.stringify(this.plugin.pluginConfig));
+ //this.plugin.saveSettings(this.configCache);
+ //this.configCache = JSON.parse(JSON.stringify(this.plugin.pluginConfig));
+ // TODO later
this.changed = false;
},
resetSettings() {
this.configCache = JSON.parse(JSON.stringify(this.plugin.pluginConfig));
this.changed = false;
},
- attemptToClose() {
+ attemptToClose(e) {
if (!this.changed) return this.close();
this.warnclose = true;
setTimeout(() => {
@@ -86,11 +97,7 @@
},
beforeMount() {
this.configCache = JSON.parse(JSON.stringify(this.plugin.pluginConfig));
- this.configCache.forEach(s => {
- if (!s.category || s.category === 'default') return;
- if (this.categories.includes(s.category)) return;
- this.categories.push(s.category);
- });
+ console.log(this.configCache);
this.changed = this.checkForChanges();
}
}
diff --git a/tests/plugins/Example/config.json b/tests/plugins/Example/config.json
index 19be502a..fadf8c32 100644
--- a/tests/plugins/Example/config.json
+++ b/tests/plugins/Example/config.json
@@ -8,99 +8,110 @@
"main": "index.js",
"defaultConfig": [
{
- "id": "test-setting-1",
- "category": "test category",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting",
- "hint": "Bool Test Setting Hint"
+ "category_default_comment": "default category has no header and is always displayed first",
+ "category": "default",
+ "settings": [
+ {
+ "id": "default-0",
+ "type": "bool",
+ "value": false,
+ "text": "Bool Test Setting 3",
+ "hint": "Bool Test Setting Hint 3"
+ },
+ {
+ "id": "default-1",
+ "type": "text",
+ "value": "defaultValue",
+ "text": "Text Test Setting",
+ "hint": "Text Test Setting Hint"
+ },
+ {
+ "id": "default-2",
+ "type": "bool",
+ "value": false,
+ "text": "Bool Test Setting 3",
+ "hint": "Bool Test Setting Hint 3"
+ },
+ {
+ "id": "default-3",
+ "type": "file",
+ "value": null,
+ "text": "Test File Setting 1",
+ "hint": "File selector with the default options."
+ },
+ {
+ "id": "default-4",
+ "type": "file",
+ "value": null,
+ "text": "Test File Setting 2",
+ "hint": "File selector with custom button text and the ability to open directories and multiple items.",
+ "dialogOptions": {
+ "buttonLabel": "Select",
+ "properties": [
+ "openFile",
+ "openDirectory",
+ "multiSelections"
+ ]
+ }
+ }
+ ]
},
{
- "id": "test-setting-2",
- "category": "test category 2",
- "type": "text",
- "value": "defaultValue",
- "text": "Text Test Setting",
- "hint": "Text Test Setting Hint"
+ "category_header_comment": "Setting a category other than default has a header with category name as the text",
+ "category": "Test Category",
+ "drawer_type_comment": "// Drawer type will create an expandable drawer for the settings",
+ "type": "drawer",
+ "settings": [
+ {
+ "id": "drawer-0",
+ "type": "bool",
+ "value": false,
+ "text": "Bool Test Setting 3",
+ "hint": "Bool Test Setting Hint 3"
+ },
+ {
+ "id": "drawer-1",
+ "type": "text",
+ "value": "defaultValue",
+ "text": "Text Test Setting",
+ "hint": "Text Test Setting Hint"
+ },
+ {
+ "id": "drawer-2",
+ "type": "bool",
+ "value": false,
+ "text": "Bool Test Setting 3",
+ "hint": "Bool Test Setting Hint 3"
+ }
+ ]
},
{
- "id": "test-setting-3",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 2",
- "hint": "Bool Test Setting Hint 2"
- },
- {
- "id": "test-setting-4",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 3",
- "hint": "Bool Test Setting Hint 3"
- },
- {
- "id": "test-setting-5",
- "category": "test category",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 4",
- "hint": "Bool Test Setting Hint 4"
- },
- {
- "id": "test-setting-6",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 5",
- "hint": "Bool Test Setting Hint 5"
- },
- {
- "id": "test-setting-7",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 6",
- "hint": "Bool Test Setting Hint 6"
- },
- {
- "id": "test-setting-8",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 7",
- "hint": "Bool Test Setting Hint 7"
- },
- {
- "id": "test-setting-9",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 8",
- "hint": "Bool Test Setting Hint 8"
- },
- {
- "id": "test-setting-10",
- "type": "bool",
- "value": false,
- "text": "Bool Test Setting 9",
- "hint": "Bool Test Setting Hint 9"
- },
- {
- "id": "test-setting-file-1",
- "type": "file",
- "value": null,
- "text": "Test File Setting 1",
- "hint": "File selector with the default options."
- },
- {
- "id": "test-setting-file-2",
- "type": "file",
- "value": null,
- "text": "Test File Setting 2",
- "hint": "File selector with custom button text and the ability to open directories and multiple items.",
- "dialogOptions": {
- "buttonLabel": "Select",
- "properties": [
- "openFile",
- "openDirectory",
- "multiSelections"
- ]
- }
+ "category": "Test Category 2",
+ "static_type_comment": "Static type will behave like default but will have a header",
+ "type": "static",
+ "settings": [
+ {
+ "id": "static-0",
+ "type": "bool",
+ "value": false,
+ "text": "Bool Test Setting 3",
+ "hint": "Bool Test Setting Hint 3"
+ },
+ {
+ "id": "static-1",
+ "type": "text",
+ "value": "defaultValue",
+ "text": "Text Test Setting",
+ "hint": "Text Test Setting Hint"
+ },
+ {
+ "id": "static-2",
+ "type": "bool",
+ "value": false,
+ "text": "Bool Test Setting 3",
+ "hint": "Bool Test Setting Hint 3"
+ }
+ ]
}
]
}