From d054a773737a29e02bfac84d09d37df0a7593c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=AB=E7=84=9A=20=E5=AF=8C=E8=89=AF?= <tomasfire@live.com> Date: Tue, 2 Jul 2024 00:21:28 +0800 Subject: [PATCH] Add spinner and disable editbox in todo until save is finished (#5960) Closes #5937. Signed-off-by: Egor Savkin <tomasfire@live.com> --- .../time-resources/src/components/CreateToDo.svelte | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/time-resources/src/components/CreateToDo.svelte b/plugins/time-resources/src/components/CreateToDo.svelte index 7d86a59045..d7c5cda335 100644 --- a/plugins/time-resources/src/components/CreateToDo.svelte +++ b/plugins/time-resources/src/components/CreateToDo.svelte @@ -1,5 +1,5 @@ <script lang="ts"> - import { ActionIcon, IconAdd, showPopup, ModernEditbox } from '@hcengineering/ui' + import { ActionIcon, IconAdd, showPopup, ModernEditbox, Spinner } from '@hcengineering/ui' import { SortingOrder, generateId, getCurrentAccount } from '@hcengineering/core' import { PersonAccount } from '@hcengineering/contact' import { ToDoPriority } from '@hcengineering/time' @@ -10,6 +10,7 @@ export let fullSize: boolean = false let value: string = '' + let disabled: boolean = false const client = getClient() const acc = getCurrentAccount() as PersonAccount @@ -58,16 +59,22 @@ width={fullSize ? '100%' : ''} size={'medium'} autoAction={false} + {disabled} bind:value on:keydown={(e) => { if (e.key === 'Enter') { - save() + disabled = true + save().finally(() => (disabled = false)) e.preventDefault() e.stopPropagation() } }} > - <ActionIcon icon={IconAdd} action={openPopup} size={'small'} /> + {#if disabled} + <Spinner size={'small'} /> + {:else} + <ActionIcon icon={IconAdd} action={openPopup} size={'small'} /> + {/if} </ModernEditbox> </div>