-
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 route to tabs synthese info (#3169)
feat(synthese) : Enable a route to go directly to specific tabs (taxonomy, metadata, etc...) of the detailed view of an observation. --------- Co-authored-by: jacquesfize <[email protected]>
- Loading branch information
1 parent
87c12e9
commit d7f8b6a
Showing
8 changed files
with
630 additions
and
457 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
frontend/src/app/shared/syntheseSharedModule/synthese-info-obs-container.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,50 @@ | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { Subject } from 'rxjs'; | ||
import { takeUntil } from 'rxjs/operators'; | ||
import { SyntheseInfoObsComponent } from './synthese-info-obs/synthese-info-obs.component'; | ||
import { Location } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'pnx-synthese-info-obs-modal-container', | ||
template: '', | ||
}) | ||
export class SyntheseObsModalWrapperComponent implements OnDestroy { | ||
destroy = new Subject<any>(); | ||
currentDialog = null; | ||
dialogResult: any; | ||
constructor( | ||
private modalService: NgbModal, | ||
private location: Location, | ||
route: ActivatedRoute | ||
) { | ||
route.params.pipe(takeUntil(this.destroy)).subscribe((params) => { | ||
// When router navigates on this component is takes the params | ||
// and opens up the photo detail modal | ||
this.currentDialog = this.modalService.open(SyntheseInfoObsComponent, { | ||
size: 'lg', | ||
windowClass: 'large-modal', | ||
}); | ||
this.currentDialog.componentInstance.idSynthese = params.id_synthese; | ||
this.currentDialog.componentInstance.selectedTab = params.tab; | ||
this.currentDialog.componentInstance.useFrom = 'synthese'; | ||
this.currentDialog.componentInstance.header = true; | ||
|
||
// Go back to home page after the modal is closed | ||
this.dialogResult = this.currentDialog.result.then( | ||
(result) => { | ||
this.location.back(); | ||
}, | ||
(reason) => { | ||
this.location.back(); | ||
} | ||
); | ||
}); | ||
} | ||
ngOnDestroy(): void { | ||
this.destroy.next(); | ||
this.currentDialog?.close(-1); | ||
this.dialogResult = null; | ||
} | ||
} |
Oops, something went wrong.