refactor(df/locale): clients module (#1257)

See: #1213
This commit is contained in:
Abhirup Pal
2020-10-16 20:17:59 +05:30
committed by GitHub
parent ee2f53e503
commit aeeb2cc5f1
17 changed files with 104 additions and 50 deletions
@@ -4,6 +4,9 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
/** Custom Services */
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Client Family Members Dialog * Client Family Members Dialog
*/ */
@@ -27,11 +30,13 @@ export class ClientFamilyMemberDialogComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder * @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {any} data Dialog Data * @param {any} data Dialog Data
* @param {SettingsService} settingsService Setting service
*/ */
constructor(public dialogRef: MatDialogRef<ClientFamilyMemberDialogComponent>, constructor(public dialogRef: MatDialogRef<ClientFamilyMemberDialogComponent>,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private datePipe: DatePipe, private datePipe: DatePipe,
@Inject(MAT_DIALOG_DATA) public data: any) { } @Inject(MAT_DIALOG_DATA) public data: any,
private settingsService: SettingsService) { }
ngOnInit() { ngOnInit() {
this.createFamilyMemberForm(); this.createFamilyMemberForm();
@@ -75,8 +80,8 @@ export class ClientFamilyMemberDialogComponent implements OnInit {
* Returns Formatted Family Member * Returns Formatted Family Member
*/ */
get familyMember() { get familyMember() {
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const familyMember = { const familyMember = {
...this.familyMemberForm.value, ...this.familyMemberForm.value,
@@ -3,6 +3,9 @@ import { Component, OnInit, Input } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
/** Custom Services */
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create Client Component * Create Client Component
*/ */
@@ -45,9 +48,11 @@ export class ClientGeneralStepComponent implements OnInit {
/** /**
* @param {FormBuilder} formBuilder Form Builder * @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private datePipe: DatePipe) { private datePipe: DatePipe,
private settingsService: SettingsService) {
this.setClientForm(); this.setClientForm();
} }
@@ -140,8 +145,8 @@ export class ClientGeneralStepComponent implements OnInit {
*/ */
get clientGeneralDetails() { get clientGeneralDetails() {
const generalDetails = this.createClientForm.value; const generalDetails = this.createClientForm.value;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const locale = 'en'; const locale = this.settingsService.language.code;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
for (const key in generalDetails) { for (const key in generalDetails) {
if (generalDetails[key] === '' || key === 'addSavings') { if (generalDetails[key] === '' || key === 'addSavings') {
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services. */ /** Custom Services. */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Client Pay Charge component. * Client Pay Charge component.
@@ -30,13 +31,15 @@ export class ClientPayChargesComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {SettingsService} settingsService Setting service
*/ */
constructor( constructor(
private clientsService: ClientsService, private clientsService: ClientsService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe private datePipe: DatePipe,
private settingsService: SettingsService
) { ) {
this.route.data.subscribe((data: { transactionData: any }) => { this.route.data.subscribe((data: { transactionData: any }) => {
this.transactionData = data.transactionData; this.transactionData = data.transactionData;
@@ -67,7 +70,7 @@ export class ClientPayChargesComponent implements OnInit {
transactionDate: this.datePipe.transform(transactionDate, dateFormat) transactionDate: this.datePipe.transform(transactionDate, dateFormat)
}); });
const transactions = this.transactionForm.value; const transactions = this.transactionForm.value;
transactions.locale = 'en'; transactions.locale = this.settingsService.language.code;
transactions.dateFormat = dateFormat; transactions.dateFormat = dateFormat;
this.clientsService.payClientCharge(this.transactionData.clientId, this.transactionData.id, transactions).subscribe(() => { this.clientsService.payClientCharge(this.transactionData.clientId, this.transactionData.id, transactions).subscribe(() => {
this.router.navigate(['../', 'general']); this.router.navigate(['../', 'general']);
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Activate Client Component * Activate Client Component
@@ -32,12 +33,14 @@ export class ActivateClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {SettingsService} settingsService Settings Service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router,
private settingsService: SettingsService) {
this.clientId = this.route.parent.snapshot.params['clientId']; this.clientId = this.route.parent.snapshot.params['clientId'];
} }
@@ -63,8 +66,8 @@ export class ActivateClientComponent implements OnInit {
*/ */
submit() { submit() {
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const prevActivationDate: Date = this.activateClientForm.value.activationDate; const prevActivationDate: Date = this.activateClientForm.value.activationDate;
this.activateClientForm.patchValue({ this.activateClientForm.patchValue({
activationDate: this.datePipe.transform(prevActivationDate, dateFormat), activationDate: this.datePipe.transform(prevActivationDate, dateFormat),
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Add Clients Charge component. * Add Clients Charge component.
@@ -37,13 +38,15 @@ export class AddClientChargeComponent implements OnInit {
* @param {Router} router Router * @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ClientsService} clientsService Clients Service * @param {ClientsService} clientsService Clients Service
* @param {SettingsService} settingsService Setting service
*/ */
constructor( constructor(
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe, private datePipe: DatePipe,
private clientsService: ClientsService private clientsService: ClientsService,
private settingsService: SettingsService
) { ) {
this.route.data.subscribe((data: { clientActionData: any }) => { this.route.data.subscribe((data: { clientActionData: any }) => {
this.clientChargeOptions = data.clientActionData.chargeOptions; this.clientChargeOptions = data.clientActionData.chargeOptions;
@@ -111,7 +114,7 @@ export class AddClientChargeComponent implements OnInit {
*/ */
submit() { submit() {
const clientCharge = this.clientChargeForm.value; const clientCharge = this.clientChargeForm.value;
clientCharge.locale = 'en'; clientCharge.locale = this.settingsService.language.code;
if (!clientCharge.feeInterval) { if (!clientCharge.feeInterval) {
clientCharge.feeInterval = this.chargeDetails.feeInterval; clientCharge.feeInterval = this.chargeDetails.feeInterval;
} }
@@ -124,7 +127,7 @@ export class AddClientChargeComponent implements OnInit {
clientCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat); clientCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat);
} }
} else { } else {
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
clientCharge.dateFormat = dateFormat; clientCharge.dateFormat = dateFormat;
if (clientCharge.dueDate) { if (clientCharge.dueDate) {
const prevDate = this.clientChargeForm.value.dueDate; const prevDate = this.clientChargeForm.value.dueDate;
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Close Client Component * Close Client Component
@@ -34,12 +35,14 @@ export class CloseClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => { this.route.data.subscribe((data: { clientActionData: any }) => {
this.closureData = data.clientActionData.narrations; this.closureData = data.clientActionData.narrations;
}); });
@@ -65,8 +68,8 @@ export class CloseClientComponent implements OnInit {
*/ */
submit() { submit() {
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const prevClosedDate: Date = this.closeClientForm.value.closureDate; const prevClosedDate: Date = this.closeClientForm.value.closureDate;
this.closeClientForm.patchValue({ this.closeClientForm.patchValue({
closureDate: this.datePipe.transform(prevClosedDate, dateFormat), closureDate: this.datePipe.transform(prevClosedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Reactivate Client Component * Reactivate Client Component
@@ -32,12 +33,14 @@ export class ReactivateClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router,
private settingsService: SettingsService) {
this.clientId = this.route.parent.snapshot.params['clientId']; this.clientId = this.route.parent.snapshot.params['clientId'];
} }
@@ -63,8 +66,8 @@ export class ReactivateClientComponent implements OnInit {
*/ */
submit() { submit() {
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const prevReactivationDate: Date = this.reactivateClientForm.value.reactivationDate; const prevReactivationDate: Date = this.reactivateClientForm.value.reactivationDate;
this.reactivateClientForm.patchValue({ this.reactivateClientForm.patchValue({
reactivationDate: this.datePipe.transform(prevReactivationDate, dateFormat), reactivationDate: this.datePipe.transform(prevReactivationDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Reject Client Component * Reject Client Component
@@ -34,12 +35,14 @@ export class RejectClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => { this.route.data.subscribe((data: { clientActionData: any }) => {
this.rejectionData = data.clientActionData.narrations; this.rejectionData = data.clientActionData.narrations;
}); });
@@ -65,8 +68,8 @@ export class RejectClientComponent implements OnInit {
*/ */
submit() { submit() {
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const prevRejectedDate: Date = this.rejectClientForm.value.rejectionDate; const prevRejectedDate: Date = this.rejectClientForm.value.rejectionDate;
this.rejectClientForm.patchValue({ this.rejectClientForm.patchValue({
rejectionDate: this.datePipe.transform(prevRejectedDate, dateFormat), rejectionDate: this.datePipe.transform(prevRejectedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Transfer Client Component * Transfer Client Component
@@ -34,12 +35,14 @@ export class TransferClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => { this.route.data.subscribe((data: { clientActionData: any }) => {
this.officeData = data.clientActionData; this.officeData = data.clientActionData;
}); });
@@ -66,8 +69,8 @@ export class TransferClientComponent implements OnInit {
*/ */
submit() { submit() {
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const prevClosedDate: Date = this.transferClientForm.value.transferDate; const prevClosedDate: Date = this.transferClientForm.value.transferDate;
this.transferClientForm.patchValue({ this.transferClientForm.patchValue({
transferDate: this.datePipe.transform(prevClosedDate, dateFormat), transferDate: this.datePipe.transform(prevClosedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Undo Client Rejection Component * Undo Client Rejection Component
@@ -37,7 +38,8 @@ export class UndoClientRejectionComponent implements OnInit {
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router,
private settingsService: SettingsService) {
this.clientId = this.route.parent.snapshot.params['clientId']; this.clientId = this.route.parent.snapshot.params['clientId'];
} }
@@ -63,8 +65,8 @@ export class UndoClientRejectionComponent implements OnInit {
*/ */
submit() { submit() {
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const prevReopenedDate: Date = this.undoClientRejectionForm.value.reopenedDate; const prevReopenedDate: Date = this.undoClientRejectionForm.value.reopenedDate;
this.undoClientRejectionForm.patchValue({ this.undoClientRejectionForm.patchValue({
reopenedDate: this.datePipe.transform(prevReopenedDate, dateFormat), reopenedDate: this.datePipe.transform(prevReopenedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Withdraw Client Component * Withdraw Client Component
@@ -34,12 +35,14 @@ export class WithdrawClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => { this.route.data.subscribe((data: { clientActionData: any }) => {
this.withdrawalData = data.clientActionData.narrations; this.withdrawalData = data.clientActionData.narrations;
}); });
@@ -65,8 +68,8 @@ export class WithdrawClientComponent implements OnInit {
*/ */
submit() { submit() {
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const prevWithdrawalDate: Date = this.withdrawClientForm.value.withdrawalDate; const prevWithdrawalDate: Date = this.withdrawClientForm.value.withdrawalDate;
this.withdrawClientForm.patchValue({ this.withdrawClientForm.patchValue({
withdrawalDate: this.datePipe.transform(prevWithdrawalDate, dateFormat), withdrawalDate: this.datePipe.transform(prevWithdrawalDate, dateFormat),
@@ -14,6 +14,7 @@ import { DeleteDialogComponent } from '../../../../shared/delete-dialog/delete-d
/** Custom Services */ /** Custom Services */
import { ClientsService } from '../../../clients.service'; import { ClientsService } from '../../../clients.service';
import { SettingsService } from 'app/settings/settings.service';
@Component({ @Component({
selector: 'mifosx-multi-row', selector: 'mifosx-multi-row',
@@ -32,7 +33,8 @@ export class MultiRowComponent implements OnInit, OnChanges {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private clientsService: ClientsService, private clientsService: ClientsService,
private dialog: MatDialog) { private dialog: MatDialog,
private settingsService: SettingsService) {
this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId'); this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId');
} }
@@ -51,7 +53,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
add() { add() {
let dataTableEntryObject: any = { let dataTableEntryObject: any = {
locale: 'en' locale: this.settingsService.language.code
}; };
const dateTransformColumns: string[] = []; const dateTransformColumns: string[] = [];
const columns = this.dataObject.columnHeaders.filter((column: any) => { const columns = this.dataObject.columnHeaders.filter((column: any) => {
@@ -13,7 +13,7 @@ import { DeleteDialogComponent } from '../../../../shared/delete-dialog/delete-d
/** Custom Services */ /** Custom Services */
import { ClientsService } from '../../../clients.service'; import { ClientsService } from '../../../clients.service';
import { SettingsService } from 'app/settings/settings.service';
@Component({ @Component({
@@ -30,7 +30,8 @@ export class SingleRowComponent implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private dialog: MatDialog, private dialog: MatDialog,
private clientsService: ClientsService) { private clientsService: ClientsService,
private settingsService: SettingsService) {
this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId'); this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId');
} }
@@ -42,7 +43,7 @@ export class SingleRowComponent implements OnInit {
add() { add() {
let dataTableEntryObject: any = { let dataTableEntryObject: any = {
locale: 'en' locale: this.settingsService.language.code
}; };
const dateTransformColumns: string[] = []; const dateTransformColumns: string[] = [];
const columns = this.dataObject.columnHeaders.filter((column: any) => { const columns = this.dataObject.columnHeaders.filter((column: any) => {
@@ -72,7 +73,7 @@ export class SingleRowComponent implements OnInit {
edit() { edit() {
let dataTableEntryObject: any = { let dataTableEntryObject: any = {
locale: 'en' locale: this.settingsService.language.code
}; };
const dateTransformColumns: string[] = []; const dateTransformColumns: string[] = [];
const columns = this.dataObject.columnHeaders.filter((column: any) => { const columns = this.dataObject.columnHeaders.filter((column: any) => {
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { ClientsService } from '../../../clients.service'; import { ClientsService } from '../../../clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Add Family Member Component * Add Family Member Component
@@ -34,12 +35,14 @@ export class AddFamilyMemberComponent implements OnInit {
* @param {Router} router Router * @param {Router} router Router
* @param {Route} route Route * @param {Route} route Route
* @param {ClientsService} clientsService Clients Service * @param {ClientsService} clientsService Clients Service
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private datePipe: DatePipe, private datePipe: DatePipe,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private clientsService: ClientsService) { private clientsService: ClientsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientTemplate: any }) => { this.route.data.subscribe((data: { clientTemplate: any }) => {
this.addFamilyMemberTemplate = data.clientTemplate.familyMemberOptions; this.addFamilyMemberTemplate = data.clientTemplate.familyMemberOptions;
}); });
@@ -76,12 +79,12 @@ export class AddFamilyMemberComponent implements OnInit {
submit() { submit() {
const prevDateOfBirth: Date = this.addFamilyMemberForm.value.dateOfBirth; const prevDateOfBirth: Date = this.addFamilyMemberForm.value.dateOfBirth;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
this.addFamilyMemberForm.patchValue({ this.addFamilyMemberForm.patchValue({
dateOfBirth: this.datePipe.transform(prevDateOfBirth, dateFormat) dateOfBirth: this.datePipe.transform(prevDateOfBirth, dateFormat)
}); });
const familyMemberData = this.addFamilyMemberForm.value; const familyMemberData = this.addFamilyMemberForm.value;
familyMemberData.locale = 'en'; familyMemberData.locale = this.settingsService.language.code;
familyMemberData.dateFormat = dateFormat; familyMemberData.dateFormat = dateFormat;
this.clientsService.addFamilyMember(this.clientId, familyMemberData).subscribe(res => { this.clientsService.addFamilyMember(this.clientId, familyMemberData).subscribe(res => {
this.router.navigate(['../'], { relativeTo: this.route }); this.router.navigate(['../'], { relativeTo: this.route });
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { ClientsService } from '../../../clients.service'; import { ClientsService } from '../../../clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Edit Family Member Component * Edit Family Member Component
@@ -34,12 +35,14 @@ export class EditFamilyMemberComponent implements OnInit {
* @param {Router} router Router * @param {Router} router Router
* @param {ActivatedRoute} route Route * @param {ActivatedRoute} route Route
* @param {ClientsService} clientsService Clients Service * @param {ClientsService} clientsService Clients Service
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private datePipe: DatePipe, private datePipe: DatePipe,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private clientsService: ClientsService) { private clientsService: ClientsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientTemplate: any, editFamilyMember: any }) => { this.route.data.subscribe((data: { clientTemplate: any, editFamilyMember: any }) => {
this.addFamilyMemberTemplate = data.clientTemplate.familyMemberOptions; this.addFamilyMemberTemplate = data.clientTemplate.familyMemberOptions;
this.familyMemberDetails = data.editFamilyMember; this.familyMemberDetails = data.editFamilyMember;
@@ -76,12 +79,12 @@ export class EditFamilyMemberComponent implements OnInit {
submit() { submit() {
const prevDateOfBirth: Date = this.editFamilyMemberForm.value.dateOfBirth; const prevDateOfBirth: Date = this.editFamilyMemberForm.value.dateOfBirth;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
this.editFamilyMemberForm.patchValue({ this.editFamilyMemberForm.patchValue({
dateOfBirth: this.datePipe.transform(prevDateOfBirth, dateFormat) dateOfBirth: this.datePipe.transform(prevDateOfBirth, dateFormat)
}); });
const familyMemberData = this.editFamilyMemberForm.value; const familyMemberData = this.editFamilyMemberForm.value;
familyMemberData.locale = 'en'; familyMemberData.locale = this.settingsService.language.code;
familyMemberData.dateFormat = dateFormat; familyMemberData.dateFormat = dateFormat;
this.clientsService.editFamilyMember(this.familyMemberDetails.clientId, this.familyMemberDetails.id, familyMemberData).subscribe(res => { this.clientsService.editFamilyMember(this.familyMemberDetails.clientId, this.familyMemberDetails.id, familyMemberData).subscribe(res => {
this.router.navigate(['../../'], { relativeTo: this.route }); this.router.navigate(['../../'], { relativeTo: this.route });
@@ -10,6 +10,10 @@ import { ClientGeneralStepComponent } from '../client-stepper/client-general-ste
import { ClientFamilyMembersStepComponent } from '../client-stepper/client-family-members-step/client-family-members-step.component'; import { ClientFamilyMembersStepComponent } from '../client-stepper/client-family-members-step/client-family-members-step.component';
import { ClientAddressStepComponent } from '../client-stepper/client-address-step/client-address-step.component'; import { ClientAddressStepComponent } from '../client-stepper/client-address-step/client-address-step.component';
/** Custom Services */
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create Client Component. * Create Client Component.
*/ */
@@ -37,10 +41,12 @@ export class CreateClientComponent {
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {ClientsService} clientsService Clients Service * @param {ClientsService} clientsService Clients Service
* @param {SettingsService} settingsService Setting service
*/ */
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private clientsService: ClientsService) { private clientsService: ClientsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientTemplate: any, clientAddressFieldConfig: any }) => { this.route.data.subscribe((data: { clientTemplate: any, clientAddressFieldConfig: any }) => {
this.clientTemplate = data.clientTemplate; this.clientTemplate = data.clientTemplate;
this.clientAddressFieldConfig = data.clientAddressFieldConfig; this.clientAddressFieldConfig = data.clientAddressFieldConfig;
@@ -68,8 +74,8 @@ export class CreateClientComponent {
* Submits the create client form. * Submits the create client form.
*/ */
submit() { submit() {
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const clientData = { const clientData = {
...this.client, ...this.client,
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { ClientsService } from '../clients.service'; import { ClientsService } from '../clients.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Edit Client Component * Edit Client Component
@@ -51,12 +52,14 @@ export class EditClientComponent implements OnInit {
* @param {Router} router Router * @param {Router} router Router
* @param {ClientsService} clientsService Clients Service * @param {ClientsService} clientsService Clients Service
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {SettingsService} settingsService Settings Service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private clientsService: ClientsService, private clientsService: ClientsService,
private datePipe: DatePipe) { private datePipe: DatePipe,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientDataAndTemplate: any }) => { this.route.data.subscribe((data: { clientDataAndTemplate: any }) => {
this.clientDataAndTemplate = data.clientDataAndTemplate; this.clientDataAndTemplate = data.clientDataAndTemplate;
}); });
@@ -151,8 +154,8 @@ export class EditClientComponent implements OnInit {
* Submits the edit client form. * Submits the edit client form.
*/ */
submit() { submit() {
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const editClientFormValue: any = this.editClientForm.getRawValue(); const editClientFormValue: any = this.editClientForm.getRawValue();
const clientData = { const clientData = {