From ece1cb5c545f6392aefddc72bec4583a15f738ef Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Tue, 19 Apr 2022 10:44:03 +0200 Subject: [PATCH] eslint issues fix --- .../project-description.component.ts | 19 +++++++------- .../project-details.component.ts | 26 ++++++++++--------- .../project-status.component.ts | 19 +++++++------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/frontend/src/app/shared/components/grids/widgets/project-description/project-description.component.ts b/frontend/src/app/shared/components/grids/widgets/project-description/project-description.component.ts index b0d799fefc..5193146284 100644 --- a/frontend/src/app/shared/components/grids/widgets/project-description/project-description.component.ts +++ b/frontend/src/app/shared/components/grids/widgets/project-description/project-description.component.ts @@ -56,17 +56,18 @@ export class WidgetProjectDescriptionComponent extends AbstractWidgetComponent i super(i18n, injector); } - ngOnInit() { - this.project$ = this - .apiV3Service - .projects - .id(this.currentProject.id!) - .get(); - - this.cdRef.detectChanges(); + ngOnInit():void { + if (this.currentProject.id) { + this.project$ = this + .apiV3Service + .projects + .id(this.currentProject.id) + .get(); + this.cdRef.detectChanges(); + } } - public get isEditable() { + public get isEditable():boolean { return false; } } diff --git a/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.ts b/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.ts index 236618aea0..23b630144f 100644 --- a/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.ts +++ b/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.ts @@ -38,7 +38,7 @@ import { import { AbstractWidgetComponent } from 'core-app/shared/components/grids/widgets/abstract-widget.component'; import { I18nService } from 'core-app/core/i18n/i18n.service'; import { CurrentProjectService } from 'core-app/core/current-project/current-project.service'; -import { SchemaResource } from 'core-app/features/hal/resources/schema-resource'; +import { SchemaAttributeObject, SchemaResource } from 'core-app/features/hal/resources/schema-resource'; import { Observable } from 'rxjs'; import { ProjectResource } from 'core-app/features/hal/resources/project-resource'; import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service'; @@ -67,21 +67,23 @@ export class WidgetProjectDetailsComponent extends AbstractWidgetComponent imple super(i18n, injector); } - ngOnInit() { + ngOnInit():void { this.loadAndRender(); - this.project$ = this - .apiV3Service - .projects - .id(this.currentProject.id!) - .requireAndStream(); + if (this.currentProject.id) { + this.project$ = this + .apiV3Service + .projects + .id(this.currentProject.id) + .requireAndStream(); + } } - public get isEditable() { + public get isEditable():boolean { return false; } - private loadAndRender() { - Promise.all([ + private loadAndRender():void { + void Promise.all([ this.loadProjectSchema(), ]) .then(([schema]) => { @@ -89,7 +91,7 @@ export class WidgetProjectDetailsComponent extends AbstractWidgetComponent imple }); } - private loadProjectSchema() { + private loadProjectSchema():Promise { return this .apiV3Service .projects @@ -101,7 +103,7 @@ export class WidgetProjectDetailsComponent extends AbstractWidgetComponent imple private setCustomFields(schema:SchemaResource) { Object.entries(schema).forEach(([key, keySchema]) => { if (/customField\d+/.exec(key)) { - this.customFields.push({ key, label: keySchema.name }); + this.customFields.push({ key, label: (keySchema as SchemaAttributeObject).name }); } }); diff --git a/frontend/src/app/shared/components/grids/widgets/project-status/project-status.component.ts b/frontend/src/app/shared/components/grids/widgets/project-status/project-status.component.ts index 12bfdbb1ba..fc839f8c11 100644 --- a/frontend/src/app/shared/components/grids/widgets/project-status/project-status.component.ts +++ b/frontend/src/app/shared/components/grids/widgets/project-status/project-status.component.ts @@ -72,17 +72,18 @@ export class WidgetProjectStatusComponent extends AbstractWidgetComponent implem super(i18n, injector); } - ngOnInit() { - this.project$ = this - .apiV3Service - .projects - .id(this.currentProject.id!) - .get(); - - this.cdRef.detectChanges(); + ngOnInit():void { + if (this.currentProject.id) { + this.project$ = this + .apiV3Service + .projects + .id(this.currentProject.id) + .get(); + this.cdRef.detectChanges(); + } } - public get isEditable() { + public get isEditable():boolean { return false; } }