diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 66daab63c..ce6d3d573 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -34,6 +34,7 @@ import { SelfServiceModule } from './self-service/self-service.module'; import { SystemModule } from './system/system.module'; import { ProductsModule } from './products/products.module'; import { OrganizationModule } from './organization/organization.module'; +import { TemplatesModule } from './templates/templates.module'; @@ -66,6 +67,7 @@ import { AppRoutingModule } from './app-routing.module'; SystemModule, ProductsModule, OrganizationModule, + TemplatesModule, AppRoutingModule, ], declarations: [WebAppComponent, NotFoundComponent], diff --git a/src/app/core/shell/toolbar/toolbar.component.html b/src/app/core/shell/toolbar/toolbar.component.html index 2ffee1563..acea733ab 100644 --- a/src/app/core/shell/toolbar/toolbar.component.html +++ b/src/app/core/shell/toolbar/toolbar.component.html @@ -104,7 +104,7 @@ - + diff --git a/src/app/templates/templates-routing.module.ts b/src/app/templates/templates-routing.module.ts new file mode 100644 index 000000000..3d45efe75 --- /dev/null +++ b/src/app/templates/templates-routing.module.ts @@ -0,0 +1,48 @@ +/** Angular Imports */ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +/** Routing Imports */ +import { Route } from '../core/route/route.service'; + +/** Translation Imports */ +import { extract } from '../core/i18n/i18n.service'; + +/** Custom Components */ +import { TemplatesComponent } from './templates.component'; + +/** Custom Resolvers */ +import { TemplatesResolver } from './templates.resolver'; + +/** Templates Routes */ +const routes: Routes = [ + Route.withShell([ + { + path: 'templates', + data: { title: extract('Templates'), breadcrumb: 'Templates' }, + children: [ + { + path: '', + component: TemplatesComponent, + resolve: { + templates: TemplatesResolver + } + } + ] + } + ]) +]; + +/** + * Templates Routing Module + * + * Configures the templates routes. + */ +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [ + TemplatesResolver + ] +}) +export class TemplatesRoutingModule { } diff --git a/src/app/templates/templates.component.html b/src/app/templates/templates.component.html new file mode 100644 index 000000000..921761dc5 --- /dev/null +++ b/src/app/templates/templates.component.html @@ -0,0 +1,45 @@ +
+ +
+ +
+ +
+ + Filter + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Entity {{ template.entity }} Type {{ template.type }} Name {{ template.name }}
+ + + +
+ +
diff --git a/src/app/templates/templates.component.scss b/src/app/templates/templates.component.scss new file mode 100644 index 000000000..1922e7ffa --- /dev/null +++ b/src/app/templates/templates.component.scss @@ -0,0 +1,3 @@ +table { + width: 100%; +} diff --git a/src/app/templates/templates.component.spec.ts b/src/app/templates/templates.component.spec.ts new file mode 100644 index 000000000..b5c63aa3e --- /dev/null +++ b/src/app/templates/templates.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TemplatesComponent } from './templates.component'; + +describe('TemplatesComponent', () => { + let component: TemplatesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TemplatesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TemplatesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/templates/templates.component.ts b/src/app/templates/templates.component.ts new file mode 100644 index 000000000..1080d9f27 --- /dev/null +++ b/src/app/templates/templates.component.ts @@ -0,0 +1,65 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material'; +import { ActivatedRoute } from '@angular/router'; + +/** rxjs Imports */ +import { of } from 'rxjs'; + +/** + * Templates component. + */ +@Component({ + selector: 'mifosx-templates', + templateUrl: './templates.component.html', + styleUrls: ['./templates.component.scss'] +}) +export class TemplatesComponent implements OnInit { + + /** Templates data. */ + templatesData: any; + /** Columns to be displayed in templates table. */ + displayedColumns: string[] = ['entity', 'type', 'name']; + /** Data source for templates table. */ + dataSource: MatTableDataSource; + + /** Paginator for templates table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for templates table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the templates data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe(( data: { templates: any }) => { + this.templatesData = data.templates; + }); + } + + /** + * Filters data in templates table based on passed value. + * @param {string} filterValue Value to filter data. + */ + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + /** + * Sets the templates table. + */ + ngOnInit() { + this.setTemplates(); + } + + /** + * Initializes the data source, paginator and sorter for templates table. + */ + setTemplates() { + this.dataSource = new MatTableDataSource(this.templatesData); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/templates/templates.module.ts b/src/app/templates/templates.module.ts new file mode 100644 index 000000000..58dd7725d --- /dev/null +++ b/src/app/templates/templates.module.ts @@ -0,0 +1,25 @@ +/** Angular Imports */ +import { NgModule } from '@angular/core'; + +/** Custom Modules */ +import { SharedModule } from '../shared/shared.module'; +import { TemplatesRoutingModule } from './templates-routing.module'; + +/** Custom Components */ +import { TemplatesComponent } from './templates.component'; + +/** + * Templates Module + * + * Templates components should be declared here. + */ +@NgModule({ + imports: [ + SharedModule, + TemplatesRoutingModule + ], + declarations: [ + TemplatesComponent + ] +}) +export class TemplatesModule { } diff --git a/src/app/templates/templates.resolver.ts b/src/app/templates/templates.resolver.ts new file mode 100644 index 000000000..809306e1c --- /dev/null +++ b/src/app/templates/templates.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 { TemplatesService } from './templates.service'; + +/** + * Templates data resolver. + */ +@Injectable() +export class TemplatesResolver implements Resolve { + + /** + * @param {TemplatesService} templatesService Templates service. + */ + constructor(private templatesService: TemplatesService) {} + + /** + * Returns the templates data. + * @returns {Observable} + */ + resolve(): Observable { + return this.templatesService.getTemplates(); + } + +} diff --git a/src/app/templates/templates.service.ts b/src/app/templates/templates.service.ts new file mode 100644 index 000000000..c50583446 --- /dev/null +++ b/src/app/templates/templates.service.ts @@ -0,0 +1,28 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** + * Templates service. + */ +@Injectable({ + providedIn: 'root' +}) +export class TemplatesService { + + /** + * @param {HttpClient} http Http Client to send requests. + */ + constructor(private http: HttpClient) { } + + /** + * @returns {Observable} Templates data + */ + getTemplates(): Observable { + return this.http.get('/templates'); + } + +}