From 003654e5b612c65c0d1b132dce42ca5c737da84c Mon Sep 17 00:00:00 2001 From: ThomasTrigatti Date: Thu, 19 Sep 2024 12:39:57 +0200 Subject: [PATCH 1/2] Fix for the function that retrive Dimensions - Fixed the cases when a dimension as "scale" attribute as "false", for the function that retrive a dimension --- .../document/dimension/dimension.component.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/components/skeleton/document/dimension/dimension.component.ts b/src/app/components/skeleton/document/dimension/dimension.component.ts index 0ae6d665..de1f3c2f 100644 --- a/src/app/components/skeleton/document/dimension/dimension.component.ts +++ b/src/app/components/skeleton/document/dimension/dimension.component.ts @@ -240,7 +240,7 @@ export class DimensionComponent implements OnInit, OnChanges { public detectCategoricalDimensionOnChange(eventData: { value?: any; target?: any; }) { if (this.task.settings.attributesMain.some(attribute => attribute.is_video) && this.task.dimensions.some(dimension => dimension.scale.type == "interval") && - this.task.dimensions.filter(dimension => dimension.scale.type == "categorical").length > 1) { + this.task.dimensions.filter(dimension => dimension.scale && dimension.scale.type === "categorical").length > 1) { let currentValue = String(Object.keys(eventData).includes('value') ? eventData.value : eventData.target.value) let primaryCategoricalDimension = this.getPrimaryCategoricalDimension(); let previousValue = this.assessmentForm.controls[primaryCategoricalDimension.name.concat('_value').concat('')].value; @@ -277,8 +277,15 @@ export class DimensionComponent implements OnInit, OnChanges { } public isVideoTypeLabelCategorical(currentCategoricalDimension : Dimension): boolean { - if (currentCategoricalDimension.scale instanceof ScaleCategorical) { + console.log(currentCategoricalDimension.name) + if (currentCategoricalDimension.scale && currentCategoricalDimension.scale instanceof ScaleCategorical) { let primaryCategoricalDimension = this.getPrimaryCategoricalDimension(); + + /* Debug Test */ + let test = this.task.settings.attributesMain.some(attribute => attribute.is_video) && currentCategoricalDimension.name != primaryCategoricalDimension.name; + //console.log(currentCategoricalDimension.name) + console.log(test); + return this.task.settings.attributesMain.some(attribute => attribute.is_video) && currentCategoricalDimension.name != primaryCategoricalDimension.name; } return false; @@ -293,16 +300,16 @@ export class DimensionComponent implements OnInit, OnChanges { private getPrimaryCategoricalDimension(): Dimension { /* Get the first categorical dimension - the master categorical dimension */ - return this.task.dimensions.filter(dimension => dimension.scale.type == "categorical")[0]; + return this.task.dimensions.find(dimension => dimension.scale && dimension.scale.type === "categorical"); } private getSecondaryCategoricalDimension(): Dimension { /* Get the second categorical dimension */ - return this.task.dimensions.filter(dimension => dimension.scale.type == "categorical")[1]; + return this.task.dimensions.filter(dimension => dimension.scale && dimension.scale.type === "categorical")[1]; } private getIntervalDimension(): Dimension { - return this.task.dimensions.find(dimension => dimension.scale.type == "interval") + return this.task.dimensions.find(dimension => dimension.scale && dimension.scale.type === "interval") } public sliderDisabled(): boolean { From 52f366628cb99b067bcda92c1025875fb2a283b7 Mon Sep 17 00:00:00 2001 From: ThomasTrigatti Date: Fri, 20 Sep 2024 09:28:35 +0200 Subject: [PATCH 2/2] Remove a console log debug --- .../skeleton/document/dimension/dimension.component.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/app/components/skeleton/document/dimension/dimension.component.ts b/src/app/components/skeleton/document/dimension/dimension.component.ts index de1f3c2f..f6bb6440 100644 --- a/src/app/components/skeleton/document/dimension/dimension.component.ts +++ b/src/app/components/skeleton/document/dimension/dimension.component.ts @@ -277,15 +277,8 @@ export class DimensionComponent implements OnInit, OnChanges { } public isVideoTypeLabelCategorical(currentCategoricalDimension : Dimension): boolean { - console.log(currentCategoricalDimension.name) if (currentCategoricalDimension.scale && currentCategoricalDimension.scale instanceof ScaleCategorical) { let primaryCategoricalDimension = this.getPrimaryCategoricalDimension(); - - /* Debug Test */ - let test = this.task.settings.attributesMain.some(attribute => attribute.is_video) && currentCategoricalDimension.name != primaryCategoricalDimension.name; - //console.log(currentCategoricalDimension.name) - console.log(test); - return this.task.settings.attributesMain.some(attribute => attribute.is_video) && currentCategoricalDimension.name != primaryCategoricalDimension.name; } return false;