refractor(df/locale):shares module (#1300)

This commit is contained in:
Abhishek Kumar
2021-08-08 13:19:47 +05:30
committed by GitHub
parent 88ee1b4fcd
commit 18ab9cf128
10 changed files with 62 additions and 30 deletions
@@ -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,
@@ -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,
@@ -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),
@@ -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),
@@ -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),
@@ -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,
@@ -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),
@@ -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),
@@ -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),
@@ -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,