+55
@@ -0,0 +1,55 @@
|
||||
<form [formGroup]="savingsAccountDetailsForm">
|
||||
|
||||
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<mat-label>Product Name</mat-label>
|
||||
<mat-select formControlName="productId" required>
|
||||
<mat-option *ngFor="let product of productData" [value]="product.id">
|
||||
{{ product.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error>
|
||||
Product Name is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<mat-label>Submitted On</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="submittedOnDatePicker"
|
||||
formControlName="submittedOnDate" required>
|
||||
<mat-datepicker-toggle matSuffix [for]="submittedOnDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #submittedOnDatePicker></mat-datepicker>
|
||||
<mat-error>
|
||||
Submission Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<mat-label>Field Officer</mat-label>
|
||||
<mat-select formControlName="fieldOfficerId">
|
||||
<mat-option *ngFor="let officer of fieldOfficerData" [value]="officer.id">
|
||||
{{ officer.displayName }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<mat-label>External ID</mat-label>
|
||||
<input matInput formControlName="externalId">
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
<div fxLayout="row" class="margin-t" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
|
||||
<button mat-raised-button matStepperPrevious disabled>
|
||||
<fa-icon icon="arrow-left"></fa-icon>
|
||||
Previous
|
||||
</button>
|
||||
<button mat-raised-button matStepperNext>
|
||||
Next
|
||||
<fa-icon icon="arrow-right"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SavingsAccountDetailsStepComponent } from './savings-account-details-step.component';
|
||||
|
||||
describe('SavingsAccountDetailsStepComponent', () => {
|
||||
let component: SavingsAccountDetailsStepComponent;
|
||||
let fixture: ComponentFixture<SavingsAccountDetailsStepComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SavingsAccountDetailsStepComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SavingsAccountDetailsStepComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
|
||||
/**
|
||||
* Savings Account Details Step
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-savings-account-details-step',
|
||||
templateUrl: './savings-account-details-step.component.html',
|
||||
styleUrls: ['./savings-account-details-step.component.scss']
|
||||
})
|
||||
export class SavingsAccountDetailsStepComponent implements OnInit {
|
||||
|
||||
/** Savings Account Template */
|
||||
@Input() savingsAccountTemplate: any;
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Product Data */
|
||||
productData: any;
|
||||
/** Field Officer Data */
|
||||
fieldOfficerData: any;
|
||||
/** Savings Account Details Form */
|
||||
savingsAccountDetailsForm: FormGroup;
|
||||
|
||||
/** Savings Account Template with product data */
|
||||
@Output() savingsAccountProductTemplate = new EventEmitter();
|
||||
|
||||
/**
|
||||
* Sets share account details form.
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {SavingsService} savingsService Savings Service.
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private savingsService: SavingsService) {
|
||||
this.createSavingsAccountDetailsForm();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.buildDependencies();
|
||||
if (this.savingsAccountTemplate) {
|
||||
this.productData = this.savingsAccountTemplate.productOptions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates savings account details form.
|
||||
*/
|
||||
createSavingsAccountDetailsForm() {
|
||||
this.savingsAccountDetailsForm = this.formBuilder.group({
|
||||
'productId': ['', Validators.required],
|
||||
'submittedOnDate': ['', Validators.required],
|
||||
'fieldOfficerId': [''],
|
||||
'externalId': ['']
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches savings account product template on productId value changes
|
||||
*/
|
||||
buildDependencies() {
|
||||
const clientId = this.savingsAccountTemplate.clientId;
|
||||
this.savingsAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => {
|
||||
this.savingsService.getSavingsAccountTemplate(clientId, productId).subscribe((response: any) => {
|
||||
this.savingsAccountProductTemplate.emit(response);
|
||||
this.savingsAccountDetailsForm.get('fieldOfficerId').patchValue('');
|
||||
this.fieldOfficerData = response.fieldOfficerOptions;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns savings account form value.
|
||||
*/
|
||||
get savingsAccountDetails() {
|
||||
return this.savingsAccountDetailsForm.value;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user