Files
cbsnexora/src/app/accounting/financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component.ts
T
Ralph HopmanandAdam Saghy cac1d11ad7 build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
2025-01-15 11:59:30 +00:00

67 lines
2.3 KiB
TypeScript

/** Angular Imports */
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
/** Custom Services */
import { AccountingService } from '../../accounting.service';
/** Custom Components */
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
import { Location } from '@angular/common';
/**
* View financial activity mapping component.
*/
@Component({
selector: 'mifosx-view-financial-activity-mapping',
templateUrl: './view-financial-activity-mapping.component.html',
styleUrls: ['./view-financial-activity-mapping.component.scss']
})
export class ViewFinancialActivityMappingComponent {
/** Financial activity account ID. */
financialActivityAccountId: any;
/** Financial activity account data. */
financialActivityAccount: any;
/**
* Retrieves the financial activity account data from `resolve`.
* @param {AccountingService} accountingService Accounting Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
*/
constructor(
private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private location: Location
) {
this.route.data.subscribe((data: { financialActivityAccount: any }) => {
this.financialActivityAccount = data.financialActivityAccount;
this.financialActivityAccountId = data.financialActivityAccount.id;
});
}
/**
* Deletes the financial activity account and redirects to financial activity mappings.
*/
deleteFinancialActivityAccount() {
const deleteFinancialActivityAccountDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `financial activity mapping ${this.financialActivityAccountId}` }
});
deleteFinancialActivityAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountingService.deleteFinancialActivityAccount(this.financialActivityAccountId).subscribe(() => {
this.router.navigate(['/accounting/financial-activity-mappings']);
});
}
});
}
goBack(): void {
this.location.back();
}
}