diff --git a/src/app/products/charges/charges.component.html b/src/app/products/charges/charges.component.html new file mode 100644 index 000000000..23493cbca --- /dev/null +++ b/src/app/products/charges/charges.component.html @@ -0,0 +1,57 @@ +
+ +
+ +
+ +
+ + Filter + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Name {{ charge.name }} Charge Applies To {{ charge.chargeAppliesTo.value }} Is Penalty? + + + Status +
+ +
+
+ + + +
+ +
diff --git a/src/app/products/charges/charges.component.scss b/src/app/products/charges/charges.component.scss new file mode 100644 index 000000000..678bf8f3d --- /dev/null +++ b/src/app/products/charges/charges.component.scss @@ -0,0 +1,23 @@ +table { + width: 100%; + + .select-row:hover { + cursor: pointer; + } +} + +.true { + color: #32cd32; +} + +.false { + color: #f44366; +} + +.ispenalty { + color: #32cd32; +} + +.nopenalty { + color: #f44366; +} diff --git a/src/app/products/charges/charges.component.spec.ts b/src/app/products/charges/charges.component.spec.ts new file mode 100644 index 000000000..ddd24e84d --- /dev/null +++ b/src/app/products/charges/charges.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ChargesComponent } from './charges.component'; + +describe('ChargesComponent', () => { + let component: ChargesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ChargesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ChargesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/products/charges/charges.component.ts b/src/app/products/charges/charges.component.ts new file mode 100644 index 000000000..fd7f00f54 --- /dev/null +++ b/src/app/products/charges/charges.component.ts @@ -0,0 +1,71 @@ +/** Angular Imports */ +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; +import { ActivatedRoute } from '@angular/router'; + +/** rxjs Imports */ +import { of } from 'rxjs'; + +/** + * Charges component. + */ +@Component({ + selector: 'mifosx-charges', + templateUrl: './charges.component.html', + styleUrls: ['./charges.component.scss'] +}) +export class ChargesComponent implements OnInit { + + /** Charge data. */ + chargeData: any; + /** Columns to be displayed in charges table. */ + displayedColumns: string[] = ['name', 'chargeAppliesTo', 'penalty', 'active']; + /** Data source for charges table. */ + dataSource: MatTableDataSource; + + /** Paginator for charges table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for charges table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the charges data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe(( data: { charges: any }) => { + this.chargeData = data.charges; + }); + } + + /** + * Filters data in charges table based on passed value. + * @param {string} filterValue Value to filter data. + */ + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + /** + * Sets the charges table. + */ + ngOnInit() { + this.setCharges(); + } + + /** + * Initializes the data source, paginator and sorter for charges table. + */ + setCharges() { + this.dataSource = new MatTableDataSource(this.chargeData); + this.dataSource.paginator = this.paginator; + this.dataSource.sortingDataAccessor = (charge: any, property: any) => { + switch (property) { + case 'chargeAppliesTo': return charge.chargeAppliesTo.value; + default: return charge[property]; + } + }; + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/products/charges/charges.resolver.ts b/src/app/products/charges/charges.resolver.ts new file mode 100644 index 000000000..eca5b1c5c --- /dev/null +++ b/src/app/products/charges/charges.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { ProductsService } from '../products.service'; + +/** + * Charges data resolver. + */ +@Injectable() +export class ChargesResolver implements Resolve { + + /** + * @param {ProductsService} productsService Products service. + */ + constructor(private productsService: ProductsService) {} + + /** + * Returns the products data. + * @returns {Observable} + */ + resolve(): Observable { + return this.productsService.getCharges(); + } + +} diff --git a/src/app/products/products-routing.module.ts b/src/app/products/products-routing.module.ts index 43f43e42b..17ffcd5a3 100644 --- a/src/app/products/products-routing.module.ts +++ b/src/app/products/products-routing.module.ts @@ -12,9 +12,11 @@ import { extract } from '../core/i18n/i18n.service'; import { ProductsComponent } from './products.component'; import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component'; import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component'; +import { ChargesComponent } from './charges/charges.component'; /** Custom Resolvers */ import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver'; +import { ChargesResolver } from './charges/charges.resolver'; /** Products Routes */ const routes: Routes = [ @@ -40,6 +42,14 @@ const routes: Routes = [ }, data: { title: extract('Recurring Deposit Products'), breadcrumb: 'Recurring Deposit Products' }, }, + { + path: 'charges', + component: ChargesComponent, + resolve: { + charges: ChargesResolver + }, + data: { title: extract('Charges'), breadcrumb: 'Charges' }, + }, ] } ]) @@ -55,6 +65,7 @@ const routes: Routes = [ exports: [RouterModule], providers: [ RecurringDepositProductsResolver, + ChargesResolver, ] }) export class ProductsRoutingModule { } diff --git a/src/app/products/products.component.html b/src/app/products/products.component.html index 6d283125e..b351c8f7e 100644 --- a/src/app/products/products.component.html +++ b/src/app/products/products.component.html @@ -32,7 +32,7 @@

Add new share product or modify or inactivate share product

- + diff --git a/src/app/products/products.module.ts b/src/app/products/products.module.ts index 4c62e0cfb..e34e65e90 100644 --- a/src/app/products/products.module.ts +++ b/src/app/products/products.module.ts @@ -9,6 +9,7 @@ import { ProductsRoutingModule } from './products-routing.module'; import { ProductsComponent } from './products.component'; import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component'; import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component'; +import { ChargesComponent } from './charges/charges.component'; /** * Products Module @@ -23,7 +24,8 @@ import { RecurringDepositProductsComponent } from './recurring-deposit-products/ declarations: [ ProductsComponent, ManageTaxConfigurationsComponent, - RecurringDepositProductsComponent + RecurringDepositProductsComponent, + ChargesComponent ], entryComponents: [ ] diff --git a/src/app/products/products.service.ts b/src/app/products/products.service.ts index 9281c26d4..996736a8e 100644 --- a/src/app/products/products.service.ts +++ b/src/app/products/products.service.ts @@ -26,4 +26,12 @@ export class ProductsService { return this.http.get('/recurringdepositproducts'); } + /** + * @param {any} Fetches charges. + * @returns {Observable} + */ + getCharges(): Observable { + return this.http.get('/charges'); + } + }