feat(accounting-rules): edit and delete rule
Add edit accounting rule component and ability to delete accounting rule.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
import { AccountingService } from '../../accounting.service';
|
||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-view-rule',
|
||||
@@ -10,7 +14,10 @@ export class ViewRuleComponent implements OnInit {
|
||||
|
||||
accountingRule: any;
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private accountingService: AccountingService,
|
||||
public dialog: MatDialog) {
|
||||
this.route.data.subscribe((data: { accountingRule: any }) => {
|
||||
this.accountingRule = data.accountingRule;
|
||||
});
|
||||
@@ -19,4 +26,18 @@ export class ViewRuleComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
deleteAccountingRule() {
|
||||
const deleteAccountingRuleDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `accounting rule ${this.accountingRule.id}` }
|
||||
});
|
||||
deleteAccountingRuleDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.accountingService.deleteAccountingRule(this.accountingRule.id)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/accounting/accounting-rules']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user