forked from xurror/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: edit and delete financial activity mapping
Add edit financial activity component and delete dialog component.
- Loading branch information
1 parent
8ebfd61
commit ff8e878
Showing
15 changed files
with
279 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 31 additions & 26 deletions
57
...ppings/create-financial-activity-mapping/create-financial-activity-mapping.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
<mat-card class="container"> | ||
<form [formGroup]="financialActivityMappingForm" (ngSubmit)="submit()"> | ||
<div class="container"> | ||
|
||
<mat-card-content> | ||
<mat-card> | ||
|
||
<form [formGroup]="financialActivityMappingForm" (ngSubmit)="submit()"> | ||
|
||
<div fxLayout="column"> | ||
<mat-card-content> | ||
|
||
<mat-form-field> | ||
<mat-select placeholder="Financial Activity" required formControlName="financialActivityId"> | ||
<mat-option *ngFor="let financialActivity of financialActivityData" [value]="financialActivity.id"> | ||
{{ financialActivity.name }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
<div fxLayout="column"> | ||
|
||
<mat-form-field> | ||
<mat-select placeholder="Account" required formControlName="glAccountId"> | ||
<mat-option *ngFor="let glAccount of glAccountData" [value]="glAccount.id"> | ||
{{ glAccount.name + ' (' + glAccount.glCode + ')' }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-select placeholder="Financial Activity" required formControlName="financialActivityId"> | ||
<mat-option *ngFor="let financialActivity of financialActivityData" [value]="financialActivity.id"> | ||
{{ financialActivity.name }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
|
||
</div> | ||
<mat-form-field> | ||
<mat-select placeholder="Account" required formControlName="glAccountId"> | ||
<mat-option *ngFor="let glAccount of glAccountData" [value]="glAccount.id"> | ||
{{ glAccount.name + ' (' + glAccount.glCode + ')' }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
|
||
</mat-card-content> | ||
</div> | ||
|
||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px"> | ||
<button type="button" mat-raised-button [routerLink]="['/accounting/financial-activity-mappings']">Cancel</button> | ||
<button mat-raised-button color="primary">Submit</button> | ||
</mat-card-actions> | ||
</mat-card-content> | ||
|
||
</form> | ||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px"> | ||
<button type="button" mat-raised-button [routerLink]="['/accounting/financial-activity-mappings']">Cancel</button> | ||
<button mat-raised-button color="primary">Submit</button> | ||
</mat-card-actions> | ||
|
||
</mat-card> | ||
</form> | ||
|
||
</mat-card> | ||
|
||
</div> |
40 changes: 40 additions & 0 deletions
40
...y-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div class="container"> | ||
|
||
<mat-card> | ||
|
||
<form [formGroup]="financialActivityMappingForm" (ngSubmit)="submit()"> | ||
|
||
<mat-card-content> | ||
|
||
<div fxLayout="column"> | ||
|
||
<mat-form-field> | ||
<mat-select placeholder="Financial Activity" required formControlName="financialActivityId"> | ||
<mat-option *ngFor="let financialActivity of financialActivityData" [value]="financialActivity.id"> | ||
{{ financialActivity.name }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
|
||
<mat-form-field> | ||
<mat-select placeholder="Account" required formControlName="glAccountId"> | ||
<mat-option *ngFor="let glAccount of glAccountData" [value]="glAccount.id"> | ||
{{ glAccount.name + ' (' + glAccount.glCode + ')' }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
|
||
</div> | ||
|
||
</mat-card-content> | ||
|
||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px"> | ||
<button type="button" mat-raised-button [routerLink]="['/accounting/financial-activity-mappings/view', financialActivityAccountId]">Cancel</button> | ||
<button mat-raised-button color="primary">Submit</button> | ||
</mat-card-actions> | ||
|
||
</form> | ||
|
||
</mat-card> | ||
|
||
</div> |
3 changes: 3 additions & 0 deletions
3
...y-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.container { | ||
max-width: 37rem; | ||
} |
25 changes: 25 additions & 0 deletions
25
...appings/edit-financial-activity-mapping/edit-financial-activity-mapping.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { EditFinancialActivityMappingComponent } from './edit-financial-activity-mapping.component'; | ||
|
||
describe('EditFinancialActivityMappingComponent', () => { | ||
let component: EditFinancialActivityMappingComponent; | ||
let fixture: ComponentFixture<EditFinancialActivityMappingComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ EditFinancialActivityMappingComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(EditFinancialActivityMappingComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
73 changes: 73 additions & 0 deletions
73
...ity-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
|
||
import { AccountingService } from '../../accounting.service'; | ||
|
||
@Component({ | ||
selector: 'mifosx-edit-financial-activity-mapping', | ||
templateUrl: './edit-financial-activity-mapping.component.html', | ||
styleUrls: ['./edit-financial-activity-mapping.component.scss'] | ||
}) | ||
export class EditFinancialActivityMappingComponent implements OnInit { | ||
|
||
financialActivityMappingForm: FormGroup; | ||
glAccountOptions: any; | ||
glAccountData: any; | ||
financialActivityAccountId: any; | ||
financialActivityData: any; | ||
|
||
constructor(private route: ActivatedRoute, | ||
private formBuider: FormBuilder, | ||
private accountingService: AccountingService, | ||
private router: Router) { } | ||
|
||
ngOnInit() { | ||
this.financialActivityAccountId = this.route.snapshot.paramMap.get('id'); | ||
this.createFinancialActivityMappingForm(); | ||
this.setGLAccountData(); | ||
this.getFinancialActivityAccount(); | ||
} | ||
|
||
createFinancialActivityMappingForm() { | ||
this.financialActivityMappingForm = this.formBuider.group({ | ||
'financialActivityId': ['', Validators.required], | ||
'glAccountId': ['', Validators.required] | ||
}); | ||
} | ||
|
||
getFinancialActivityAccount() { | ||
this.accountingService.getFinancialActivityAccount(this.financialActivityAccountId, true) | ||
.subscribe((financialActivityAccountData: any) => { | ||
this.glAccountOptions = financialActivityAccountData.glAccountOptions; | ||
this.financialActivityData = financialActivityAccountData.financialActivityOptions; | ||
this.financialActivityMappingForm.get('financialActivityId').setValue(financialActivityAccountData.financialActivityData.id); | ||
this.financialActivityMappingForm.get('glAccountId').setValue(financialActivityAccountData.glAccountData.id); | ||
}); | ||
} | ||
|
||
setGLAccountData() { | ||
this.financialActivityMappingForm.get('financialActivityId').valueChanges.subscribe(financialActivityId => { | ||
switch (financialActivityId) { | ||
case 100: | ||
case 101: | ||
case 102: | ||
case 103: this.glAccountData = this.glAccountOptions.assetAccountOptions; | ||
break; | ||
case 200: | ||
case 201: this.glAccountData = this.glAccountOptions.liabilityAccountOptions; | ||
break; | ||
case 300: this.glAccountData = this.glAccountOptions.equityAccountOptions; | ||
break; | ||
} | ||
}); | ||
} | ||
|
||
submit() { | ||
this.accountingService.updateFinancialActivityAccount(this.financialActivityAccountId, this.financialActivityMappingForm.value) | ||
.subscribe((response: any) => { | ||
this.router.navigate(['/accounting/financial-activity-mappings/view', response.resourceId]); | ||
}); | ||
} | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
...y-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<h1 mat-dialog-title>Delete</h1> | ||
<div mat-dialog-content> | ||
<p>Are you sure you want to delete {{ data.deleteContext }} ?</p> | ||
</div> | ||
<mat-dialog-actions align="end"> | ||
<button mat-button mat-dialog-close>Cancel</button> | ||
<button mat-button [mat-dialog-close]="{ delete: true }">Confirm</button> | ||
</mat-dialog-actions> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/shared/delete-dialog/delete-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DeleteDialogComponent } from './delete-dialog.component'; | ||
|
||
describe('DeleteDialogComponent', () => { | ||
let component: DeleteDialogComponent; | ||
let fixture: ComponentFixture<DeleteDialogComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DeleteDialogComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DeleteDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, OnInit, Inject } from '@angular/core'; | ||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; | ||
|
||
@Component({ | ||
selector: 'mifosx-delete-dialog', | ||
templateUrl: './delete-dialog.component.html', | ||
styleUrls: ['./delete-dialog.component.scss'] | ||
}) | ||
export class DeleteDialogComponent implements OnInit { | ||
|
||
constructor(public dialogRef: MatDialogRef<DeleteDialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) public data: any) { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
Oops, something went wrong.