Move out DatePipe to use in one place Dates

This commit is contained in:
Jose Alberto Hernandez
2022-06-29 14:34:01 -05:00
parent 5bc9f0dac0
commit 5eeaed3ee9
75 changed files with 295 additions and 287 deletions
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, ViewChild } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Components */
import { SavingsAccountDetailsStepComponent } from '../savings-account-stepper/savings-account-details-step/savings-account-details-step.component';
@@ -11,6 +10,7 @@ import { SavingsAccountChargesStepComponent } from '../savings-account-stepper/s
/** Custom Services */
import { SavingsService } from '../savings.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Create Savings Account Component
@@ -38,13 +38,13 @@ export class CreateSavingsAccountComponent {
* Fetches savings account template from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Utils
* @param {Dates} dateUtils Date Utils
* @param {SavingsService} savingsService Savings Service
* @param {SettingsService} settingsService Settings Service
*/
constructor(private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private savingsService: SavingsService,
private settingsService: SettingsService
) {
@@ -113,7 +113,7 @@ export class CreateSavingsAccountComponent {
feeOnMonthDay: charge.feeOnMonthDay,
feeInterval: charge.feeInterval
})),
submittedOnDate: this.datePipe.transform(this.savingsAccount.submittedOnDate, dateFormat),
submittedOnDate: this.dateUtils.formatDate(this.savingsAccount.submittedOnDate, dateFormat),
dateFormat,
monthDayFormat,
locale
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, ViewChild } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Components */
import { SavingsAccountDetailsStepComponent } from '../savings-account-stepper/savings-account-details-step/savings-account-details-step.component';
@@ -11,6 +10,7 @@ import { SavingsAccountChargesStepComponent } from '../savings-account-stepper/s
/** Custom Services */
import { SavingsService } from '../savings.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Edit Savings Account Component
@@ -38,13 +38,13 @@ export class EditSavingsAccountComponent {
* Fetches savings account template from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Utils
* @param {Dates} dateUtils Date Utils
* @param {SavingsService} savingsService Savings Service
* @param {SettingsService} settingsService Settings Service
*/
constructor(private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private savingsService: SavingsService,
private settingsService: SettingsService
) {
@@ -114,11 +114,11 @@ export class EditSavingsAccountComponent {
charges: this.savingsAccount.charges.map((charge: any) => ({
chargeId: charge.id,
amount: charge.amount,
dueDate: this.datePipe.transform(charge.dueDate, dateFormat),
feeOnMonthDay: this.datePipe.transform(charge.feeOnMonthDay, dateFormat),
dueDate: this.dateUtils.formatDate(charge.dueDate, dateFormat),
feeOnMonthDay: this.dateUtils.formatDate(charge.feeOnMonthDay, dateFormat),
feeInterval: charge.feeInterval
})),
submittedOnDate: this.datePipe.transform(this.savingsAccount.submittedOnDate, dateFormat),
submittedOnDate: this.dateUtils.formatDate(this.savingsAccount.submittedOnDate, dateFormat),
dateFormat,
monthDayFormat,
locale
@@ -2,7 +2,6 @@
import { Component, OnInit, OnChanges, Input } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Custom Dialogs */
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
@@ -11,6 +10,7 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
import { Dates } from 'app/core/utils/dates';
/**
* Savings Account Charges Step
@@ -44,7 +44,7 @@ export class SavingsAccountChargesStepComponent implements OnInit, OnChanges {
* @param {MatDialog} dialog Mat Dialog
*/
constructor(public dialog: MatDialog,
private datePipe: DatePipe) {}
private dateUtils: Dates) {}
ngOnInit() {
this.currencyCode.valueChanges.subscribe(() => {
@@ -127,7 +127,7 @@ export class SavingsAccountChargesStepComponent implements OnInit, OnChanges {
if (response.data) {
let newCharge: any;
const dateFormat = 'dd MMMM yyyy';
const date = this.datePipe.transform(response.data.value.date, dateFormat);
const date = this.dateUtils.formatDate(response.data.value.date, dateFormat);
switch (charge.chargeTimeType.value) {
case 'Specified due date':
case 'Weekly Fee':
@@ -3,7 +3,6 @@ import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { MatTableDataSource, MatTable } from '@angular/material/table';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -19,6 +18,7 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
import { Dates } from 'app/core/utils/dates';
/**
* Charges Tab Component
@@ -62,12 +62,12 @@ export class ChargesTabComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
* @param {DatePipe} datePipe DatePipe.
* @param {Dates} dateUtils Date Utils.
* @param {SettingsService} settingsService Setting service
*/
constructor(private savingsService: SavingsService,
private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private router: Router,
public dialog: MatDialog,
private settingsService: SettingsService) {
@@ -131,7 +131,7 @@ export class ChargesTabComponent implements OnInit {
const dateFormat = this.settingsService.dateFormat;
const dataObject = {
...response.data.value,
dueDate: this.datePipe.transform(response.data.value.dueDate, dateFormat),
dueDate: this.dateUtils.formatDate(response.data.value.dueDate, dateFormat),
dateFormat,
locale
};
@@ -3,7 +3,6 @@ import { Component, OnChanges, OnInit, Input, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatTable } from '@angular/material/table';
import { MatDialog } from '@angular/material/dialog';
import { DatePipe } from '@angular/common';
/** Custom Dialogs */
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
@@ -19,6 +18,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke
/** Custom Services */
import { SavingsService } from '../../../savings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Savings Account Multi Row Data Tables
@@ -50,13 +50,13 @@ export class MultiRowComponent implements OnInit, OnChanges {
/**
* Fetches savings account Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Utils.
* @param {Dates} dateUtils Date Utils.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Setting service
*/
constructor(private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private savingsService: SavingsService,
private dialog: MatDialog,
private settingsService: SettingsService) {
@@ -151,7 +151,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
addDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
dateTransformColumns.forEach((column) => {
response.data.value[column] = this.datePipe.transform(response.data.value[column], dataTableEntryObject.dateFormat);
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
});
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
this.savingsService.addSavingsDatatableEntry(this.savingAccountId, this.datatableName, dataTableEntryObject).subscribe(() => {
@@ -2,7 +2,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { DatePipe } from '@angular/common';
/** Custom Components */
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
@@ -18,6 +17,7 @@ import { CheckboxBase } from 'app/shared/form-dialog/formfield/model/checkbox-ba
/** Custom Services */
import { SavingsService } from '../../../savings.service';
import { Dates } from 'app/core/utils/dates';
/**
@@ -41,13 +41,13 @@ export class SingleRowComponent implements OnInit {
/**
* Fetches savings account Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Utils.
* @param {Dates} dateUtils Date Utils.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Setting service
*/
constructor(private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private dialog: MatDialog,
private savingsService: SavingsService,
private settingsService: SettingsService) {
@@ -82,7 +82,7 @@ export class SingleRowComponent implements OnInit {
addDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
dateTransformColumns.forEach((column) => {
response.data.value[column] = this.datePipe.transform(response.data.value[column], dataTableEntryObject.dateFormat);
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
});
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
this.savingsService.addSavingsDatatableEntry(this.savingAccountId, this.datatableName, dataTableEntryObject).subscribe(() => {
@@ -117,7 +117,7 @@ export class SingleRowComponent implements OnInit {
editDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
dateTransformColumns.forEach((column) => {
response.data.value[column] = this.datePipe.transform(response.data.value[column], dataTableEntryObject.dateFormat);
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
});
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
this.savingsService.editSavingsDatatableEntry(this.savingAccountId, this.datatableName, dataTableEntryObject).subscribe(() => {
@@ -2,7 +2,6 @@
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -10,6 +9,7 @@ import { SettingsService } from 'app/settings/settings.service';
/** Custom Dialogs */
import { UndoTransactionDialogComponent } from '../../custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component';
import { Dates } from 'app/core/utils/dates';
/**
* View Transaction Component.
@@ -31,12 +31,12 @@ export class ViewTransactionComponent {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
* @param {DatePipe} datePipe DatePipe.
* @param {Dates} dateUtils Date Utils.
* @param {SettingsService} settingsService Setting service
*/
constructor(private savingsService: SavingsService,
private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private router: Router,
public dialog: MatDialog,
private settingsService: SettingsService) {
@@ -56,7 +56,7 @@ export class ViewTransactionComponent {
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const data = {
transactionDate: this.datePipe.transform(this.transactionData.date && new Date(this.transactionData.date), dateFormat),
transactionDate: this.dateUtils.formatDate(this.transactionData.date && new Date(this.transactionData.date), dateFormat),
transactionAmount: 0,
dateFormat,
locale
@@ -2,7 +2,6 @@
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -18,6 +17,7 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
import { Dates } from 'app/core/utils/dates';
/**
* View Charge Component.
@@ -40,12 +40,12 @@ export class ViewChargeComponent {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
* @param {DatePipe} datePipe DatePipe.
* @param {Dates} dateUtils Date Utils.
* @param {SettingsService} settingsService Setting service
*/
constructor(private savingsService: SavingsService,
private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private router: Router,
public dialog: MatDialog,
private settingsService: SettingsService) {
@@ -89,7 +89,7 @@ export class ViewChargeComponent {
const dateFormat = this.settingsService.dateFormat;
const dataObject = {
...response.data.value,
dueDate: this.datePipe.transform(response.data.value.dueDate, dateFormat),
dueDate: this.dateUtils.formatDate(response.data.value.dueDate, dateFormat),
dateFormat,
locale
};
+1 -2
View File
@@ -1,6 +1,5 @@
/** Angular Imports */
import { NgModule } from '@angular/core';
import { DatePipe } from '@angular/common';
/** Custom Modules */
import { SavingsRoutingModule } from './savings-routing.module';
@@ -99,6 +98,6 @@ import { ApplyAnnualFeesSavingsAccountComponent } from './saving-account-actions
EditTransactionComponent,
ApplyAnnualFeesSavingsAccountComponent
],
providers: [DatePipe]
providers: [ ]
})
export class SavingsModule {}