From c3a80aa51dcffb3b6ed8465860228c1e38d57ad2 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Thu, 9 Jun 2022 15:39:41 +0200 Subject: [PATCH] [editor] Fix likert row generation - Missing type inforamtion as constructor parameter - Also the new ID generation mechanism uses the type of the element to request an ID from the the IDManager. Here was a mismatch, where the type is 'likert-row', but the IDManager only knew 'likert_row'. This is now files all IDs use hyphens instead of underscores. --- projects/common/util/id-manager.ts | 2 +- .../element-model-properties.component.ts | 14 ++++++++++---- projects/editor/src/app/services/unit.service.ts | 12 ------------ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/projects/common/util/id-manager.ts b/projects/common/util/id-manager.ts index d62741a50..09bc3eb92 100644 --- a/projects/common/util/id-manager.ts +++ b/projects/common/util/id-manager.ts @@ -16,7 +16,7 @@ export class IDManager { audio: 0, video: 0, likert: 0, - likert_row: 0, + 'likert-row': 0, slider: 0, 'spell-correct': 0, 'radio-group-images': 0, diff --git a/projects/editor/src/app/components/properties-panel/model-properties-tab/element-model-properties.component.ts b/projects/editor/src/app/components/properties-panel/model-properties-tab/element-model-properties.component.ts index 152f4b85c..e176e7050 100644 --- a/projects/editor/src/app/components/properties-panel/model-properties-tab/element-model-properties.component.ts +++ b/projects/editor/src/app/components/properties-panel/model-properties-tab/element-model-properties.component.ts @@ -11,6 +11,7 @@ import { DomSanitizer } from '@angular/platform-browser'; import { DragNDropValueObject, InputElementValue, TextImageLabel, UIElement } from 'common/models/elements/element'; import { LikertRowElement } from 'common/models/elements/compound-elements/likert/likert-row'; import { LikertElement } from 'common/models/elements/compound-elements/likert/likert'; +import { IDManager } from 'common/util/id-manager'; @Component({ selector: 'aspect-element-model-properties-component', @@ -84,10 +85,15 @@ export class ElementModelPropertiesComponent { } addLikertRow(rowLabelText: string): void { - const newRow = this.unitService.createLikertRowElement( - rowLabelText, - (this.combinedProperties.columns as TextImageLabel[]).length - ); + const newRow = new LikertRowElement({ + type: 'likert-row', + rowLabel: { + text: rowLabelText, + imgSrc: null, + position: 'above' + }, + columnCount: (this.combinedProperties.columns as TextImageLabel[]).length + }, IDManager.getInstance()); (this.combinedProperties.rows as LikertRowElement[]).push(newRow); this.updateModel.emit({ property: 'rows', value: this.combinedProperties.rows as LikertRowElement[] }); } diff --git a/projects/editor/src/app/services/unit.service.ts b/projects/editor/src/app/services/unit.service.ts index 4632609d7..0545daf10 100644 --- a/projects/editor/src/app/services/unit.service.ts +++ b/projects/editor/src/app/services/unit.service.ts @@ -273,18 +273,6 @@ export class UnitService { this.veronaApiService.sendVoeDefinitionChangedNotification(this.unit); } - createLikertRowElement(rowLabelText: string, columnCount: number): LikertRowElement { - return new LikertRowElement({ - id: IDManager.getInstance().getNewID('likert_row'), - rowLabel: { - text: rowLabelText, - imgSrc: null, - position: 'above' - }, - columnCount: columnCount - } as Partial<LikertRowElement>); - } - alignElements(elements: PositionedUIElement[], alignmentDirection: 'left' | 'right' | 'top' | 'bottom'): void { switch (alignmentDirection) { case 'left': -- GitLab