refactor (df/locale): organization module (#1268)

See: #1213
This commit is contained in:
Benura Abeywardena
2020-11-12 19:36:37 +05:30
committed by GitHub
parent dbd34aaf42
commit 5f90bc00bd
26 changed files with 139 additions and 62 deletions
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services. */ /** Custom Services. */
import { OrganizationService } from '../organization.service'; import { OrganizationService } from '../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Bulk Loan Reassignment component. * Bulk Loan Reassignment component.
@@ -40,11 +41,14 @@ export class BulkLoanReassignmnetComponent implements OnInit {
* Get Office data from `resolver`. * Get Office data from `resolver`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {OrganizationService} organizationSevice Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {Router} router Router. * @param {Router} router Router.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private organizationSevice: OrganizationService, private organizationSevice: OrganizationService,
private settingsService: SettingsService,
private datePipe: DatePipe, private datePipe: DatePipe,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { offices: any} ) => { this.route.data.subscribe((data: { offices: any} ) => {
@@ -109,13 +113,13 @@ export class BulkLoanReassignmnetComponent implements OnInit {
* Submits bulk loan reassignment form. * Submits bulk loan reassignment form.
*/ */
submit() { submit() {
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
const assignmentDate = this.bulkLoanForm.value.assignmentDate; const assignmentDate = this.bulkLoanForm.value.assignmentDate;
this.bulkLoanForm.patchValue({ this.bulkLoanForm.patchValue({
assignmentDate: this.datePipe.transform(assignmentDate, dateFormat) assignmentDate: this.datePipe.transform(assignmentDate, dateFormat)
}); });
const bulkForm = this.bulkLoanForm.value; const bulkForm = this.bulkLoanForm.value;
bulkForm.locale = 'en'; bulkForm.locale = this.settingsService.language.code;
bulkForm.dateFormat = dateFormat; bulkForm.dateFormat = dateFormat;
bulkForm.loans = this.loans; bulkForm.loans = this.loans;
this.organizationSevice.createLoanReassignment(bulkForm).subscribe((response: any) => { this.organizationSevice.createLoanReassignment(bulkForm).subscribe((response: any) => {
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../../organization.service'; import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create employee component. * Create employee component.
@@ -30,12 +31,14 @@ export class CreateEmployeeComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date. * @param {DatePipe} datePipe Date Pipe to format date.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe) { private datePipe: DatePipe) {
@@ -72,12 +75,12 @@ export class CreateEmployeeComponent implements OnInit {
submit() { submit() {
const prevJoiningDate: Date = this.employeeForm.value.joiningDate; const prevJoiningDate: Date = this.employeeForm.value.joiningDate;
// 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.employeeForm.patchValue({ this.employeeForm.patchValue({
joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat) joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat)
}); });
const employee = this.employeeForm.value; const employee = this.employeeForm.value;
employee.locale = 'en'; employee.locale = this.settingsService.language.code;
employee.dateFormat = dateFormat; employee.dateFormat = dateFormat;
this.organizationService.createEmployee(employee).subscribe((response: any) => { this.organizationService.createEmployee(employee).subscribe((response: any) => {
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 { OrganizationService } from '../../organization.service'; import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Edit Employee Component. * Edit Employee Component.
@@ -32,12 +33,14 @@ export class EditEmployeeComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date. * @param {DatePipe} datePipe Date Pipe to format date.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe) { private datePipe: DatePipe) {
@@ -76,12 +79,12 @@ export class EditEmployeeComponent implements OnInit {
submit() { submit() {
const prevJoiningDate: Date = this.editEmployeeForm.value.joiningDate; const prevJoiningDate: Date = this.editEmployeeForm.value.joiningDate;
// 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.editEmployeeForm.patchValue({ this.editEmployeeForm.patchValue({
joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat) joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat)
}); });
const employee = this.editEmployeeForm.value; const employee = this.editEmployeeForm.value;
employee.locale = 'en'; employee.locale = this.settingsService.language.code;
employee.dateFormat = dateFormat; employee.dateFormat = dateFormat;
this.organizationService.updateEmployee(this.employeeData.id, employee).subscribe((response: any) => { this.organizationService.updateEmployee(this.employeeData.id, employee).subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
@@ -9,6 +9,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../organization.service'; import { OrganizationService } from '../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Fund Mapping Component. * Fund Mapping Component.
@@ -45,11 +46,13 @@ export class FundMappingComponent implements OnInit {
* Retrieves the advance search template from `resolve`. * Retrieves the advance search template from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date. * @param {DatePipe} datePipe Date Pipe to format date.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private datePipe: DatePipe) { private datePipe: DatePipe) {
this.route.data.subscribe((data: { advanceSearchTemplate: any }) => { this.route.data.subscribe((data: { advanceSearchTemplate: any }) => {
@@ -146,8 +149,8 @@ export class FundMappingComponent implements OnInit {
submit() { submit() {
this.isCollapsed = true; this.isCollapsed = true;
// 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 = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
this.fundMappingForm.patchValue({ this.fundMappingForm.patchValue({
'loanFromDate': this.datePipe.transform(this.fundMappingForm.value.loanFromDate, dateFormat), 'loanFromDate': this.datePipe.transform(this.fundMappingForm.value.loanFromDate, dateFormat),
'loanToDate': this.datePipe.transform(this.fundMappingForm.value.loanToDate, dateFormat) 'loanToDate': this.datePipe.transform(this.fundMappingForm.value.loanToDate, dateFormat)
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services. */ /** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create Holiday component. * Create Holiday component.
@@ -41,6 +42,7 @@ export class CreateHolidayComponent implements OnInit {
private route: ActivatedRoute, private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settings: SettingsService,
private router: Router ) { private router: Router ) {
this.route.data.subscribe((data: { offices: any, holidayTemplate: any }) => { this.route.data.subscribe((data: { offices: any, holidayTemplate: any }) => {
this.officesData = data.offices; this.officesData = data.offices;
@@ -84,8 +86,8 @@ export class CreateHolidayComponent implements OnInit {
* Submits the create holiday Form. * Submits the create holiday Form.
*/ */
submit() { submit() {
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settings.dateFormat;
const locale = 'en'; const locale = this.settings.language.code;
this.holidayForm.patchValue({ this.holidayForm.patchValue({
'fromDate': this.datePipe.transform(this.holidayForm.value.fromDate, dateFormat), 'fromDate': this.datePipe.transform(this.holidayForm.value.fromDate, dateFormat),
'toDate': this.datePipe.transform(this.holidayForm.value.toDate, dateFormat), 'toDate': this.datePipe.transform(this.holidayForm.value.toDate, dateFormat),
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services. */ /** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Edit Holiday component. * Edit Holiday component.
@@ -42,6 +43,7 @@ export class EditHolidayComponent implements OnInit {
private route: ActivatedRoute, private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private organizatioService: OrganizationService, private organizatioService: OrganizationService,
private settings: SettingsService,
private router: Router ) { private router: Router ) {
this.route.data.subscribe((data: { holiday: any, holidayTemplate: any }) => { this.route.data.subscribe((data: { holiday: any, holidayTemplate: any }) => {
this.holidayData = data.holiday; this.holidayData = data.holiday;
@@ -98,7 +100,7 @@ export class EditHolidayComponent implements OnInit {
* Submits Edit Holiday Form. * Submits Edit Holiday Form.
*/ */
submit() { submit() {
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settings.dateFormat;
if (!this.isActiveHoliday) { if (!this.isActiveHoliday) {
const fromDate: Date = this.holidayForm.value.fromDate; const fromDate: Date = this.holidayForm.value.fromDate;
const toDate: Date = this.holidayForm.value.toDate; const toDate: Date = this.holidayForm.value.toDate;
@@ -114,7 +116,7 @@ export class EditHolidayComponent implements OnInit {
}); });
} }
const holidayForm = this.holidayForm.value; const holidayForm = this.holidayForm.value;
holidayForm.locale = 'en'; holidayForm.locale = this.settings.language.code;
holidayForm.dateFormat = dateFormat; holidayForm.dateFormat = dateFormat;
this.organizatioService.updateHoliday(this.holidayData.id, holidayForm).subscribe(response => { this.organizatioService.updateHoliday(this.holidayData.id, holidayForm).subscribe(response => {
/** TODO Add Redirects to ViewMakerCheckerTask page. */ /** TODO Add Redirects to ViewMakerCheckerTask page. */
@@ -15,6 +15,7 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../../organization.service'; import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create Loan Provisioning Criteria Component. * Create Loan Provisioning Criteria Component.
@@ -54,11 +55,13 @@ export class CreateLoanProvisioningCriteriaComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router, private router: Router,
public dialog: MatDialog, public dialog: MatDialog,
private route: ActivatedRoute) { private route: ActivatedRoute) {
@@ -171,7 +174,7 @@ export class CreateLoanProvisioningCriteriaComponent implements OnInit {
* Creates a loan provisioning criteria. * Creates a loan provisioning criteria.
*/ */
submit() { submit() {
const locale = 'en'; const locale = this.settingsService.language.code;
const loanProvisioningCriteria = { const loanProvisioningCriteria = {
...this.provisioningCriteriaForm.value, ...this.provisioningCriteriaForm.value,
loanProducts: this.provisioningCriteriaForm.get('loanProducts').value.map((product: any) => ({ loanProducts: this.provisioningCriteriaForm.get('loanProducts').value.map((product: any) => ({
@@ -15,6 +15,7 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../../organization.service'; import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Edit Loan Provisioning Criteria Component. * Edit Loan Provisioning Criteria Component.
@@ -54,12 +55,14 @@ export class EditLoanProvisioningCriteriaComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private router: Router, private router: Router,
private settingsService: SettingsService,
public dialog: MatDialog, public dialog: MatDialog,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.route.data.subscribe((data: { loanProvisioningCriteriaAndTemplate: any }) => { this.route.data.subscribe((data: { loanProvisioningCriteriaAndTemplate: any }) => {
@@ -179,7 +182,7 @@ export class EditLoanProvisioningCriteriaComponent implements OnInit {
* Edits the loan provisioning criteria. * Edits the loan provisioning criteria.
*/ */
submit() { submit() {
const locale = 'en'; const locale = this.settingsService.language.code;
const loanProvisioningCriteria = { const loanProvisioningCriteria = {
...this.provisioningCriteriaForm.value, ...this.provisioningCriteriaForm.value,
loanProducts: this.provisioningCriteriaForm.get('loanProducts').value.map((product: any) => ({ loanProducts: this.provisioningCriteriaForm.get('loanProducts').value.map((product: any) => ({
@@ -31,6 +31,7 @@ export class CreateOfficeComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date. * @param {DatePipe} datePipe Date Pipe to format date.
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Edit Office component. * Edit Office component.
@@ -29,6 +30,7 @@ export class EditOfficeComponent implements OnInit {
/** /**
* Retrieves the charge data from `resolve`. * Retrieves the charge data from `resolve`.
* @param {ProductsService} organizationService Organization Service. * @param {ProductsService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @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.
@@ -36,6 +38,7 @@ export class EditOfficeComponent implements OnInit {
* @param {DatePipe} datepipe Convert Date. * @param {DatePipe} datepipe Convert Date.
*/ */
constructor(private organizationService: OrganizationService, constructor(private organizationService: OrganizationService,
private settingsService: SettingsService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
@@ -68,12 +71,12 @@ export class EditOfficeComponent implements OnInit {
*/ */
submit() { submit() {
const openedOn: Date = this.officeForm.value.openingDate; const openedOn: Date = this.officeForm.value.openingDate;
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
this.officeForm.patchValue({ this.officeForm.patchValue({
openingDate: this.datepipe.transform(openedOn, dateFormat) openingDate: this.datepipe.transform(openedOn, dateFormat)
}); });
const office = this.officeForm.value; const office = this.officeForm.value;
office.locale = 'en'; office.locale = this.settingsService.language.code;
office.dateFormat = dateFormat; office.dateFormat = dateFormat;
this.organizationService.updateOffice(this.officeData.id, office).subscribe((response: any) => { this.organizationService.updateOffice(this.officeData.id, office).subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route }); this.router.navigate(['../'], { relativeTo: this.route });
@@ -18,6 +18,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../../../../organization.service'; import { OrganizationService } from '../../../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Office Multi Row Data Tables * Office Multi Row Data Tables
@@ -51,11 +52,13 @@ export class MultiRowComponent implements OnInit, OnChanges {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe. * @param {DatePipe} datePipe Date Pipe.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {MatDialog} dialog Mat Dialog. * @param {MatDialog} dialog Mat Dialog.
*/ */
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private dialog: MatDialog) { private dialog: MatDialog) {
this.officeId = this.route.parent.parent.snapshot.paramMap.get('id'); 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. * Adds a new row to the given multi row data table.
*/ */
add() { add() {
let dataTableEntryObject: any = { locale: 'en' }; let dataTableEntryObject: any = { 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) => {
return ((column.columnName !== 'id') && (column.columnName !== 'office_id')); return ((column.columnName !== 'id') && (column.columnName !== 'office_id'));
@@ -118,7 +121,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
}); });
case 'DATE': { case 'DATE': {
dateTransformColumns.push(column.columnName); dateTransformColumns.push(column.columnName);
dataTableEntryObject.dateFormat = 'yyyy-MM-dd'; dataTableEntryObject.dateFormat = this.settingsService.dateFormat;
return new DatepickerBase({ return new DatepickerBase({
controlName: column.columnName, controlName: column.columnName,
label: column.columnName, label: column.columnName,
@@ -17,6 +17,7 @@ import { CheckboxBase } from 'app/shared/form-dialog/formfield/model/checkbox-ba
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../../../../organization.service'; import { OrganizationService } from '../../../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Offices Single Row Data Tables * Offices Single Row Data Tables
@@ -41,12 +42,14 @@ export class SingleRowComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe. * @param {DatePipe} datePipe Date Pipe.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {MatDialog} dialog Mat Dialog. * @param {MatDialog} dialog Mat Dialog.
*/ */
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private dialog: MatDialog, private dialog: MatDialog,
private organizationService: OrganizationService) { private organizationService: OrganizationService,
private settingsService: SettingsService ) {
this.officeId = this.route.parent.parent.snapshot.paramMap.get('id'); 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. * Creates a new instance of the given single row data table.
*/ */
add() { add() {
let dataTableEntryObject: any = { locale: 'en' }; let dataTableEntryObject: any = { 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) => {
return ((column.columnName !== 'id') && (column.columnName !== 'office_id')); 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. * Edits the current instance of single row data table.
*/ */
edit() { edit() {
let dataTableEntryObject: any = { locale: 'en' }; let dataTableEntryObject: any = { 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) => {
return ((column.columnName !== 'id') && (column.columnName !== 'office_id')); return ((column.columnName !== 'id') && (column.columnName !== 'office_id'));
@@ -179,7 +182,7 @@ export class SingleRowComponent implements OnInit {
}); });
case 'DATE': { case 'DATE': {
dateTransformColumns.push(column.columnName); dateTransformColumns.push(column.columnName);
dataTableEntryObject.dateFormat = 'yyyy-MM-dd'; dataTableEntryObject.dateFormat = this.settingsService.dateFormat;
return new DatepickerBase({ return new DatepickerBase({
controlName: column.columnName, controlName: column.columnName,
label: column.columnName, label: column.columnName,
+8 -5
View File
@@ -5,6 +5,9 @@ import { HttpClient, HttpParams } from '@angular/common/http';
/** rxjs Imports */ /** rxjs Imports */
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
/** Custom Imports. */
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Organization service. * Organization service.
*/ */
@@ -16,7 +19,7 @@ export class OrganizationService {
/** /**
* @param {HttpClient} http Http Client to send requests. * @param {HttpClient} http Http Client to send requests.
*/ */
constructor(private http: HttpClient) { } constructor(private http: HttpClient, private settingsService: SettingsService) { }
/** /**
* @returns {Observable<any>} Loan Provisioning Criteria data * @returns {Observable<any>} Loan Provisioning Criteria data
@@ -740,8 +743,8 @@ export class OrganizationService {
getImportTemplate(urlSuffix: string, officeId: any, staffId: any, legalFormType: string): Observable<any> { getImportTemplate(urlSuffix: string, officeId: any, staffId: any, legalFormType: string): Observable<any> {
let httpParams = new HttpParams() let httpParams = new HttpParams()
.set('tenantIdentifier', 'default') .set('tenantIdentifier', 'default')
.set('locale', 'en') .set('locale', this.settingsService.language.code)
.set('dateFormat', 'dd MMMM yyyy'); .set('dateFormat', this.settingsService.dateFormat);
if (officeId) { if (officeId) {
httpParams = httpParams.set('officeId', officeId.toString()); httpParams = httpParams.set('officeId', officeId.toString());
} }
@@ -778,8 +781,8 @@ export class OrganizationService {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
formData.append('locale', 'en'); formData.append('locale', this.settingsService.language.code);
formData.append('datefFormat', 'dd MMMM yyyy'); formData.append('datefFormat', this.settingsService.dateFormat);
return this.http.post(`${urlSuffix}/uploadtemplate`, formData , { params: httpParams } ); return this.http.post(`${urlSuffix}/uploadtemplate`, formData , { params: httpParams } );
} }
@@ -9,6 +9,7 @@ import { CampaignMessageStepComponent } from '../sms-campaign-stepper/campaign-m
/** Custom Services */ /** Custom Services */
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create SMS Campaign Component * Create SMS Campaign Component
@@ -35,11 +36,13 @@ export class CreateCampaignComponent {
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {Router} router Router * @param {Router} router Router
* @param {OrganizationService} organizationService Organization Service * @param {OrganizationService} organizationService Organization Service
* @param {SettingsService} settingsService Settings Service
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
*/ */
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private datePipe: DatePipe) { private datePipe: DatePipe) {
this.route.data.subscribe((data: { smsCampaignTemplate: any }) => { this.route.data.subscribe((data: { smsCampaignTemplate: any }) => {
this.smsCampaignTemplate = data.smsCampaignTemplate; this.smsCampaignTemplate = data.smsCampaignTemplate;
@@ -76,8 +79,8 @@ export class CreateCampaignComponent {
*/ */
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 dateTimeFormat = 'dd MMMM yyyy HH:mm:ss'; const dateTimeFormat = 'dd MMMM yyyy HH:mm:ss';
const smsCampaign = { const smsCampaign = {
...this.smsCampaign, ...this.smsCampaign,
@@ -5,6 +5,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** Custom Components */ /** Custom Components */
import { CampaignMessageStepComponent } from '../sms-campaign-stepper/campaign-message-step/campaign-message-step.component'; 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 {Router} router Router
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {OrganizationService} organizationService Organiztion Service * @param {OrganizationService} organizationService Organiztion Service
* @param {SettingsService} settingsService Settings Service
*/ */
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService) { private organizationService: OrganizationService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { smsCampaign: any, smsCampaignTemplate: any }) => { this.route.data.subscribe((data: { smsCampaign: any, smsCampaignTemplate: any }) => {
this.smsCampaignTemplate = data.smsCampaignTemplate; this.smsCampaignTemplate = data.smsCampaignTemplate;
this.smsCampaign = data.smsCampaign; this.smsCampaign = data.smsCampaign;
@@ -67,8 +70,8 @@ export class EditCampaignComponent {
*/ */
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 dateTimeFormat = 'dd MMMM yyyy HH:mm:ss'; const dateTimeFormat = 'dd MMMM yyyy HH:mm:ss';
const smsCampaign: any = { const smsCampaign: any = {
campaignName: this.smsCampaign.campaignName, campaignName: this.smsCampaign.campaignName,
@@ -8,6 +8,7 @@ import { distinctUntilChanged } from 'rxjs/operators';
/** Custom Services */ /** Custom Services */
import { ReportsService } from 'app/reports/reports.service'; import { ReportsService } from 'app/reports/reports.service';
import { SettingsService } from 'app/settings/settings.service';
/** Custom Models */ /** Custom Models */
import { ReportParameter } from 'app/reports/common-models/report-parameter.model'; import { ReportParameter } from 'app/reports/common-models/report-parameter.model';
@@ -45,6 +46,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges {
* @param {ReportsService} reportsService Reports Service * @param {ReportsService} reportsService Reports Service
*/ */
constructor(private reportsService: ReportsService, constructor(private reportsService: ReportsService,
private settingsService: SettingsService,
private datePipe: DatePipe) { } private datePipe: DatePipe) { }
ngOnChanges() { ngOnChanges() {
@@ -75,7 +77,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges {
this.fetchSelectOptions(param, param.name); this.fetchSelectOptions(param, param.name);
break; break;
case 'date': case 'date':
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
const newControlValue = this.datePipe.transform(controlValue, dateFormat); const newControlValue = this.datePipe.transform(controlValue, dateFormat);
this.ReportForm.get(param.name).patchValue(newControlValue); this.ReportForm.get(param.name).patchValue(newControlValue);
break; break;
@@ -5,6 +5,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { ReportsService } from 'app/reports/reports.service'; import { ReportsService } from 'app/reports/reports.service';
import { SettingsService } from 'app/settings/settings.service';
/** Custom Models */ /** Custom Models */
import { ReportParameter } from 'app/reports/common-models/report-parameter.model'; import { ReportParameter } from 'app/reports/common-models/report-parameter.model';
@@ -38,10 +39,12 @@ export class BusinessRuleParametersComponent implements OnChanges {
@Output() templateParameters = new EventEmitter(); @Output() templateParameters = new EventEmitter();
/** /**
* @param {ReportsService} reportsService Reports Service * @param {ReportsService} reportsService Reports Service.
* @param {DatePipe} datePipe Date Pipe * @param {SettingsService} settingsService Settings Service.
* @param {DatePipe} datePipe Date Pipe.
*/ */
constructor(private reportsService: ReportsService, constructor(private reportsService: ReportsService,
private settingsService: SettingsService,
private datePipe: DatePipe) { } private datePipe: DatePipe) { }
ngOnChanges() { ngOnChanges() {
@@ -152,7 +155,7 @@ export class BusinessRuleParametersComponent implements OnChanges {
formattedResponse[newKey] = value['id']; formattedResponse[newKey] = value['id'];
break; break;
case 'date': case 'date':
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
formattedResponse[newKey] = this.datePipe.transform(value, dateFormat); formattedResponse[newKey] = this.datePipe.transform(value, dateFormat);
break; break;
case 'none': case 'none':
@@ -16,6 +16,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../../organization.service'; import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* View SMS Campaign Component * View SMS Campaign Component
@@ -77,13 +78,15 @@ export class ViewCampaignComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder * @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {OrganizationService} organizationService Organization Service * @param {OrganizationService} organizationService Organization Service
* @param {SettingsService} settingsService Setting Service
*/ */
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
public dialog: MatDialog, public dialog: MatDialog,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService) { private organizationService: OrganizationService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { smsCampaign: any }) => { this.route.data.subscribe((data: { smsCampaign: any }) => {
this.smsCampaignData = data.smsCampaign; this.smsCampaignData = data.smsCampaign;
}); });
@@ -140,8 +143,8 @@ export class ViewCampaignComponent implements OnInit {
const closeCampaignDialogRef = this.dialog.open(FormDialogComponent, { data }); const closeCampaignDialogRef = this.dialog.open(FormDialogComponent, { data });
closeCampaignDialogRef.afterClosed().subscribe((response: any) => { closeCampaignDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) { if (response.data) {
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const dataObject = { const dataObject = {
closureDate: this.datePipe.transform(response.data.value.closureDate, dateFormat), closureDate: this.datePipe.transform(response.data.value.closureDate, dateFormat),
dateFormat, dateFormat,
@@ -175,8 +178,8 @@ export class ViewCampaignComponent implements OnInit {
const activateCampaignDialogRef = this.dialog.open(FormDialogComponent, { data }); const activateCampaignDialogRef = this.dialog.open(FormDialogComponent, { data });
activateCampaignDialogRef.afterClosed().subscribe((response: any) => { activateCampaignDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) { if (response.data) {
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const dataObject = { const dataObject = {
activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat), activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat),
dateFormat, dateFormat,
@@ -210,8 +213,8 @@ export class ViewCampaignComponent implements OnInit {
const reactivateCampaignDialogRef = this.dialog.open(FormDialogComponent, { data }); const reactivateCampaignDialogRef = this.dialog.open(FormDialogComponent, { data });
reactivateCampaignDialogRef.afterClosed().subscribe((response: any) => { reactivateCampaignDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) { if (response.data) {
const locale = 'en'; const locale = this.settingsService.language.code;
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const dataObject = { const dataObject = {
activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat), activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat),
dateFormat, dateFormat,
@@ -257,14 +260,14 @@ export class ViewCampaignComponent implements OnInit {
const prevFromDate: Date = this.smsForm.value.fromDate; const prevFromDate: Date = this.smsForm.value.fromDate;
const prevToDate: Date = this.smsForm.value.toDate; const prevToDate: Date = this.smsForm.value.toDate;
// 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.smsForm.patchValue({ this.smsForm.patchValue({
fromDate: this.datePipe.transform(prevFromDate, dateFormat), fromDate: this.datePipe.transform(prevFromDate, dateFormat),
toDate: this.datePipe.transform(prevToDate, dateFormat) toDate: this.datePipe.transform(prevToDate, dateFormat)
}); });
const SMS = this.smsForm.value; const SMS = this.smsForm.value;
SMS.id = this.smsCampaignData.id; SMS.id = this.smsCampaignData.id;
SMS.locale = 'en'; SMS.locale = this.settingsService.language.code;
SMS.dateFormat = dateFormat; SMS.dateFormat = dateFormat;
SMS.status = this.status; SMS.status = this.status;
this.organizationService.getMessagebyStatus(SMS).subscribe((response: any) => { this.organizationService.getMessagebyStatus(SMS).subscribe((response: any) => {
@@ -9,6 +9,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../organization.service'; import { OrganizationService } from '../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* View Standing Instructions History Component. * View Standing Instructions History Component.
@@ -45,12 +46,14 @@ export class StandingInstructionsHistoryComponent implements OnInit {
* Retrieves the instructions template from `resolve`. * Retrieves the instructions template from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date. * @param {DatePipe} datePipe Date Pipe to format date.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private datePipe: DatePipe) { private datePipe: DatePipe) {
@@ -103,9 +106,9 @@ export class StandingInstructionsHistoryComponent implements OnInit {
search() { search() {
this.isCollapsed = true; this.isCollapsed = true;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const instruction = this.instructionForm.value; const instruction = this.instructionForm.value;
instruction.locale = 'en'; instruction.locale = this.settingsService.language.code;
instruction.dateFormat = dateFormat; instruction.dateFormat = dateFormat;
instruction.fromDate = this.datePipe.transform(instruction.fromDate, dateFormat); instruction.fromDate = this.datePipe.transform(instruction.fromDate, dateFormat);
instruction.toDate = this.datePipe.transform(instruction.toDate, dateFormat); instruction.toDate = this.datePipe.transform(instruction.toDate, dateFormat);
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services. */ /** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Allocate Cash component. * Allocate Cash component.
@@ -32,12 +33,14 @@ export class AllocateCashComponent implements OnInit {
* @param {ActivatedRoute} route ActivateRoute. * @param {ActivatedRoute} route ActivateRoute.
* @param {DatePipe} datePipe Date Pipe. * @param {DatePipe} datePipe Date Pipe.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {Router} router Router. * @param {Router} router Router.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { cashierTemplate: any}) => { this.route.data.subscribe((data: { cashierTemplate: any}) => {
this.cashierData = data.cashierTemplate; this.cashierData = data.cashierTemplate;
@@ -68,14 +71,14 @@ export class AllocateCashComponent implements OnInit {
* Submits Allocate Cash form. * Submits Allocate Cash form.
*/ */
submit() { submit() {
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const txnDate = this.allocateCashForm.value.txnDate; const txnDate = this.allocateCashForm.value.txnDate;
this.allocateCashForm.patchValue({ this.allocateCashForm.patchValue({
txnDate: this.datePipe.transform(txnDate, dateFormat) txnDate: this.datePipe.transform(txnDate, dateFormat)
}); });
const allocateCashForm = this.allocateCashForm.value; const allocateCashForm = this.allocateCashForm.value;
allocateCashForm.dateFormat = dateFormat; 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.organizationService.allocateCash(this.cashierData.tellerId, this.cashierData.cashierId, allocateCashForm).subscribe((response: any) => {
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 { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create Cashier component. * Create Cashier component.
@@ -33,12 +34,14 @@ export class CreateCashierComponent implements OnInit {
* @param {Router} router Router. * @param {Router} router Router.
* @param {DatePipe} datePipe Date Pipe. * @param {DatePipe} datePipe Date Pipe.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @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 datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService ) { private organizationService: OrganizationService,
private settingsService: SettingsService ) {
this.route.data.subscribe((data: { cashierTemplate: any }) => { this.route.data.subscribe((data: { cashierTemplate: any }) => {
this.cashierTemplate = data.cashierTemplate; this.cashierTemplate = data.cashierTemplate;
}); });
@@ -65,7 +68,7 @@ export class CreateCashierComponent implements OnInit {
* Submits Create cashier form. * Submits Create cashier form.
*/ */
submit() { submit() {
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const startDate = this.createCashierForm.value.startDate; const startDate = this.createCashierForm.value.startDate;
const endDate = this.createCashierForm.value.endDate; const endDate = this.createCashierForm.value.endDate;
this.createCashierForm.patchValue({ this.createCashierForm.patchValue({
@@ -73,7 +76,7 @@ export class CreateCashierComponent implements OnInit {
'endDate': this.datePipe.transform(endDate, dateFormat) 'endDate': this.datePipe.transform(endDate, dateFormat)
}); });
const createCashierForm = this.createCashierForm.value; const createCashierForm = this.createCashierForm.value;
createCashierForm.locale = 'en'; createCashierForm.locale = this.settingsService.language.code;
createCashierForm.dateFormat = dateFormat; createCashierForm.dateFormat = dateFormat;
this.organizationService.createCashier(this.cashierTemplate.tellerId, createCashierForm).subscribe((response: any) => { this.organizationService.createCashier(this.cashierTemplate.tellerId, createCashierForm).subscribe((response: any) => {
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 { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Edit Cashier component. * Edit Cashier component.
@@ -35,12 +36,14 @@ export class EditCashierComponent implements OnInit {
* @param {Router} router Router. * @param {Router} router Router.
* @param {DatePipe} datePipe Date Pipe. * @param {DatePipe} datePipe Date Pipe.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @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 datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService ) { private organizationService: OrganizationService,
private settingsService: SettingsService ) {
this.route.data.subscribe((data: { cashier: any, cashierTemplate: any }) => { this.route.data.subscribe((data: { cashier: any, cashierTemplate: any }) => {
this.cashierData.data = data.cashier; this.cashierData.data = data.cashier;
this.cashierData.template = data.cashierTemplate; this.cashierData.template = data.cashierTemplate;
@@ -69,7 +72,7 @@ export class EditCashierComponent implements OnInit {
* Submits edit cashier form. * Submits edit cashier form.
*/ */
submit() { submit() {
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
const startDate = this.editCashierForm.value.startDate; const startDate = this.editCashierForm.value.startDate;
const endDate = this.editCashierForm.value.endDate; const endDate = this.editCashierForm.value.endDate;
this.editCashierForm.patchValue({ this.editCashierForm.patchValue({
@@ -77,7 +80,7 @@ export class EditCashierComponent implements OnInit {
'endDate': this.datePipe.transform(endDate, dateFormat) 'endDate': this.datePipe.transform(endDate, dateFormat)
}); });
const editCashierForm = this.editCashierForm.value; const editCashierForm = this.editCashierForm.value;
editCashierForm.locale = 'en'; editCashierForm.locale = this.settingsService.language.code;
editCashierForm.dateFormat = dateFormat; editCashierForm.dateFormat = dateFormat;
editCashierForm.staffId = this.cashierData.data.staffId; editCashierForm.staffId = this.cashierData.data.staffId;
this.organizationService.updateCashier(this.cashierData.data.tellerId, this.cashierData.data.id, editCashierForm).subscribe((response: any) => { this.organizationService.updateCashier(this.cashierData.data.tellerId, this.cashierData.data.id, editCashierForm).subscribe((response: any) => {
@@ -1,8 +1,12 @@
/** Angular Imports. */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
/** Customer Services. */
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
import { SettingsService } from 'app/settings/settings.service';
@Component({ @Component({
selector: 'mifosx-settle-cash', selector: 'mifosx-settle-cash',
@@ -26,12 +30,14 @@ export class SettleCashComponent implements OnInit {
* @param {ActivatedRoute} route ActivateRoute. * @param {ActivatedRoute} route ActivateRoute.
* @param {DatePipe} datePipe Date Pipe. * @param {DatePipe} datePipe Date Pipe.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {Router} router Router. * @param {Router} router Router.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private datePipe: DatePipe, private datePipe: DatePipe,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { cashierTemplate: any}) => { this.route.data.subscribe((data: { cashierTemplate: any}) => {
this.cashierData = data.cashierTemplate; this.cashierData = data.cashierTemplate;
@@ -62,14 +68,14 @@ export class SettleCashComponent implements OnInit {
* Submits Settle Cash form. * Submits Settle Cash form.
*/ */
submit() { submit() {
const dateFormat = 'dd MMMM yyyy'; const dateFormat = this.settingsService.dateFormat;
const txnDate = this.settleCashForm.value.txnDate; const txnDate = this.settleCashForm.value.txnDate;
this.settleCashForm.patchValue({ this.settleCashForm.patchValue({
txnDate: this.datePipe.transform(txnDate, dateFormat) txnDate: this.datePipe.transform(txnDate, dateFormat)
}); });
const settleCashForm = this.settleCashForm.value; const settleCashForm = this.settleCashForm.value;
settleCashForm.dateFormat = dateFormat; 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.organizationService.settleCash(this.cashierData.tellerId, this.cashierData.cashierId, settleCashForm).subscribe((response: any) => {
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 { OrganizationService } from '../../organization.service'; import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create teller component. * Create teller component.
@@ -32,12 +33,14 @@ export class CreateTellerComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date. * @param {DatePipe} datePipe Date Pipe to format date.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe) { private datePipe: DatePipe) {
@@ -77,13 +80,13 @@ export class CreateTellerComponent implements OnInit {
const prevStartDate: Date = this.tellerForm.value.startDate; const prevStartDate: Date = this.tellerForm.value.startDate;
const prevEndDate: Date = this.tellerForm.value.endDate; const prevEndDate: Date = this.tellerForm.value.endDate;
// 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.tellerForm.patchValue({ this.tellerForm.patchValue({
startDate: this.datePipe.transform(prevStartDate, dateFormat), startDate: this.datePipe.transform(prevStartDate, dateFormat),
endDate: this.datePipe.transform(prevEndDate, dateFormat) endDate: this.datePipe.transform(prevEndDate, dateFormat)
}); });
const teller = this.tellerForm.value; const teller = this.tellerForm.value;
teller.locale = 'en'; teller.locale = this.settingsService.language.code;
teller.dateFormat = dateFormat; teller.dateFormat = dateFormat;
this.organizationService.createTeller(teller).subscribe((response: any) => { this.organizationService.createTeller(teller).subscribe((response: any) => {
this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../../organization.service'; import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create teller component. * Create teller component.
@@ -35,12 +36,14 @@ export class EditTellerComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date. * @param {DatePipe} datePipe Date Pipe to format date.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe) { private datePipe: DatePipe) {
@@ -89,13 +92,13 @@ export class EditTellerComponent implements OnInit {
const prevStartDate: Date = this.tellerForm.value.startDate; const prevStartDate: Date = this.tellerForm.value.startDate;
const prevEndDate: Date = this.tellerForm.value.endDate; const prevEndDate: Date = this.tellerForm.value.endDate;
// 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.tellerForm.patchValue({ this.tellerForm.patchValue({
startDate: this.datePipe.transform(prevStartDate, dateFormat), startDate: this.datePipe.transform(prevStartDate, dateFormat),
endDate: this.datePipe.transform(prevEndDate, dateFormat) endDate: this.datePipe.transform(prevEndDate, dateFormat)
}); });
const teller = this.tellerForm.value; const teller = this.tellerForm.value;
teller.locale = 'en'; teller.locale = this.settingsService.language.code;
teller.officeId = this.tellerData.officeId; teller.officeId = this.tellerData.officeId;
teller.dateFormat = dateFormat; teller.dateFormat = dateFormat;
this.organizationService.updateTeller(this.tellerData.id, teller).subscribe((response: any) => { this.organizationService.updateTeller(this.tellerData.id, teller).subscribe((response: any) => {
@@ -5,6 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { OrganizationService } from '../organization.service'; import { OrganizationService } from '../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/** Recurrence default value. */ /** Recurrence default value. */
const recurrenceDefaultValue = 'FREQ=WEEKLY;INTERVAL=1;BYDAY='; const recurrenceDefaultValue = 'FREQ=WEEKLY;INTERVAL=1;BYDAY=';
@@ -41,11 +42,13 @@ export class WorkingDaysComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {OrganizationService} organizationService Organization Service. * @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { workingDays: any }) => { this.route.data.subscribe((data: { workingDays: any }) => {
this.workingDaysData = data.workingDays; this.workingDaysData = data.workingDays;
@@ -103,7 +106,7 @@ export class WorkingDaysComponent implements OnInit {
submit() { submit() {
const workingDays = this.workingDaysForm.value; const workingDays = this.workingDaysForm.value;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
workingDays.locale = 'en'; workingDays.locale = this.settingsService.language.code;
let recurrence = recurrenceDefaultValue; let recurrence = recurrenceDefaultValue;
for (let i = 0; i < this.weekDays.length; i++) { for (let i = 0; i < this.weekDays.length; i++) {
if (workingDays.recurrence[i]) { if (workingDays.recurrence[i]) {