-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add modal for edit import action
- create modal action component - call modal on edit import and next button step - add model modalData - remove deleteModal (replace by new component) [Refs]: https://github.com/orgs/PnX-SI/projects/13?pane=issue&itemId=82942301 Reviewed-by: andriacap
- Loading branch information
Showing
17 changed files
with
411 additions
and
100 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
frontend/src/app/modules/imports/components/action-modal/action-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div | ||
class="modal-header" | ||
[attr.data-qa]="modalData.headerDataQa" | ||
> | ||
<h4 class="modal-title pull-left">{{ modalData.title }}</h4> | ||
<button | ||
type="button" | ||
class="close pull-right" | ||
aria-label="Close" | ||
(click)="c()" | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
<p>{{ modalData.bodyMessage }}</p> | ||
<p | ||
*ngIf="modalData.additionalMessage" | ||
class="attention-message" | ||
> | ||
{{ modalData.additionalMessage }} | ||
</p> | ||
|
||
<button | ||
type="button" | ||
(click)="c()" | ||
mat-raised-button | ||
class="mr-1" | ||
> | ||
{{ modalData.cancelButtonText || 'Annuler' }} | ||
</button> | ||
|
||
<button | ||
type="button" | ||
(click)="performAction()" | ||
mat-raised-button | ||
[color]="modalData.confirmButtonColor || 'primary'" | ||
[attr.data-qa]="modalData.confirmButtonDataQa" | ||
> | ||
{{ modalData.confirmButtonText || 'Confirmer' }} | ||
</button> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
frontend/src/app/modules/imports/components/action-modal/action-modal.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.attention-message { | ||
color: red; | ||
font-weight: bold; | ||
} |
58 changes: 58 additions & 0 deletions
58
frontend/src/app/modules/imports/components/action-modal/action-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | ||
import { CommonService } from '@geonature_common/service/common.service'; | ||
import { ImportDataService } from '../../services/data.service'; | ||
import { Import } from '../../models/import.model'; | ||
import { ModalData } from '../../models/modal-data.model'; | ||
|
||
@Component({ | ||
selector: 'import-action-modal', | ||
templateUrl: './action-modal.component.html', | ||
styleUrls: ['./action-modal.component.scss'], | ||
}) | ||
export class ModalActionImport implements OnInit { | ||
@Input() data: Import; | ||
@Input() c: any; | ||
@Input() actionType: 'delete' | 'edit' = 'delete'; | ||
@Input() modalData: ModalData = { | ||
title: 'Confirmation', | ||
bodyMessage: 'Êtes-vous sûr de vouloir effectuer cette action ?', | ||
additionalMessage: '', | ||
cancelButtonText: 'Annuler', | ||
confirmButtonText: 'Confirmer', | ||
confirmButtonColor: 'warn', | ||
headerDataQa: 'generic-modal-header', | ||
confirmButtonDataQa: 'modal-confirm-action', | ||
}; | ||
@Output() onAction = new EventEmitter<{ confirmed: boolean; actionType: string; data?: any }>(); | ||
|
||
constructor( | ||
private _commonService: CommonService, | ||
private _ds: ImportDataService | ||
) {} | ||
|
||
ngOnInit() {} | ||
|
||
// Méthode générique pour traiter les actions | ||
performAction() { | ||
if (this.actionType === 'delete') { | ||
this.deleteImport(); | ||
} else if (this.actionType === 'edit') { | ||
this.editImport(); | ||
} | ||
} | ||
|
||
// Supprimer l'import | ||
deleteImport() { | ||
this._ds.deleteImport(this.data.id_import).subscribe(() => { | ||
this._commonService.translateToaster('success', 'Import.ImportStatus.DeleteSuccessfully'); | ||
this.onAction.emit({ confirmed: true, actionType: this.actionType, data: this.data }); | ||
this.c(); | ||
}); | ||
} | ||
|
||
// Modifier l'import | ||
editImport() { | ||
this.onAction.emit({ confirmed: true, actionType: this.actionType, data: this.data }); | ||
this.c(); | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
frontend/src/app/modules/imports/components/delete-modal/delete-modal.component.html
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
frontend/src/app/modules/imports/components/delete-modal/delete-modal.component.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.