From e1a4a276489174c9cabf979159895516da654514 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Mon, 13 Jun 2022 21:09:24 +0200
Subject: feat: Create isSubmitting bool for determining when the form is
 submitting, this is used instead of formIsLoading on the submit button

---
 apps/projects/src/app/pages/views/entry-form/index.svelte | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'apps/projects/src/app/pages/views/entry-form/index.svelte')

diff --git a/apps/projects/src/app/pages/views/entry-form/index.svelte b/apps/projects/src/app/pages/views/entry-form/index.svelte
index cf3d173..e43d2a9 100644
--- a/apps/projects/src/app/pages/views/entry-form/index.svelte
+++ b/apps/projects/src/app/pages/views/entry-form/index.svelte
@@ -16,6 +16,7 @@
 
     let formError = "";
     let formIsLoading = false;
+    let isSubmitting = false;
     let description = "";
     let descriptionError = "";
     let dateTimePart;
@@ -91,7 +92,7 @@
         formError = "";
         if (validate_form()) {
             const payload = get_payload() as TimeEntryDto;
-            formIsLoading = true;
+            isSubmitting = true;
             if (is_guid(payload.id)) {
                 const response = await edit_entry_async(payload);
                 if (response.ok) {
@@ -99,7 +100,7 @@
                     dispatch("updated", response.data);
                 } else {
                     formError = $LL.views.entryForm.entryUpdateError();
-                    formIsLoading = false;
+                    isSubmitting = false;
                 }
             } else {
                 const response = await create_entry_async(payload);
@@ -108,7 +109,7 @@
                     dispatch("created");
                 } else {
                     formError = $LL.views.entryForm.entryCreateError();
-                    formIsLoading = false;
+                    isSubmitting = false;
                 }
             }
         }
@@ -142,6 +143,7 @@
             else description = value;
         },
         reset() {
+            isSubmitting = false;
             formIsLoading = false;
             entryId = "";
             labelsPart.reset();
@@ -188,7 +190,7 @@
                     variant="subtle"
             />
         {/if}
-        <Button loading={formIsLoading}
+        <Button loading={isSubmitting}
                 type="submit"
                 variant="primary"
                 text={entryId ? $LL.views.entryForm.save() : $LL.views.entryForm.create()}
-- 
cgit v1.3

