From 3e1d0f9c8a6cad6d5ed540d23e65e2e1681ec8a1 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Fri, 3 Jun 2022 00:14:12 +0200 Subject: [PATCH] Fix a bunch of code style issues --- projects/common/models/elements/button/button.ts | 2 +- .../elements/compound-elements/likert/likert-row.ts | 2 +- .../elements/compound-elements/likert/likert.ts | 9 +++------ projects/common/models/elements/frame/frame.ts | 2 +- .../models/elements/input-elements/checkbox.ts | 2 +- .../models/elements/input-elements/drop-list.ts | 5 +++-- .../models/elements/input-elements/dropdown.ts | 2 +- .../input-elements/radio-button-group-complex.ts | 2 +- .../elements/input-elements/radio-button-group.ts | 2 +- .../common/models/elements/input-elements/slider.ts | 2 +- .../models/elements/input-elements/spell-correct.ts | 2 +- .../models/elements/input-elements/text-area.ts | 2 +- .../models/elements/input-elements/text-field.ts | 2 +- .../common/models/elements/media-elements/audio.ts | 2 +- .../common/models/elements/media-elements/image.ts | 2 +- .../common/models/elements/media-elements/video.ts | 2 +- projects/common/models/elements/text/text.ts | 8 +++----- projects/common/models/section.ts | 5 +++-- projects/common/util/unit-utils.ts | 2 +- .../src/app/components/canvas/canvas.component.html | 2 +- .../src/app/components/canvas/canvas.component.ts | 10 +++++----- .../canvas/dynamic-section-helper-grid.component.ts | 12 ++++++------ .../canvas/overlays/canvas-element-overlay.ts | 4 ++-- .../input-groups/drop-list-properties.component.ts | 2 +- 24 files changed, 42 insertions(+), 45 deletions(-) diff --git a/projects/common/models/elements/button/button.ts b/projects/common/models/elements/button/button.ts index 595b107c5..2596637f7 100644 --- a/projects/common/models/elements/button/button.ts +++ b/projects/common/models/elements/button/button.ts @@ -1,7 +1,7 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, PositionedUIElement, PositionProperties, UIElement } from 'common/models/elements/element'; import { ButtonComponent } from 'common/components/button/button.component'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; export class ButtonElement extends UIElement implements PositionedUIElement { diff --git a/projects/common/models/elements/compound-elements/likert/likert-row.ts b/projects/common/models/elements/compound-elements/likert/likert-row.ts index e4ae7a398..715d0f6c1 100644 --- a/projects/common/models/elements/compound-elements/likert/likert-row.ts +++ b/projects/common/models/elements/compound-elements/likert/likert-row.ts @@ -1,5 +1,5 @@ -import { InputElement, TextImageLabel } from 'common/models/elements/element'; import { Type } from '@angular/core'; +import { InputElement, TextImageLabel } from 'common/models/elements/element'; import { ElementComponent } from 'common/directives/element-component.directive'; import { LikertRadioButtonGroupComponent diff --git a/projects/common/models/elements/compound-elements/likert/likert.ts b/projects/common/models/elements/compound-elements/likert/likert.ts index 261fac499..076ad6d8c 100644 --- a/projects/common/models/elements/compound-elements/likert/likert.ts +++ b/projects/common/models/elements/compound-elements/likert/likert.ts @@ -1,13 +1,10 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { - BasicStyles, CompoundElement, - PositionedUIElement, - PositionProperties, - TextImageLabel, - UIElement + BasicStyles, CompoundElement, UIElement, + PositionedUIElement, PositionProperties, TextImageLabel } from 'common/models/elements/element'; import { LikertRowElement } from 'common/models/elements/compound-elements/likert/likert-row'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { LikertComponent } from 'common/components/compound-elements/likert/likert.component'; diff --git a/projects/common/models/elements/frame/frame.ts b/projects/common/models/elements/frame/frame.ts index 409933c0e..5a63eafef 100644 --- a/projects/common/models/elements/frame/frame.ts +++ b/projects/common/models/elements/frame/frame.ts @@ -1,8 +1,8 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, PositionedUIElement, PositionProperties, UIElement } from 'common/models/elements/element'; import { FrameComponent } from 'common/components/frame/frame.component'; import { ElementComponent } from 'common/directives/element-component.directive'; -import { Type } from '@angular/core'; export class FrameElement extends UIElement implements PositionedUIElement { position: PositionProperties; diff --git a/projects/common/models/elements/input-elements/checkbox.ts b/projects/common/models/elements/input-elements/checkbox.ts index 00f448bd8..a7d8b77c4 100644 --- a/projects/common/models/elements/input-elements/checkbox.ts +++ b/projects/common/models/elements/input-elements/checkbox.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { CheckboxComponent } from 'common/components/input-elements/checkbox.component'; diff --git a/projects/common/models/elements/input-elements/drop-list.ts b/projects/common/models/elements/input-elements/drop-list.ts index e392fb3d7..a0a5727d2 100644 --- a/projects/common/models/elements/input-elements/drop-list.ts +++ b/projects/common/models/elements/input-elements/drop-list.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { DropListComponent } from 'common/components/input-elements/drop-list.component'; @@ -24,7 +24,8 @@ export class DropListElement extends InputElement implements PositionedUIElement if (element.copyOnDrop) this.copyOnDrop = element.copyOnDrop; if (element.orientation) this.orientation = element.orientation; if (element.highlightReceivingDropList) this.highlightReceivingDropList = element.highlightReceivingDropList; - if (element.highlightReceivingDropListColor) this.highlightReceivingDropListColor = element.highlightReceivingDropListColor; + if (element.highlightReceivingDropListColor) this.highlightReceivingDropListColor = + element.highlightReceivingDropListColor; this.position = ElementFactory.initPositionProps({ useMinHeight: true, ...element.position }); this.styling = { ...ElementFactory.initStylingProps({ diff --git a/projects/common/models/elements/input-elements/dropdown.ts b/projects/common/models/elements/input-elements/dropdown.ts index 2f25dedca..0a2029587 100644 --- a/projects/common/models/elements/input-elements/dropdown.ts +++ b/projects/common/models/elements/input-elements/dropdown.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { DropdownComponent } from 'common/components/input-elements/dropdown.component'; diff --git a/projects/common/models/elements/input-elements/radio-button-group-complex.ts b/projects/common/models/elements/input-elements/radio-button-group-complex.ts index b0bd11853..18a5c1be4 100644 --- a/projects/common/models/elements/input-elements/radio-button-group-complex.ts +++ b/projects/common/models/elements/input-elements/radio-button-group-complex.ts @@ -1,3 +1,4 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, @@ -6,7 +7,6 @@ import { PositionProperties, TextImageLabel } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { RadioGroupImagesComponent } from 'common/components/input-elements/radio-group-images.component'; diff --git a/projects/common/models/elements/input-elements/radio-button-group.ts b/projects/common/models/elements/input-elements/radio-button-group.ts index 1549dec75..b6f4403c7 100644 --- a/projects/common/models/elements/input-elements/radio-button-group.ts +++ b/projects/common/models/elements/input-elements/radio-button-group.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { RadioButtonGroupComponent } from 'common/components/input-elements/radio-button-group.component'; diff --git a/projects/common/models/elements/input-elements/slider.ts b/projects/common/models/elements/input-elements/slider.ts index f71a9cfb1..fdd6c6556 100644 --- a/projects/common/models/elements/input-elements/slider.ts +++ b/projects/common/models/elements/input-elements/slider.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { SliderComponent } from 'common/components/input-elements/slider.component'; diff --git a/projects/common/models/elements/input-elements/spell-correct.ts b/projects/common/models/elements/input-elements/spell-correct.ts index bbaa278a7..678561493 100644 --- a/projects/common/models/elements/input-elements/spell-correct.ts +++ b/projects/common/models/elements/input-elements/spell-correct.ts @@ -1,3 +1,4 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, @@ -6,7 +7,6 @@ import { PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { SpellCorrectComponent } from 'common/components/input-elements/spell-correct.component'; diff --git a/projects/common/models/elements/input-elements/text-area.ts b/projects/common/models/elements/input-elements/text-area.ts index df2645318..ef6eb0d97 100644 --- a/projects/common/models/elements/input-elements/text-area.ts +++ b/projects/common/models/elements/input-elements/text-area.ts @@ -1,3 +1,4 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, @@ -6,7 +7,6 @@ import { PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { TextAreaComponent } from 'common/components/input-elements/text-area.component'; diff --git a/projects/common/models/elements/input-elements/text-field.ts b/projects/common/models/elements/input-elements/text-field.ts index aec57c7dd..584ee9980 100644 --- a/projects/common/models/elements/input-elements/text-field.ts +++ b/projects/common/models/elements/input-elements/text-field.ts @@ -1,9 +1,9 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, InputAssistancePreset, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { TextFieldComponent } from 'common/components/input-elements/text-field.component'; diff --git a/projects/common/models/elements/media-elements/audio.ts b/projects/common/models/elements/media-elements/audio.ts index ca2c2712d..388ac28b0 100644 --- a/projects/common/models/elements/media-elements/audio.ts +++ b/projects/common/models/elements/media-elements/audio.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { PlayerElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { AudioComponent } from 'common/components/media-elements/audio.component'; diff --git a/projects/common/models/elements/media-elements/image.ts b/projects/common/models/elements/media-elements/image.ts index 4ce17a75b..f189af3e1 100644 --- a/projects/common/models/elements/media-elements/image.ts +++ b/projects/common/models/elements/media-elements/image.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { PositionedUIElement, PositionProperties, UIElement } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { ImageComponent } from 'common/components/media-elements/image.component'; diff --git a/projects/common/models/elements/media-elements/video.ts b/projects/common/models/elements/media-elements/video.ts index 99e285f58..89ff862e1 100644 --- a/projects/common/models/elements/media-elements/video.ts +++ b/projects/common/models/elements/media-elements/video.ts @@ -1,6 +1,6 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { PlayerElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { VideoComponent } from 'common/components/media-elements/video.component'; diff --git a/projects/common/models/elements/text/text.ts b/projects/common/models/elements/text/text.ts index 8186aedd7..7474633bb 100644 --- a/projects/common/models/elements/text/text.ts +++ b/projects/common/models/elements/text/text.ts @@ -1,11 +1,9 @@ +import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { - BasicStyles, - PositionedUIElement, - PositionProperties, - UIElement + BasicStyles, PositionedUIElement, + PositionProperties, UIElement } from 'common/models/elements/element'; -import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { TextComponent } from 'common/components/text/text.component'; diff --git a/projects/common/models/section.ts b/projects/common/models/section.ts index 3fbd1d2fd..8e5c76918 100644 --- a/projects/common/models/section.ts +++ b/projects/common/models/section.ts @@ -1,4 +1,6 @@ -import { PositionedUIElement, UIElement } from 'common/models/elements/element'; +import { Type } from '@angular/core'; +import { IDManager } from 'common/util/id-manager'; +import { PositionedUIElement, UIElement, UIElementValue } from 'common/models/elements/element'; import { ButtonElement } from 'common/models/elements/button/button'; import { TextElement } from 'common/models/elements/text/text'; import { TextFieldElement } from 'common/models/elements/input-elements/text-field'; @@ -23,7 +25,6 @@ import { SliderElement } from 'common/models/elements/input-elements/slider'; import { SpellCorrectElement } from 'common/models/elements/input-elements/spell-correct'; import { FrameElement } from 'common/models/elements/frame/frame'; import { ToggleButtonElement } from 'common/models/elements/compound-elements/cloze/cloze-child-elements/toggle-button'; -import { IDManager } from 'common/util/id-manager'; export class Section { [index: string]: any; diff --git a/projects/common/util/unit-utils.ts b/projects/common/util/unit-utils.ts index b242c9c2e..c5989685a 100644 --- a/projects/common/util/unit-utils.ts +++ b/projects/common/util/unit-utils.ts @@ -1,6 +1,6 @@ import { UIElement, UIElementType } from 'common/models/elements/element'; -export abstract class UnitUtils { +export abstract class UnitUtils { // TODO delete this. replce by unit method static findUIElements(value: any | unknown[], type?: UIElementType): UIElement[] { const elements: UIElement[] = []; if (value && typeof value === 'object') { diff --git a/projects/editor/src/app/components/canvas/canvas.component.html b/projects/editor/src/app/components/canvas/canvas.component.html index d99ef49a9..8f130d24d 100644 --- a/projects/editor/src/app/components/canvas/canvas.component.html +++ b/projects/editor/src/app/components/canvas/canvas.component.html @@ -14,7 +14,7 @@ [allowDelete]="page.sections.length > 1" (moveSection)="unitService.moveSection(section, page, $event)" (duplicateSection)="unitService.duplicateSection(section, page, i)" - (selectElementComponent)="selectElementComponent($event)"> + (selectElementComponent)="selectElementOverlay($event)"> </aspect-section-menu> <aspect-section-static *ngIf="!section.dynamicPositioning" #sectionComponent diff --git a/projects/editor/src/app/components/canvas/canvas.component.ts b/projects/editor/src/app/components/canvas/canvas.component.ts index b7346e505..4fc948d6b 100644 --- a/projects/editor/src/app/components/canvas/canvas.component.ts +++ b/projects/editor/src/app/components/canvas/canvas.component.ts @@ -25,7 +25,7 @@ import { Section } from 'common/models/section'; export class CanvasComponent { @Input() page!: Page; @ViewChildren('sectionComponent') - childSectionComponents!: QueryList<SectionStaticComponent | SectionDynamicComponent>; + sectionComponents!: QueryList<SectionStaticComponent | SectionDynamicComponent>; constructor(public selectionService: SelectionService, public unitService: UnitService) { } @@ -75,8 +75,8 @@ export class CanvasComponent { this.selectionService.selectedPageSectionIndex = this.page.sections.length - 1; } - selectElementComponent(element: UIElement): void { - const elementComponent = this.getElementComponent(element); + selectElementOverlay(element: UIElement): void { + const elementComponent = this.getElementOverlay(element); if (elementComponent) { this.selectionService.selectElement({ elementComponent: elementComponent, multiSelect: false }); } else { @@ -84,8 +84,8 @@ export class CanvasComponent { } } - private getElementComponent(element: UIElement): CanvasElementOverlay | null { - for (const sectionComponent of this.childSectionComponents.toArray()) { + private getElementOverlay(element: UIElement): CanvasElementOverlay | null { + for (const sectionComponent of this.sectionComponents.toArray()) { for (const elementComponent of sectionComponent.childElementComponents.toArray()) { if (elementComponent.element.id === element.id) { return elementComponent; diff --git a/projects/editor/src/app/components/canvas/dynamic-section-helper-grid.component.ts b/projects/editor/src/app/components/canvas/dynamic-section-helper-grid.component.ts index 37d00cd23..f8c898252 100644 --- a/projects/editor/src/app/components/canvas/dynamic-section-helper-grid.component.ts +++ b/projects/editor/src/app/components/canvas/dynamic-section-helper-grid.component.ts @@ -17,7 +17,7 @@ import { Section } from 'common/models/section'; [style.grid-row-start]="y + 1" [style.grid-row-end]="y + 1" cdkDropList [cdkDropListData]="{ sectionIndex: sectionIndex, gridCoordinates: [x + 1, y + 1] }" - (cdkDropListDropped)="drop($any($event))" + (cdkDropListDropped)="drop($event)" id="list-{{sectionIndex}}-{{x+1}}-{{y+1}}" (dragover)="$event.preventDefault()" (drop)="newElementDropped( $event, x + 1, y + 1)"> @@ -97,7 +97,7 @@ export class DynamicSectionHelperGridComponent implements OnInit, OnChanges { this.rowCountArray = Array(Math.max(numberOfRows, 1)); } - drop(event: CdkDragDrop<{ sectionIndex: number; gridCoordinates?: number[]; }>): void { + drop(event: CdkDragDrop<{ sectionIndex: number; gridCoordinates: number[]; }>): void { const dragItemData: { dragType: string; element: UIElement; } = event.item.data; // Move element to other section - handled by parent (page-canvas). @@ -111,23 +111,23 @@ export class DynamicSectionHelperGridComponent implements OnInit, OnChanges { this.unitService.updateElementsPositionProperty( [event.item.data.element], 'gridColumn', - event.container.data.gridCoordinates![0] + event.container.data.gridCoordinates[0] ); this.unitService.updateElementsPositionProperty( [dragItemData.element], 'gridRow', - event.container.data.gridCoordinates![1] + event.container.data.gridCoordinates[1] ); } else if (event.item.data.dragType === 'resize') { this.unitService.updateElementsPositionProperty( [dragItemData.element], 'gridColumnEnd', - event.container.data.gridCoordinates![0] + 1 + event.container.data.gridCoordinates[0] + 1 ); this.unitService.updateElementsPositionProperty( [dragItemData.element], 'gridRowEnd', - event.container.data.gridCoordinates![1] + 1 + event.container.data.gridCoordinates[1] + 1 ); } else { throw new Error('Unknown drop event'); diff --git a/projects/editor/src/app/components/canvas/overlays/canvas-element-overlay.ts b/projects/editor/src/app/components/canvas/overlays/canvas-element-overlay.ts index 73ff5e32d..1388d7d08 100644 --- a/projects/editor/src/app/components/canvas/overlays/canvas-element-overlay.ts +++ b/projects/editor/src/app/components/canvas/overlays/canvas-element-overlay.ts @@ -10,7 +10,7 @@ import { SelectionService } from '../../../services/selection.service'; import { CompoundElementComponent } from 'common/directives/compound-element.directive'; import { ClozeComponent } from 'common/components/compound-elements/cloze/cloze.component'; import { CompoundChildOverlayComponent } from - 'common/components/compound-elements/cloze/compound-child-overlay.component'; + 'common/components/compound-elements/cloze/compound-child-overlay.component'; import { UIElement } from 'common/models/elements/element'; @Directive() @@ -70,7 +70,7 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy { } } - elementClicked(event: MouseEvent): void { + elementClicked(event: MouseEvent): void { //TODO method name if (!this.isSelected) { this.selectElement(event.shiftKey); } diff --git a/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/drop-list-properties.component.ts b/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/drop-list-properties.component.ts index 83360045f..dcf7b37f8 100644 --- a/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/drop-list-properties.component.ts +++ b/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/drop-list-properties.component.ts @@ -1,5 +1,5 @@ import { - Component, ElementRef, EventEmitter, Input, Output, ViewChild + Component, EventEmitter, Input, Output } from '@angular/core'; import { UnitService } from '../../../../services/unit.service'; import { SelectionService } from '../../../../services/selection.service'; -- GitLab