{"version":3,"sources":["webpack:///./src/resources/plan-report-header/ZoneReportUpdated.ts","webpack:///./src/resources/plan-report-header/UnitReportUpdated.ts","webpack:///./src/resources/plan-report-header/StateReportUpdated.ts","webpack:///./src/resources/plan-report-header/CentralReportUpdated.ts","webpack:///./src/resources/plan-report-header/PlanReportHeaderData.ts","webpack:///./src/resources/pager/pager.ts","webpack:///./src/resources/pager/pager.html","webpack:///./src/resources/plan-report-header/plan-report-header.ts","webpack:///./src/resources/plan-report-header/plan-report-header.html","webpack:///./src/resources/plan-report-shell/plan-report-shell.ts","webpack:///./src/resources/plan-report-shell/plan-report-shell.html"],"names":["title","id","identifier","status","organization","reportingPeriod","organizationDetails","this","details","Math","floor","pagingdata","totalRecords","pageSize","first","page","last","pages","ps","curr","push","load","pageNumber","loadpage","defaultBindingMode","oneWay","Pager","module","exports","PlanReportHeader","appRouter","auth","unitService","stateService","zoneService","centralService","dialogService","signalr","ea","isDownloadingList","isDownloadingDetail","isResettingPlan","isResettingYPlanFromQ","isResettingReport","isResettingYReportFromQ","isRecalculatingPlan","isRecalculatingYPlanFromQ","isRecalculatingReport","isRecalculatingYReportFromQ","signalreventhandlers","onUnitReportUpdated","clearResetRecalculateFlags","publish","onUnitReportUpdateFailed","e","$values","join","onZoneReportUpdated","onZoneReportUpdateFailed","onStateReportUpdated","onStateReportUpdateFailed","onCentralReportUpdated","onCentralReportUpdateFailed","attached","key","hasOwnProperty","on","detached","off","headerData","organizationType","Unit","Zone","State","Central","Error","downloadAsList","copydownloadservice","downloadReport","List","blob","downloadAsDetail","Detail","resetPlan","open","viewModel","model","whenClosed","response","wasCancelled","resetrecalculateservice","console","log","resetYPlanFromQ","resetReport","resetYReportFromQ","recalculatePlan","recalculateYPlanFromQ","recalculateReport","recalculateYReportFromQ","isActive","routehref","route","routes","find","r","href","navModel","reportingFrequency","Yearly","reportStatus","Submitted","isSystemAdmin","PlanReportShell"],"mappings":"4FAAA,oD,kCCAA,oD,kCCAA,oD,kCCAA,oD,kCC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AKwB,KAAKiF,eAAiBzG,KAAKuG,eAAiB,IAAaC,W,gCAGzE,sBAAI,sBAAO,C,IAAX,WACI,OAAOxG,KAAKuG,eAAiB,IAAaC,W,gCAG9C,YAAA5D,2BAAA,WACI5C,KAAKkC,iBAAkB,EACvBlC,KAAKmC,uBAAwB,EAC7BnC,KAAKoC,mBAAoB,EACzBpC,KAAKqC,yBAA0B,EAC/BrC,KAAKsC,qBAAsB,EAC3BtC,KAAKuC,2BAA4B,EACjCvC,KAAKwC,uBAAwB,EAC7BxC,KAAKyC,6BAA8B,GAhZe,GAArD,YAAS,CAAExB,mBAAoB,IAAYC,S,gBAAsB,M,iCACZ,GAArD,YAAS,CAAED,mBAAoB,IAAYC,S,gEACU,GAArD,YAAS,CAAED,mBAAoB,IAAYC,S,sDACU,GAArD,YAAS,CAAED,mBAAoB,IAAYC,S,4DAhBnCwF,EAAe,GAF3B,IACA,I,uBAoByB,IACL,IAEO,IACC,IACD,IACG,IACD,gBACN,IACL,OA5BNA,GAAb,I,iGCzBAtF,EAAOC,QAAU","file":"app~d2caeabb.a64431677d2c3f203c04.chunk.js","sourcesContent":["export class ZoneReportUpdated {\r\n}\r\n","export class UnitReportUpdated {\r\n}\r\n","export class StateReportUpdated {\r\n}\r\n","export class CentralReportUpdated {\r\n}\r\n","import { OrganizationReference } from \"models/OrganizationReference\";\r\nimport { ReportStatus } from \"models/ReportStatus\";\r\nimport { ReportingPeriod } from \"models/ReportingPeriod\";\r\n\r\nexport class PlanReportHeaderData {\r\n constructor(\r\n public title: string,\r\n public id: number,\r\n public identifier: string,\r\n public status: ReportStatus,\r\n public organization: OrganizationReference,\r\n public reportingPeriod: ReportingPeriod\r\n ) { }\r\n\r\n get organizationDetails() {\r\n var organizationDetails = this.organization.details;\r\n\r\n if(!organizationDetails) {\r\n organizationDetails = \"Not Provided\";\r\n }\r\n\r\n return organizationDetails;\r\n }\r\n}\r\n","import { bindable, computedFrom, containerless, bindingMode } from \"aurelia-framework\";\r\nimport { PagingData } from \"models/PagingData\";\r\n\r\n@containerless\r\nexport class Pager {\r\n @bindable({ defaultBindingMode: bindingMode.oneWay }) pagingdata: PagingData;\r\n @bindable loadpage: (pageNumber: number) => Promise;\r\n\r\n @computedFrom('pagingData')\r\n get pages(){\r\n return Math.floor(this.pagingdata.totalRecords / this.pagingdata.pageSize) + (this.pagingdata.totalRecords % this.pagingdata.pageSize > 0 ? 1 : 0);\r\n }\r\n\r\n get displaypages(){\r\n let first = this.pagingdata.page - 5 < 1 ? 1 : this.pagingdata.page - 5;\r\n const last = first + 9 > this.pages ? this.pages : first + 9;\r\n first = last - 9 < first && last - 9 > 0 ? last - 9 : first;\r\n const ps = [];\r\n let curr = first;\r\n do {\r\n ps.push(curr);\r\n curr = curr + 1;\r\n } while (curr <= last)\r\n return ps;\r\n }\r\n\r\n async load(pageNumber: number) {\r\n if(this.loadpage) {\r\n await this.loadpage(pageNumber);\r\n }\r\n }\r\n}","module.exports = \"\\r\\n\";","import { bindable, bindingMode, containerless, autoinject } from \"aurelia-framework\";\r\nimport { PlanReportHeaderData } from \"resources/plan-report-header/PlanReportHeaderData\";\r\n\r\n@containerless\r\n@autoinject\r\nexport class PlanReportHeader {\r\n @bindable({ defaultBindingMode: bindingMode.oneWay }) headerData: PlanReportHeaderData;\r\n\r\n constructor() {}\r\n}\r\n","module.exports = \"\\r\\n\";","import { bindable, bindingMode, containerless, autoinject, PLATFORM } from \"aurelia-framework\";\r\nimport { EventAggregator } from \"aurelia-event-aggregator\";\r\nimport { DialogService, DialogSettings } from \"aurelia-dialog\";\r\nimport { saveAs } from \"file-saver\";\r\nimport * as toastr from \"toastr\";\r\nimport { StatePlanReportService } from \"services/StatePlanReportService\";\r\nimport { UnitPlanReportService } from \"services/UnitPlanReportService\";\r\nimport { ZonePlanReportService } from \"services/ZonePlanReportService\";\r\nimport { CentralPlanReportService } from \"services/CentralPlanReportService\";\r\nimport { OrganizationType } from \"models/OrganizationType\";\r\nimport { ExcelReportType } from \"models/ExcelReportType\";\r\nimport { PlanReportHeaderData } from \"resources/plan-report-header/PlanReportHeaderData\";\r\nimport { SignalrWrapper } from \"signalrwrapper\";\r\nimport { CentralReportUpdated } from \"resources/plan-report-header/CentralReportUpdated\";\r\nimport { StateReportUpdated } from \"resources/plan-report-header/StateReportUpdated\";\r\nimport { ZoneReportUpdated } from \"resources/plan-report-header/ZoneReportUpdated\";\r\nimport { UnitReportUpdated } from \"resources/plan-report-header/UnitReportUpdated\";\r\nimport { YesNo } from \"resources/yes-no-dialog/YesNo\";\r\nimport { AppRouter } from \"aurelia-router\";\r\nimport { ReportStatus } from \"models/ReportStatus\";\r\nimport { ReportingFrequency } from \"models/ReportingFrequency\";\r\nimport { AuthService } from \"auth-service\";\r\n\r\n@containerless\r\n@autoinject\r\nexport class PlanReportShell {\r\n isDownloadingList = false;\r\n isDownloadingDetail = false;\r\n isResettingPlan = false;\r\n isResettingYPlanFromQ = false;\r\n isResettingReport = false;\r\n isResettingYReportFromQ = false;\r\n isRecalculatingPlan = false;\r\n isRecalculatingYPlanFromQ = false;\r\n isRecalculatingReport = false;\r\n isRecalculatingYReportFromQ = false;\r\n signalreventhandlers: any = {};\r\n\r\n @bindable({ defaultBindingMode: bindingMode.oneWay }) headerData: PlanReportHeaderData;\r\n @bindable({ defaultBindingMode: bindingMode.oneWay }) organizationType: OrganizationType;\r\n @bindable({ defaultBindingMode: bindingMode.oneWay }) itemId: number;\r\n @bindable({ defaultBindingMode: bindingMode.oneWay }) reportStatus: ReportStatus;\r\n\r\n constructor(\r\n public appRouter: AppRouter,\r\n public auth: AuthService,\r\n\r\n public unitService: UnitPlanReportService,\r\n public stateService: StatePlanReportService,\r\n public zoneService: ZonePlanReportService,\r\n public centralService: CentralPlanReportService,\r\n public dialogService: DialogService,\r\n public signalr: SignalrWrapper,\r\n public ea: EventAggregator) {\r\n this.signalreventhandlers = {\r\n \"UnitReportUpdated\": this.onUnitReportUpdated,\r\n \"UnitReportUpdateFailed\": this.onUnitReportUpdateFailed,\r\n \"ZoneReportUpdated\": this.onZoneReportUpdated,\r\n \"ZoneReportUpdateFailed\": this.onZoneReportUpdateFailed,\r\n \"StateReportUpdated\": this.onStateReportUpdated,\r\n \"StateReportUpdateFailed\": this.onStateReportUpdateFailed,\r\n \"CentralReportUpdated\": this.onCentralReportUpdated,\r\n \"CentralReportUpdateFailed\": this.onCentralReportUpdateFailed\r\n };\r\n }\r\n\r\n async attached() {\r\n for (const key in this.signalreventhandlers) {\r\n if (this.signalreventhandlers.hasOwnProperty(key)) {\r\n this.signalr.on(key, this.signalreventhandlers[key]);\r\n }\r\n }\r\n }\r\n\r\n detached() {\r\n for (const key in this.signalreventhandlers) {\r\n if (this.signalreventhandlers.hasOwnProperty(key)) {\r\n this.signalr.off(key, this.signalreventhandlers[key]);\r\n }\r\n }\r\n }\r\n\r\n get copydownloadservice(): UnitPlanReportService | StatePlanReportService | ZonePlanReportService | CentralPlanReportService {\r\n switch(this.headerData.organization.organizationType) {\r\n case OrganizationType.Unit: return this.unitService;\r\n case OrganizationType.Zone: return this.zoneService;\r\n case OrganizationType.State: return this.stateService;\r\n case OrganizationType.Central: return this.centralService;\r\n default: throw new Error(\"Not Implemented\");\r\n }\r\n }\r\n\r\n get resetrecalculateservice(): StatePlanReportService | ZonePlanReportService | CentralPlanReportService {\r\n switch(this.headerData.organization.organizationType) {\r\n case OrganizationType.Zone: return this.zoneService;\r\n case OrganizationType.State: return this.stateService;\r\n case OrganizationType.Central: return this.centralService;\r\n default: throw new Error(\"Not Implemented\");\r\n }\r\n }\r\n\r\n async downloadAsList() {\r\n this.isDownloadingList = true;\r\n const blob = await this.copydownloadservice.downloadReport(this.headerData.id, ExcelReportType.List);\r\n this.isDownloadingList = false;\r\n if(!blob) {\r\n toastr.error(\"Error downloading\")\r\n return;\r\n }\r\n saveAs(blob, `${this.headerData.id}.xlsx`);\r\n }\r\n\r\n async downloadAsDetail() {\r\n this.isDownloadingDetail = true;\r\n const blob = await this.copydownloadservice.downloadReport(this.headerData.id, ExcelReportType.Detail);\r\n this.isDownloadingDetail = false;\r\n if(!blob) {\r\n toastr.error(\"Error downloading\")\r\n return;\r\n }\r\n saveAs(blob, `${this.headerData.id}.xlsx`);\r\n }\r\n\r\n async resetPlan() {\r\n const shouldReset = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to override only plan, excluding report, with `Generated Data`?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n\r\n if(!shouldReset) return;\r\n\r\n this.isResettingPlan = true;\r\n try {\r\n await this.resetrecalculateservice.resetPlan(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isResettingPlan = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Overriding plan submitted\");\r\n }\r\n\r\n async resetYPlanFromQ() {\r\n const shouldReset = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to override only plan, excluding report, with `Generated Data` and `Own Generated Data`?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n\r\n if(!shouldReset) return;\r\n\r\n this.isResettingYPlanFromQ = true;\r\n try {\r\n await this.resetrecalculateservice.resetYPlanFromQ(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isResettingYPlanFromQ = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Overriding plan submitted\");\r\n }\r\n\r\n async resetReport() {\r\n const shouldReset = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to override only report, excluding plan, with `Generated Data`?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n\r\n if(!shouldReset) return;\r\n\r\n this.isResettingReport = true;\r\n try {\r\n await this.resetrecalculateservice.resetReport(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isResettingReport = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Overriding report submitted\");\r\n }\r\n\r\n async resetYReportFromQ() {\r\n const shouldReset = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to override only report, excluding plan, with `Generated Data` and `Own Generated Data`?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n\r\n if(!shouldReset) return;\r\n\r\n this.isResettingYReportFromQ = true;\r\n try {\r\n await this.resetrecalculateservice.resetYReportFromQ(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isResettingYReportFromQ = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Overriding report submitted\");\r\n }\r\n\r\n async recalculatePlan() {\r\n const shouldRecalculate = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to recalculate `Generated Data` of only plan, excluding report, from child plans?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n if(!shouldRecalculate) return;\r\n\r\n this.isRecalculatingPlan = true;\r\n try {\r\n await this.resetrecalculateservice.recalculatePlan(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isRecalculatingPlan = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Recalculation for plan submitted\");\r\n }\r\n\r\n async recalculateYPlanFromQ() {\r\n const shouldRecalculate = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to recalculate `Generated Data` and `Own Generated Data` of only yearly plan, excluding report, from own quarter plans?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n if(!shouldRecalculate) return;\r\n\r\n this.isRecalculatingYPlanFromQ = true;\r\n try {\r\n await this.resetrecalculateservice.recalculateYPlanFromQ(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isRecalculatingYPlanFromQ = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Recalculation for plan submitted\");\r\n }\r\n\r\n async recalculateReport() {\r\n const shouldRecalculate = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to recalculate `Generated Data` of only report, excluding plan, from child reports?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n if(!shouldRecalculate) return;\r\n\r\n this.isRecalculatingReport = true;\r\n try {\r\n await this.resetrecalculateservice.recalculateReport(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isRecalculatingReport = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Recalculation for report submitted\");\r\n }\r\n\r\n async recalculateYReportFromQ() {\r\n const shouldRecalculate = await this.dialogService.open({\r\n viewModel: PLATFORM.moduleName(\"resources/yes-no-dialog/yes-no-dialog\"),\r\n model: new YesNo(\r\n \"Are you sure you want to recalculate `Generated Data` and `Own Generated Data` of only yearly report, excluding plan, from own quarter reports?\",\r\n \"\"\r\n ),\r\n })\r\n .whenClosed(response => {\r\n if(response.wasCancelled) return false;\r\n return true;\r\n });\r\n if(!shouldRecalculate) return;\r\n\r\n this.isRecalculatingYReportFromQ = true;\r\n try {\r\n await this.resetrecalculateservice.recalculateYReportFromQ(this.headerData.organization.id, this.headerData.id);\r\n } catch(error) {\r\n this.isRecalculatingYReportFromQ = false;\r\n console.log(error);\r\n toastr.error(error);\r\n return;\r\n }\r\n toastr.success(\"Recalculation for report submitted\");\r\n }\r\n\r\n isActive(routehref: string) {\r\n const route = this.appRouter.routes.find(r => r.href === routehref);\r\n const result= route\r\n ? route.navModel.isActive\r\n : false;\r\n return result;\r\n }\r\n\r\n get canDownload() {\r\n return (\r\n this.headerData &&\r\n this.headerData.id &&\r\n !this.isDownloadingList &&\r\n !this.isDownloadingDetail &&\r\n !this.isResettingPlan &&\r\n !this.isResettingYPlanFromQ &&\r\n !this.isResettingReport &&\r\n !this.isResettingYReportFromQ &&\r\n !this.isRecalculatingPlan &&\r\n !this.isRecalculatingReport &&\r\n !this.isRecalculatingYPlanFromQ &&\r\n !this.isRecalculatingYReportFromQ\r\n );\r\n }\r\n\r\n get canReset() {\r\n return (\r\n this.headerData &&\r\n this.headerData.id &&\r\n !this.isDownloadingList &&\r\n !this.isDownloadingDetail &&\r\n !this.isResettingPlan &&\r\n !this.isResettingYPlanFromQ &&\r\n !this.isResettingReport &&\r\n !this.isResettingYReportFromQ &&\r\n !this.isRecalculatingPlan &&\r\n !this.isRecalculatingReport &&\r\n !this.isRecalculatingYPlanFromQ &&\r\n !this.isRecalculatingYReportFromQ\r\n );\r\n }\r\n\r\n get canRecalculate() {\r\n return (\r\n this.headerData &&\r\n this.headerData.id &&\r\n !this.isDownloadingList &&\r\n !this.isDownloadingDetail &&\r\n !this.isResettingPlan &&\r\n !this.isResettingYPlanFromQ &&\r\n !this.isResettingReport &&\r\n !this.isResettingYReportFromQ &&\r\n !this.isRecalculatingPlan &&\r\n !this.isRecalculatingReport &&\r\n !this.isRecalculatingYPlanFromQ &&\r\n !this.isRecalculatingYReportFromQ\r\n );\r\n }\r\n\r\n get isReportingFrequencyYearly() {\r\n return this.headerData.reportingPeriod.reportingFrequency === ReportingFrequency.Yearly;\r\n }\r\n\r\n get isOrganizationTypeUnit() {\r\n return this.headerData.organization.organizationType === OrganizationType.Unit;\r\n }\r\n\r\n get isOrganizationTypeZone() {\r\n return this.headerData.organization.organizationType === OrganizationType.Zone;\r\n }\r\n\r\n get isOrganizationTypeState() {\r\n return this.headerData.organization.organizationType === OrganizationType.State;\r\n }\r\n\r\n get isOrganizationTypeCentral() {\r\n return this.headerData.organization.organizationType === OrganizationType.Central;\r\n }\r\n\r\n get isOrganizationTypeNotUnit() {\r\n return this.headerData.organization.organizationType !== OrganizationType.Unit;\r\n }\r\n\r\n get isReportStatusUnsubmitted() {\r\n return this.reportStatus !== ReportStatus.Submitted;\r\n }\r\n\r\n get canEditLastPeriod() {\r\n return this.auth.isSystemAdmin && this.reportStatus === ReportStatus.Submitted;\r\n }\r\n\r\n get canCopy() {\r\n return this.reportStatus === ReportStatus.Submitted;\r\n }\r\n\r\n clearResetRecalculateFlags() {\r\n this.isResettingPlan = false;\r\n this.isResettingYPlanFromQ = false;\r\n this.isResettingReport = false;\r\n this.isResettingYReportFromQ = false;\r\n this.isRecalculatingPlan = false;\r\n this.isRecalculatingYPlanFromQ = false;\r\n this.isRecalculatingReport = false;\r\n this.isRecalculatingYReportFromQ = false;\r\n }\r\n\r\n onUnitReportUpdated = async (id: number) => {\r\n this.clearResetRecalculateFlags();\r\n this.ea.publish(new UnitReportUpdated());\r\n }\r\n\r\n onUnitReportUpdateFailed = (e: {$values: string[]}) => {\r\n this.clearResetRecalculateFlags();\r\n toastr.error(e.$values.join(\"\\n\"));\r\n }\r\n\r\n onZoneReportUpdated = async (id: number) => {\r\n this.clearResetRecalculateFlags();\r\n this.ea.publish(new ZoneReportUpdated());\r\n }\r\n\r\n onZoneReportUpdateFailed = (e: {$values: string[]}) => {\r\n this.clearResetRecalculateFlags();\r\n toastr.error(e.$values.join(\"\\n\"));\r\n }\r\n\r\n onStateReportUpdated = async (id: number) => {\r\n this.clearResetRecalculateFlags();\r\n this.ea.publish(new StateReportUpdated());\r\n }\r\n\r\n onStateReportUpdateFailed = (e: {$values: string[]}) => {\r\n this.clearResetRecalculateFlags();\r\n toastr.error(e.$values.join(\"\\n\"));\r\n }\r\n\r\n onCentralReportUpdated = async (id: number) => {\r\n this.clearResetRecalculateFlags();\r\n this.ea.publish(new CentralReportUpdated());\r\n }\r\n\r\n onCentralReportUpdateFailed = (e: {$values: string[]}) => {\r\n this.clearResetRecalculateFlags();\r\n toastr.error(e.$values.join(\"\\n\"));\r\n }\r\n}\r\n","module.exports = \"\\r\\n\";"],"sourceRoot":""}