feat: add create loan account (#1050)
Fixes: #220 Co-authored-by: Abhijeet Singh <abhijeet40308@gmail.com>
This commit is contained in:
co-authored by
Abhijeet Singh
parent
11d74bd665
commit
843e4ed981
+39
@@ -0,0 +1,39 @@
|
||||
<h1 mat-dialog-title>Add Loan Collateral</h1>
|
||||
|
||||
<div mat-dialog-content [formGroup]="addCollateralForm" fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Collateral Type</mat-label>
|
||||
<mat-select formControlName="type" required>
|
||||
<mat-option *ngFor="let collateralType of collateralTypeData" [value]="collateralType.id">
|
||||
{{ collateralType.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error>
|
||||
Collateral Type is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Value</mat-label>
|
||||
<input type="number" matInput formControlName="value" required>
|
||||
<mat-error>
|
||||
Value is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Description</mat-label>
|
||||
<input type="text" matInput formControlName="description" required>
|
||||
<mat-error>
|
||||
Description is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
<mat-dialog-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
|
||||
<button mat-raised-button mat-dialog-close> Cancel </button>
|
||||
<button mat-raised-button color="primary" [mat-dialog-close]="{ data: addCollateralForm }"
|
||||
[disabled]="!addCollateralForm.valid || addCollateralForm.pristine">{{ layout.addButtonText }}</button>
|
||||
</mat-dialog-actions>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoansAccountAddCollateralDialogComponent } from './loans-account-add-collateral-dialog.component';
|
||||
|
||||
describe('LoansAccountAddCollateralDialogComponent', () => {
|
||||
let component: LoansAccountAddCollateralDialogComponent;
|
||||
let fixture: ComponentFixture<LoansAccountAddCollateralDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ LoansAccountAddCollateralDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LoansAccountAddCollateralDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import { Component, OnInit, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-loans-account-add-collateral-dialog',
|
||||
templateUrl: './loans-account-add-collateral-dialog.component.html',
|
||||
styleUrls: ['./loans-account-add-collateral-dialog.component.scss']
|
||||
})
|
||||
export class LoansAccountAddCollateralDialogComponent implements OnInit {
|
||||
|
||||
layout: {
|
||||
addButtonText?: string
|
||||
} = {
|
||||
addButtonText: 'Add'
|
||||
};
|
||||
|
||||
addCollateralForm: FormGroup;
|
||||
collateralTypeData: any;
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<LoansAccountAddCollateralDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private formBuilder: FormBuilder) {
|
||||
this.createAddCollateralForm();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.dialogRef.updateSize('400px');
|
||||
console.log('collateral: ', this.data.collateralTypeOptions);
|
||||
|
||||
this.collateralTypeData = this.data.collateralTypeOptions;
|
||||
}
|
||||
|
||||
createAddCollateralForm() {
|
||||
this.addCollateralForm = this.formBuilder.group({
|
||||
'type': ['', Validators.required],
|
||||
'value': ['', Validators.required],
|
||||
'description': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user