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