From c04334fd6819dafa8aec680e7f29e799c9463053 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Tue, 31 Dec 2024 16:32:05 -0800 Subject: [PATCH 1/3] Add the 'Fetching Data' spinner for downloading business summary and loading document lists --- src/components/bcros/LoadingModal.vue | 26 +++++++++++++++++++ .../bcros/businessDetails/Links.vue | 24 +++-------------- .../bcros/filing/CommonTemplate.vue | 12 +++++++-- .../bcros/filing/common/HeaderActions.vue | 14 ++++++++-- src/layouts/business.vue | 7 +++-- src/layouts/default.vue | 7 +++-- src/stores/ui.ts | 2 ++ src/utils/download-file.ts | 2 -- 8 files changed, 59 insertions(+), 35 deletions(-) create mode 100644 src/components/bcros/LoadingModal.vue diff --git a/src/components/bcros/LoadingModal.vue b/src/components/bcros/LoadingModal.vue new file mode 100644 index 00000000..5f2123d8 --- /dev/null +++ b/src/components/bcros/LoadingModal.vue @@ -0,0 +1,26 @@ + + + diff --git a/src/components/bcros/businessDetails/Links.vue b/src/components/bcros/businessDetails/Links.vue index fb1382d4..39dd60db 100644 --- a/src/components/bcros/businessDetails/Links.vue +++ b/src/components/bcros/businessDetails/Links.vue @@ -22,8 +22,8 @@ const { isAllowedToFile, isDisableNonBenCorps } = useBcrosBusiness() const isCommentOpen = ref(false) const isDissolutionDialogOpen = ref(false) const { goToCreatePage } = useBcrosNavigate() +const ui = useBcrosDashboardUi() const filings = useBcrosFilings() -const isFetchingDataSpinner = ref(false) const isAllowedBusinessSummary = computed(() => !!currentBusinessIdentifier.value && @@ -122,7 +122,7 @@ const promptChangeBusinessInfo = () => { /** Request and Download Business Summary Document. */ const downloadBusinessSummary = async (): Promise => { - isFetchingDataSpinner.value = true + ui.fetchingData = true const businessId = currentBusiness.value.identifier const apiURL = useRuntimeConfig().public.legalApiURL const summaryDocument: DocumentI = { @@ -135,7 +135,7 @@ const downloadBusinessSummary = async (): Promise => { if (blob) { saveBlob(blob, summaryDocument.filename) } - isFetchingDataSpinner.value = false + ui.fetchingData = false } /** Creates a draft filing and navigates to the Create UI to file a company dissolution filing. */ @@ -183,24 +183,6 @@ const contacts = getContactInfo('registries') @@ -103,6 +105,7 @@ const { isAllowedToFile, isBaseCompany, isDisableNonBenCorps, isEntityCoop, isEn const { currentBusiness } = storeToRefs(useBcrosBusiness()) const { isBootstrapFiling } = useBcrosBusinessBootstrap() const { goToEditPage } = useBcrosNavigate() +const ui = useBcrosDashboardUi() const isCommentOpen = ref(false) const filings = useBcrosFilings() @@ -323,14 +326,21 @@ const actions: any[][] = [[ } ]] -const handleButtonClick = () => { +const handleButtonClick = async () => { // toggle expansion state isExpanded.value = !isExpanded.value // if the filing has documentsLink but the documents list is empty // (i.e., when View More is clicked for the first time), load the documents list if (filing.value.documents === undefined && filing.value.documentsLink) { - loadDocumentList(filing.value) + ui.fetchingData = true + + await loadDocumentList(filing.value) + + // wait for another 500ms to show the loading modal + await new Promise(resolve => setTimeout(resolve, 500)) + + ui.fetchingData = false } } diff --git a/src/layouts/business.vue b/src/layouts/business.vue index 62ff8b0c..161fd6c5 100644 --- a/src/layouts/business.vue +++ b/src/layouts/business.vue @@ -2,7 +2,7 @@ const route = useRoute() const { isStaffAccount } = useBcrosAccount() -const { dashboardIsLoading } = storeToRefs(useBcrosDashboardUi()) +const { dashboardIsLoading, fetchingData } = storeToRefs(useBcrosDashboardUi()) const crumbConstructors = computed(() => { if (isStaffAccount) { @@ -20,9 +20,8 @@ onMounted(async () => {