From 6015f92be40ceaf972ef73fa41b04f37b652e91c Mon Sep 17 00:00:00 2001 From: Andria Capai Date: Wed, 22 Jan 2025 18:03:28 +0100 Subject: [PATCH] refact: add logic to check if import is done - Add method and accessor get to check if import is completed - Replace code where checking if import is completed Reviewed-by: andriacap --- .../components/import_list/import-list.component.ts | 2 +- .../import_process/import-process.service.ts | 13 +++++++++++++ .../import_report/import_report.component.html | 2 +- .../import_report/import_report.component.ts | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/modules/imports/components/import_list/import-list.component.ts b/frontend/src/app/modules/imports/components/import_list/import-list.component.ts index f2d6564d38..ecc1091b20 100644 --- a/frontend/src/app/modules/imports/components/import_list/import-list.component.ts +++ b/frontend/src/app/modules/imports/components/import_list/import-list.component.ts @@ -186,7 +186,7 @@ export class ImportListComponent implements OnInit { // Prépare les données de la modale en fonction de l'action if (actionType === 'edit') { let additionalMessage:string; - if(!!this.selectedRow.date_end_import) { + if(this.importProcessService.checkImportDone(this.selectedRow)) { additionalMessage = 'Attention : Vous vous apprêtez à modifier un import terminé. Toute modification entraînera la suppression des données importées.' } else { additionalMessage = 'Attention : à chaque confirmation de chaque étape de cet import en cours , les données seront écrasées.' diff --git a/frontend/src/app/modules/imports/components/import_process/import-process.service.ts b/frontend/src/app/modules/imports/components/import_process/import-process.service.ts index fa69769471..5913430092 100644 --- a/frontend/src/app/modules/imports/components/import_process/import-process.service.ts +++ b/frontend/src/app/modules/imports/components/import_process/import-process.service.ts @@ -98,4 +98,17 @@ export class ImportProcessService { this.importData = importData; this.navigateToStep(this.getLastAvailableStep()); } + + + checkImportDone(importData: Import): boolean { + return !!importData?.date_end_import; + } + + + get isImportCompleted(): boolean { + return this.importData ? this.checkImportDone(this.importData) : false; + } + + + } diff --git a/frontend/src/app/modules/imports/components/import_report/import_report.component.html b/frontend/src/app/modules/imports/components/import_report/import_report.component.html index d36189cdb9..93668bbb6d 100644 --- a/frontend/src/app/modules/imports/components/import_report/import_report.component.html +++ b/frontend/src/app/modules/imports/components/import_report/import_report.component.html @@ -428,7 +428,7 @@
Périmètre géographique des données importées Afficher dans {{ this.importData.destination.label }} diff --git a/frontend/src/app/modules/imports/components/import_report/import_report.component.ts b/frontend/src/app/modules/imports/components/import_report/import_report.component.ts index 0b0c937261..5517848185 100644 --- a/frontend/src/app/modules/imports/components/import_report/import_report.component.ts +++ b/frontend/src/app/modules/imports/components/import_report/import_report.component.ts @@ -118,7 +118,7 @@ export class ImportReportComponent implements OnInit { */ loadValidData(importData: Import | null) { if (importData) { - if (importData.date_end_import && importData.id_source) { + if (this.importProcessService.isImportCompleted && importData.id_source) { this._dataService.getBbox(importData.id_source).subscribe((data) => { this.validBbox = data; }); @@ -224,7 +224,7 @@ export class ImportReportComponent implements OnInit { if (this.importData?.task_progress === -1) { this.importStatus = 'EN ERREUR'; this.importStatusClass = 'inerror'; - } else if (this.importData?.date_end_import) { + } else if (this.importProcessService.isImportCompleted) { this.importStatus = 'TERMINE'; this.importStatusClass = 'importdone'; }