diff --git a/src/app/groups/create-group/create-group.component.ts b/src/app/groups/create-group/create-group.component.ts index ad61999d8..d370da3ff 100644 --- a/src/app/groups/create-group/create-group.component.ts +++ b/src/app/groups/create-group/create-group.component.ts @@ -7,6 +7,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { GroupsService } from '../groups.service'; import { ClientsService } from '../../clients/clients.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Create Group component. @@ -43,13 +44,15 @@ export class CreateGroupComponent implements OnInit, AfterViewInit { * @param {ClientsService} clientsService CentersService. * @param {GroupsService} groupService GroupsService. * @param {DatePipe} datePipe Date Pipe to format date. + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private clientsService: ClientsService, private groupService: GroupsService, - private datePipe: DatePipe) { + private datePipe: DatePipe, + private settingsService: SettingsService) { this.route.data.subscribe( (data: {offices: any} ) => { this.officeData = data.offices; }); @@ -149,13 +152,13 @@ export class CreateGroupComponent implements OnInit, AfterViewInit { const submittedOnDate: Date = this.groupForm.value.submittedOnDate; const activationDate: Date = this.groupForm.value.activationDate; // TODO: Update once language and date settings are setup - const dateFormat = 'dd MMMM yyyy'; + const dateFormat = this.settingsService.dateFormat; this.groupForm.patchValue({ submittedOnDate: this.datePipe.transform(submittedOnDate, dateFormat), activationDate: this.datePipe.transform(activationDate, dateFormat) }); const group = this.groupForm.value; - group.locale = 'en'; + group.locale = this.settingsService.language.code; group.dateFormat = dateFormat; group.clientMembers = []; this.clientMembers.forEach((client: any) => group.clientMembers.push(client.id)); diff --git a/src/app/groups/edit-group/edit-group.component.ts b/src/app/groups/edit-group/edit-group.component.ts index 49969fe94..14ace7c94 100644 --- a/src/app/groups/edit-group/edit-group.component.ts +++ b/src/app/groups/edit-group/edit-group.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { GroupsService } from '../groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Group component. @@ -37,12 +38,14 @@ export class EditGroupComponent implements OnInit { * @param {Router} router Router for navigation. * @param {GroupsService} groupService GroupsService. * @param {DatePipe} datePipe Date Pipe to format date. + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private groupService: GroupsService, - private datePipe: DatePipe) { + private datePipe: DatePipe, + private settingsService: SettingsService) { this.route.data.subscribe( (data: { groupAndTemplateData: any, groupViewData: any } ) => { this.staffData = data.groupAndTemplateData.staffOptions; this.groupData = data.groupAndTemplateData; @@ -96,13 +99,13 @@ export class EditGroupComponent implements OnInit { const submittedOnDate: Date = this.editGroupForm.value.submittedOnDate; const activationDate: Date = this.editGroupForm.value.activationDate; // TODO: Update once language and date settings are setup - const dateFormat = 'dd MMMM yyyy'; + const dateFormat = this.settingsService.dateFormat; this.editGroupForm.patchValue({ submittedOnDate: this.datePipe.transform(submittedOnDate, dateFormat), activationDate: activationDate && this.datePipe.transform(activationDate, dateFormat) }); const group = this.editGroupForm.value; - group.locale = 'en'; + group.locale = this.settingsService.language.code; group.dateFormat = dateFormat; this.groupService.updateGroup(group, this.groupData.id).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); diff --git a/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts b/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts index c797abb08..353fe5158 100644 --- a/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts +++ b/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts @@ -18,6 +18,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke /** Custom Services */ import { GroupsService } from '../../../groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Group Multi Row Data Tables @@ -52,11 +53,13 @@ export class MultiRowComponent implements OnInit, OnChanges { * @param {DatePipe} datePipe Date Pipe. * @param {GroupsService} groupsService Groups Service. * @param {MatDialog} dialog Mat Dialog. + * @param {SettingsService} settingsService SettingsService */ constructor(private route: ActivatedRoute, private datePipe: DatePipe, private groupsService: GroupsService, - private dialog: MatDialog) { + private dialog: MatDialog, + private settingsService: SettingsService) { this.groupId = this.route.parent.parent.snapshot.paramMap.get('groupId'); } @@ -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 !== 'group_id')); diff --git a/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts b/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts index 76027ffa4..21ee7b7c0 100644 --- a/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts +++ b/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts @@ -17,7 +17,7 @@ import { CheckboxBase } from 'app/shared/form-dialog/formfield/model/checkbox-ba /** Custom Services */ import { GroupsService } from '../../../groups.service'; - +import { SettingsService } from 'app/settings/settings.service'; /** * Groups Single Row Data Tables @@ -43,11 +43,13 @@ export class SingleRowComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe. * @param {GroupsService} groupsService Groups Service. * @param {MatDialog} dialog Mat Dialog. + * @param {SettingsService} settingsService SettingsService */ constructor(private route: ActivatedRoute, private datePipe: DatePipe, private dialog: MatDialog, - private groupsService: GroupsService) { + private groupsService: GroupsService, + private settingsService: SettingsService) { this.groupId = this.route.parent.parent.snapshot.paramMap.get('groupId'); } @@ -65,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 !== 'group_id')); diff --git a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts index d0e379ee7..6f2b46d2d 100644 --- a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts +++ b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Activate Group Component @@ -32,12 +33,14 @@ export class ActivateGroupComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.groupId = this.route.parent.snapshot.params['groupId']; } @@ -60,8 +63,8 @@ export class ActivateGroupComponent implements OnInit { */ 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 prevactivationDate: Date = this.activateGroupForm.value.activationDate; this.activateGroupForm.patchValue({ activationDate: this.datePipe.transform(prevactivationDate, dateFormat), diff --git a/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts b/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts index fd12fe3b4..5ea367dfb 100644 --- a/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts +++ b/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Group Meetings Component @@ -41,12 +42,14 @@ export class AttachGroupMeetingComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.route.data.subscribe((data: { groupActionData: any }) => { this.calendarTemplate = data.groupActionData; this.frequencyOptions = this.calendarTemplate.frequencyOptions; @@ -112,8 +115,8 @@ export class AttachGroupMeetingComponent implements OnInit { */ 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 title = `groups_${this.groupId}_CollectionMeeting`; const typeId = '1'; const prevStartDate: Date = this.groupMeetingForm.value.startDate; diff --git a/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts b/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts index 6f915e1cb..758dede29 100644 --- a/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts +++ b/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Close Group Component @@ -34,12 +35,14 @@ export class CloseGroupComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.route.data.subscribe((data: { groupActionData: any }) => { this.closureData = data.groupActionData.closureReasons; }); @@ -65,8 +68,8 @@ export class CloseGroupComponent implements OnInit { */ 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 prevClosedDate: Date = this.closeGroupForm.value.closureDate; this.closeGroupForm.patchValue({ closureDate: this.datePipe.transform(prevClosedDate, dateFormat), diff --git a/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts b/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts index 361bf61e1..7b0e51e24 100644 --- a/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts +++ b/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Group Meetings Schedule Component @@ -39,12 +40,14 @@ export class EditGroupMeetingScheduleComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.route.data.subscribe((data: { groupActionData: any }) => { this.calendarTemplate = data.groupActionData; this.nextMeetingDates = this.calendarTemplate.nextTenRecurringDates; @@ -72,8 +75,8 @@ export class EditGroupMeetingScheduleComponent implements OnInit { */ 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 reschedulebasedOnMeetingDates = true; const prevOldDate: Date = new Date(this.groupEditMeetingScheduleForm.value.presentMeetingDate); const prevNewDate: Date = this.groupEditMeetingScheduleForm.value.newMeetingDate; diff --git a/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts b/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts index 06217ce96..e31105a6b 100644 --- a/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts +++ b/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Edit Group Meetings Component @@ -43,12 +44,14 @@ export class EditGroupMeetingComponent implements OnInit { * @param {DatePipe} datePipe Date Pipe * @param {ActivatedRoute} route Activated Route * @param {Router} router Router + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, private datePipe: DatePipe, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private settingsService: SettingsService) { this.route.data.subscribe((data: { groupActionData: any }) => { this.calendarTemplate = data.groupActionData; this.frequencyOptions = this.calendarTemplate.frequencyOptions; @@ -117,8 +120,8 @@ export class EditGroupMeetingComponent implements OnInit { */ 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 title = `groups_${this.groupId}_CollectionMeeting`; const typeId = '1'; const prevStartDate: Date = this.groupEditMeetingForm.value.startDate; diff --git a/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts b/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts index 07f99a418..d294faec6 100644 --- a/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts +++ b/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts @@ -7,6 +7,7 @@ import { FormControl } from '@angular/forms'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** Custom Dialogs */ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; @@ -47,12 +48,14 @@ export class GroupAttendanceComponent implements OnInit { * @param {Router} router Router * @param {GroupsService} groupsService Groups Service * @param {MatDialog} dialog Mat Dialog + * @param {SettingsService} settingsService SettingsService */ constructor(private route: ActivatedRoute, private datePipe: DatePipe, private router: Router, private groupsService: GroupsService, - public dialog: MatDialog) { + public dialog: MatDialog, + private settingsService: SettingsService) { this.route.data.subscribe(( data: { groupActionData: any }) => { this.groupData = data.groupActionData; this.membersData = data.groupActionData.clientMembers; @@ -113,8 +116,8 @@ export class GroupAttendanceComponent implements OnInit { */ 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 prevMeetingDate: Date = new Date(this.meetingDate.value); this.meetingDate.patchValue(this.datePipe.transform(prevMeetingDate, dateFormat)); const data = { diff --git a/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.ts b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.ts index 37edea3e3..870de21f9 100644 --- a/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.ts +++ b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.ts @@ -5,6 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Group Transfer Clients component. @@ -33,11 +34,13 @@ export class GroupTransferClientsComponent implements OnInit, AfterViewInit { * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation * @param {GroupsService} groupsService GroupsService. + * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private groupsService: GroupsService) { + private groupsService: GroupsService, + private settingsService: SettingsService) { this.route.data.subscribe((data: { groupActionData: any }) => { this.groupData = data.groupActionData; this.clientMembers = this.groupData.clientMembers; @@ -87,7 +90,7 @@ export class GroupTransferClientsComponent implements OnInit, AfterViewInit { * if successful redirects to group. */ submit() { - const locale = 'en'; + const locale = this.settingsService.language.code; const data = { ...this.transferClientsForm.value, destinationGroupId: this.transferClientsForm.get('destinationGroupId').value.id,