From cb66e9488e6d80ad71ea4d7e2b81465baba63aa8 Mon Sep 17 00:00:00 2001 From: GCCollab Date: Tue, 2 Apr 2024 17:42:29 +0000 Subject: [PATCH] Code formatting ignore-deploy --- src/app/core/models/location.model.ts | 36 +++++++++---------- .../features/calendar/calendar.component.ts | 4 +-- src/app/features/events/models/event.ts | 16 +++++++-- .../event-form/event-form.component.ts | 12 +++---- .../components/input/input.component.html | 6 ++-- .../location-form.component.html | 7 ++-- .../location-form.component.scss | 5 ++- .../location-form/location-form.component.ts | 20 +++++------ 8 files changed, 54 insertions(+), 52 deletions(-) diff --git a/src/app/core/models/location.model.ts b/src/app/core/models/location.model.ts index d7f5de1..4799e5a 100644 --- a/src/app/core/models/location.model.ts +++ b/src/app/core/models/location.model.ts @@ -1,4 +1,4 @@ -import { ILocationForm } from "src/app/shared/components/location-form/location-form.component"; +import { ILocationForm } from 'src/app/shared/components/location-form/location-form.component'; export class Location implements ILocationForm { address: string; @@ -21,77 +21,77 @@ export class Location implements ILocationForm { } export interface IProvince { - titleEn: string, - titleFr: string, - abbreviation: string + titleEn: string; + titleFr: string; + abbreviation: string; } export const Provinces: IProvince[] = [ { titleEn: 'Alberta', titleFr: 'Alberta', - abbreviation: 'AB' + abbreviation: 'AB', }, { titleEn: 'British Columbia', titleFr: 'Colombie-Britannique', - abbreviation: 'BC' + abbreviation: 'BC', }, { titleEn: 'Manitoba', titleFr: 'Manitoba', - abbreviation: 'MB' + abbreviation: 'MB', }, { titleEn: 'New Brunswick', titleFr: 'Nouveau-Brunswick', - abbreviation: 'NB' + abbreviation: 'NB', }, { titleEn: 'Newfoundland and Labrador', titleFr: 'Terre-Neuve-et-Labrador', - abbreviation: 'NL' + abbreviation: 'NL', }, { titleEn: 'Northwest Territories', titleFr: 'Territoires du Nord-Ouest', - abbreviation: 'NT' + abbreviation: 'NT', }, { titleEn: 'Nova Scotia', titleFr: 'Nouvelle-Écosse', - abbreviation: 'NS' + abbreviation: 'NS', }, { titleEn: 'Nunavut', titleFr: 'Nunavut', - abbreviation: 'NU' + abbreviation: 'NU', }, { titleEn: 'Ontario', titleFr: 'Ontario', - abbreviation: 'ON' + abbreviation: 'ON', }, { titleEn: 'Prince Edward Island', titleFr: 'Île-du-Prince-Édouard', - abbreviation: 'PE' + abbreviation: 'PE', }, { titleEn: 'Quebec', titleFr: 'Québec', - abbreviation: 'QC' + abbreviation: 'QC', }, { titleEn: 'Saskatchewan', titleFr: 'Saskatchewan', - abbreviation: 'SK' + abbreviation: 'SK', }, { titleEn: 'Yukon Territory', titleFr: 'Territoire du Yukon', - abbreviation: 'YT' - } + abbreviation: 'YT', + }, ]; Object.freeze(Provinces); diff --git a/src/app/features/calendar/calendar.component.ts b/src/app/features/calendar/calendar.component.ts index 9efcb86..21c5592 100644 --- a/src/app/features/calendar/calendar.component.ts +++ b/src/app/features/calendar/calendar.component.ts @@ -77,7 +77,7 @@ export class CalendarComponent implements OnInit, OnChanges, OnDestroy { postalCode: '', city: '', province: Province.ON, - country: 'Canada' + country: 'Canada', }, eventOnlinePlatform: '', eventDuration: 'Single', @@ -345,7 +345,7 @@ export class CalendarComponent implements OnInit, OnChanges, OnDestroy { postalCode: '', city: '', province: Province.ON, - country: 'Canada' + country: 'Canada', }, eventOnlinePlatform: '', eventDuration: 'Single', diff --git a/src/app/features/events/models/event.ts b/src/app/features/events/models/event.ts index b23bbca..97051d8 100644 --- a/src/app/features/events/models/event.ts +++ b/src/app/features/events/models/event.ts @@ -54,7 +54,13 @@ export class Event { event.title = eventForm.eventName; event.eventType = eventForm.eventType; event.description = eventForm.eventDescription; - event.location = new Location(eventForm.eventLocation.address, eventForm.eventLocation.postalCode, eventForm.eventLocation.city, eventForm.eventLocation.province, eventForm.eventLocation.country); + event.location = new Location( + eventForm.eventLocation.address, + eventForm.eventLocation.postalCode, + eventForm.eventLocation.city, + eventForm.eventLocation.province, + eventForm.eventLocation.country + ); event.language = eventForm.eventLanguage; event.tags = this.tags; event.startDate = new Date([eventForm.eventStartDate, eventForm.eventStartTime].join(' ')); @@ -81,7 +87,13 @@ export class Event { event.title = eventForm.eventName; event.eventType = eventForm.eventType; event.description = eventForm.eventDescription; - event.location = new Location(eventForm.eventLocation.address, eventForm.eventLocation.postalCode, eventForm.eventLocation.city, eventForm.eventLocation.province, eventForm.eventLocation.country); + event.location = new Location( + eventForm.eventLocation.address, + eventForm.eventLocation.postalCode, + eventForm.eventLocation.city, + eventForm.eventLocation.province, + eventForm.eventLocation.country + ); event.language = eventForm.eventLanguage; event.tags = ['']; event.startDate = new Date([eventForm.eventStartDate, eventForm.eventStartTime].join(' ')); diff --git a/src/app/shared/components/event-form/event-form.component.ts b/src/app/shared/components/event-form/event-form.component.ts index a652bf0..276d306 100644 --- a/src/app/shared/components/event-form/event-form.component.ts +++ b/src/app/shared/components/event-form/event-form.component.ts @@ -26,7 +26,7 @@ export class EventFormComponent implements OnInit, OnDestroy, AfterContentInit { postalCode: '', city: '', province: Province.ON, - country: 'Canada' + country: 'Canada', }, eventOnlinePlatform: '', eventDuration: EventDuration.Single, @@ -49,15 +49,13 @@ export class EventFormComponent implements OnInit, OnDestroy, AfterContentInit { ngOnInit(): void { for (const [key, value] of Object.entries(this.model)) { if (!this.form.controls[key]) { - if (key == 'eventDescription'){ + if (key == 'eventDescription') { this.form.addControl(key, new FormControl(value, [EditorValidators.required(), EditorValidators.maxLength(this.maxCharacters)])); - } - else if (key == 'eventLocation') { + } else if (key == 'eventLocation') { continue; - } - else { + } else { this.form.addControl(key, new FormControl(value, [Validators.required, this.minValidator, this.maxValidator])); - } + } } else { this.form.controls[key].setValue(value); } diff --git a/src/app/shared/components/input/input.component.html b/src/app/shared/components/input/input.component.html index 8d53bff..c88e6e7 100644 --- a/src/app/shared/components/input/input.component.html +++ b/src/app/shared/components/input/input.component.html @@ -66,12 +66,10 @@ {{ control.errors!['maxlength'].requiredLength }}. - + {{ translations.input.error.postalCode | translate }} - - {{ label }} {{ translations.input.error.required | translate }} - + {{ label }} {{ translations.input.error.required | translate }} diff --git a/src/app/shared/components/location-form/location-form.component.html b/src/app/shared/components/location-form/location-form.component.html index fcf2b19..5d806c5 100644 --- a/src/app/shared/components/location-form/location-form.component.html +++ b/src/app/shared/components/location-form/location-form.component.html @@ -16,7 +16,7 @@ [name]="'postalCode'" formControlName="postalCode" [control]="form.controls['postalCode'] | formControl" - [label]="translations.forms.location.postalCode| translate" + [label]="translations.forms.location.postalCode | translate" [placeholder]="translations.forms.placeholder | translate" [required]="true" > @@ -39,10 +39,7 @@ * - + @for (prov of provinces; track $index) { {{ translateService.currentLang === 'en' ? prov.titleEn : prov.titleFr }} diff --git a/src/app/shared/components/location-form/location-form.component.scss b/src/app/shared/components/location-form/location-form.component.scss index d4481c3..f45e1f1 100644 --- a/src/app/shared/components/location-form/location-form.component.scss +++ b/src/app/shared/components/location-form/location-form.component.scss @@ -32,7 +32,7 @@ padding-bottom: 16px; } - // TODO: Move to global style when we reuse + // TODO: Move to global style when we reuse ::ng-deep { .gcc-form-select { mat-label { @@ -50,7 +50,7 @@ align-content: center; flex-wrap: wrap; } - + .mat-mdc-form-field-infix { padding-right: 10px; } @@ -64,5 +64,4 @@ } } } - } diff --git a/src/app/shared/components/location-form/location-form.component.ts b/src/app/shared/components/location-form/location-form.component.ts index b0e65ee..8ac3ab8 100644 --- a/src/app/shared/components/location-form/location-form.component.ts +++ b/src/app/shared/components/location-form/location-form.component.ts @@ -23,24 +23,22 @@ export class LocationFormComponent implements OnInit, OnDestroy { provinces = Provinces; - constructor(public translations: Translations, - public translateService: TranslateService) { - - } + constructor( + public translations: Translations, + public translateService: TranslateService + ) {} ngOnInit(): void { for (const [key, value] of Object.entries(this.model)) { if (!this.form.controls[key]) { if (key == 'postalCode') { this.form.addControl(key, new FormControl(value, [Validators.required, Validators.minLength(6), Validators.maxLength(7), this.postalCodeValidator()])); - } - else if (key == 'province') { + } else if (key == 'province') { const province = value as IProvince; this.form.addControl(key, new FormControl(province.abbreviation, [Validators.required])); - } - else { + } else { this.form.addControl(key, new FormControl(value, [Validators.required, Validators.minLength(3), Validators.maxLength(30)])); - } + } } else { this.form.controls[key].setValue(value); } @@ -61,7 +59,7 @@ export class LocationFormComponent implements OnInit, OnDestroy { return (control: AbstractControl): { [key: string]: unknown } | null => { const postalCodePattern = /^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/; if (control.value && !postalCodePattern.test(control.value)) { - return { 'invalidPostalCode': true }; + return { invalidPostalCode: true }; } return null; }; @@ -74,4 +72,4 @@ export interface ILocationForm { city: string; province: IProvince; country: string; -} \ No newline at end of file +}