From 5f90bc00bda18940bfea011feafb18cf7f4e94be Mon Sep 17 00:00:00 2001 From: Benura Abeywardena <43112139+BLasan@users.noreply.github.com> Date: Thu, 12 Nov 2020 19:36:37 +0530 Subject: [PATCH] refactor (df/locale): organization module (#1268) See: #1213 --- .../bulk-loan-reassignmnet.component.ts | 8 +++++-- .../create-employee.component.ts | 7 +++++-- .../edit-employee/edit-employee.component.ts | 7 +++++-- .../fund-mapping/fund-mapping.component.ts | 7 +++++-- .../create-holiday.component.ts | 6 ++++-- .../edit-holiday/edit-holiday.component.ts | 6 ++++-- ...te-loan-provisioning-criteria.component.ts | 5 ++++- ...it-loan-provisioning-criteria.component.ts | 5 ++++- .../create-office/create-office.component.ts | 1 + .../edit-office/edit-office.component.ts | 7 +++++-- .../multi-row/multi-row.component.ts | 7 +++++-- .../single-row/single-row.component.ts | 11 ++++++---- src/app/organization/organization.service.ts | 13 +++++++----- .../create-campaign.component.ts | 7 +++++-- .../edit-campaign/edit-campaign.component.ts | 9 +++++--- ...edit-business-rule-parameters.component.ts | 4 +++- .../business-rule-parameters.component.ts | 9 +++++--- .../view-campaign/view-campaign.component.ts | 21 +++++++++++-------- ...standing-instructions-history.component.ts | 7 +++++-- .../allocate-cash/allocate-cash.component.ts | 7 +++++-- .../create-cashier.component.ts | 9 +++++--- .../edit-cashier/edit-cashier.component.ts | 9 +++++--- .../settle-cash/settle-cash.component.ts | 10 +++++++-- .../create-teller/create-teller.component.ts | 7 +++++-- .../edit-teller/edit-teller.component.ts | 7 +++++-- .../working-days/working-days.component.ts | 5 ++++- 26 files changed, 139 insertions(+), 62 deletions(-) diff --git a/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts b/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts index bdb4c4ab1..ead6a51f3 100644 --- a/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts +++ b/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services. */ import { OrganizationService } from '../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Bulk Loan Reassignment component. @@ -40,11 +41,14 @@ export class BulkLoanReassignmnetComponent implements OnInit { * Get Office data from `resolver`. * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. + * @param {OrganizationService} organizationSevice Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private organizationSevice: OrganizationService, + private settingsService: SettingsService, private datePipe: DatePipe, private router: Router) { this.route.data.subscribe((data: { offices: any} ) => { @@ -109,13 +113,13 @@ export class BulkLoanReassignmnetComponent implements OnInit { * Submits bulk loan reassignment form. */ submit() { - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; const assignmentDate = this.bulkLoanForm.value.assignmentDate; this.bulkLoanForm.patchValue({ assignmentDate: this.datePipe.transform(assignmentDate, dateFormat) }); const bulkForm = this.bulkLoanForm.value; - bulkForm.locale = 'en'; + bulkForm.locale = this.settingsService.language.code; bulkForm.dateFormat = dateFormat; bulkForm.loans = this.loans; this.organizationSevice.createLoanReassignment(bulkForm).subscribe((response: any) => { diff --git a/src/app/organization/employees/create-employee/create-employee.component.ts b/src/app/organization/employees/create-employee/create-employee.component.ts index dabdca707..c1971ff76 100644 --- a/src/app/organization/employees/create-employee/create-employee.component.ts +++ b/src/app/organization/employees/create-employee/create-employee.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create employee component. @@ -30,12 +31,14 @@ export class CreateEmployeeComponent implements OnInit { * Retrieves the offices data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {DatePipe} datePipe Date Pipe to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, + private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, private datePipe: DatePipe) { @@ -72,12 +75,12 @@ export class CreateEmployeeComponent implements OnInit { submit() { const prevJoiningDate: Date = this.employeeForm.value.joiningDate; // TODO: Update once language and date settings are setup - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; this.employeeForm.patchValue({ joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat) }); const employee = this.employeeForm.value; - employee.locale = 'en'; + employee.locale = this.settingsService.language.code; employee.dateFormat = dateFormat; this.organizationService.createEmployee(employee).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); diff --git a/src/app/organization/employees/edit-employee/edit-employee.component.ts b/src/app/organization/employees/edit-employee/edit-employee.component.ts index e7f09237a..5ffdde810 100644 --- a/src/app/organization/employees/edit-employee/edit-employee.component.ts +++ b/src/app/organization/employees/edit-employee/edit-employee.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Employee Component. @@ -32,12 +33,14 @@ export class EditEmployeeComponent implements OnInit { * Retrieves the offices data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {DatePipe} datePipe Date Pipe to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, + private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, private datePipe: DatePipe) { @@ -76,12 +79,12 @@ export class EditEmployeeComponent implements OnInit { submit() { const prevJoiningDate: Date = this.editEmployeeForm.value.joiningDate; // TODO: Update once language and date settings are setup - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; this.editEmployeeForm.patchValue({ joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat) }); const employee = this.editEmployeeForm.value; - employee.locale = 'en'; + employee.locale = this.settingsService.language.code; employee.dateFormat = dateFormat; this.organizationService.updateEmployee(this.employeeData.id, employee).subscribe((response: any) => { this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); diff --git a/src/app/organization/fund-mapping/fund-mapping.component.ts b/src/app/organization/fund-mapping/fund-mapping.component.ts index 813f82249..93ac46794 100644 --- a/src/app/organization/fund-mapping/fund-mapping.component.ts +++ b/src/app/organization/fund-mapping/fund-mapping.component.ts @@ -9,6 +9,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Fund Mapping Component. @@ -45,11 +46,13 @@ export class FundMappingComponent implements OnInit { * Retrieves the advance search template from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router for navigation. * @param {DatePipe} datePipe Date Pipe to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, + private settingsService: SettingsService, private route: ActivatedRoute, private datePipe: DatePipe) { this.route.data.subscribe((data: { advanceSearchTemplate: any }) => { @@ -146,8 +149,8 @@ export class FundMappingComponent implements OnInit { submit() { this.isCollapsed = true; // TODO: Update once language and date settings are setup - const locale = 'en'; - const dateFormat = 'yyyy-MM-dd'; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; this.fundMappingForm.patchValue({ 'loanFromDate': this.datePipe.transform(this.fundMappingForm.value.loanFromDate, dateFormat), 'loanToDate': this.datePipe.transform(this.fundMappingForm.value.loanToDate, dateFormat) diff --git a/src/app/organization/holidays/create-holiday/create-holiday.component.ts b/src/app/organization/holidays/create-holiday/create-holiday.component.ts index 476fd662e..bf636cca5 100644 --- a/src/app/organization/holidays/create-holiday/create-holiday.component.ts +++ b/src/app/organization/holidays/create-holiday/create-holiday.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create Holiday component. @@ -41,6 +42,7 @@ export class CreateHolidayComponent implements OnInit { private route: ActivatedRoute, private datePipe: DatePipe, private organizationService: OrganizationService, + private settings: SettingsService, private router: Router ) { this.route.data.subscribe((data: { offices: any, holidayTemplate: any }) => { this.officesData = data.offices; @@ -84,8 +86,8 @@ export class CreateHolidayComponent implements OnInit { * Submits the create holiday Form. */ submit() { - const dateFormat = 'yyyy-MM-dd'; - const locale = 'en'; + const dateFormat = this.settings.dateFormat; + const locale = this.settings.language.code; this.holidayForm.patchValue({ 'fromDate': this.datePipe.transform(this.holidayForm.value.fromDate, dateFormat), 'toDate': this.datePipe.transform(this.holidayForm.value.toDate, dateFormat), diff --git a/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts b/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts index 76b28bb08..b64ffd962 100644 --- a/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts +++ b/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Holiday component. @@ -42,6 +43,7 @@ export class EditHolidayComponent implements OnInit { private route: ActivatedRoute, private datePipe: DatePipe, private organizatioService: OrganizationService, + private settings: SettingsService, private router: Router ) { this.route.data.subscribe((data: { holiday: any, holidayTemplate: any }) => { this.holidayData = data.holiday; @@ -98,7 +100,7 @@ export class EditHolidayComponent implements OnInit { * Submits Edit Holiday Form. */ submit() { - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settings.dateFormat; if (!this.isActiveHoliday) { const fromDate: Date = this.holidayForm.value.fromDate; const toDate: Date = this.holidayForm.value.toDate; @@ -114,7 +116,7 @@ export class EditHolidayComponent implements OnInit { }); } const holidayForm = this.holidayForm.value; - holidayForm.locale = 'en'; + holidayForm.locale = this.settings.language.code; holidayForm.dateFormat = dateFormat; this.organizatioService.updateHoliday(this.holidayData.id, holidayForm).subscribe(response => { /** TODO Add Redirects to ViewMakerCheckerTask page. */ diff --git a/src/app/organization/loan-provisioning-criteria/create-loan-provisioning-criteria/create-loan-provisioning-criteria.component.ts b/src/app/organization/loan-provisioning-criteria/create-loan-provisioning-criteria/create-loan-provisioning-criteria.component.ts index 36117d3a9..e231cdac7 100644 --- a/src/app/organization/loan-provisioning-criteria/create-loan-provisioning-criteria/create-loan-provisioning-criteria.component.ts +++ b/src/app/organization/loan-provisioning-criteria/create-loan-provisioning-criteria/create-loan-provisioning-criteria.component.ts @@ -15,6 +15,7 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen /** Custom Services */ import { OrganizationService } from '../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create Loan Provisioning Criteria Component. @@ -54,11 +55,13 @@ export class CreateLoanProvisioningCriteriaComponent implements OnInit { * Retrieves the offices data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, + private settingsService: SettingsService, private router: Router, public dialog: MatDialog, private route: ActivatedRoute) { @@ -171,7 +174,7 @@ export class CreateLoanProvisioningCriteriaComponent implements OnInit { * Creates a loan provisioning criteria. */ submit() { - const locale = 'en'; + const locale = this.settingsService.language.code; const loanProvisioningCriteria = { ...this.provisioningCriteriaForm.value, loanProducts: this.provisioningCriteriaForm.get('loanProducts').value.map((product: any) => ({ diff --git a/src/app/organization/loan-provisioning-criteria/edit-loan-provisioning-criteria/edit-loan-provisioning-criteria.component.ts b/src/app/organization/loan-provisioning-criteria/edit-loan-provisioning-criteria/edit-loan-provisioning-criteria.component.ts index 05a6a1b78..e84025860 100644 --- a/src/app/organization/loan-provisioning-criteria/edit-loan-provisioning-criteria/edit-loan-provisioning-criteria.component.ts +++ b/src/app/organization/loan-provisioning-criteria/edit-loan-provisioning-criteria/edit-loan-provisioning-criteria.component.ts @@ -15,6 +15,7 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen /** Custom Services */ import { OrganizationService } from '../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Loan Provisioning Criteria Component. @@ -54,12 +55,14 @@ export class EditLoanProvisioningCriteriaComponent implements OnInit { * Retrieves the offices data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private router: Router, + private settingsService: SettingsService, public dialog: MatDialog, private route: ActivatedRoute) { this.route.data.subscribe((data: { loanProvisioningCriteriaAndTemplate: any }) => { @@ -179,7 +182,7 @@ export class EditLoanProvisioningCriteriaComponent implements OnInit { * Edits the loan provisioning criteria. */ submit() { - const locale = 'en'; + const locale = this.settingsService.language.code; const loanProvisioningCriteria = { ...this.provisioningCriteriaForm.value, loanProducts: this.provisioningCriteriaForm.get('loanProducts').value.map((product: any) => ({ diff --git a/src/app/organization/offices/create-office/create-office.component.ts b/src/app/organization/offices/create-office/create-office.component.ts index 62afb72f8..dce7b6c75 100644 --- a/src/app/organization/offices/create-office/create-office.component.ts +++ b/src/app/organization/offices/create-office/create-office.component.ts @@ -31,6 +31,7 @@ export class CreateOfficeComponent implements OnInit { * Retrieves the offices data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {DatePipe} datePipe Date Pipe to format date. diff --git a/src/app/organization/offices/edit-office/edit-office.component.ts b/src/app/organization/offices/edit-office/edit-office.component.ts index aebc1ebed..6075151c9 100644 --- a/src/app/organization/offices/edit-office/edit-office.component.ts +++ b/src/app/organization/offices/edit-office/edit-office.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Office component. @@ -29,6 +30,7 @@ export class EditOfficeComponent implements OnInit { /** * Retrieves the charge data from `resolve`. * @param {ProductsService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. @@ -36,6 +38,7 @@ export class EditOfficeComponent implements OnInit { * @param {DatePipe} datepipe Convert Date. */ constructor(private organizationService: OrganizationService, + private settingsService: SettingsService, private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, @@ -68,12 +71,12 @@ export class EditOfficeComponent implements OnInit { */ submit() { const openedOn: Date = this.officeForm.value.openingDate; - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; this.officeForm.patchValue({ openingDate: this.datepipe.transform(openedOn, dateFormat) }); const office = this.officeForm.value; - office.locale = 'en'; + office.locale = this.settingsService.language.code; office.dateFormat = dateFormat; this.organizationService.updateOffice(this.officeData.id, office).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); diff --git a/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts b/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts index b62c239f4..83fa61561 100644 --- a/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts +++ b/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts @@ -18,6 +18,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke /** Custom Services */ import { OrganizationService } from '../../../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Office Multi Row Data Tables @@ -51,11 +52,13 @@ export class MultiRowComponent implements OnInit, OnChanges { * @param {ActivatedRoute} route Activated Route. * @param {DatePipe} datePipe Date Pipe. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {MatDialog} dialog Mat Dialog. */ constructor(private route: ActivatedRoute, private datePipe: DatePipe, private organizationService: OrganizationService, + private settingsService: SettingsService, private dialog: MatDialog) { this.officeId = this.route.parent.parent.snapshot.paramMap.get('id'); } @@ -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 !== 'office_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, diff --git a/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts b/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts index 75603624c..fc293503c 100644 --- a/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts +++ b/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts @@ -17,6 +17,7 @@ import { CheckboxBase } from 'app/shared/form-dialog/formfield/model/checkbox-ba /** Custom Services */ import { OrganizationService } from '../../../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Offices Single Row Data Tables @@ -41,12 +42,14 @@ export class SingleRowComponent implements OnInit { * @param {ActivatedRoute} route Activated Route. * @param {DatePipe} datePipe Date Pipe. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {MatDialog} dialog Mat Dialog. */ constructor(private route: ActivatedRoute, private datePipe: DatePipe, private dialog: MatDialog, - private organizationService: OrganizationService) { + private organizationService: OrganizationService, + private settingsService: SettingsService ) { this.officeId = this.route.parent.parent.snapshot.paramMap.get('id'); } @@ -64,7 +67,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 !== 'office_id')); @@ -94,7 +97,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 !== 'office_id')); @@ -179,7 +182,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, diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index 3ecae14ff..e543630fd 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -5,6 +5,9 @@ import { HttpClient, HttpParams } from '@angular/common/http'; /** rxjs Imports */ import { Observable } from 'rxjs'; +/** Custom Imports. */ +import { SettingsService } from 'app/settings/settings.service'; + /** * Organization service. */ @@ -16,7 +19,7 @@ export class OrganizationService { /** * @param {HttpClient} http Http Client to send requests. */ - constructor(private http: HttpClient) { } + constructor(private http: HttpClient, private settingsService: SettingsService) { } /** * @returns {Observable} Loan Provisioning Criteria data @@ -740,8 +743,8 @@ export class OrganizationService { getImportTemplate(urlSuffix: string, officeId: any, staffId: any, legalFormType: string): Observable { let httpParams = new HttpParams() .set('tenantIdentifier', 'default') - .set('locale', 'en') - .set('dateFormat', 'dd MMMM yyyy'); + .set('locale', this.settingsService.language.code) + .set('dateFormat', this.settingsService.dateFormat); if (officeId) { httpParams = httpParams.set('officeId', officeId.toString()); } @@ -778,8 +781,8 @@ export class OrganizationService { } const formData = new FormData(); formData.append('file', file); - formData.append('locale', 'en'); - formData.append('datefFormat', 'dd MMMM yyyy'); + formData.append('locale', this.settingsService.language.code); + formData.append('datefFormat', this.settingsService.dateFormat); return this.http.post(`${urlSuffix}/uploadtemplate`, formData , { params: httpParams } ); } diff --git a/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts b/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts index acb803ca1..289d80438 100644 --- a/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts +++ b/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts @@ -9,6 +9,7 @@ import { CampaignMessageStepComponent } from '../sms-campaign-stepper/campaign-m /** Custom Services */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create SMS Campaign Component @@ -35,11 +36,13 @@ export class CreateCampaignComponent { * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {OrganizationService} organizationService Organization Service + * @param {SettingsService} settingsService Settings Service * @param {DatePipe} datePipe Date Pipe */ constructor(private route: ActivatedRoute, private router: Router, private organizationService: OrganizationService, + private settingsService: SettingsService, private datePipe: DatePipe) { this.route.data.subscribe((data: { smsCampaignTemplate: any }) => { this.smsCampaignTemplate = data.smsCampaignTemplate; @@ -76,8 +79,8 @@ export class CreateCampaignComponent { */ 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 dateTimeFormat = 'dd MMMM yyyy HH:mm:ss'; const smsCampaign = { ...this.smsCampaign, diff --git a/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts b/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts index e276efb85..51b19f4e8 100644 --- a/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts +++ b/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts @@ -5,6 +5,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** Custom Components */ import { CampaignMessageStepComponent } from '../sms-campaign-stepper/campaign-message-step/campaign-message-step.component'; @@ -35,11 +36,13 @@ export class EditCampaignComponent { * @param {Router} router Router * @param {DatePipe} datePipe Date Pipe * @param {OrganizationService} organizationService Organiztion Service + * @param {SettingsService} settingsService Settings Service */ constructor(private route: ActivatedRoute, private router: Router, private datePipe: DatePipe, - private organizationService: OrganizationService) { + private organizationService: OrganizationService, + private settingsService: SettingsService) { this.route.data.subscribe((data: { smsCampaign: any, smsCampaignTemplate: any }) => { this.smsCampaignTemplate = data.smsCampaignTemplate; this.smsCampaign = data.smsCampaign; @@ -67,8 +70,8 @@ export class EditCampaignComponent { */ 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 dateTimeFormat = 'dd MMMM yyyy HH:mm:ss'; const smsCampaign: any = { campaignName: this.smsCampaign.campaignName, diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts index 6597287d6..7ed65d817 100644 --- a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts +++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts @@ -8,6 +8,7 @@ import { distinctUntilChanged } from 'rxjs/operators'; /** Custom Services */ import { ReportsService } from 'app/reports/reports.service'; +import { SettingsService } from 'app/settings/settings.service'; /** Custom Models */ import { ReportParameter } from 'app/reports/common-models/report-parameter.model'; @@ -45,6 +46,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges { * @param {ReportsService} reportsService Reports Service */ constructor(private reportsService: ReportsService, + private settingsService: SettingsService, private datePipe: DatePipe) { } ngOnChanges() { @@ -75,7 +77,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges { this.fetchSelectOptions(param, param.name); break; case 'date': - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; const newControlValue = this.datePipe.transform(controlValue, dateFormat); this.ReportForm.get(param.name).patchValue(newControlValue); break; diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts b/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts index 8ab0f4bb7..54934d2ff 100644 --- a/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts +++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts @@ -5,6 +5,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { ReportsService } from 'app/reports/reports.service'; +import { SettingsService } from 'app/settings/settings.service'; /** Custom Models */ import { ReportParameter } from 'app/reports/common-models/report-parameter.model'; @@ -38,10 +39,12 @@ export class BusinessRuleParametersComponent implements OnChanges { @Output() templateParameters = new EventEmitter(); /** - * @param {ReportsService} reportsService Reports Service - * @param {DatePipe} datePipe Date Pipe + * @param {ReportsService} reportsService Reports Service. + * @param {SettingsService} settingsService Settings Service. + * @param {DatePipe} datePipe Date Pipe. */ constructor(private reportsService: ReportsService, + private settingsService: SettingsService, private datePipe: DatePipe) { } ngOnChanges() { @@ -152,7 +155,7 @@ export class BusinessRuleParametersComponent implements OnChanges { formattedResponse[newKey] = value['id']; break; case 'date': - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; formattedResponse[newKey] = this.datePipe.transform(value, dateFormat); break; case 'none': diff --git a/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts b/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts index 656b2977c..f8bd7bdce 100644 --- a/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts +++ b/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts @@ -16,6 +16,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke /** Custom Services */ import { OrganizationService } from '../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * View SMS Campaign Component @@ -77,13 +78,15 @@ export class ViewCampaignComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder * @param {DatePipe} datePipe Date Pipe * @param {OrganizationService} organizationService Organization Service + * @param {SettingsService} settingsService Setting Service */ constructor(private router: Router, private route: ActivatedRoute, public dialog: MatDialog, private formBuilder: FormBuilder, private datePipe: DatePipe, - private organizationService: OrganizationService) { + private organizationService: OrganizationService, + private settingsService: SettingsService) { this.route.data.subscribe((data: { smsCampaign: any }) => { this.smsCampaignData = data.smsCampaign; }); @@ -140,8 +143,8 @@ export class ViewCampaignComponent implements OnInit { const closeCampaignDialogRef = this.dialog.open(FormDialogComponent, { data }); closeCampaignDialogRef.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 = { closureDate: this.datePipe.transform(response.data.value.closureDate, dateFormat), dateFormat, @@ -175,8 +178,8 @@ export class ViewCampaignComponent implements OnInit { const activateCampaignDialogRef = this.dialog.open(FormDialogComponent, { data }); activateCampaignDialogRef.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 = { activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat), dateFormat, @@ -210,8 +213,8 @@ export class ViewCampaignComponent implements OnInit { const reactivateCampaignDialogRef = this.dialog.open(FormDialogComponent, { data }); reactivateCampaignDialogRef.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 = { activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat), dateFormat, @@ -257,14 +260,14 @@ export class ViewCampaignComponent implements OnInit { const prevFromDate: Date = this.smsForm.value.fromDate; const prevToDate: Date = this.smsForm.value.toDate; // TODO: Update once language and date settings are setup - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; this.smsForm.patchValue({ fromDate: this.datePipe.transform(prevFromDate, dateFormat), toDate: this.datePipe.transform(prevToDate, dateFormat) }); const SMS = this.smsForm.value; SMS.id = this.smsCampaignData.id; - SMS.locale = 'en'; + SMS.locale = this.settingsService.language.code; SMS.dateFormat = dateFormat; SMS.status = this.status; this.organizationService.getMessagebyStatus(SMS).subscribe((response: any) => { diff --git a/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts b/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts index 06cd29591..79aa1acbc 100644 --- a/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts +++ b/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts @@ -9,6 +9,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * View Standing Instructions History Component. @@ -45,12 +46,14 @@ export class StandingInstructionsHistoryComponent implements OnInit { * Retrieves the instructions template from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {DatePipe} datePipe Date Pipe to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, + private settingsService: SettingsService, private router: Router, private route: ActivatedRoute, private datePipe: DatePipe) { @@ -103,9 +106,9 @@ export class StandingInstructionsHistoryComponent implements OnInit { search() { this.isCollapsed = true; // TODO: Update once language and date settings are setup - const dateFormat = 'dd MMMM yyyy'; + const dateFormat = this.settingsService.dateFormat; const instruction = this.instructionForm.value; - instruction.locale = 'en'; + instruction.locale = this.settingsService.language.code; instruction.dateFormat = dateFormat; instruction.fromDate = this.datePipe.transform(instruction.fromDate, dateFormat); instruction.toDate = this.datePipe.transform(instruction.toDate, dateFormat); diff --git a/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts b/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts index d14fe4eaf..6a2a49a9e 100644 --- a/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts +++ b/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Allocate Cash component. @@ -32,12 +33,14 @@ export class AllocateCashComponent implements OnInit { * @param {ActivatedRoute} route ActivateRoute. * @param {DatePipe} datePipe Date Pipe. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private datePipe: DatePipe, private organizationService: OrganizationService, + private settingsService: SettingsService, private router: Router) { this.route.data.subscribe((data: { cashierTemplate: any}) => { this.cashierData = data.cashierTemplate; @@ -68,14 +71,14 @@ export class AllocateCashComponent implements OnInit { * Submits Allocate Cash form. */ submit() { - const dateFormat = 'dd MMMM yyyy'; + const dateFormat = this.settingsService.dateFormat; const txnDate = this.allocateCashForm.value.txnDate; this.allocateCashForm.patchValue({ txnDate: this.datePipe.transform(txnDate, dateFormat) }); const allocateCashForm = this.allocateCashForm.value; allocateCashForm.dateFormat = dateFormat; - allocateCashForm.locale = 'en'; + allocateCashForm.locale = this.settingsService.language.code; this.organizationService.allocateCash(this.cashierData.tellerId, this.cashierData.cashierId, allocateCashForm).subscribe((response: any) => { this.router.navigate(['../'], {relativeTo: this.route}); }); diff --git a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts index 1eaaeeb44..910ab86d6 100644 --- a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts +++ b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create Cashier component. @@ -33,12 +34,14 @@ export class CreateCashierComponent implements OnInit { * @param {Router} router Router. * @param {DatePipe} datePipe Date Pipe. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private datePipe: DatePipe, - private organizationService: OrganizationService ) { + private organizationService: OrganizationService, + private settingsService: SettingsService ) { this.route.data.subscribe((data: { cashierTemplate: any }) => { this.cashierTemplate = data.cashierTemplate; }); @@ -65,7 +68,7 @@ export class CreateCashierComponent implements OnInit { * Submits Create cashier form. */ submit() { - const dateFormat = 'dd MMMM yyyy'; + const dateFormat = this.settingsService.dateFormat; const startDate = this.createCashierForm.value.startDate; const endDate = this.createCashierForm.value.endDate; this.createCashierForm.patchValue({ @@ -73,7 +76,7 @@ export class CreateCashierComponent implements OnInit { 'endDate': this.datePipe.transform(endDate, dateFormat) }); const createCashierForm = this.createCashierForm.value; - createCashierForm.locale = 'en'; + createCashierForm.locale = this.settingsService.language.code; createCashierForm.dateFormat = dateFormat; this.organizationService.createCashier(this.cashierTemplate.tellerId, createCashierForm).subscribe((response: any) => { this.router.navigate(['../'], {relativeTo: this.route}); diff --git a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts index 94afcc3aa..3ad9041b8 100644 --- a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts +++ b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Cashier component. @@ -35,12 +36,14 @@ export class EditCashierComponent implements OnInit { * @param {Router} router Router. * @param {DatePipe} datePipe Date Pipe. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private datePipe: DatePipe, - private organizationService: OrganizationService ) { + private organizationService: OrganizationService, + private settingsService: SettingsService ) { this.route.data.subscribe((data: { cashier: any, cashierTemplate: any }) => { this.cashierData.data = data.cashier; this.cashierData.template = data.cashierTemplate; @@ -69,7 +72,7 @@ export class EditCashierComponent implements OnInit { * Submits edit cashier form. */ submit() { - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; const startDate = this.editCashierForm.value.startDate; const endDate = this.editCashierForm.value.endDate; this.editCashierForm.patchValue({ @@ -77,7 +80,7 @@ export class EditCashierComponent implements OnInit { 'endDate': this.datePipe.transform(endDate, dateFormat) }); const editCashierForm = this.editCashierForm.value; - editCashierForm.locale = 'en'; + editCashierForm.locale = this.settingsService.language.code; editCashierForm.dateFormat = dateFormat; editCashierForm.staffId = this.cashierData.data.staffId; this.organizationService.updateCashier(this.cashierData.data.tellerId, this.cashierData.data.id, editCashierForm).subscribe((response: any) => { diff --git a/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts b/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts index 138cb3029..a966fab45 100644 --- a/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts +++ b/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts @@ -1,8 +1,12 @@ +/** Angular Imports. */ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { DatePipe } from '@angular/common'; + +/** Customer Services. */ import { OrganizationService } from 'app/organization/organization.service'; +import { SettingsService } from 'app/settings/settings.service'; @Component({ selector: 'mifosx-settle-cash', @@ -26,12 +30,14 @@ export class SettleCashComponent implements OnInit { * @param {ActivatedRoute} route ActivateRoute. * @param {DatePipe} datePipe Date Pipe. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private datePipe: DatePipe, private organizationService: OrganizationService, + private settingsService: SettingsService, private router: Router) { this.route.data.subscribe((data: { cashierTemplate: any}) => { this.cashierData = data.cashierTemplate; @@ -62,14 +68,14 @@ export class SettleCashComponent implements OnInit { * Submits Settle Cash form. */ submit() { - const dateFormat = 'dd MMMM yyyy'; + const dateFormat = this.settingsService.dateFormat; const txnDate = this.settleCashForm.value.txnDate; this.settleCashForm.patchValue({ txnDate: this.datePipe.transform(txnDate, dateFormat) }); const settleCashForm = this.settleCashForm.value; settleCashForm.dateFormat = dateFormat; - settleCashForm.locale = 'en'; + settleCashForm.locale = this.settingsService.language.code; this.organizationService.settleCash(this.cashierData.tellerId, this.cashierData.cashierId, settleCashForm).subscribe((response: any) => { this.router.navigate(['../'], {relativeTo: this.route}); }); diff --git a/src/app/organization/tellers/create-teller/create-teller.component.ts b/src/app/organization/tellers/create-teller/create-teller.component.ts index e8bdb4ea6..216112e02 100644 --- a/src/app/organization/tellers/create-teller/create-teller.component.ts +++ b/src/app/organization/tellers/create-teller/create-teller.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create teller component. @@ -32,12 +33,14 @@ export class CreateTellerComponent implements OnInit { * Retrieves the offices data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {DatePipe} datePipe Date Pipe to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, + private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, private datePipe: DatePipe) { @@ -77,13 +80,13 @@ export class CreateTellerComponent implements OnInit { const prevStartDate: Date = this.tellerForm.value.startDate; const prevEndDate: Date = this.tellerForm.value.endDate; // TODO: Update once language and date settings are setup - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; this.tellerForm.patchValue({ startDate: this.datePipe.transform(prevStartDate, dateFormat), endDate: this.datePipe.transform(prevEndDate, dateFormat) }); const teller = this.tellerForm.value; - teller.locale = 'en'; + teller.locale = this.settingsService.language.code; teller.dateFormat = dateFormat; this.organizationService.createTeller(teller).subscribe((response: any) => { this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); diff --git a/src/app/organization/tellers/edit-teller/edit-teller.component.ts b/src/app/organization/tellers/edit-teller/edit-teller.component.ts index cde547059..a5638af64 100644 --- a/src/app/organization/tellers/edit-teller/edit-teller.component.ts +++ b/src/app/organization/tellers/edit-teller/edit-teller.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create teller component. @@ -35,12 +36,14 @@ export class EditTellerComponent implements OnInit { * Retrieves the offices data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {DatePipe} datePipe Date Pipe to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, + private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, private datePipe: DatePipe) { @@ -89,13 +92,13 @@ export class EditTellerComponent implements OnInit { const prevStartDate: Date = this.tellerForm.value.startDate; const prevEndDate: Date = this.tellerForm.value.endDate; // TODO: Update once language and date settings are setup - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; this.tellerForm.patchValue({ startDate: this.datePipe.transform(prevStartDate, dateFormat), endDate: this.datePipe.transform(prevEndDate, dateFormat) }); const teller = this.tellerForm.value; - teller.locale = 'en'; + teller.locale = this.settingsService.language.code; teller.officeId = this.tellerData.officeId; teller.dateFormat = dateFormat; this.organizationService.updateTeller(this.tellerData.id, teller).subscribe((response: any) => { diff --git a/src/app/organization/working-days/working-days.component.ts b/src/app/organization/working-days/working-days.component.ts index 5488e63de..1923f96ba 100644 --- a/src/app/organization/working-days/working-days.component.ts +++ b/src/app/organization/working-days/working-days.component.ts @@ -5,6 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router'; /** Custom Services */ import { OrganizationService } from '../organization.service'; +import { SettingsService } from 'app/settings/settings.service'; /** Recurrence default value. */ const recurrenceDefaultValue = 'FREQ=WEEKLY;INTERVAL=1;BYDAY='; @@ -41,11 +42,13 @@ export class WorkingDaysComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. * @param {OrganizationService} organizationService Organization Service. + * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router for navigation. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private organizationService: OrganizationService, + private settingsService: SettingsService, private router: Router) { this.route.data.subscribe((data: { workingDays: any }) => { this.workingDaysData = data.workingDays; @@ -103,7 +106,7 @@ export class WorkingDaysComponent implements OnInit { submit() { const workingDays = this.workingDaysForm.value; // TODO: Update once language and date settings are setup - workingDays.locale = 'en'; + workingDays.locale = this.settingsService.language.code; let recurrence = recurrenceDefaultValue; for (let i = 0; i < this.weekDays.length; i++) { if (workingDays.recurrence[i]) {