Format date fields without patch form
This commit is contained in:
committed by
Arnold Gálovics
parent
9d43181cea
commit
6ea3d97538
+15
-12
@@ -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 { LoansService } from 'app/loans/loans.service';
|
||||
@@ -44,14 +44,14 @@ export class EditTransactionComponent implements OnInit {
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {LoansService} loansService Loans Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {DatePipe} datePipe DatePipe.
|
||||
* @param {Dates} dateUtils Date Utils.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
private loansService: LoansService,
|
||||
private settingsService: SettingsService) {
|
||||
this.route.data.subscribe((data: { loansAccountTransactionTemplate: 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.loansService.executeLoansAccountTransactionsCommand(this.loanAccountId, '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.loansService.executeLoansAccountTransactionsCommand(this.loanAccountId, 'modify', data, this.transactionTemplateData.id)
|
||||
.subscribe((res: any) => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
|
||||
+1
-1
@@ -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>
|
||||
|
||||
+5
-5
@@ -2,11 +2,11 @@
|
||||
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 { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/**
|
||||
* Export Client Loans Transactions Component
|
||||
@@ -36,13 +36,13 @@ 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
|
||||
*/
|
||||
constructor(private sanitizer: DomSanitizer,
|
||||
private reportsService: ReportsService,
|
||||
private formBuilder: FormBuilder,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
private route: ActivatedRoute) {
|
||||
this.route.parent.parent.data.subscribe((data: { loanDetailsData: any }) => {
|
||||
this.loansAccountId = data.loanDetailsData.accountNo;
|
||||
@@ -70,8 +70,8 @@ export class ExportTransactionsComponent implements OnInit {
|
||||
generate() {
|
||||
const data = {
|
||||
'output-type': 'PDF',
|
||||
R_startDate: this.datePipe.transform(this.transactionsReportForm.value.fromDate, 'yyyy-MM-dd'),
|
||||
R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'),
|
||||
R_startDate: this.dateUtils.formatDate(this.transactionsReportForm.value.fromDate, 'yyyy-MM-dd'),
|
||||
R_endDate: this.dateUtils.formatDate(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'),
|
||||
R_selectLoan: this.loansAccountId
|
||||
};
|
||||
this.reportsService.getPentahoRunReportData('Client Loan Account Schedule', data, 'default', 'en', 'dd MMMM yyyy')
|
||||
|
||||
Reference in New Issue
Block a user