done
This commit is contained in:
+29
@@ -8,6 +8,7 @@
|
||||
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
@@ -38,6 +39,8 @@ import { ViewDividendComponent } from '../../../products/share-products/view-div
|
||||
export class DividendRequestsComponent implements OnInit {
|
||||
private service = inject(PendingDividendsService);
|
||||
private productsService = inject(ProductsService);
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
|
||||
rows: any[] = [];
|
||||
loading = false;
|
||||
@@ -51,9 +54,30 @@ export class DividendRequestsComponent implements OnInit {
|
||||
viewDividendId: number | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.openRequestedDeclaration();
|
||||
this.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the breakdown straight away when the officer arrived here from a specific declaration.
|
||||
*
|
||||
* The Dividends list sends them here to approve one declaration in particular, so making them
|
||||
* find its row again in a list of every pending declaration would undo the point of the link.
|
||||
* Read from the query string rather than a service so a refreshed or shared URL still opens the
|
||||
* same declaration.
|
||||
*/
|
||||
private openRequestedDeclaration(): void {
|
||||
const params = this.route.snapshot.queryParams;
|
||||
const productId = Number(params['productId']);
|
||||
const dividendId = Number(params['dividendId']);
|
||||
if (!productId || !dividendId) {
|
||||
return;
|
||||
}
|
||||
this.viewProductId = productId;
|
||||
this.viewDividendId = dividendId;
|
||||
this.showViewModal = true;
|
||||
}
|
||||
|
||||
openView(row: any): void {
|
||||
this.viewProductId = row.productId;
|
||||
this.viewDividendId = row.dividendId;
|
||||
@@ -64,6 +88,11 @@ export class DividendRequestsComponent implements OnInit {
|
||||
this.showViewModal = false;
|
||||
this.viewProductId = null;
|
||||
this.viewDividendId = null;
|
||||
// Dropped from the URL as well, or the declaration the officer just closed would reopen on the
|
||||
// next refresh and there would be no way to get back to the plain list.
|
||||
if (this.route.snapshot.queryParams['dividendId']) {
|
||||
this.router.navigate([], { relativeTo: this.route, queryParams: {}, replaceUrl: true });
|
||||
}
|
||||
}
|
||||
|
||||
onViewActionCompleted(): void {
|
||||
|
||||
Reference in New Issue
Block a user