Format date fields without patch form
This commit is contained in:
committed by
Arnold Gálovics
parent
9d43181cea
commit
6ea3d97538
+6
-6
@@ -30,7 +30,7 @@
|
||||
|
||||
<mat-form-field class="m-t-20" *ngIf="closeSavingsAccountForm.controls['amount']">
|
||||
<mat-label>Transaction Amount</mat-label>
|
||||
<input type=number required matInput formControlName="amount"/>
|
||||
<input type="number" required matInput formControlName="amount"/>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="closeSavingsAccountForm.controls['paymentTypeId']">
|
||||
@@ -49,27 +49,27 @@
|
||||
<fa-icon [icon]="!addPaymentDetailsFlag ? 'plus-circle' : 'minus-circle'" size="lg"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<mat-form-field *ngIf="closeSavingsAccountForm.controls['accountNumber']">
|
||||
<mat-label>Account Number</mat-label>
|
||||
<input type="number" formControlName="accountNumber" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
<mat-form-field *ngIf="closeSavingsAccountForm.controls['checkNumber']">
|
||||
<mat-label>Cheque</mat-label>
|
||||
<input type="number" formControlName="checkNumber" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
<mat-form-field *ngIf="closeSavingsAccountForm.controls['routingCode']">
|
||||
<mat-label>Routing Code</mat-label>
|
||||
<input formControlName="routingCode" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
<mat-form-field *ngIf="closeSavingsAccountForm.controls['receiptNumber']">
|
||||
<mat-label>Receipt Number</mat-label>
|
||||
<input formControlName="receiptNumber" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
<mat-form-field *ngIf="closeSavingsAccountForm.controls['bankNumber']">
|
||||
<mat-label>Bank</mat-label>
|
||||
<input formControlName="bankNumber" matInput />
|
||||
|
||||
+8
-8
@@ -1,8 +1,8 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
@@ -36,14 +36,14 @@ export class CloseSavingsAccountComponent implements OnInit {
|
||||
/**
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {SavingsService} savingsService Savings Service
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {Dates} dateUtils Date Utils
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
* @param {SettingsService} settingsService Setting service
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private savingsService: SavingsService,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private settingsService: SettingsService) {
|
||||
@@ -114,15 +114,15 @@ export class CloseSavingsAccountComponent implements OnInit {
|
||||
* if successful redirects to the saving account.
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
const closeSavingsAccountFormData = this.closeSavingsAccountForm.value;
|
||||
const locale = this.settingsService.language.code;
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const prevClosedOnDate: Date = this.closeSavingsAccountForm.value.closedOnDate;
|
||||
this.closeSavingsAccountForm.patchValue({
|
||||
closedOnDate: this.datePipe.transform(prevClosedOnDate, dateFormat),
|
||||
});
|
||||
if (closeSavingsAccountFormData.closedOnDate instanceof Date) {
|
||||
closeSavingsAccountFormData.closedOnDate = this.dateUtils.formatDate(prevClosedOnDate, dateFormat);
|
||||
}
|
||||
const data = {
|
||||
...this.closeSavingsAccountForm.value,
|
||||
...closeSavingsAccountFormData,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user