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:
+43
-22
@@ -1,8 +1,11 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { AccountingService } from '../accounting.service';
|
||||
|
||||
/**
|
||||
* Financial activity mappings component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-financial-activity-mappings',
|
||||
templateUrl: './financial-activity-mappings.component.html',
|
||||
@@ -10,32 +13,50 @@ import { AccountingService } from '../accounting.service';
|
||||
})
|
||||
export class FinancialActivityMappingsComponent implements OnInit {
|
||||
|
||||
/** Financial activity account data. */
|
||||
financialActivityAccountData: any;
|
||||
/** Columns to be displayed in financial activity mappings table. */
|
||||
displayedColumns: string[] = ['financialActivity', 'glAccountName', 'glAccountCode'];
|
||||
dataSource: any;
|
||||
/** Data source for financial activity mappings table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for financial activity mappings table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for financial activity mappings table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private accountingService: AccountingService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.getFinancialActivityAccounts();
|
||||
}
|
||||
|
||||
getFinancialActivityAccounts() {
|
||||
this.accountingService.getFinancialActivityAccounts().subscribe((financialActivityAccounts: any) => {
|
||||
this.dataSource = new MatTableDataSource(financialActivityAccounts);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sortingDataAccessor = (financialActivityAccount: any, property: any) => {
|
||||
switch (property) {
|
||||
case 'financialActivity': return financialActivityAccount.financialActivityData.name;
|
||||
case 'glAccountName': return financialActivityAccount.glAccountData.name;
|
||||
case 'glAccountCode': return financialActivityAccount.glAccountData.glCode;
|
||||
default: return financialActivityAccount[property];
|
||||
}
|
||||
};
|
||||
this.dataSource.sort = this.sort;
|
||||
/**
|
||||
* Retrieves the financial activity accounts data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { financialActivityAccounts: any }) => {
|
||||
this.financialActivityAccountData = data.financialActivityAccounts;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the financial activity mappings table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setFinancialActivityAccounts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for financial activity mappings table.
|
||||
*/
|
||||
setFinancialActivityAccounts() {
|
||||
this.dataSource = new MatTableDataSource(this.financialActivityAccountData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sortingDataAccessor = (financialActivityAccount: any, property: any) => {
|
||||
switch (property) {
|
||||
case 'financialActivity': return financialActivityAccount.financialActivityData.name;
|
||||
case 'glAccountName': return financialActivityAccount.glAccountData.name;
|
||||
case 'glAccountCode': return financialActivityAccount.glAccountData.glCode;
|
||||
default: return financialActivityAccount[property];
|
||||
}
|
||||
};
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user