Last active
May 25, 2020 10:02
-
-
Save flohw/c05d450771b1bf479b15302398dc8156 to your computer and use it in GitHub Desktop.
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
resolve(route: ActivatedRouteSnapshot): Observable<T> | Promise<T> | T { | |
return this.list.get(route.paramMap.get('id')) | |
.pipe(catchError((err: HttpErrorResponse) => { | |
if (err.status === 404) { | |
this.flashes.danger('Élément non trouvé', 'L\'élément que vous cherchez n\'exsite pas.'); | |
this.router.navigate([this.redirectTo]); | |
return EMPTY; | |
} | |
if (err.status === 500) { | |
this.flashes.danger('Erreur serveur', err.error.message); | |
this.router.navigate([this.redirectTo]); | |
return EMPTY; | |
} | |
return throwError(err); | |
})) as Observable<T> | Promise<T> | T; | |
} |
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
export class ListComponent extends GenericListSubComponent<Contract> { | |
objects$: Observable<PaginatedResult<Contract>>; | |
edit(contract: Contract): void { | |
const modal = this.modalService.open(EditComponent); | |
modal.componentInstance.object = SpreadRecursive.clone(contract); | |
modal.componentInstance.parent = SpreadRecursive.clone(this.route.parent.parent.snapshot.data.object); | |
modal.result | |
.then(() => this.updateList(this._page, this._per_page, this._sort, this._filters)) | |
.catch(() => {}); | |
} | |
constructor( | |
protected service: IndustrialContractListService, | |
protected route: ActivatedRoute, | |
protected router: Router, | |
protected flashes: FlashMessagesService, | |
protected modalService: NgbModal, | |
) { | |
super(service, route, router, flashes); | |
this.parent = this.route.parent.parent.snapshot.data.object; | |
} |
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
<ng-container *ngIf="objects$|async as contratcs"> | |
<div *ngFor="let contract of contracts._embedded.items"> | |
<button (click)="edit(contract)"></button> | |
</div> | |
</ng-container> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment