diff --git a/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.html b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.html new file mode 100644 index 000000000..aaad01d3b --- /dev/null +++ b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.html @@ -0,0 +1,135 @@ +
+ +
+ + + + + + + + +
Mapping Between Entities + + Offices --> Loan Products + + + Offices --> Savings Products + + + Offices --> Charges/Fees + + + Roles --> Loan Products + + + Roles --> Savings Products + +
+ + + + + + +
+ {{firstMappingEntity}} access to {{secondMappingEntity}} + + +
+ + + {{firstMappingEntity}} + + + All + + + {{ firstEntity.name }} + + + + {{firstMappingEntity}} is required + + + + + {{secondMappingEntity}} + + + All + + + {{ secondEntity.name }} + + + + {{secondMappingEntity}} is required + + + + + + + + + +
+ +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{firstMappingEntity}} {{ listdata.fromEntity }} {{secondMappingEntity}} {{ listdata.toEntity }} Start Date {{ listdata.startData }} End Date {{ listdata.endDate }} + + + +
+ +
+
+ +
+ +
+
+
diff --git a/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.scss b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.spec.ts b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.spec.ts new file mode 100644 index 000000000..169414902 --- /dev/null +++ b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EntityToEntityMappingComponent } from './entity-to-entity-mapping.component'; + +describe('EntityToEntityMappingComponent', () => { + let component: EntityToEntityMappingComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EntityToEntityMappingComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EntityToEntityMappingComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.ts b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.ts new file mode 100644 index 000000000..8d75498b2 --- /dev/null +++ b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.component.ts @@ -0,0 +1,186 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; +import { ActivatedRoute } from '@angular/router'; + +/** Custom Services */ +import { SystemService } from 'app/system/system.service'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; + +/** + * Entity to Entity Mapping Component + */ +@Component({ + selector: 'mifosx-entity-to-entity-mapping', + templateUrl: './entity-to-entity-mapping.component.html', + styleUrls: ['./entity-to-entity-mapping.component.scss'] +}) +export class EntityToEntityMappingComponent implements OnInit { + + /** Stores entity to entity mapping data */ + entityMappings: string[] = []; + /** Stores Id of selected mapping type */ + selectedMappingType = 0; + /** Stores Id of first Entity filter */ + selectedFromId = 0; + /** Stores Id of second Entity filter */ + selectedToId = 0; + /** Checks wheter the filter is default or customized */ + hasClickedFilters = false; + /** Selected Entity Id */ + retrieveById = 0; + /** Stores filtered data */ + filterPreference: any; + + /** + * stores the data for clicked mapType + */ + firstEntityData: string[] = []; + secondEntityData: string[] = []; + firstMappingEntity: string; + secondMappingEntity: string; + /** Data source for entity table. */ + datasource: MatTableDataSource; + /** Data source for entity to entity list data. */ + entityMappingsListData: MatTableDataSource; + /** Filter Preference Form */ + filterPreferenceForm: FormGroup; + /** List of Entity to Entity Mapping */ + displayedColumns: string[] = ['entitymapping']; + /** Columns for details of a chosen mapping */ + entityMappingListColumns: string[] = ['fromentity', 'toentity', 'startdate', 'enddate', 'edit', 'delete']; + + /** Paginator for entity table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for entity table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the codes data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute, + private formBuilder: FormBuilder, + private systemService: SystemService) { + this.route.data.subscribe((data: { entityMappings: any }) => { + this.entityMappings = data.entityMappings; + }); + } + + /** + * Creates the filter preference form. + */ + createFilterPreferenceForm() { + this.filterPreferenceForm = this.formBuilder.group({ + 'mappingFirstParamId': ['', Validators.required], + 'mappingSecondParamId': ['', Validators.required] + }); + } + + /** + * Sets the mapping table. + */ + ngOnInit() { + this.setMapping(); + } + + setMapping() { + this.datasource = new MatTableDataSource(this.entityMappings); + this.datasource.paginator = this.paginator; + this.datasource.sort = this.sort; + } + + /** + * Displays filter based on mapping id + * @param id Entity Mapping Id + */ + showFilters(id: number) { + this.selectedMappingType = id; + this.hasClickedFilters = false; + this.fetchRelatedData(this.selectedMappingType); + this.selectedFromId = 0; + this.selectedToId = 0; + } + + /** Fetches data based on the selected mapping type */ + fetchRelatedData(id: number) { + this.retrieveById = id; + this.createFilterPreferenceForm(); + switch (this.retrieveById) { + + case 1: + this.systemService.getOffices().subscribe((response: any) => { + this.firstEntityData = response; + this.firstMappingEntity = 'Office'; + }); + this.systemService.getLoanProducts().subscribe((response: any) => { + this.secondEntityData = response; + this.secondMappingEntity = 'Loan Products'; + }); + break; + case 2: + this.systemService.getOffices().subscribe((response: any) => { + this.firstEntityData = response; + this.firstMappingEntity = 'Office'; + }); + this.systemService.getSavingProducts().subscribe((response: any) => { + this.secondEntityData = response; + this.secondMappingEntity = 'Saving Products'; + }); + break; + case 3: + this.systemService.getOffices().subscribe((response: any) => { + this.firstEntityData = response; + this.firstMappingEntity = 'Office'; + }); + this.systemService.getCharges().subscribe((response: any) => { + this.secondEntityData = response; + this.secondMappingEntity = 'Charges'; + }); + break; + case 4: + this.systemService.getRoles().subscribe((response: any) => { + this.firstEntityData = response; + this.firstMappingEntity = 'Role'; + }); + this.systemService.getLoanProducts().subscribe((response: any) => { + this.secondEntityData = response; + this.secondMappingEntity = 'Loan Products'; + }); + break; + case 5: + this.systemService.getRoles().subscribe((response: any) => { + this.firstEntityData = response; + this.firstMappingEntity = 'Role'; + }); + this.systemService.getSavingProducts().subscribe((response: any) => { + this.secondEntityData = response; + this.secondMappingEntity = 'Saving Products'; + }); + break; + } + + } + + /** + * Submits the filter preference form and creates a entityMappingList data + */ + showFilteredData() { + this.filterPreference = this.filterPreferenceForm.value; + if (this.filterPreference.mappingFirstParamId === '') { + this.filterPreference.mappingFirstParamId = undefined; + } + if (this.filterPreference.mappingSecondParamId === '') { + this.filterPreference.mappingSecondParamId = undefined; + } + this.hasClickedFilters = true; + this.selectedFromId = this.filterPreference.mappingFirstParamId; + this.selectedToId = this.filterPreference.mappingSecondParamId; + this.systemService.getEntitytoEntityData(this.retrieveById, this.selectedFromId, this.selectedToId).subscribe((response: any) => { + this.entityMappingsListData = new MatTableDataSource(response); + this.entityMappingsListData.paginator = this.paginator; + this.entityMappingsListData.sort = this.sort; + }); + } + +} diff --git a/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.resolver.ts b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.resolver.ts new file mode 100644 index 000000000..6d64f765b --- /dev/null +++ b/src/app/system/entity-to-entity-mapping/entity-to-entity-mapping.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 { SystemService } from '../system.service'; + +/** + * Entity to entity mapping data resolver. + */ +@Injectable() +export class EntityToEntityMappingResolver implements Resolve { + + /** + * @param {SystemService} systemService System service. + */ + constructor(private systemService: SystemService) { } + + /** + * Returns the Mapping data. + * @returns {Observable} + */ + resolve(): Observable { + return this.systemService.getEntityMappings(); + } + +} diff --git a/src/app/system/system-routing.module.ts b/src/app/system/system-routing.module.ts index 01d994773..2def116f9 100644 --- a/src/app/system/system-routing.module.ts +++ b/src/app/system/system-routing.module.ts @@ -46,6 +46,7 @@ import { AuditTrailsComponent } from './audit-trails/audit-trails.component'; import { ViewAuditComponent } from './audit-trails/view-audit/view-audit.component'; import { ViewRoleComponent } from './roles-and-permissions/view-role/view-role.component'; import { EditRoleComponent } from './roles-and-permissions/edit-role/edit-role.component'; +import { EntityToEntityMappingComponent } from './entity-to-entity-mapping/entity-to-entity-mapping.component'; /** Custom Resolvers */ import { CodesResolver } from './codes/codes.resolver'; @@ -78,6 +79,7 @@ import { ViewSchedulerJobResolver } from './manage-scheduler-jobs/view-scheduler import { EditSchedulerJobComponent } from './manage-scheduler-jobs/edit-scheduler-job/edit-scheduler-job.component'; import { ManageSchedulerJobResolver } from './manage-scheduler-jobs/manage-scheduler-job.resolver'; import { ViewRoleResolver } from './roles-and-permissions/view-role/view-role.resolver'; +import { EntityToEntityMappingResolver } from './entity-to-entity-mapping/entity-to-entity-mapping.resolver'; const routes: Routes = [ Route.withShell([ @@ -130,6 +132,14 @@ const routes: Routes = [ ], }, + { + path: 'entity-to-entity-mapping', + component: EntityToEntityMappingComponent, + data: { title: extract('Entity to Entity Mapping'), breadcrumb: 'Entity to Entity Mapping' }, + resolve: { + entityMappings: EntityToEntityMappingResolver + } + }, { path: 'external-services', data: { title: extract('External Services'), breadcrumb: 'External Services' }, @@ -556,7 +566,8 @@ const routes: Routes = [ AuditTrailResolver, ViewSchedulerJobResolver, ManageSchedulerJobResolver, - ViewRoleResolver + ViewRoleResolver, + EntityToEntityMappingResolver ] }) export class SystemRoutingModule { } diff --git a/src/app/system/system.component.html b/src/app/system/system.component.html index 8a87b3665..b821b4ba2 100644 --- a/src/app/system/system.component.html +++ b/src/app/system/system.component.html @@ -48,7 +48,7 @@

Define Hooks

- + diff --git a/src/app/system/system.module.ts b/src/app/system/system.module.ts index cd2521938..adfee6af1 100644 --- a/src/app/system/system.module.ts +++ b/src/app/system/system.module.ts @@ -47,6 +47,7 @@ import { CreateHookComponent } from './manage-hooks/create-hook/create-hook.comp import { ColumnDialogComponent } from './manage-data-tables/column-dialog/column-dialog.component'; import { ViewRoleComponent } from './roles-and-permissions/view-role/view-role.component'; import { EditRoleComponent } from './roles-and-permissions/edit-role/edit-role.component'; +import { EntityToEntityMappingComponent } from './entity-to-entity-mapping/entity-to-entity-mapping.component'; /** Dialog Component Imports */ import { ReportParameterDialogComponent } from './manage-reports/report-parameter-dialog/report-parameter-dialog.component'; @@ -104,7 +105,8 @@ import { EditSchedulerJobComponent } from './manage-scheduler-jobs/edit-schedule ViewSchedulerJobComponent, EditSchedulerJobComponent, ViewRoleComponent, - EditRoleComponent + EditRoleComponent, + EntityToEntityMappingComponent ], entryComponents: [ ReportParameterDialogComponent, diff --git a/src/app/system/system.service.ts b/src/app/system/system.service.ts index 286e033a7..36a211ff4 100644 --- a/src/app/system/system.service.ts +++ b/src/app/system/system.service.ts @@ -459,4 +459,50 @@ export class SystemService { return this.http.get('/audits/searchtemplate'); } + /** + * @returns {Observable} Fetches Mapping Data. + */ + getEntityMappings(): Observable { + return this.http.get('/entitytoentitymapping'); + } + + /** + * @param mappingId Mapping Id. + * @param fromId From Entity ID. + * @param toId To Entity ID. + * @returns {Observable} fetches the list of mappings for particular mapping type + */ + getEntitytoEntityData(mappingId: number, fromId: number, toId: number): Observable { + return this.http.get(`/entitytoentitymapping/${mappingId}/${fromId}/${toId}`); + } + + /** + * @returns {Observable} Offices data + */ + getOffices(): Observable { + return this.http.get('/offices'); + } + + /** + * @returns {Observable} Loan products data. + */ + getLoanProducts(): Observable { + return this.http.get('/loanproducts'); + } + + /** + * @returns {Observable} Saving products data + */ + getSavingProducts(): Observable { + return this.http.get('/savingsproducts'); + } + + /** + * @returns {Observable} Charges data + */ + getCharges(): Observable { + return this.http.get('/charges'); + } + + }