Format date fields without patch form

This commit is contained in:
Jose Alberto Hernandez
2022-06-10 10:34:19 +02:00
committed by Arnold Gálovics
parent 9d43181cea
commit 6ea3d97538
191 changed files with 1408 additions and 1173 deletions
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services. */
import { OrganizationService } from '../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Bulk Loan Reassignment component.
@@ -49,7 +49,7 @@ export class BulkLoanReassignmnetComponent implements OnInit {
private route: ActivatedRoute,
private organizationSevice: OrganizationService,
private settingsService: SettingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private router: Router) {
this.route.data.subscribe((data: { offices: any} ) => {
this.offices = data.offices;
@@ -113,16 +113,20 @@ export class BulkLoanReassignmnetComponent implements OnInit {
* Submits bulk loan reassignment form.
*/
submit() {
const bulkLoanFormData = this.bulkLoanForm.value;
const locale = this.settingsService.language.code;
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 = this.settingsService.language.code;
bulkForm.dateFormat = dateFormat;
bulkForm.loans = this.loans;
this.organizationSevice.createLoanReassignment(bulkForm).subscribe((response: any) => {
const prevAssignmentDate = this.bulkLoanForm.value.assignmentDate;
if (bulkLoanFormData.assignmentDate instanceof Date) {
bulkLoanFormData.assignmentDate = this.dateUtils.formatDate(prevAssignmentDate, dateFormat);
}
const data = {
...bulkLoanFormData,
dateFormat,
locale
};
data.loans = this.loans;
this.organizationSevice.createLoanReassignment(data).subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Create employee component.
@@ -34,14 +34,14 @@ export class CreateEmployeeComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
* @param {Dates} dateUtils Date Utils to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices;
});
@@ -73,16 +73,19 @@ export class CreateEmployeeComponent implements OnInit {
* if successful redirects to employees.
*/
submit() {
const prevJoiningDate: Date = this.employeeForm.value.joiningDate;
// TODO: Update once language and date settings are setup
const employeeFormData = this.employeeForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.employeeForm.patchValue({
joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat)
});
const employee = this.employeeForm.value;
employee.locale = this.settingsService.language.code;
employee.dateFormat = dateFormat;
this.organizationService.createEmployee(employee).subscribe((response: any) => {
const prevJoiningDate: Date = this.employeeForm.value.joiningDate;
if (employeeFormData.joiningDate instanceof Date) {
employeeFormData.joiningDate = this.dateUtils.formatDate(prevJoiningDate, dateFormat);
}
const data = {
...employeeFormData,
dateFormat,
locale
};
this.organizationService.createEmployee(data).subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Edit Employee Component.
@@ -36,14 +36,14 @@ export class EditEmployeeComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
* @param {Dates} dateUtils Date Utils to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { employee: any, offices: any }) => {
this.employeeData = data.employee;
this.officeData = data.employee.allowedOffices;
@@ -77,16 +77,19 @@ export class EditEmployeeComponent implements OnInit {
* if successful redirects to the employee edited.
*/
submit() {
const prevJoiningDate: Date = this.editEmployeeForm.value.joiningDate;
// TODO: Update once language and date settings are setup
const editEmployeeFormData = this.editEmployeeForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.editEmployeeForm.patchValue({
joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat)
});
const employee = this.editEmployeeForm.value;
employee.locale = this.settingsService.language.code;
employee.dateFormat = dateFormat;
this.organizationService.updateEmployee(this.employeeData.id, employee).subscribe((response: any) => {
const prevJoiningDate: Date = this.editEmployeeForm.value.joiningDate;
if (editEmployeeFormData.joiningDate instanceof Date) {
editEmployeeFormData.joiningDate = this.dateUtils.formatDate(prevJoiningDate, dateFormat);
}
const data = {
...editEmployeeFormData,
dateFormat,
locale
};
this.organizationService.updateEmployee(this.employeeData.id, data).subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
});
}
@@ -5,11 +5,11 @@ import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Fund Mapping Component.
@@ -48,13 +48,13 @@ export class FundMappingComponent implements OnInit {
* @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
* @param {Dates} dateUtils Date Utils to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute,
private datePipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { advanceSearchTemplate: any }) => {
this.advanceSearchTemplate = data.advanceSearchTemplate;
});
@@ -148,20 +148,24 @@ export class FundMappingComponent implements OnInit {
*/
submit() {
this.isCollapsed = true;
// TODO: Update once language and date settings are setup
const fundMappingFormData = this.fundMappingForm.value;
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)
});
const fundMapping = {
...this.fundMappingForm.value,
const prevLoanFromDate: Date = this.fundMappingForm.value.loanFromDate;
const prevLoanToDate: Date = this.fundMappingForm.value.loanToDate;
if (fundMappingFormData.loanFromDate instanceof Date) {
fundMappingFormData.loanFromDate = this.dateUtils.formatDate(prevLoanFromDate, dateFormat);
}
if (fundMappingFormData.loanToDate instanceof Date) {
fundMappingFormData.loanToDate = this.dateUtils.formatDate(prevLoanToDate, dateFormat);
}
const data = {
...fundMappingFormData,
entities: ['loans'],
dateFormat,
locale
};
this.organizationService.retrieveAdvanceSearchResults(fundMapping).subscribe((response: any) => {
this.organizationService.retrieveAdvanceSearchResults(data).subscribe((response: any) => {
this.setLoans(response);
});
}
@@ -2,7 +2,7 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service';
@@ -34,13 +34,13 @@ export class CreateHolidayComponent implements OnInit {
* Get offices and holiday template from `Resolver`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {Dates} dateUtils Date Utils.
* @param {OrganizationService} organizationService Organization Service.
* @param {Router} router Router.
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private organizationService: OrganizationService,
private settings: SettingsService,
private router: Router ) {
@@ -86,23 +86,27 @@ export class CreateHolidayComponent implements OnInit {
* Submits the create holiday Form.
*/
submit() {
const holidayFormData = this.holidayForm.value;
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),
});
if (this.holidayForm.contains('repaymentsRescheduledTo')) {
this.holidayForm.patchValue({
'repaymentsRescheduledTo': this.datePipe.transform(this.holidayForm.value.repaymentsRescheduledTo, dateFormat)
});
const prevFromDate: Date = this.holidayForm.value.fromDate;
const prevToDate: Date = this.holidayForm.value.toDate;
if (holidayFormData.closureDate instanceof Date) {
holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
}
const holiday = {
...this.holidayForm.value,
if (holidayFormData.closureDate instanceof Date) {
holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
}
if (this.holidayForm.contains('repaymentsRescheduledTo')) {
const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo;
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(prevRepaymentsRescheduledTo, dateFormat);
}
const data = {
...holidayFormData,
dateFormat,
locale
};
this.organizationService.createHoliday(holiday).subscribe((response: any) => {
this.organizationService.createHoliday(data).subscribe((response: any) => {
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
});
}
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service';
@@ -35,15 +35,15 @@ export class EditHolidayComponent implements OnInit {
* Get holiday and holiday template from `Resolver`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {Dates} dateUtils Date Utils.
* @param {OrganizationService} organizatioService Organization Service.
* @param {Router} router Router.
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private datePipe: DatePipe,
private dateUtils: Dates,
private organizatioService: OrganizationService,
private settings: SettingsService,
private settingsService: SettingsService,
private router: Router ) {
this.route.data.subscribe((data: { holiday: any, holidayTemplate: any }) => {
this.holidayData = data.holiday;
@@ -100,25 +100,29 @@ export class EditHolidayComponent implements OnInit {
* Submits Edit Holiday Form.
*/
submit() {
const dateFormat = this.settings.dateFormat;
const holidayFormData = this.holidayForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
if (!this.isActiveHoliday) {
const fromDate: Date = this.holidayForm.value.fromDate;
const toDate: Date = this.holidayForm.value.toDate;
if (this.reSchedulingType === 2 ) {
const repaymentScheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo;
this.holidayForm.patchValue({
repaymentsRescheduledTo: this.datePipe.transform(repaymentScheduledTo, dateFormat)
});
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(repaymentScheduledTo, dateFormat);
}
const prevFromDate: Date = this.holidayForm.value.fromDate;
const prevToDate: Date = this.holidayForm.value.toDate;
if (holidayFormData.closureDate instanceof Date) {
holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
}
if (holidayFormData.closureDate instanceof Date) {
holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
}
this.holidayForm.patchValue({
fromDate: this.datePipe.transform(fromDate, dateFormat),
toDate: this.datePipe.transform(toDate, dateFormat)
});
}
const holidayForm = this.holidayForm.value;
holidayForm.locale = this.settings.language.code;
holidayForm.dateFormat = dateFormat;
this.organizatioService.updateHoliday(this.holidayData.id, holidayForm).subscribe(response => {
const data = {
...holidayFormData,
dateFormat,
locale
};
this.organizatioService.updateHoliday(this.holidayData.id, data).subscribe(response => {
/** TODO Add Redirects to ViewMakerCheckerTask page. */
this.router.navigate(['../'], { relativeTo: this.route });
});
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Create Office component.
@@ -34,14 +34,14 @@ export class CreateOfficeComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
* @param {Dates} dateUtils Date Utils to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router,
private route: ActivatedRoute,
private datePipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices;
});
@@ -68,16 +68,19 @@ export class CreateOfficeComponent implements OnInit {
* if successful redirects to offices
*/
submit() {
const prevOpeningDate: Date = this.officeForm.value.openingDate;
// TODO: Update once language and date settings are setup
const officeFormData = this.officeForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.officeForm.patchValue({
openingDate: this.datePipe.transform(prevOpeningDate, dateFormat)
});
const office = this.officeForm.value;
office.locale = this.settingsService.language.code;
office.dateFormat = dateFormat;
this.organizationService.createOffice(office).subscribe(response => {
const prevOpeningDate: Date = this.officeForm.value.openingDate;
if (officeFormData.openingDate instanceof Date) {
officeFormData.openingDate = this.dateUtils.formatDate(prevOpeningDate, dateFormat);
}
const data = {
...officeFormData,
dateFormat,
locale
};
this.organizationService.createOffice(data).subscribe(response => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
@@ -40,7 +40,7 @@
<mat-form-field>
<mat-label>External ID</mat-label>
<input matInput formControlName="externalId" formControlName="externalId">
<input matInput formControlName="externalId">
</mat-form-field>
</div>
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { OrganizationService } from 'app/organization/organization.service';
@@ -35,14 +35,14 @@ export class EditOfficeComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
* @param {DatePipe} datepipe Convert Date.
* @param {Dates} dateUtils Date Utils
*/
constructor(private organizationService: OrganizationService,
private settingsService: SettingsService,
private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datepipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { officeTemplate: any }) => {
this.officeData = data.officeTemplate;
});
@@ -70,15 +70,19 @@ export class EditOfficeComponent implements OnInit {
* Submits the edit office form.
*/
submit() {
const openedOn: Date = this.officeForm.value.openingDate;
const officeFormData = this.officeForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.officeForm.patchValue({
openingDate: this.datepipe.transform(openedOn, dateFormat)
});
const office = this.officeForm.value;
office.locale = this.settingsService.language.code;
office.dateFormat = dateFormat;
this.organizationService.updateOffice(this.officeData.id, office).subscribe((response: any) => {
const prevOpenedOn: Date = this.officeForm.value.openingDate;
if (officeFormData.openingDate instanceof Date) {
officeFormData.openingDate = this.dateUtils.formatDate(prevOpenedOn, dateFormat);
}
const data = {
...officeFormData,
dateFormat,
locale
};
this.organizationService.updateOffice(this.officeData.id, data).subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
@@ -50,7 +50,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
/**
* Fetches office Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {DatePipe} datePipe Date Utils.
* @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {MatDialog} dialog Mat Dialog.
@@ -40,7 +40,7 @@ export class SingleRowComponent implements OnInit {
/**
* Fetches office Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {DatePipe} datePipe Date Utils.
* @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {MatDialog} dialog Mat Dialog.
@@ -150,7 +150,7 @@ export class SingleRowComponent implements OnInit {
/**
* Maps API response to data table form fields.
* @param {any} columns Data Table Columns.
* @param {string[]} dateTransformColumns Columns transformed with date pipe.
* @param {string[]} dateTransformColumns Columns transformed with Date Utils.
* @param {any} dataTableEntryObject Additional data table details.
*/
getFormfields(columns: any, dateTransformColumns: string[], dataTableEntryObject: any) {
@@ -37,7 +37,7 @@ export class CreateCampaignComponent {
* @param {Router} router Router
* @param {OrganizationService} organizationService Organization Service
* @param {SettingsService} settingsService Settings Service
* @param {DatePipe} datePipe Date Pipe
* @param {DatePipe} datePipe Date Utils
*/
constructor(private route: ActivatedRoute,
private router: Router,
@@ -34,7 +34,7 @@ export class EditCampaignComponent {
* Fetches campaign template from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe
* @param {DatePipe} datePipe Date Utils
* @param {OrganizationService} organizationService Organiztion Service
* @param {SettingsService} settingsService Settings Service
*/
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, OnChanges, Input, Output, EventEmitter } from '@angular/core';
import { Validators, FormGroup, FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Rxjs Imports */
import { distinctUntilChanged } from 'rxjs/operators';
@@ -13,6 +12,7 @@ import { SettingsService } from 'app/settings/settings.service';
/** Custom Models */
import { ReportParameter } from 'app/reports/common-models/report-parameter.model';
import { SelectOption } from 'app/reports/common-models/select-option.model';
import { Dates } from 'app/core/utils/dates';
/**
* Edit Business Rule Parameters.
@@ -47,7 +47,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges {
*/
constructor(private reportsService: ReportsService,
private settingsService: SettingsService,
private datePipe: DatePipe) { }
private dateUtils: Dates) { }
ngOnChanges() {
if (this.paramData) {
@@ -78,7 +78,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges {
break;
case 'date':
const dateFormat = this.settingsService.dateFormat;
const newControlValue = this.datePipe.transform(controlValue, dateFormat);
const newControlValue = this.dateUtils.formatDate(controlValue, dateFormat);
this.ReportForm.get(param.name).patchValue(newControlValue);
break;
}
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, OnChanges, Input, Output, EventEmitter } from '@angular/core';
import { Validators, FormGroup, FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { ReportsService } from 'app/reports/reports.service';
@@ -10,6 +9,7 @@ import { SettingsService } from 'app/settings/settings.service';
/** Custom Models */
import { ReportParameter } from 'app/reports/common-models/report-parameter.model';
import { SelectOption } from 'app/reports/common-models/select-option.model';
import { Dates } from 'app/core/utils/dates';
/**
* Business Rule Parameters Component.
@@ -41,11 +41,11 @@ export class BusinessRuleParametersComponent implements OnChanges {
/**
* @param {ReportsService} reportsService Reports Service.
* @param {SettingsService} settingsService Settings Service.
* @param {DatePipe} datePipe Date Pipe.
* @param {Dates} dateUtils Date Utils.
*/
constructor(private reportsService: ReportsService,
private settingsService: SettingsService,
private datePipe: DatePipe) { }
private dateUtils: Dates) { }
ngOnChanges() {
if (this.paramData) {
@@ -156,7 +156,7 @@ export class BusinessRuleParametersComponent implements OnChanges {
break;
case 'date':
const dateFormat = this.settingsService.dateFormat;
formattedResponse[newKey] = this.datePipe.transform(value, dateFormat);
formattedResponse[newKey] = this.dateUtils.formatDate(value, dateFormat);
break;
case 'none':
formattedResponse[newKey] = value;
@@ -4,7 +4,6 @@ import { FormGroup, FormBuilder } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { MatTableDataSource, MatTable } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Dialogs */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
@@ -17,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';
import { Dates } from 'app/core/utils/dates';
/**
* View SMS Campaign Component
@@ -76,7 +76,7 @@ export class ViewCampaignComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route
* @param {MatDialog} dialog Mat Dialog
* @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {OrganizationService} organizationService Organization Service
* @param {SettingsService} settingsService Setting Service
*/
@@ -84,7 +84,7 @@ export class ViewCampaignComponent implements OnInit {
private route: ActivatedRoute,
public dialog: MatDialog,
private formBuilder: FormBuilder,
private datePipe: DatePipe,
private dateUtils: Dates,
private organizationService: OrganizationService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { smsCampaign: any }) => {
@@ -146,7 +146,7 @@ export class ViewCampaignComponent implements OnInit {
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const dataObject = {
closureDate: this.datePipe.transform(response.data.value.closureDate, dateFormat),
closureDate: this.dateUtils.formatDate(response.data.value.closureDate, dateFormat),
dateFormat,
locale
};
@@ -181,7 +181,7 @@ export class ViewCampaignComponent implements OnInit {
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const dataObject = {
activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat),
activationDate: this.dateUtils.formatDate(response.data.value.activationDate, dateFormat),
dateFormat,
locale
};
@@ -216,7 +216,7 @@ export class ViewCampaignComponent implements OnInit {
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const dataObject = {
activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat),
activationDate: this.dateUtils.formatDate(response.data.value.activationDate, dateFormat),
dateFormat,
locale
};
@@ -257,20 +257,25 @@ export class ViewCampaignComponent implements OnInit {
* Retrives messages by status.
*/
search() {
const smsFormData = this.smsForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
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 = 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 = this.settingsService.language.code;
SMS.dateFormat = dateFormat;
SMS.status = this.status;
this.organizationService.getMessagebyStatus(SMS).subscribe((response: any) => {
if (smsFormData.fromDate instanceof Date) {
smsFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
}
if (smsFormData.toDate instanceof Date) {
smsFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
}
const data = {
...smsFormData,
id: this.smsCampaignData.id,
status: this.status,
dateFormat,
locale
};
this.organizationService.getMessagebyStatus(data).subscribe((response: any) => {
this.dataSource.data = response.pageItems;
this.messageTableRef.renderRows();
});
@@ -5,11 +5,11 @@ import { MatSort } from '@angular/material/sort';
import { MatTableDataSource, MatTable } from '@angular/material/table';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* View Standing Instructions History Component.
@@ -49,14 +49,14 @@ export class StandingInstructionsHistoryComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
* @param {Dates} dateUtils Date Utils to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router,
private route: ActivatedRoute,
private datePipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { standingInstructionsTemplate: any }) => {
this.standingInstructionsTemplate = data.standingInstructionsTemplate;
});
@@ -105,14 +105,23 @@ export class StandingInstructionsHistoryComponent implements OnInit {
*/
search() {
this.isCollapsed = true;
// TODO: Update once language and date settings are setup
const instructionFormData = this.instructionForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const instruction = this.instructionForm.value;
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);
this.organizationService.getStandingInstructions(instruction).subscribe((response: any) => {
const prevFromDate: Date = this.instructionForm.value.fromDate;
const prevToDate: Date = this.instructionForm.value.toDate;
if (instructionFormData.fromDate instanceof Date) {
instructionFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
}
if (instructionFormData.toDate instanceof Date) {
instructionFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
}
const data = {
...instructionFormData,
dateFormat,
locale
};
this.organizationService.getStandingInstructions(data).subscribe((response: any) => {
this.setInstructions(response.pageItems);
});
}
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service';
@@ -31,14 +31,14 @@ export class AllocateCashComponent implements OnInit {
* Get cashier data from `Resolver`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route ActivateRoute.
* @param {DatePipe} datePipe Date Pipe.
* @param {Dates} dateUtils Date Utils.
* @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 dateUtils: Dates,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router) {
@@ -59,7 +59,7 @@ export class AllocateCashComponent implements OnInit {
'office': [{value: this.cashierData.officeName, disabled: true}],
'tellerName': [{value: this.cashierData.tellerName, disabled: true}],
'cashier': [{value: this.cashierData.cashierName, disabled: true}],
'assignmentPeriod': [{value: this.datePipe.transform(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.datePipe.transform(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}],
'assignmentPeriod': [{value: this.dateUtils.formatDate(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.dateUtils.formatDate(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}],
'txnDate': [new Date(), Validators.required],
'currencyCode': ['', Validators.required],
'txnAmount': ['', Validators.required],
@@ -71,15 +71,19 @@ export class AllocateCashComponent implements OnInit {
* Submits Allocate Cash form.
*/
submit() {
const allocateCashFormData = this.allocateCashForm.value;
const locale = this.settingsService.language.code;
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 = this.settingsService.language.code;
this.organizationService.allocateCash(this.cashierData.tellerId, this.cashierData.cashierId, allocateCashForm).subscribe((response: any) => {
if (allocateCashFormData.closureDate instanceof Date) {
allocateCashFormData.txnDate = this.dateUtils.formatDate(txnDate, dateFormat);
}
const data = {
...allocateCashFormData,
dateFormat,
locale
};
this.organizationService.allocateCash(this.cashierData.tellerId, this.cashierData.cashierId, data).subscribe((response: any) => {
this.router.navigate(['../'], {relativeTo: this.route});
});
}
@@ -55,7 +55,7 @@
</mat-error>
</mat-form-field>
<div fxFlex="48%" style="padding-top: 10px;">
<div fxFlex="48%" class="space">
<mat-checkbox labelPosition="before" formControlName="isFullDay">
Full Day?
</mat-checkbox>
@@ -0,0 +1,3 @@
.space {
padding-top: 10px;
}
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service';
@@ -32,14 +32,14 @@ export class CreateCashierComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router.
* @param {DatePipe} datePipe Date Pipe.
* @param {Dates} dateUtils Date Utils.
* @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private organizationService: OrganizationService,
private settingsService: SettingsService ) {
this.route.data.subscribe((data: { cashierTemplate: any }) => {
@@ -68,17 +68,23 @@ export class CreateCashierComponent implements OnInit {
* Submits Create cashier form.
*/
submit() {
const createCashierFormData = this.createCashierForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const startDate = this.createCashierForm.value.startDate;
const endDate = this.createCashierForm.value.endDate;
this.createCashierForm.patchValue({
'startDate': this.datePipe.transform(startDate, dateFormat),
'endDate': this.datePipe.transform(endDate, dateFormat)
});
const createCashierForm = this.createCashierForm.value;
createCashierForm.locale = this.settingsService.language.code;
createCashierForm.dateFormat = dateFormat;
this.organizationService.createCashier(this.cashierTemplate.tellerId, createCashierForm).subscribe((response: any) => {
const prevStartDate: Date = this.createCashierForm.value.startDate;
const prevEndDate: Date = this.createCashierForm.value.endDate;
if (createCashierFormData.startDate instanceof Date) {
createCashierFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat);
}
if (createCashierFormData.endDate instanceof Date) {
createCashierFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat);
}
const data = {
...createCashierFormData,
dateFormat,
locale
};
this.organizationService.createCashier(this.cashierTemplate.tellerId, data).subscribe((response: any) => {
this.router.navigate(['../'], {relativeTo: this.route});
});
}
@@ -61,7 +61,7 @@
</mat-error>
</mat-form-field>
<div fxFlex="48%" style="padding-top: 10px;">
<div fxFlex="48%" class="space">
<mat-checkbox labelPosition="before" formControlName="isFullDay">
Full Day?
</mat-checkbox>
@@ -0,0 +1,3 @@
.space {
padding-top: 10px;
}
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service';
@@ -34,14 +34,14 @@ export class EditCashierComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router.
* @param {DatePipe} datePipe Date Pipe.
* @param {Dates} dateUtils Date Utils.
* @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private organizationService: OrganizationService,
private settingsService: SettingsService ) {
this.route.data.subscribe((data: { cashier: any, cashierTemplate: any }) => {
@@ -72,18 +72,24 @@ export class EditCashierComponent implements OnInit {
* Submits edit cashier form.
*/
submit() {
const editCashierFormData = this.editCashierForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const startDate = this.editCashierForm.value.startDate;
const endDate = this.editCashierForm.value.endDate;
this.editCashierForm.patchValue({
'startDate': this.datePipe.transform(startDate, dateFormat),
'endDate': this.datePipe.transform(endDate, dateFormat)
});
const editCashierForm = this.editCashierForm.value;
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) => {
const prevStartDate: Date = this.editCashierForm.value.startDate;
const prevEndDate: Date = this.editCashierForm.value.endDate;
if (editCashierFormData.startDate instanceof Date) {
editCashierFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat);
}
if (editCashierFormData.endDate instanceof Date) {
editCashierFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat);
}
const data = {
...editCashierFormData,
staffId: this.cashierData.data.staffId,
dateFormat,
locale
};
this.organizationService.updateCashier(this.cashierData.data.tellerId, this.cashierData.data.id, data).subscribe((response: any) => {
this.router.navigate(['../'], {relativeTo: this.route});
});
}
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Customer Services. */
import { OrganizationService } from 'app/organization/organization.service';
@@ -28,14 +28,14 @@ export class SettleCashComponent implements OnInit {
* Get cashier data from `Resolver`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {ActivatedRoute} route ActivateRoute.
* @param {DatePipe} datePipe Date Pipe.
* @param {Dates} dateUtils Date Utils.
* @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 dateUtils: Dates,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router) {
@@ -56,7 +56,7 @@ export class SettleCashComponent implements OnInit {
'office': [{value: this.cashierData.officeName, disabled: true}],
'tellerName': [{value: this.cashierData.tellerName, disabled: true}],
'cashier': [{value: this.cashierData.cashierName, disabled: true}],
'assignmentPeriod': [{value: this.datePipe.transform(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.datePipe.transform(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}],
'assignmentPeriod': [{value: this.dateUtils.formatDate(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.dateUtils.formatDate(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}],
'txnDate': [new Date(), Validators.required],
'currencyCode': ['', Validators.required],
'txnAmount': ['', Validators.required],
@@ -68,15 +68,19 @@ export class SettleCashComponent implements OnInit {
* Submits Settle Cash form.
*/
submit() {
const settleCashFormData = this.settleCashForm.value;
const locale = this.settingsService.language.code;
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 = this.settingsService.language.code;
this.organizationService.settleCash(this.cashierData.tellerId, this.cashierData.cashierId, settleCashForm).subscribe((response: any) => {
const prevTxnDate: Date = this.settleCashForm.value.txnDate;
if (settleCashFormData.txnDate instanceof Date) {
settleCashFormData.txnDate = this.dateUtils.formatDate(prevTxnDate, dateFormat);
}
const data = {
...settleCashFormData,
dateFormat,
locale
};
this.organizationService.settleCash(this.cashierData.tellerId, this.cashierData.cashierId, data).subscribe((response: any) => {
this.router.navigate(['../'], {relativeTo: this.route});
});
}
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Create teller component.
@@ -36,14 +36,14 @@ export class CreateTellerComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
* @param {Dates} dateUtils Date Utils to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices;
});
@@ -77,18 +77,23 @@ export class CreateTellerComponent implements OnInit {
* if successful redirects to tellers.
*/
submit() {
const tellerFormData = this.tellerForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
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 = 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 = this.settingsService.language.code;
teller.dateFormat = dateFormat;
this.organizationService.createTeller(teller).subscribe((response: any) => {
if (tellerFormData.startDate instanceof Date) {
tellerFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat);
}
if (tellerFormData.endDate instanceof Date) {
tellerFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat);
}
const data = {
...tellerFormData,
dateFormat,
locale
};
this.organizationService.createTeller(data).subscribe((response: any) => {
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
});
}
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Create teller component.
@@ -39,14 +39,14 @@ export class EditTellerComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
* @param {Dates} dateUtils Date Utils to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe) {
private dateUtils: Dates) {
this.route.data.subscribe((data: { teller: any, offices: any }) => {
this.tellerData = data.teller;
this.officeData = data.offices;
@@ -89,19 +89,24 @@ export class EditTellerComponent implements OnInit {
* if successful redirects to tellers.
*/
submit() {
const tellerFormData = this.tellerForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
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 = 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 = this.settingsService.language.code;
teller.officeId = this.tellerData.officeId;
teller.dateFormat = dateFormat;
this.organizationService.updateTeller(this.tellerData.id, teller).subscribe((response: any) => {
if (tellerFormData.startDate instanceof Date) {
tellerFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat);
}
if (tellerFormData.endDate instanceof Date) {
tellerFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat);
}
const data = {
...tellerFormData,
officeId: this.tellerData.officeId,
dateFormat,
locale
};
this.organizationService.updateTeller(this.tellerData.id, data).subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
});
}