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
@@ -50,7 +50,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
/**
* Fetches savings account Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {DatePipe} datePipe Date Utils.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Setting service
@@ -41,7 +41,7 @@ export class SingleRowComponent implements OnInit {
/**
* Fetches savings account Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {DatePipe} datePipe Date Utils.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Setting service
@@ -151,7 +151,7 @@ export class SingleRowComponent implements OnInit {
/**
* Maps API response to data table form fields.
* @param {any} columns Data Table Columns.
* @param {string[]} dateTransformColumns Columns transformed with date pipe.
* @param {string[]} dateTransformColumns Columns transformed with Date Utils.
* @param {any} dataTableEntryObject Additional data table details.
*/
getFormfields(columns: any, dateTransformColumns: string[], dataTableEntryObject: any) {
@@ -32,4 +32,4 @@
</form>
<iframe *ngIf="!hideOutput" [src]="pentahoUrl" frameborder="0" width=100% height="750px;"></iframe>
<iframe *ngIf="!hideOutput" [src]="pentahoUrl" frameborder="0" width="100%" height="750px;"></iframe>
@@ -2,12 +2,12 @@
import { Component, OnInit } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { ReportsService } from 'app/reports/reports.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Export Client Savings Transactions Component
@@ -37,14 +37,14 @@ export class ExportTransactionsComponent implements OnInit {
* @param {DomSanitizer} sanitizer DOM Sanitizer
* @param {ReportsService} reportsService Reports Service
* @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {SettingsService} settingsService Settings Service
*/
constructor(private sanitizer: DomSanitizer,
private reportsService: ReportsService,
private formBuilder: FormBuilder,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private settingsService: SettingsService) {
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
@@ -73,8 +73,8 @@ export class ExportTransactionsComponent implements OnInit {
generate() {
const data = {
'output-type': 'PDF',
R_startDate: this.datePipe.transform(this.transactionsReportForm.value.fromDate, this.settingsService.dateFormat),
R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, this.settingsService.dateFormat),
R_startDate: this.dateUtils.formatDate(this.transactionsReportForm.value.fromDate, this.settingsService.dateFormat),
R_endDate: this.dateUtils.formatDate(this.transactionsReportForm.value.toDate, this.settingsService.dateFormat),
R_savingsAccountId: this.savingsAccountId
};
this.reportsService.getPentahoRunReportData('Client Saving Transactions', data, 'default', this.settingsService.language.code, this.settingsService.dateFormat)
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -44,14 +44,14 @@ export class EditTransactionComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {SavingsService} savingsService Savings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe DatePipe.
* @param {Dates} dateUtils Date Utils.
* @param {Router} router Router for navigation.
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private savingsService: SavingsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { savingsAccountTransactionTemplate: any }) => {
@@ -108,16 +108,19 @@ export class EditTransactionComponent implements OnInit {
* Method to submit the transaction details.
*/
submit() {
const prevTransactionDate: Date = this.editTransactionForm.value.transactionDate;
// TODO: Update once language and date settings are setup
const editTransactionFormData = this.editTransactionForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.editTransactionForm.patchValue({
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat)
});
const transactionData = this.editTransactionForm.value;
transactionData.locale = this.settingsService.language.code;
transactionData.dateFormat = dateFormat;
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, 'modify', transactionData, this.transactionTemplateData.id)
const prevTransactionDate: Date = this.editTransactionForm.value.transactionDate;
if (editTransactionFormData.transactionDate instanceof Date) {
editTransactionFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
}
const data = {
...editTransactionFormData,
dateFormat,
locale
};
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, 'modify', data, this.transactionTemplateData.id)
.subscribe(res => {
this.router.navigate(['../'], { relativeTo: this.route });
});