From 21fc03da43e119f3add27bdbd5d2e8e824590120 Mon Sep 17 00:00:00 2001 From: Ethan McQuarrie Date: Thu, 13 Apr 2023 09:53:38 +1200 Subject: [PATCH] WAITP-1146 Delete report alongside map overlay --- .../src/apiV2/mapOverlays/DeleteMapOverlays.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/central-server/src/apiV2/mapOverlays/DeleteMapOverlays.js b/packages/central-server/src/apiV2/mapOverlays/DeleteMapOverlays.js index b6b599aaa5..0d86bb571f 100644 --- a/packages/central-server/src/apiV2/mapOverlays/DeleteMapOverlays.js +++ b/packages/central-server/src/apiV2/mapOverlays/DeleteMapOverlays.js @@ -10,4 +10,11 @@ export class DeleteMapOverlays extends DeleteHandler { async assertUserHasAccess() { await this.assertPermissions(assertBESAdminAccess); } + + async deleteRecord() { + const mapOverlay = await this.resourceModel.findById(this.recordId); + const reportModel = mapOverlay.legacy ? this.models.legacyReport : this.models.report; + await reportModel.delete({ code: mapOverlay.report_code }); + return super.deleteRecord(); + } }