From 1e3a2b7eb7eba610f0f89058b52a4ea49a80c869 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 19 Sep 2023 14:46:10 +0200 Subject: [PATCH 1/2] spaced comments --- .eslintrc.json | 3 ++- .vscode/settings.json | 1 + src/app/app.component.spec.ts | 2 +- src/app/form/form-view/form-view.component.ts | 2 +- .../structure-form.component.ts | 2 +- .../make-appointment.component.ts | 2 +- .../online-demarch.component.ts | 2 +- .../structure-edition-summary.component.ts | 2 +- src/app/shared/enum/structureType.enum.ts | 2 +- src/app/shared/pipes/phone.pipe.ts | 2 +- .../more-filters/more-filters.component.ts | 2 +- .../structure-list-search.component.ts | 2 +- src/app/utils/CustomRegExp.ts | 22 +++++++++---------- src/app/utils/formUtils.ts | 2 +- src/app/utils/utils.ts | 4 ++-- src/stories/button.component.ts | 4 ++-- src/stories/header.component.ts | 12 +++++----- src/test.ts | 2 +- 18 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index fe31ef2d2..e0ab1a185 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -29,7 +29,8 @@ "prefix": "app", "style": "kebab-case" } - ] + ], + "spaced-comment": ["error", "always", { "block": { "exceptions": ["*"] } }] } }, { diff --git a/.vscode/settings.json b/.vscode/settings.json index 6f79238d7..3658ccdb7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,6 +42,7 @@ "metropole", "Metropole", "monday", + "NOSONAR", "onespace", "orientator", "Orientator", diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 1a1d0edd2..fa8a3e787 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -23,7 +23,7 @@ describe('AppComponent', () => { expect(app.title).toEqual('pamn'); }); - /*it('should render title', () => { + /* it('should render title', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.nativeElement; diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index 076e17698..610402167 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -206,7 +206,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { phone: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.PHONE)]), password: new UntypedFormControl('', [ Validators.required, - Validators.pattern(CustomRegExp.PASSWORD), //NOSONAR + Validators.pattern(CustomRegExp.PASSWORD), // NOSONAR ]), confirmPassword: new UntypedFormControl(''), }, diff --git a/src/app/form/form-view/structure-form/structure-form.component.ts b/src/app/form/form-view/structure-form/structure-form.component.ts index e6a3e1b6f..3a12a285a 100644 --- a/src/app/form/form-view/structure-form/structure-form.component.ts +++ b/src/app/form/form-view/structure-form/structure-form.component.ts @@ -63,7 +63,7 @@ export class StructureFormComponent implements OnChanges, OnInit { ngOnChanges(changes: SimpleChanges): void { if (changes.currentStep) { - //facultative steps + // facultative steps if ( this.currentStep === structureFormStep.structureCreationFinishedInfo || this.currentStep === structureFormStep.structureHours || diff --git a/src/app/form/orientation-form-view/online-demarch/appointment/make-appointment/make-appointment.component.ts b/src/app/form/orientation-form-view/online-demarch/appointment/make-appointment/make-appointment.component.ts index 577a07b0d..af7010b67 100644 --- a/src/app/form/orientation-form-view/online-demarch/appointment/make-appointment/make-appointment.component.ts +++ b/src/app/form/orientation-form-view/online-demarch/appointment/make-appointment/make-appointment.component.ts @@ -108,7 +108,7 @@ export class MakeAppointmentComponent implements OnInit { this.structures.forEach((structure) => { // check each of its personnalOffers structure.personalOffers?.forEach((po) => { - //if the needs the user selected are all part of the personalOffer, keep the structure for display + // if the needs the user selected are all part of the personalOffer, keep the structure for display if ( this.filtersOnOffers.onlineProcedures.every((offer) => po.categories.onlineProcedures.includes(offer)) && this.filtersOnOffers.baseSkills.every((offer) => po.categories.baseSkills.includes(offer)) diff --git a/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts b/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts index 1ef602988..48276bc41 100644 --- a/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts +++ b/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts @@ -21,7 +21,7 @@ export class OnlineDemarchComponent implements OnInit { ngOnInit(): void { this.selectedModules = this.form.get('onlineDemarcheType').value; - //TODO move this in form init categories + // TODO move this in form init categories this.searchService.getCategories().subscribe((categories: Category[]) => { this.accompanimentType = categories.find((el) => el.id === CategoryEnum.onlineProcedures).modules; }); diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts index d0ab70c02..1e7fc5245 100644 --- a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts @@ -39,7 +39,7 @@ export class StructureEditionSummaryComponent implements OnInit { public buttonTypeEnum = ButtonType; public equipmentEnum = Equipment; - //Digital learning + // Digital learning public categories: Category[] = []; public showBaseSkills = false; public showAdvancedSkills = false; diff --git a/src/app/shared/enum/structureType.enum.ts b/src/app/shared/enum/structureType.enum.ts index a43e115ae..7016d6b29 100644 --- a/src/app/shared/enum/structureType.enum.ts +++ b/src/app/shared/enum/structureType.enum.ts @@ -2,7 +2,7 @@ export enum StructureTypeEnum { fablab = 'Fablab', // A supprimer ? - //A remplacer par Association ? + // A remplacer par Association ? associationQuartier = 'Structure associative de quartier', associationCaritative = 'Association caritative', diff --git a/src/app/shared/pipes/phone.pipe.ts b/src/app/shared/pipes/phone.pipe.ts index af1e964f7..4e5d2693e 100644 --- a/src/app/shared/pipes/phone.pipe.ts +++ b/src/app/shared/pipes/phone.pipe.ts @@ -3,7 +3,7 @@ import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'phone' }) export class PhonePipe implements PipeTransform { transform(value: string): string { - //Remove dot and space from the phone string and add space in each 2 numbers + // Remove dot and space from the phone string and add space in each 2 numbers const regexArray = value.replace(/\s|\./g, '').match(/.{1,2}/g); return regexArray.join(' '); } diff --git a/src/app/structure-list/components/more-filters/more-filters.component.ts b/src/app/structure-list/components/more-filters/more-filters.component.ts index 5022bf2ca..b20f67860 100644 --- a/src/app/structure-list/components/more-filters/more-filters.component.ts +++ b/src/app/structure-list/components/more-filters/more-filters.component.ts @@ -16,7 +16,7 @@ export class MoreFiltersComponent implements OnInit, OnChanges { @Input() public modalType: TypeModal; @Input() public categories: Category[]; - //checked modules filter list + // checked modules filter list @Input() public modules: Module[] = []; @Output() searchEvent = new EventEmitter(); @Output() closeEvent = new EventEmitter(); diff --git a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts index a57d693ee..740599d6f 100644 --- a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts +++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts @@ -107,7 +107,7 @@ export class StructureListSearchComponent implements OnInit { this.searchEvent.emit(filters); } - //Update url with new params added or removed + // Update url with new params added or removed public updateUrlParams(filters: Filter[]): void { // No url update if the page is displaying structure details, because it must keep the url with the structure id, neither for orientation if ( diff --git a/src/app/utils/CustomRegExp.ts b/src/app/utils/CustomRegExp.ts index 7582ce5fa..3aec8f1ca 100644 --- a/src/app/utils/CustomRegExp.ts +++ b/src/app/utils/CustomRegExp.ts @@ -2,28 +2,28 @@ export class CustomRegExp { /** * Validate a password (at least 8 characters, 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character) */ - public static readonly DIGIT: RegExp = /^(?=.*[0-9])/; //NOSONAR - public static readonly SPECHAR: RegExp = /^(?=.*[*.! @#$%^&(){}\[\]:;<>,?\/\\~_+\-=|])/; //NOSONAR - public static readonly UPPERCASE: RegExp = /^(?=.*[A-Z])/; //NOSONAR - public static readonly LOWERCASE: RegExp = /^(?=.*[a-z])/; //NOSONAR - public static readonly MINLENGTH: RegExp = /^(?=.{8,})/; //NOSONAR + public static readonly DIGIT: RegExp = /^(?=.*[0-9])/; // NOSONAR + public static readonly SPECHAR: RegExp = /^(?=.*[*.! @#$%^&(){}\[\]:;<>,?\/\\~_+\-=|])/; // NOSONAR + public static readonly UPPERCASE: RegExp = /^(?=.*[A-Z])/; // NOSONAR + public static readonly LOWERCASE: RegExp = /^(?=.*[a-z])/; // NOSONAR + public static readonly MINLENGTH: RegExp = /^(?=.{8,})/; // NOSONAR public static readonly PASSWORD: RegExp = new RegExp( CustomRegExp.LOWERCASE.source + CustomRegExp.UPPERCASE.source + CustomRegExp.DIGIT.source + CustomRegExp.SPECHAR.source + CustomRegExp.MINLENGTH.source - ); //NOSONAR + ); // NOSONAR /** * Validate an email */ - public static readonly EMAIL: RegExp = /^[A-Za-z0-9.\-_]+@[A-Za-z0-9.-]+[.][a-z]{2,3}$/; //NOSONAR - public static readonly TEXT_WITHOUT_NUMBER: RegExp = /^[A-Za-zÀ-ÖØ-öø-ÿ-\' ]{1,}$/; //NOSONAR + public static readonly EMAIL: RegExp = /^[A-Za-z0-9.\-_]+@[A-Za-z0-9.-]+[.][a-z]{2,3}$/; // NOSONAR + public static readonly TEXT_WITHOUT_NUMBER: RegExp = /^[A-Za-zÀ-ÖØ-öø-ÿ-\' ]{1,}$/; // NOSONAR /** * Validate a phone number (4 or 10 digits, allowing spaces, dashes and dots as spacers) */ - public static readonly PHONE: RegExp = /^(?:(?:\+|00)|0)\s*[1-9](?:[\s.-]*\d{2}){4}$|^(?:[\s.-]*\d{2}){2}$/; //NOSONAR - public static readonly WEBSITE: RegExp = /^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}|[a-zA-Z0-9]+\.[^\s]{2,})/; //NOSONAR + public static readonly PHONE: RegExp = /^(?:(?:\+|00)|0)\s*[1-9](?:[\s.-]*\d{2}){4}$|^(?:[\s.-]*\d{2}){2}$/; // NOSONAR + public static readonly WEBSITE: RegExp = /^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}|[a-zA-Z0-9]+\.[^\s]{2,})/; // NOSONAR public static readonly LINKEDIN: string = '(linkedin.com/.{1,})'; public static readonly FACEBOOK: string = '(facebook.com/.{1,})'; public static readonly TWITTER: string = '(twitter.com/.{1,})'; @@ -33,5 +33,5 @@ export class CustomRegExp { /** * Validate a location request in search bar */ - public static readonly LOCATION: RegExp = /^\d+\s[A-z]+\s[A-z]+/g; //NOSONAR + public static readonly LOCATION: RegExp = /^\d+\s[A-z]+\s[A-z]+/g; // NOSONAR } diff --git a/src/app/utils/formUtils.ts b/src/app/utils/formUtils.ts index ed9bef319..0d8760ea0 100644 --- a/src/app/utils/formUtils.ts +++ b/src/app/utils/formUtils.ts @@ -122,7 +122,7 @@ export class formUtils { advancedSkills: new UntypedFormControl(structure.categories?.advancedSkills), solidarityMaterial: this.loadArrayForCheckbox(structure.categories?.solidarityMaterial, false), }), - //TODO: remettre ou migrer les données de accompagnements à distance + // TODO: remettre ou migrer les données de accompagnements à distance remoteAccompaniment: new UntypedFormControl(false), otherDescription: new UntypedFormControl(structure.otherDescription), nbComputers: new UntypedFormControl( diff --git a/src/app/utils/utils.ts b/src/app/utils/utils.ts index 373828f1d..a2c893b11 100644 --- a/src/app/utils/utils.ts +++ b/src/app/utils/utils.ts @@ -23,7 +23,7 @@ export class Utils { // Check to refresh every 2 number. if (phoneNoSpace.length % 2 === 0) { // Add space every 2 number - form.get(controlName).setValue(phoneNoSpace.replace(/(?!^)(?=(?:\d{2})+$)/g, ' ')); //NOSONAR + form.get(controlName).setValue(phoneNoSpace.replace(/(?!^)(?=(?:\d{2})+$)/g, ' ')); // NOSONAR } } @@ -33,7 +33,7 @@ export class Utils { // Check to refresh every 2 number. if (phoneNoSpace.length % 2 === 0) { // Add space every 2 number - return phoneNoSpace.replace(/(?!^)(?=(?:\d{2})+$)/g, ' '); //NOSONAR + return phoneNoSpace.replace(/(?!^)(?=(?:\d{2})+$)/g, ' '); // NOSONAR } return phoneNumber; } diff --git a/src/stories/button.component.ts b/src/stories/button.component.ts index 28dcc97e5..955870cdf 100644 --- a/src/stories/button.component.ts +++ b/src/stories/button.component.ts @@ -6,9 +6,9 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; imports: [CommonModule], template: ` <button type="button" - (click)="onClick.emit($event)" - [ngClass]="classes" + [ngClass]="classes" [ngStyle]="{ 'background-color': backgroundColor }" + (click)="onClick.emit($event)"" > {{ label }} </button>`, diff --git a/src/stories/header.component.ts b/src/stories/header.component.ts index 2980d3b32..1e63bf216 100644 --- a/src/stories/header.component.ts +++ b/src/stories/header.component.ts @@ -33,8 +33,8 @@ import type { User } from './User'; <storybook-button *ngIf="user" size="small" - (onClick)="onLogout.emit($event)" - label="Log out" + label="Log out" + (onClick)="onLogout.emit($event)"" ></storybook-button> </div> <div *ngIf="!user"> @@ -42,8 +42,8 @@ import type { User } from './User'; *ngIf="!user" size="small" class="margin-left" - (onClick)="onLogin.emit($event)" - label="Log in" + label="Log in" + (onClick)="onLogin.emit($event)"" ></storybook-button> <storybook-button *ngIf="!user" @@ -51,8 +51,8 @@ import type { User } from './User'; size="small" primary="true" class="margin-left" - (onClick)="onCreateAccount.emit($event)" - label="Sign up" + label="Sign up" + (onClick)="onCreateAccount.emit($event)"" ></storybook-button> </div> </div> diff --git a/src/test.ts b/src/test.ts index 408798c07..0dcc45fbe 100644 --- a/src/test.ts +++ b/src/test.ts @@ -7,4 +7,4 @@ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@ang // First, initialize the Angular testing environment. getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { teardown: { destroyAfterEach: false } -}); //NOSONAR +}); // NOSONAR -- GitLab From a94db1827f9a76ae12b7a64b11bd7466ffa753ca Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 19 Sep 2023 15:00:24 +0200 Subject: [PATCH 2/2] optional chaining --- .eslintrc.json | 4 +++- .../manage-users/manage-users.component.ts | 4 ++-- src/app/form/form-view/form-view.component.ts | 7 ++----- .../online-demarch.component.ts | 2 +- .../orientation-form-view.component.ts | 2 +- src/app/map/models/geojson.model.ts | 2 +- src/app/models/day.model.ts | 2 +- src/app/models/structure.model.ts | 2 +- src/app/models/week.model.ts | 14 +++++++------- .../accompaniment-picker.component.ts | 2 +- src/app/structure-list/models/category.model.ts | 7 +++---- 11 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e0ab1a185..627aaa08a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -30,7 +30,9 @@ "style": "kebab-case" } ], - "spaced-comment": ["error", "always", { "block": { "exceptions": ["*"] } }] + "spaced-comment": ["error", "always", { "block": { "exceptions": ["*"] } }], + + "@typescript-eslint/prefer-optional-chain": "warn" } }, { diff --git a/src/app/admin/components/manage-users/manage-users.component.ts b/src/app/admin/components/manage-users/manage-users.component.ts index ad7d51399..12bbd8a51 100644 --- a/src/app/admin/components/manage-users/manage-users.component.ts +++ b/src/app/admin/components/manage-users/manage-users.component.ts @@ -229,7 +229,7 @@ export class ManageUsersComponent { }); } } else { - if (context.oldValue && context.oldValue.name) { + if (context.oldValue?.name) { context.node.data[context.colDef.field] = context.oldValue; context.api.refreshCells({ rowNodes: [context.node], columns: [context.column.colId] }); } @@ -253,7 +253,7 @@ export class ManageUsersComponent { }); } } else { - if (context.oldValue && context.oldValue.name) { + if (context.oldValue?.name) { context.node.data[context.colDef.field] = context.oldValue; context.api.refreshCells({ rowNodes: [context.node], columns: [context.column.colId] }); } diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index 610402167..4f16a52de 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -194,10 +194,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { private createAccountForm(email?: string): void { this.accountForm = new UntypedFormGroup( { - email: new UntypedFormControl(email ? email : '', [ - Validators.required, - Validators.pattern(CustomRegExp.EMAIL), - ]), + email: new UntypedFormControl(email ?? '', [Validators.required, Validators.pattern(CustomRegExp.EMAIL)]), name: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.TEXT_WITHOUT_NUMBER)]), surname: new UntypedFormControl('', [ Validators.required, @@ -347,7 +344,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { }).subscribe(async () => { // if register a new user as a new member structure, no structure to choose if (this.isRegisterNewMember) { - if (this.profile.job && this.profile.job.hasPersonalOffer) { + if (this.profile.job?.hasPersonalOffer) { this.structureService.getStructure(this.profile.structuresLink[0]).subscribe((structure) => { this.structure = new Structure(structure); this.router.navigateByUrl('form/personaloffer'); diff --git a/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts b/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts index 48276bc41..a2521e608 100644 --- a/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts +++ b/src/app/form/orientation-form-view/online-demarch/online-demarch-common/online-demarch.component.ts @@ -43,7 +43,7 @@ export class OnlineDemarchComponent implements OnInit { } public isSelectedModule(moduleId: string): boolean { - if (this.selectedModules && this.selectedModules.map((module) => module.id).includes(moduleId)) return true; + if (this.selectedModules?.map((module) => module.id).includes(moduleId)) return true; return false; } public handleClose(): void { diff --git a/src/app/form/orientation-form-view/orientation-form-view.component.ts b/src/app/form/orientation-form-view/orientation-form-view.component.ts index 07a940ce3..41cdd5f63 100644 --- a/src/app/form/orientation-form-view/orientation-form-view.component.ts +++ b/src/app/form/orientation-form-view/orientation-form-view.component.ts @@ -633,7 +633,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked private targetStructures(structureChoice: AbstractControl): OrientationIndicatorStructure[] { const targetStructures: OrientationIndicatorStructure[] = []; - if (structureChoice && structureChoice.value) { + if (structureChoice?.value) { structureChoice.value.forEach((structure: Structure) => { targetStructures.push({ nom: structure.structureName, diff --git a/src/app/map/models/geojson.model.ts b/src/app/map/models/geojson.model.ts index 8ca263895..e6821e97a 100644 --- a/src/app/map/models/geojson.model.ts +++ b/src/app/map/models/geojson.model.ts @@ -8,7 +8,7 @@ export class GeoJson { constructor(obj?: any) { Object.assign(this, obj, { - geometry: obj && obj.geometry ? new AddressGeometry(obj.geometry) : null, + geometry: obj?.geometry ? new AddressGeometry(obj.geometry) : null, }); } } diff --git a/src/app/models/day.model.ts b/src/app/models/day.model.ts index 005ccfa24..a73a3ba7d 100644 --- a/src/app/models/day.model.ts +++ b/src/app/models/day.model.ts @@ -6,7 +6,7 @@ export class Day { constructor(obj?: any) { Object.assign(this, obj, { - time: obj && obj.time ? obj.time.map((time) => new Time(time)) : [], + time: obj?.time ? obj.time.map((time) => new Time(time)) : [], }); } } diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index 1e4cd5c61..2143e144b 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -65,7 +65,7 @@ export class Structure { constructor(obj?: any) { Object.assign(this, obj, { - hours: obj && obj.hours ? new Week(obj.hours) : new Week(), + hours: obj?.hours ? new Week(obj.hours) : new Week(), categories: { accessModality: obj?.categories?.accessModality || [], advancedSkills: obj?.categories?.advancedSkills || [], diff --git a/src/app/models/week.model.ts b/src/app/models/week.model.ts index d76404c96..77c35b5c4 100644 --- a/src/app/models/week.model.ts +++ b/src/app/models/week.model.ts @@ -13,13 +13,13 @@ export class Week { constructor(obj?: any) { Object.assign(this, obj, { - monday: obj && obj.monday ? new Day(obj.monday) : new Day(), - tuesday: obj && obj.tuesday ? new Day(obj.tuesday) : new Day(), - wednesday: obj && obj.wednesday ? new Day(obj.wednesday) : new Day(), - thursday: obj && obj.thursday ? new Day(obj.thursday) : new Day(), - friday: obj && obj.friday ? new Day(obj.friday) : new Day(), - saturday: obj && obj.saturday ? new Day(obj.saturday) : new Day(), - sunday: obj && obj.sunday ? new Day(obj.sunday) : new Day(), + monday: obj?.monday ? new Day(obj.monday) : new Day(), + tuesday: obj?.tuesday ? new Day(obj.tuesday) : new Day(), + wednesday: obj?.wednesday ? new Day(obj.wednesday) : new Day(), + thursday: obj?.thursday ? new Day(obj.thursday) : new Day(), + friday: obj?.friday ? new Day(obj.friday) : new Day(), + saturday: obj?.saturday ? new Day(obj.saturday) : new Day(), + sunday: obj?.sunday ? new Day(obj.sunday) : new Day(), }); } diff --git a/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts b/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts index cbd8c77f3..0f2e2fbac 100644 --- a/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts +++ b/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts @@ -46,7 +46,7 @@ export class AccompanimentPickerComponent implements OnInit, OnChanges { } public isSelectedModule(module: Module): boolean { - if (this.selectedModules && this.selectedModules.includes(module)) return true; + if (this.selectedModules?.includes(module)) return true; return false; } } diff --git a/src/app/structure-list/models/category.model.ts b/src/app/structure-list/models/category.model.ts index 1bef26f77..2987cf0c4 100644 --- a/src/app/structure-list/models/category.model.ts +++ b/src/app/structure-list/models/category.model.ts @@ -8,10 +8,9 @@ export class Category { constructor(obj?: any) { Object.assign(this, obj, { - modules: - obj && obj.modules - ? obj.modules.map((module: Module) => new Module(module.id, module.name, module.displayText)) - : null, + modules: obj?.modules + ? obj.modules.map((module: Module) => new Module(module.id, module.name, module.displayText)) + : null, }); } } -- GitLab