refractor: accounting module (#300)
* Refractor components. * Add resolvers. * Add relative router links. * Replace mat-icons by font-awesome icons. * Add comments. Fixes: #298
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
||||
<button mat-raised-button color="primary" [routerLink]="['/accounting/accounting-rules/view', accountingRule?.id, 'edit']">
|
||||
<mat-icon>edit</mat-icon> Edit
|
||||
<button mat-raised-button color="primary" [routerLink]="['edit']">
|
||||
<fa-icon icon="edit"></fa-icon>
|
||||
Edit
|
||||
</button>
|
||||
<button mat-raised-button color="warn" (click)="deleteAccountingRule()">
|
||||
<mat-icon>delete</mat-icon> Delete
|
||||
<fa-icon icon="trash"></fa-icon>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -25,11 +27,11 @@
|
||||
{{ accountingRule.officeName }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
<div fxFlex="50%" class="header" *ngIf="accountingRule.description">
|
||||
Description
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
<div fxFlex="50%" *ngIf="accountingRule.description">
|
||||
{{ accountingRule.description }}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
div {
|
||||
margin: 1rem 0;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.header {
|
||||
font-weight: 500;
|
||||
&.header {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
/** Custom Services */
|
||||
import { AccountingService } from '../../accounting.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||
|
||||
/**
|
||||
* View accounting rule component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-view-rule',
|
||||
templateUrl: './view-rule.component.html',
|
||||
@@ -12,11 +19,19 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
|
||||
})
|
||||
export class ViewRuleComponent implements OnInit {
|
||||
|
||||
/** Accounting rule. */
|
||||
accountingRule: any;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
/**
|
||||
* Retrieves the accounting rule 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 accountingService: AccountingService,
|
||||
public dialog: MatDialog) {
|
||||
this.route.data.subscribe((data: { accountingRule: any }) => {
|
||||
this.accountingRule = data.accountingRule;
|
||||
@@ -26,6 +41,9 @@ export class ViewRuleComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the accounting rule and redirects to accounting rules.
|
||||
*/
|
||||
deleteAccountingRule() {
|
||||
const deleteAccountingRuleDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `accounting rule ${this.accountingRule.id}` }
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { AccountingService } from '../../accounting.service';
|
||||
|
||||
@Injectable()
|
||||
export class ViewAccountingRuleResolver implements Resolve<Object> {
|
||||
|
||||
constructor(private accountingService: AccountingService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const id = route.paramMap.get('id');
|
||||
|
||||
return this.accountingService.getAccountingRule(id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user