From 18ab9cf1282681faebbb58f2b63efd48607c5faf Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 8 Aug 2021 13:19:47 +0530 Subject: [PATCH] refractor(df/locale):shares module (#1300) --- .../create-shares-account.component.ts | 9 ++++++--- .../edit-shares-account.component.ts | 9 ++++++--- .../activate-shares-account.component.ts | 9 ++++++--- .../apply-shares/apply-shares.component.ts | 9 ++++++--- .../approve-shares-account.component.ts | 9 ++++++--- .../approve-shares/approve-shares.component.ts | 11 ++++++++--- .../close-shares-account.component.ts | 9 ++++++--- .../redeem-shares/redeem-shares.component.ts | 9 ++++++--- .../reject-shares-account.component.ts | 9 ++++++--- .../reject-shares/reject-shares.component.ts | 9 ++++++--- 10 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/app/shares/create-shares-account/create-shares-account.component.ts b/src/app/shares/create-shares-account/create-shares-account.component.ts index 33f572988..89c84f178 100644 --- a/src/app/shares/create-shares-account/create-shares-account.component.ts +++ b/src/app/shares/create-shares-account/create-shares-account.component.ts @@ -10,6 +10,7 @@ import { SharesAccountChargesStepComponent } from '../shares-account-stepper/sha /** Custom Services */ import { SharesService } from '../shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create Shares Account Component @@ -39,11 +40,13 @@ export class CreateSharesAccountComponent { * @param {Router} router Router * @param {DatePipe} datePipe Date Pipe * @param {SharesService} sharesService Shares Service + * @param {SettingsService} settingsService Settings Service */ constructor(private route: ActivatedRoute, private router: Router, private datePipe: DatePipe, - private sharesService: SharesService) { + private sharesService: SharesService, + private settingsService: SettingsService) { this.route.data.subscribe((data: { sharesAccountTemplate: any }) => { this.sharesAccountTemplate = data.sharesAccountTemplate; }); @@ -97,8 +100,8 @@ export class CreateSharesAccountComponent { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const sharesAccount = { ...this.sharesAccount, clientId: this.sharesAccountTemplate.clientId, diff --git a/src/app/shares/edit-shares-account/edit-shares-account.component.ts b/src/app/shares/edit-shares-account/edit-shares-account.component.ts index 866e866bc..725293dc9 100644 --- a/src/app/shares/edit-shares-account/edit-shares-account.component.ts +++ b/src/app/shares/edit-shares-account/edit-shares-account.component.ts @@ -10,6 +10,7 @@ import { SharesAccountChargesStepComponent } from '../shares-account-stepper/sha /** Custom Services */ import { SharesService } from '../shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Shares Account Component @@ -39,11 +40,13 @@ export class EditSharesAccountComponent { * @param {Router} router Router * @param {DatePipe} datePipe Date Pipe * @param {SharesService} sharesService Shares Service + * @param {SettingsService} settingsService Settings Service */ constructor(private route: ActivatedRoute, private router: Router, private datePipe: DatePipe, - private sharesService: SharesService) { + private sharesService: SharesService, + private settingsService: SettingsService) { this.route.data.subscribe((data: { sharesAccountAndTemplate: any }) => { this.sharesAccountAndTemplate = data.sharesAccountAndTemplate; }); @@ -102,8 +105,8 @@ export class EditSharesAccountComponent { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const sharesAccount = { ...this.sharesAccount, clientId: this.sharesAccountAndTemplate.clientId, diff --git a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts index 0e78124b3..9aee7b9f5 100644 --- a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Activate Shares Account Component @@ -32,12 +33,14 @@ export class ActivateSharesAccountComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; } @@ -63,8 +66,8 @@ export class ActivateSharesAccountComponent implements OnInit { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevActivatedDate: Date = this.activateSharesAccountForm.value.activatedDate; this.activateSharesAccountForm.patchValue({ activatedDate: this.datePipe.transform(prevActivatedDate, dateFormat), diff --git a/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts b/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts index 7683081ef..2c11486d2 100644 --- a/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts +++ b/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Apply Shares Component @@ -35,12 +36,14 @@ export class ApplySharesComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; this.route.data.subscribe((data: { shareAccountActionData: any }) => { this.sharesAccountData = data.shareAccountActionData; @@ -74,8 +77,8 @@ export class ApplySharesComponent implements OnInit { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevRequestedDate: Date = this.applySharesForm.value.requestedDate; this.applySharesForm.patchValue({ requestedDate: this.datePipe.transform(prevRequestedDate, dateFormat), diff --git a/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts b/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts index ab361743d..ac90f6708 100644 --- a/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Approve Shares Account Component @@ -32,12 +33,14 @@ export class ApproveSharesAccountComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; } @@ -64,8 +67,8 @@ export class ApproveSharesAccountComponent implements OnInit { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevApprovedDate: Date = this.approveSharesAccountForm.value.approvedDate; this.approveSharesAccountForm.patchValue({ approvedDate: this.datePipe.transform(prevApprovedDate, dateFormat), diff --git a/src/app/shares/shares-account-actions/approve-shares/approve-shares.component.ts b/src/app/shares/shares-account-actions/approve-shares/approve-shares.component.ts index 8f3b24321..25bc0cbed 100644 --- a/src/app/shares/shares-account-actions/approve-shares/approve-shares.component.ts +++ b/src/app/shares/shares-account-actions/approve-shares/approve-shares.component.ts @@ -12,6 +12,7 @@ import { ApproveShareDialogComponent } from './approve-share-dialog/approve-shar /** Custom Serices */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Approve shares component. @@ -44,10 +45,14 @@ export class ApproveSharesComponent implements OnInit { /** * @param {SharesService} sharesService Shares Service + * @param {ActivatedRoute} route Activated Route + * @param {MatDialog} dialog Dialog reference. + * @param {SettingsService} settingsService Settings Service */ constructor(private sharesService: SharesService, private route: ActivatedRoute, - public dialog: MatDialog) { + public dialog: MatDialog, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; this.route.data.subscribe((data: { shareAccountActionData: any }) => { this.sharesAccountData = data.shareAccountActionData; @@ -82,8 +87,8 @@ export class ApproveSharesComponent implements OnInit { }); approveSharesDialogRef.afterClosed().subscribe((response: any) => { if (response.approve) { - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const data = { requestedShares: [{id}], dateFormat, diff --git a/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts b/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts index 0ddcb3862..95aad8f8f 100644 --- a/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Close Shares Account Component @@ -32,12 +33,14 @@ export class CloseSharesAccountComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; } @@ -64,8 +67,8 @@ export class CloseSharesAccountComponent implements OnInit { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevClosedDate: Date = this.closeSharesAccountForm.value.closedDate; this.closeSharesAccountForm.patchValue({ closedDate: this.datePipe.transform(prevClosedDate, dateFormat), diff --git a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts index 16f370bee..c3dec741d 100644 --- a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts +++ b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Redeem Shares Component @@ -35,12 +36,14 @@ export class RedeemSharesComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; this.route.data.subscribe((data: { shareAccountActionData: any }) => { this.sharesAccountData = data.shareAccountActionData; @@ -74,8 +77,8 @@ export class RedeemSharesComponent implements OnInit { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevRequestedDate: Date = this.redeemSharesForm.value.requestedDate; this.redeemSharesForm.patchValue({ requestedDate: this.datePipe.transform(prevRequestedDate, dateFormat), diff --git a/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts b/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts index 990ba69c0..d1fbf50cc 100644 --- a/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Reject Shares Account Component @@ -32,12 +33,14 @@ export class RejectSharesAccountComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; } @@ -64,8 +67,8 @@ export class RejectSharesAccountComponent implements OnInit { */ submit() { // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevRejectedDate: Date = this.rejectSharesAccountForm.value.rejectedDate; this.rejectSharesAccountForm.patchValue({ rejectedDate: this.datePipe.transform(prevRejectedDate, dateFormat), diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.ts b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.ts index 090a60668..d19048db2 100644 --- a/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.ts +++ b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.ts @@ -12,6 +12,7 @@ import { RejectShareDialogComponent } from './reject-share-dialog/reject-share-d /** Custom Serices */ import { SharesService } from 'app/shares/shares.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Reject shares component. @@ -46,10 +47,12 @@ export class RejectSharesComponent implements OnInit { * @param {SharesService} sharesService Shares Service * @param {ActivatedRoute} route Activated Route * @param {MatDialog} dialog Mat Dialog + * @param {SettingsService} settingsService Settings Service. */ constructor(private sharesService: SharesService, private route: ActivatedRoute, - public dialog: MatDialog) { + public dialog: MatDialog, + private settingsService: SettingsService) { this.accountId = this.route.parent.snapshot.params['shareAccountId']; this.route.data.subscribe((data: { shareAccountActionData: any }) => { this.sharesAccountData = data.shareAccountActionData; @@ -84,8 +87,8 @@ export class RejectSharesComponent implements OnInit { }); rejectSharesDialogRef.afterClosed().subscribe((response: any) => { if (response.reject) { - const locale = 'en'; - const dateFormat = 'dd MMMM yyyy'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const data = { requestedShares: [{id}], dateFormat,