diff --git a/public/js/components/filter/Filter/TablePresets.js b/public/js/components/filter/Filter/TablePresets.js index 79f1b3e91..a8a0c8e4c 100644 --- a/public/js/components/filter/Filter/TablePresets.js +++ b/public/js/components/filter/Filter/TablePresets.js @@ -34,6 +34,7 @@ export default { presetInfo: null, newPreset: null, newPresetName: "", + presetIndexBeingApplied: null, }; }, computed: { @@ -161,6 +162,9 @@ export default { }, }, methods: { + getPresetIndex() { + return this.presetIndexBeingApplied; + }, async showPresetInfo(preset) { let shouldUpdatePresetInfo; if (!this.presetInfo) { @@ -393,14 +397,22 @@ export default { this.fetchCustomUserTabulatorPresets(); } }, - async applyPreset(preset) { - preset = this.syncPresetWithConfig(preset); - window.localStorage["tabulatorPreset-" + this.$props.presetsId] = - preset.id ? "custom:" + preset.id : "general:" + preset.name; + async applyPreset(preset, index) { + this.presetIndexBeingApplied = index; - this.$props.tabulator.modules.tablePresets.applyPreset(preset); - - this.$emit("tablePresetApplied", { preset }); + // workaround for updating DOM and displaying preset-loading spinner + // conventional use of $nextTick ineffective + setTimeout(() => { + preset = this.syncPresetWithConfig(preset); + window.localStorage["tabulatorPreset-" + this.$props.presetsId] = + preset.id ? "custom:" + preset.id : "general:" + preset.name; + + this.$props.tabulator.modules.tablePresets.applyPreset(preset); + + this.$emit("tablePresetApplied", { preset }); + + this.presetIndexBeingApplied = null; + }, 50); }, async fetchCustomUserTabulatorPresets() { let tabulatorPresetsResponse = await this.$api.call( @@ -453,7 +465,7 @@ export default { if (!preset) return; - this.applyPreset(preset); + this.applyPreset(preset, null); }, }, async created() { @@ -467,8 +479,19 @@ export default {