Skip to content

Commit

Permalink
feat: add route to tabs synthese info (#3169)
Browse files Browse the repository at this point in the history
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
andriacap and jacquesfize authored Oct 7, 2024
1 parent 87c12e9 commit d7f8b6a
Show file tree
Hide file tree
Showing 8 changed files with 630 additions and 457 deletions.
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;
}
}
Loading

0 comments on commit d7f8b6a

Please sign in to comment.