-
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.
[GN_META] Enable acquisition framework deletion (#3224)
* feat: add delete af button + update route to handle multiple authorization case * feat: add test for af deletion --------- Co-authored-by: Jacques Fize <4259846+jacquesfize@users.noreply.github.com>
- Loading branch information
1 parent
88a5bd2
commit 30918bd
Showing
11 changed files
with
226 additions
and
61 deletions.
There are no files selected for viewing
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
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
23 changes: 23 additions & 0 deletions
23
frontend/src/app/metadataModule/af/button-delete-af.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,23 @@ | ||
<ng-container [ngSwitch]="buttonType"> | ||
<button | ||
*ngSwitchCase="ButtonType.Toolbar" | ||
mat-icon-button | ||
[disabled]="disabled" | ||
matTooltip="Supprimer le cadre d'acquisition" | ||
(click)="deleteAcquisitionFramework()" | ||
style="color: black" | ||
> | ||
<mat-icon>delete</mat-icon> | ||
</button> | ||
<button | ||
*ngSwitchCase="ButtonType.Floating" | ||
mat-mini-fab | ||
color="warn" | ||
[disabled]="disabled" | ||
matTooltip="Supprimer le cadre d'acquisition" | ||
(click)="deleteAcquisitionFramework()" | ||
class="mr-2 float-right" | ||
> | ||
<mat-icon>delete</mat-icon> | ||
</button> | ||
</ng-container> |
Empty file.
63 changes: 63 additions & 0 deletions
63
frontend/src/app/metadataModule/af/button-delete-af.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,63 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { DataFormService } from '@geonature_common/form/data-form.service'; | ||
import { MetadataService } from '../services/metadata.service'; | ||
import { ConfirmationDialog } from '@geonature_common/others/modal-confirmation/confirmation.dialog'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
import { Router } from '@angular/router'; | ||
|
||
enum ButtonType { | ||
Toolbar = 'Toolbar', | ||
Floating = 'Floating', | ||
} | ||
|
||
const METADATA_URL = '/metadata'; | ||
@Component({ | ||
selector: 'gn-button-delete-af', | ||
templateUrl: './button-delete-af.component.html', | ||
styleUrls: ['./button-delete-af.component.scss'], | ||
}) | ||
export class ButtonDeleteAfComponent { | ||
readonly ButtonType = ButtonType; | ||
|
||
@Input() | ||
acquisitionFramework: any; | ||
|
||
@Input() | ||
redirectionUrl: string = METADATA_URL; | ||
|
||
@Input() | ||
buttonType: ButtonType = ButtonType.Toolbar; | ||
|
||
constructor( | ||
private _dfs: DataFormService, | ||
private _mds: MetadataService, | ||
private _dialog: MatDialog, | ||
private _router: Router | ||
) {} | ||
|
||
deleteAcquisitionFramework() { | ||
const dialogRef = this._dialog.open(ConfirmationDialog, { | ||
width: 'auto', | ||
position: { top: '5%' }, | ||
data: { | ||
message: "Voulez-vous supprimer ce cadre d'acquisition ?", | ||
yesColor: 'primary', | ||
noColor: 'warn', | ||
}, | ||
}); | ||
dialogRef.afterClosed().subscribe((result) => { | ||
if (result) { | ||
this._dfs.deleteAf(this.acquisitionFramework.id_acquisition_framework).subscribe((res) => { | ||
this._mds.getMetadata(); | ||
if (this.redirectionUrl) { | ||
this._router.navigate([this.redirectionUrl]); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
get disabled() { | ||
return !this.acquisitionFramework.cruved.D; | ||
} | ||
} |
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.