Skip to content

Commit

Permalink
refact: add logic to check if import is done
Browse files Browse the repository at this point in the history
- Add method and accessor get to check if import is completed
- Replace code where checking if import is completed

Reviewed-by: andriacap
  • Loading branch information
andriacap committed Jan 22, 2025
1 parent fee3af7 commit 737412a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class ImportStepComponent implements OnInit {
}

checkBeforeNextStep(){
if (!!this.importData?.date_end_import) {
if (this.importProcessService.isImportCompleted) {
this.openModal(this.editModal);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ <h5 class="card-title mt-1">Périmètre géographique des données importées</h
[routerLink]="'/' + this.importData.destination.module.module_path"
[queryParams]="{ id_import: this.importData.id_import }"
color="primary"
[disabled]="importData?.date_end_import === null"
[disabled]="!importProcessService.isImportCompleted"
>
Afficher dans {{ this.importData.destination.label }}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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';
}
Expand Down

0 comments on commit 737412a

Please sign in to comment.