refactor(df/locale): fixed-deposits module (#1283)

Centralize the date formats and language code in fixed-deposits module using SettingsService

Fixes: #1213
This commit is contained in:
Shantanu Joshi
2021-08-08 13:13:32 +05:30
committed by GitHub
parent c4663ff286
commit 997611a9f3
14 changed files with 92 additions and 56 deletions
@@ -7,6 +7,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
import { SettingsService } from 'app/settings/settings.service';
/** Custom Dialogs */
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
@@ -63,12 +64,14 @@ export class ChargesTabComponent implements OnInit {
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
* @param {DatePipe} datePipe DatePipe.
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private savingsService: SavingsService,
private route: ActivatedRoute,
private datePipe: DatePipe,
private router: Router,
public dialog: MatDialog) {
public dialog: MatDialog,
private settingsService: SettingsService) {
this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => {
this.fixedDepositsAccountData = data.fixedDepositsAccountData;
this.chargesData = this.fixedDepositsAccountData.charges;
@@ -124,8 +127,8 @@ export class ChargesTabComponent implements OnInit {
const payChargeDialogRef = this.dialog.open(FormDialogComponent, { data });
payChargeDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
const locale = 'en';
const dateFormat = 'dd MMMM yyyy';
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const dataObject = {
...response.data.value,
dueDate: this.datePipe.transform(response.data.value.dueDate, dateFormat),
@@ -194,8 +197,8 @@ export class ChargesTabComponent implements OnInit {
const editChargeDialogRef = this.dialog.open(FormDialogComponent, { data });
editChargeDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
const locale = 'en';
const dateFormat = 'dd MMMM yyyy';
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const dataObject = {
...response.data.value,
dateFormat,
@@ -18,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';
/**
* Savings Account Multi Row Data Tables
@@ -52,11 +53,13 @@ export class MultiRowComponent implements OnInit, OnChanges {
* @param {DatePipe} datePipe Date Pipe.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private route: ActivatedRoute,
private datePipe: DatePipe,
private savingsService: SavingsService,
private dialog: MatDialog) {
private dialog: MatDialog,
private settingsService: SettingsService) {
this.accountId = this.route.parent.parent.snapshot.paramMap.get('fixedDepositAccountId');
}
@@ -85,7 +88,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
* Adds a new row to the given multi row data table.
*/
add() {
let dataTableEntryObject: any = { locale: 'en' };
let dataTableEntryObject: any = { locale: this.settingsService.language.code };
const dateTransformColumns: string[] = [];
const columns = this.dataObject.columnHeaders.filter((column: any) => {
return ((column.columnName !== 'id') && (column.columnName !== 'savings_account_id'));
@@ -118,7 +121,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
});
case 'DATE': {
dateTransformColumns.push(column.columnName);
dataTableEntryObject.dateFormat = 'yyyy-MM-dd';
dataTableEntryObject.dateFormat = this.settingsService.dateFormat;
return new DatepickerBase({
controlName: column.columnName,
label: column.columnName,
@@ -17,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';
/**
@@ -43,11 +44,13 @@ export class SingleRowComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private route: ActivatedRoute,
private datePipe: DatePipe,
private dialog: MatDialog,
private savingsService: SavingsService) {
private savingsService: SavingsService,
private settingsService: SettingsService) {
this.accountId = this.route.parent.parent.snapshot.paramMap.get('fixedDepositAccountId');
}
@@ -65,7 +68,7 @@ export class SingleRowComponent implements OnInit {
* Creates a new instance of the given single row data table.
*/
add() {
let dataTableEntryObject: any = { locale: 'en' };
let dataTableEntryObject: any = { locale: this.settingsService.language.code };
const dateTransformColumns: string[] = [];
const columns = this.dataObject.columnHeaders.filter((column: any) => {
return ((column.columnName !== 'id') && (column.columnName !== 'savings_account_id'));
@@ -95,7 +98,7 @@ export class SingleRowComponent implements OnInit {
* Edits the current instance of single row data table.
*/
edit() {
let dataTableEntryObject: any = { locale: 'en' };
let dataTableEntryObject: any = { locale: this.settingsService.language.code };
const dateTransformColumns: string[] = [];
const columns = this.dataObject.columnHeaders.filter((column: any) => {
return ((column.columnName !== 'id') && (column.columnName !== 'savings_account_id'));
@@ -180,7 +183,7 @@ export class SingleRowComponent implements OnInit {
});
case 'DATE': {
dateTransformColumns.push(column.columnName);
dataTableEntryObject.dateFormat = 'yyyy-MM-dd';
dataTableEntryObject.dateFormat = this.settingsService.dateFormat;
return new DatepickerBase({
controlName: column.columnName,
label: column.columnName,
@@ -7,6 +7,7 @@ import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service';
import { AccountTransfersService } from 'app/account-transfers/account-transfers.service';
import { SettingsService } from 'app/settings/settings.service';
/** Dialog Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
@@ -47,11 +48,13 @@ export class StandingInstructionsTabComponent implements OnInit {
* @param {FixedDepositsService} fixedDepositsService FixedDepositsService
* @param {MatDialog} dialog Mat Dialog
* @param {AccountTransfersService} accountTransfersService Accounts Transfer Service
* @param {SettingsService} settingsService Settings Service
*/
constructor(private route: ActivatedRoute,
private fixedDepositsService: FixedDepositsService,
private dialog: MatDialog,
private accountTransfersService: AccountTransfersService) {
private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService) {
this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => {
this.fixedDepositsData = data.fixedDepositsAccountData;
});
@@ -68,8 +71,8 @@ export class StandingInstructionsTabComponent implements OnInit {
const clientId = this.fixedDepositsData.clientId;
const clientName = this.fixedDepositsData.clientName;
const accountId = this.fixedDepositsData.id;
const locale = 'en';
const dateFormat = 'dd MMMM yyyy';
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.fixedDepositsService.getStandingInstructions(clientId, clientName, accountId, locale, dateFormat).subscribe((response: any) => {
this.instructionsData = response.pageItems;
this.dataSource.data = this.instructionsData;