From ffac6130da5661904d88122c758151f63dcabe38 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Thu, 7 Dec 2023 10:37:40 +0530 Subject: [PATCH] #1193 - added custom dashboard action call after reset (part of previous commit) --- .../openchs-android/src/service/SyncService.js | 16 ++++++++++------ .../service/customDashboard/ReportCardService.js | 7 ++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/openchs-android/src/service/SyncService.js b/packages/openchs-android/src/service/SyncService.js index c65942f61..7b84e8e8b 100644 --- a/packages/openchs-android/src/service/SyncService.js +++ b/packages/openchs-android/src/service/SyncService.js @@ -28,10 +28,11 @@ import TaskUnAssignmentService from "./task/TaskUnAssignmentService"; import UserSubjectAssignmentService from "./UserSubjectAssignmentService"; import moment from "moment"; import AllSyncableEntityMetaData from "../model/AllSyncableEntityMetaData"; -import ProgramConfigService from './ProgramConfigService'; import {IndividualSearchActionNames as IndividualSearchActions} from '../action/individual/IndividualSearchActions'; -import {LandingViewActionsNames as LandingViewActions} from '../action/LandingViewActions'; +import {LandingViewActionsNames as Actions, LandingViewActionsNames as LandingViewActions} from '../action/LandingViewActions'; import {MyDashboardActionNames} from '../action/mydashboard/MyDashboardActions'; +import {CustomDashboardActionNames} from '../action/customDashboard/CustomDashboardActions'; +import LocalCacheService from "./LocalCacheService"; @Service("syncService") class SyncService extends BaseService { @@ -373,12 +374,15 @@ class SyncService extends BaseService { this.dispatchAction('RESET'); this.context.getService(PrivilegeService).deleteRevokedEntities(); //Invoking this in MenuView.deleteData as well - //To load subjectType after sync this.dispatchAction(IndividualSearchActions.ON_LOAD); - this.dispatchAction(MyDashboardActionNames.ON_LOAD); //Invoking this after full sync reset as well - - //To re-render LandingView after sync + this.dispatchAction(MyDashboardActionNames.ON_LOAD); this.dispatchAction(LandingViewActions.ON_LOAD, {syncRequired}); + LocalCacheService.getPreviouslySelectedSubjectTypeUuid().then(cachedSubjectTypeUUID => { + this.dispatchAction(Actions.ON_LOAD, {cachedSubjectTypeUUID}); + }); + this.dispatchAction(CustomDashboardActionNames.ON_LOAD, {onlyPrimary: false}); + this.dispatchAction(CustomDashboardActionNames.REMOVE_OLDER_COUNTS); + setTimeout(() => this.dispatchAction(CustomDashboardActionNames.REFRESH_COUNT), 500); } } diff --git a/packages/openchs-android/src/service/customDashboard/ReportCardService.js b/packages/openchs-android/src/service/customDashboard/ReportCardService.js index bb447e156..d0b22d30f 100644 --- a/packages/openchs-android/src/service/customDashboard/ReportCardService.js +++ b/packages/openchs-android/src/service/customDashboard/ReportCardService.js @@ -31,7 +31,8 @@ class ReportCardService extends BaseService { } getCountForApprovalCardsType(type, reportFilters) { - const {result} = this.getResultForApprovalCardsType(type, reportFilters); + const approvalStatus_status = getApprovalStatusForType(type); + const {result} = this.getService(EntityApprovalStatusService).getAllEntitiesForReports(approvalStatus_status, reportFilters) return { primaryValue: _.map(result, ({data}) => data.length).reduce((total, l) => total + l, 0), secondaryValue: null, @@ -41,7 +42,7 @@ class ReportCardService extends BaseService { getResultForApprovalCardsType(type, reportFilters) { const approvalStatus_status = getApprovalStatusForType(type); - return this.getService(EntityApprovalStatusService).getAllEntitiesForReports(approvalStatus_status, reportFilters); + return this.getService(EntityApprovalStatusService).getAllSubjects(approvalStatus_status, reportFilters); } getCountForCommentCardType() { @@ -135,7 +136,7 @@ class ReportCardService extends BaseService { return {status: null, result}; } case standardReportCardType.isApprovalType() : - return this.getResultForApprovalCardsType(standardReportCardType.name, reportFilters); + return {status: null, result: this.getResultForApprovalCardsType(standardReportCardType.name, reportFilters)}; case standardReportCardType.isDefaultType() : return this.getResultForDefaultCardsType(standardReportCardType.name, reportFilters); case standardReportCardType.isCommentType() : {