Skip to content

Commit

Permalink
Code formatting ignore-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
GCCollabBot committed Apr 2, 2024
1 parent 8f1fb33 commit cb66e94
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 52 deletions.
36 changes: 18 additions & 18 deletions src/app/core/models/location.model.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/app/features/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class CalendarComponent implements OnInit, OnChanges, OnDestroy {
postalCode: '',
city: '',
province: Province.ON,
country: 'Canada'
country: 'Canada',
},
eventOnlinePlatform: '',
eventDuration: 'Single',
Expand Down Expand Up @@ -345,7 +345,7 @@ export class CalendarComponent implements OnInit, OnChanges, OnDestroy {
postalCode: '',
city: '',
province: Province.ON,
country: 'Canada'
country: 'Canada',
},
eventOnlinePlatform: '',
eventDuration: 'Single',
Expand Down
16 changes: 14 additions & 2 deletions src/app/features/events/models/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(' '));
Expand All @@ -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(' '));
Expand Down
12 changes: 5 additions & 7 deletions src/app/shared/components/event-form/event-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class EventFormComponent implements OnInit, OnDestroy, AfterContentInit {
postalCode: '',
city: '',
province: Province.ON,
country: 'Canada'
country: 'Canada',
},
eventOnlinePlatform: '',
eventDuration: EventDuration.Single,
Expand All @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions src/app/shared/components/input/input.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@
{{ control.errors!['maxlength'].requiredLength }}.
</mat-error>

<mat-error *ngIf="control && control.hasError('invalidPostalCode') && (!control.hasError('minlength') && !control.hasError('maxlength'))">
<mat-error *ngIf="control && control.hasError('invalidPostalCode') && !control.hasError('minlength') && !control.hasError('maxlength')">
{{ translations.input.error.postalCode | translate }}
</mat-error>

<mat-error *ngIf="control && control.hasError('required')">
{{ label }} {{ translations.input.error.required | translate }}
</mat-error>
<mat-error *ngIf="control && control.hasError('required')"> {{ label }} {{ translations.input.error.required | translate }} </mat-error>
</mat-form-field>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand All @@ -39,10 +39,7 @@
<span class="required-star">*</span>
</mat-label>
<mat-form-field>
<mat-select [placeholder]="translations.forms.location.province | translate"
[formControl]="form.controls['province'] | formControl"
[value]="model.province.abbreviation"
>
<mat-select [placeholder]="translations.forms.location.province | translate" [formControl]="form.controls['province'] | formControl" [value]="model.province.abbreviation">
@for (prov of provinces; track $index) {
<mat-option [value]="prov.abbreviation">
{{ translateService.currentLang === 'en' ? prov.titleEn : prov.titleFr }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -50,7 +50,7 @@
align-content: center;
flex-wrap: wrap;
}

.mat-mdc-form-field-infix {
padding-right: 10px;
}
Expand All @@ -64,5 +64,4 @@
}
}
}

}
20 changes: 9 additions & 11 deletions src/app/shared/components/location-form/location-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
};
Expand All @@ -74,4 +72,4 @@ export interface ILocationForm {
city: string;
province: IProvince;
country: string;
}
}

0 comments on commit cb66e94

Please sign in to comment.