feat: edit and delete financial activity mapping
Add edit financial activity component and delete dialog component.
This commit is contained in:
@@ -10,6 +10,7 @@ import { SearchJournalEntryComponent } from './search-journal-entry/search-journ
|
||||
import { FinancialActivityMappingsComponent } from './financial-activity-mappings/financial-activity-mappings.component';
|
||||
import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component';
|
||||
import { ViewFinancialActivityMappingComponent } from './financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component';
|
||||
import { EditFinancialActivityMappingComponent } from './financial-activity-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component';
|
||||
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
@@ -62,8 +63,18 @@ const routes: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'view/:id',
|
||||
component: ViewFinancialActivityMappingComponent,
|
||||
data: {title: extract('View Financial Activity Mapping'), routeParamBreadcrumb: 'id' }
|
||||
data: { title: extract('View Financial Activity Mapping'), routeParamBreadcrumb: 'id' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: ViewFinancialActivityMappingComponent
|
||||
},
|
||||
{
|
||||
path: 'edit',
|
||||
component: EditFinancialActivityMappingComponent,
|
||||
data: { title: extract('Edit Financial Activity Mapping'), breadcrumb: 'Edit', routeParamBreadcrumb: false }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { SearchJournalEntryComponent } from './search-journal-entry/search-journ
|
||||
import { FinancialActivityMappingsComponent } from './financial-activity-mappings/financial-activity-mappings.component';
|
||||
import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component';
|
||||
import { ViewFinancialActivityMappingComponent } from './financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component';
|
||||
import { EditFinancialActivityMappingComponent } from './financial-activity-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -33,7 +34,8 @@ import { ViewFinancialActivityMappingComponent } from './financial-activity-mapp
|
||||
SearchJournalEntryComponent,
|
||||
FinancialActivityMappingsComponent,
|
||||
CreateFinancialActivityMappingComponent,
|
||||
ViewFinancialActivityMappingComponent
|
||||
ViewFinancialActivityMappingComponent,
|
||||
EditFinancialActivityMappingComponent
|
||||
],
|
||||
entryComponents: [
|
||||
RevertTransactionComponent,
|
||||
|
||||
@@ -83,8 +83,17 @@ export class AccountingService {
|
||||
return this.http.post('/financialactivityaccounts', financialActivityAccount);
|
||||
}
|
||||
|
||||
getFinancialActivityAccount(financialActivityAccountId: number) {
|
||||
return this.http.get(`/financialactivityaccounts/${financialActivityAccountId}`);
|
||||
getFinancialActivityAccount(financialActivityAccountId: number, template: boolean) {
|
||||
const httpParams = new HttpParams().set('template', template.toString());
|
||||
return this.http.get(`/financialactivityaccounts/${financialActivityAccountId}`, { params: httpParams });
|
||||
}
|
||||
|
||||
updateFinancialActivityAccount(financialActivityAccountId: number, financialActivityAccount: any) {
|
||||
return this.http.put(`/financialactivityaccounts/${financialActivityAccountId}`, financialActivityAccount);
|
||||
}
|
||||
|
||||
deleteFinancialActivityAccount(financialActivityAccountId: number) {
|
||||
return this.http.delete(`/financialactivityaccounts/${financialActivityAccountId}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+31
-26
@@ -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
@@ -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
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
+25
@@ -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
@@ -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]);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" class="container m-b-20">
|
||||
<button mat-raised-button color="primary">
|
||||
<button mat-raised-button color="primary" [routerLink]="['/accounting/financial-activity-mappings/view', financialActivityAccountId, 'edit']">
|
||||
<mat-icon>edit</mat-icon> Edit
|
||||
</button>
|
||||
<button mat-raised-button color="warn">
|
||||
<button mat-raised-button color="warn" (click)="deleteFinancialActivityAccount()">
|
||||
<mat-icon>delete</mat-icon> Delete
|
||||
</button>
|
||||
</div>
|
||||
|
||||
+22
-4
@@ -1,6 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
import { AccountingService } from '../../accounting.service';
|
||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-view-financial-activity-mapping',
|
||||
@@ -13,7 +16,9 @@ export class ViewFinancialActivityMappingComponent implements OnInit {
|
||||
financialActivityAccountData: any;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private accountingService: AccountingService) { }
|
||||
private router: Router,
|
||||
private accountingService: AccountingService,
|
||||
public dialog: MatDialog) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.financialActivityAccountId = this.route.snapshot.paramMap.get('id');
|
||||
@@ -21,11 +26,24 @@ export class ViewFinancialActivityMappingComponent implements OnInit {
|
||||
}
|
||||
|
||||
getFinancialActivityAccount() {
|
||||
this.accountingService.getFinancialActivityAccount(this.financialActivityAccountId)
|
||||
this.accountingService.getFinancialActivityAccount(this.financialActivityAccountId, false)
|
||||
.subscribe((financialActivityAccountData: any) => {
|
||||
this.financialActivityAccountData = financialActivityAccountData;
|
||||
console.log(financialActivityAccountData);
|
||||
});
|
||||
}
|
||||
|
||||
deleteFinancialActivityAccount() {
|
||||
const deleteFinancialActivityAccountDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `financial activity mapping ${this.financialActivityAccountId}` }
|
||||
});
|
||||
deleteFinancialActivityAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.accountingService.deleteFinancialActivityAccount(this.financialActivityAccountId)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/accounting/financial-activity-mappings']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { LoaderComponent } from './loader/loader.component';
|
||||
import { FileUploadComponent } from './file-upload/file-upload.component';
|
||||
import { CoreModule } from '../core/core.module';
|
||||
import { DeleteDialogComponent } from './delete-dialog/delete-dialog.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -12,11 +13,15 @@ import { CoreModule } from '../core/core.module';
|
||||
],
|
||||
declarations: [
|
||||
LoaderComponent,
|
||||
FileUploadComponent
|
||||
FileUploadComponent,
|
||||
DeleteDialogComponent
|
||||
],
|
||||
exports: [
|
||||
LoaderComponent,
|
||||
FileUploadComponent
|
||||
],
|
||||
entryComponents: [
|
||||
DeleteDialogComponent
|
||||
]
|
||||
})
|
||||
export class SharedModule { }
|
||||
|
||||
Reference in New Issue
Block a user