From e783958100e21d8e624ffcc08fcf42a5c3131029 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Tue, 14 May 2019 00:19:58 +0200 Subject: [PATCH] createprojectgroup: add loading indicator and enabled to button --- src/components/createprojectgroup.vue | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/components/createprojectgroup.vue b/src/components/createprojectgroup.vue index b506ed9..e9d3747 100644 --- a/src/components/createprojectgroup.vue +++ b/src/components/createprojectgroup.vue @@ -13,7 +13,12 @@
- +
@@ -38,13 +43,29 @@ export default { data() { return { createProjectGroupError: null, - projectGroupName: null + createProjectGroupLoading: false, + createProjectGroupLoadingTimeout: null, + projectGroupName: "" }; }, + computed: { + createProjectGroupButtonEnabled: function() { + return this.projectGroupName.length; + } + }, methods: { resetErrors() { this.createProjectGroupError = null; }, + startProjectGroupLoading() { + this.createProjectGroupLoadingTimeout = setTimeout(() => { + this.createProjectGroupLoading = true; + }, 300); + }, + stopProjectGroupLoading() { + clearTimeout(this.createProjectGroupLoadingTimeout); + this.createProjectGroupLoading = false; + }, async createProjectGroup() { this.resetErrors(); @@ -54,10 +75,12 @@ export default { } let parentref = refArray.join("/"); + this.startProjectGroupLoading(); let { error } = await createProjectGroup( parentref, this.projectGroupName ); + this.stopProjectGroupLoading(); if (error) { this.createProjectGroupError = error; return;