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
@@ -8,10 +8,10 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
import { SettingsService } from 'app/settings/settings.service';
/** Custom Services */
import { DatePipe } from '@angular/common';
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { Dates } from 'app/core/utils/dates';
/**
* Fixed Deposit Account Charges Step
@@ -45,11 +45,11 @@ export class FixedDepositAccountChargesStepComponent implements OnInit, OnChange
/**
* @param {MatDialog} dialog Mat Dialog
* @param {DatePipe} datePipe Date Utils
* @param {Dates} dateUtils Date Utils
* @param {SettingsService} settingsService Settings Service
*/
constructor(public dialog: MatDialog,
private datePipe: DatePipe,
private dateUtils: Dates,
private settingsService: SettingsService) { }
ngOnInit() {
@@ -132,7 +132,7 @@ export class FixedDepositAccountChargesStepComponent implements OnInit, OnChange
if (response.data) {
let newCharge: any;
const dateFormat = this.settingsService.dateFormat;
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
@@ -63,12 +63,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 Settings 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 'app/savings/savings.service';
import { SettingsService } from 'app/settings/settings.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 Settings 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.accountId, 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 'app/savings/savings.service';
import { SettingsService } from 'app/settings/settings.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 Settings 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.accountId, 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.accountId, this.datatableName, dataTableEntryObject).subscribe(() => {
@@ -1,6 +1,5 @@
/** Angular Imports */
import { NgModule } from '@angular/core';
import { DatePipe } from '@angular/common';
/** Custom Modules */
import { SharedModule } from 'app/shared/shared.module';
@@ -88,6 +87,6 @@ import { EditFixedDepositAccountComponent } from './edit-fixed-deposit-account/e
DirectivesModule,
FixedDepositsRoutingModule
],
providers: [DatePipe]
providers: [ ]
})
export class FixedDepositsModule { }
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { RecurringDepositsService } from '../recurring-deposits.service';
@@ -13,6 +12,7 @@ import { RecurringDepositsAccountTermsStepComponent } from '../recurring-deposit
import { RecurringDepositsAccountCurrencyStepComponent } from '../recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component';
import { RecurringDepositsAccountSettingsStepComponent } from '../recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component';
import { RecurringDepositsAccountChargesStepComponent } from '../recurring-deposits-account-stepper/recurring-deposits-account-charges-step/recurring-deposits-account-charges-step.component';
import { Dates } from 'app/core/utils/dates';
/**
* Create new recurring deposit account
@@ -38,7 +38,7 @@ export class CreateRecurringDepositsAccountComponent implements OnInit {
constructor(private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private recurringDepositsService: RecurringDepositsService,
private settingsService: SettingsService,
) {
@@ -122,13 +122,13 @@ export class CreateRecurringDepositsAccountComponent implements OnInit {
charges: this.recurringDepositAccount.charges.map((charge: any) => ({
chargeId: charge.id,
amount: charge.amount,
dueDate: charge.dueDate && this.datePipe.transform(charge.dueDate, dateFormat),
dueDate: charge.dueDate && this.dateUtils.formatDate(charge.dueDate, dateFormat),
feeOnMonthDay: charge.feeOnMonthDay,
feeInterval: charge.feeInterval
})),
isCalendarInherited: this.recurringDepositAccount.recurringDepositAccount ? this.recurringDepositAccount.recurringDepositAccount : false,
submittedOnDate: this.datePipe.transform(this.recurringDepositAccount.submittedOnDate, dateFormat),
expectedFirstDepositOnDate: this.datePipe.transform(this.recurringDepositAccount.expectedFirstDepositOnDate, dateFormat),
submittedOnDate: this.dateUtils.formatDate(this.recurringDepositAccount.submittedOnDate, dateFormat),
expectedFirstDepositOnDate: this.dateUtils.formatDate(this.recurringDepositAccount.expectedFirstDepositOnDate, dateFormat),
dateFormat,
monthDayFormat,
locale
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { RecurringDepositsService } from '../recurring-deposits.service';
@@ -13,6 +12,7 @@ import { RecurringDepositsAccountTermsStepComponent } from '../recurring-deposit
import { RecurringDepositsAccountCurrencyStepComponent } from '../recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component';
import { RecurringDepositsAccountSettingsStepComponent } from '../recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component';
import { RecurringDepositsAccountChargesStepComponent } from '../recurring-deposits-account-stepper/recurring-deposits-account-charges-step/recurring-deposits-account-charges-step.component';
import { Dates } from 'app/core/utils/dates';
/**
* Edit new recurring deposit account
@@ -38,7 +38,7 @@ export class EditRecurringDepositAccountComponent implements OnInit {
constructor(private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private recurringDepositsService: RecurringDepositsService,
private settingsService: SettingsService,
) {
@@ -128,13 +128,13 @@ export class EditRecurringDepositAccountComponent implements OnInit {
charges: this.recurringDepositAccount.charges.map((charge: any) => ({
chargeId: charge.id,
amount: charge.amount,
dueDate: charge.dueDate && this.datePipe.transform(charge.dueDate, dateFormat),
dueDate: charge.dueDate && this.dateUtils.formatDate(charge.dueDate, dateFormat),
feeOnMonthDay: charge.feeOnMonthDay,
feeInterval: charge.feeInterval
})),
isCalendarInherited: this.recurringDepositAccount.recurringDepositAccount ? this.recurringDepositAccount.recurringDepositAccount : false,
submittedOnDate: this.datePipe.transform(this.recurringDepositAccount.submittedOnDate, dateFormat),
expectedFirstDepositOnDate: this.datePipe.transform(this.recurringDepositAccount.expectedFirstDepositOnDate, dateFormat),
submittedOnDate: this.dateUtils.formatDate(this.recurringDepositAccount.submittedOnDate, dateFormat),
expectedFirstDepositOnDate: this.dateUtils.formatDate(this.recurringDepositAccount.expectedFirstDepositOnDate, dateFormat),
dateFormat,
monthDayFormat,
locale
@@ -8,11 +8,11 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
/** Custom Services */
import { DatePipe } from '@angular/common';
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Recurring Deposit Account Charges Step
@@ -41,7 +41,7 @@ export class RecurringDepositsAccountChargesStepComponent implements OnInit, OnC
isChargesPatched = false;
constructor(public dialog: MatDialog,
private datePipe: DatePipe,
private dateUtils: Dates,
private settingsService: SettingsService, ) {
}
@@ -126,7 +126,7 @@ export class RecurringDepositsAccountChargesStepComponent implements OnInit, OnC
if (response.data) {
let newCharge: any;
const dateFormat = this.settingsService.dateFormat;
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';
@@ -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';
/**
* Charges Tab Component
@@ -61,7 +61,7 @@ export class ChargesTabComponent implements OnInit {
*/
constructor(private route: ActivatedRoute,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private router: Router,
public dialog: MatDialog,
private settingsService: SettingsService, ) {
@@ -109,7 +109,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';
@@ -18,6 +17,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Savings Account Multi Row Data Tables
@@ -49,12 +49,12 @@ 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.
*/
constructor(private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private savingsService: SavingsService,
private dialog: MatDialog) {
this.accountId = this.route.parent.parent.snapshot.paramMap.get('recurringDepositAccountId');
@@ -148,7 +148,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.accountId, 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 'app/savings/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 Settings 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.accountId, 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.accountId, this.datatableName, dataTableEntryObject).subscribe(() => {
@@ -2,7 +2,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { RecurringDepositsService } from '../recurring-deposits.service';
@@ -44,7 +43,6 @@ export class RecurringDepositsAccountViewComponent implements OnInit {
*/
constructor(private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private recurringDepositsService: RecurringDepositsService,
private savingsService: SavingsService,
public dialog: MatDialog) {
@@ -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 { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service';
@@ -10,6 +9,7 @@ import { SettingsService } from 'app/settings/settings.service';
/** Custom Dialogs */
import { RecurringDepositConfirmationDialogComponent } from '../../custom-dialogs/recurring-deposit-confirmation-dialog/recurring-deposit-confirmation-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 Settings Service
*/
constructor(private recurringDepositsService: RecurringDepositsService,
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
@@ -1,6 +1,5 @@
/** Angular Imports */
import { NgModule } from '@angular/core';
import { DatePipe } from '@angular/common';
/** Custom Modules */
import { RecurringDepositsRoutingModule } from './recurring-deposits-routing.module';
@@ -86,6 +85,6 @@ import { RecurringDepositConfirmationDialogComponent } from './recurring-deposit
ViewTransactionComponent,
EditTransactionComponent
],
providers: [DatePipe]
providers: [ ]
})
export class RecurringDepositsModule {}