From 5a9ad943a26b8c99a6d874a9a8aa4ec8eeb706fc Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 10 Oct 2019 23:25:34 +0300 Subject: [PATCH] dashboard: ctrl+s/cmd+s to save config, style tweaks --- .../dashboard/GuildConfigEditor.vue | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/dashboard/src/components/dashboard/GuildConfigEditor.vue b/dashboard/src/components/dashboard/GuildConfigEditor.vue index cffc1291..008342f4 100644 --- a/dashboard/src/components/dashboard/GuildConfigEditor.vue +++ b/dashboard/src/components/dashboard/GuildConfigEditor.vue @@ -3,8 +3,6 @@ Loading...
-
Saving...
-
Saved!
Errors:
{{ error }}
@@ -12,10 +10,16 @@

Config for {{ guild.name }}

- + +
+ Saving... +
- +
@@ -73,6 +77,17 @@ tabSize: 2 }); + this.$refs.aceEditor.editor.commands.addCommand({ + name: 'save', + bindKey: { + win: "Ctrl-S", + mac: "Cmd-S" + }, + exec: editor => { + this.save(); + }, + }); + this.fitEditorToWindow(); }, fitEditorToWindow() { @@ -91,6 +106,8 @@ }); }, async save() { + if (this.saving) return; + this.saved = false; this.saving = true; this.errors = []; @@ -99,11 +116,14 @@ clearTimeout(this.savedTimeout); } + const minWaitTime = new Promise(resolve => setTimeout(resolve, 300)); + try { await this.$store.dispatch("guilds/saveConfig", { guildId: this.$route.params.guildId, config: this.editableConfig, }); + await minWaitTime; this.saving = false; this.saved = true;