Format date fields without patch form

This commit is contained in:
Jose Alberto Hernandez
2022-06-10 10:34:19 +02:00
committed by Arnold Gálovics
parent 9d43181cea
commit 6ea3d97538
191 changed files with 1408 additions and 1173 deletions
@@ -38,7 +38,7 @@ export class CreateSharesAccountComponent {
* Fetches shares account template from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe
* @param {DatePipe} datePipe Date Utils
* @param {SharesService} sharesService Shares Service
* @param {SettingsService} settingsService Settings Service
*/
@@ -38,7 +38,7 @@ export class EditSharesAccountComponent {
* Fetches shares account template from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe
* @param {DatePipe} datePipe Date Utils
* @param {SharesService} sharesService Shares Service
* @param {SettingsService} settingsService Settings Service
*/
@@ -1,12 +1,12 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Activate Shares Account Component
@@ -30,14 +30,14 @@ export class ActivateSharesAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private formBuilder: FormBuilder,
private sharesService: SharesService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -65,15 +65,15 @@ export class ActivateSharesAccountComponent implements OnInit {
* if successful redirects to the share account.
*/
submit() {
// TODO: Update once language and date settings are setup
const activateSharesAccountFormData = this.activateSharesAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevActivatedDate: Date = this.activateSharesAccountForm.value.activatedDate;
this.activateSharesAccountForm.patchValue({
activatedDate: this.datePipe.transform(prevActivatedDate, dateFormat),
});
if (activateSharesAccountFormData.activatedDate instanceof Date) {
activateSharesAccountFormData.activatedDate = this.dateUtils.formatDate(prevActivatedDate, dateFormat);
}
const data = {
...this.activateSharesAccountForm.value,
...activateSharesAccountFormData,
dateFormat,
locale
};
@@ -1,12 +1,12 @@
/** Angular Imports */
import { Component, OnInit, Input } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Apply Shares Component
@@ -33,14 +33,14 @@ export class ApplySharesComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service
*/
constructor(private formBuilder: FormBuilder,
private sharesService: SharesService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -76,15 +76,15 @@ export class ApplySharesComponent implements OnInit {
* if successful redirects to the share account.
*/
submit() {
// TODO: Update once language and date settings are setup
const applySharesFormData = this.applySharesForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevRequestedDate: Date = this.applySharesForm.value.requestedDate;
this.applySharesForm.patchValue({
requestedDate: this.datePipe.transform(prevRequestedDate, dateFormat),
});
if (applySharesFormData.requestedDate instanceof Date) {
applySharesFormData.requestedDate = this.dateUtils.formatDate(prevRequestedDate, dateFormat);
}
const data = {
...this.applySharesForm.value,
...applySharesFormData,
unitPrice: this.applySharesForm.get('unitPrice').value,
dateFormat,
locale
@@ -1,12 +1,12 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Approve Shares Account Component
@@ -30,14 +30,14 @@ export class ApproveSharesAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private formBuilder: FormBuilder,
private sharesService: SharesService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -66,15 +66,15 @@ export class ApproveSharesAccountComponent implements OnInit {
* if successful redirects to the share account.
*/
submit() {
// TODO: Update once language and date settings are setup
const approveSharesAccountFormData = this.approveSharesAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevApprovedDate: Date = this.approveSharesAccountForm.value.approvedDate;
this.approveSharesAccountForm.patchValue({
approvedDate: this.datePipe.transform(prevApprovedDate, dateFormat),
});
if (approveSharesAccountFormData.approvedDate instanceof Date) {
approveSharesAccountFormData.approvedDate = this.dateUtils.formatDate(prevApprovedDate, dateFormat);
}
const data = {
...this.approveSharesAccountForm.value,
...approveSharesAccountFormData,
dateFormat,
locale
};
@@ -1,12 +1,12 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Close Shares Account Component
@@ -30,14 +30,14 @@ export class CloseSharesAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private formBuilder: FormBuilder,
private sharesService: SharesService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -66,15 +66,15 @@ export class CloseSharesAccountComponent implements OnInit {
* if successful redirects to the share account.
*/
submit() {
// TODO: Update once language and date settings are setup
const closeSharesAccountFormData = this.closeSharesAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevClosedDate: Date = this.closeSharesAccountForm.value.closedDate;
this.closeSharesAccountForm.patchValue({
closedDate: this.datePipe.transform(prevClosedDate, dateFormat),
});
if (closeSharesAccountFormData.closedDate instanceof Date) {
closeSharesAccountFormData.closedDate = this.dateUtils.formatDate(prevClosedDate, dateFormat);
}
const data = {
...this.closeSharesAccountForm.value,
...closeSharesAccountFormData,
dateFormat,
locale
};
@@ -1,12 +1,12 @@
/** Angular Imports */
import { Component, OnInit, Input } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Redeem Shares Component
@@ -33,14 +33,14 @@ export class RedeemSharesComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private formBuilder: FormBuilder,
private sharesService: SharesService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -76,15 +76,15 @@ export class RedeemSharesComponent implements OnInit {
* if successful redirects to the share account.
*/
submit() {
// TODO: Update once language and date settings are setup
const redeemSharesFormData = this.redeemSharesForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevRequestedDate: Date = this.redeemSharesForm.value.requestedDate;
this.redeemSharesForm.patchValue({
requestedDate: this.datePipe.transform(prevRequestedDate, dateFormat),
});
if (redeemSharesFormData.requestedDate instanceof Date) {
redeemSharesFormData.requestedDate = this.dateUtils.formatDate(prevRequestedDate, dateFormat);
}
const data = {
...this.redeemSharesForm.value,
...redeemSharesFormData,
unitPrice: this.redeemSharesForm.get('unitPrice').value,
dateFormat,
locale
@@ -1,12 +1,12 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Reject Shares Account Component
@@ -30,14 +30,14 @@ export class RejectSharesAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service
*/
constructor(private formBuilder: FormBuilder,
private sharesService: SharesService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -66,15 +66,15 @@ export class RejectSharesAccountComponent implements OnInit {
* if successful redirects to the share account.
*/
submit() {
// TODO: Update once language and date settings are setup
const rejectSharesAccountFormData = this.rejectSharesAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevRejectedDate: Date = this.rejectSharesAccountForm.value.rejectedDate;
this.rejectSharesAccountForm.patchValue({
rejectedDate: this.datePipe.transform(prevRejectedDate, dateFormat),
});
if (rejectSharesAccountFormData.rejectedDate instanceof Date) {
rejectSharesAccountFormData.rejectedDate = this.dateUtils.formatDate(prevRejectedDate, dateFormat);
}
const data = {
...this.rejectSharesAccountForm.value,
...rejectSharesAccountFormData,
dateFormat,
locale
};