From 15a2e2e6721c6516d3c5e2a99a3aabf41546eaec Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Wed, 10 Aug 2022 13:16:43 +0200 Subject: [PATCH] Improve code style --- ...edia-player-element-component.directive.ts | 2 +- .../common/models/elements/button/button.ts | 4 ++- .../cloze-child-elements/drop-list-simple.ts | 11 ++++++-- .../compound-elements/likert/likert.ts | 4 +-- .../common/models/elements/frame/frame.ts | 6 ++-- .../elements/input-elements/checkbox.ts | 4 ++- .../elements/input-elements/drop-list.ts | 5 ++-- .../elements/input-elements/dropdown.ts | 2 +- .../models/elements/input-elements/slider.ts | 4 ++- projects/common/models/section.ts | 28 ++++++++++--------- projects/editor/src/app/app.module.ts | 13 +++++---- 11 files changed, 51 insertions(+), 32 deletions(-) diff --git a/projects/common/directives/media-player-element-component.directive.ts b/projects/common/directives/media-player-element-component.directive.ts index de525feb4..812567cda 100644 --- a/projects/common/directives/media-player-element-component.directive.ts +++ b/projects/common/directives/media-player-element-component.directive.ts @@ -3,10 +3,10 @@ import { } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import { ElementComponent } from './element-component.directive'; import { AudioElement } from 'common/models/elements/media-elements/audio'; import { VideoElement } from 'common/models/elements/media-elements/video'; import { ValueChangeElement } from 'common/models/elements/element'; +import { ElementComponent } from './element-component.directive'; @Directive() export abstract class MediaPlayerElementComponent extends ElementComponent implements OnInit, OnDestroy { diff --git a/projects/common/models/elements/button/button.ts b/projects/common/models/elements/button/button.ts index 02de40b0b..4b44a4cc2 100644 --- a/projects/common/models/elements/button/button.ts +++ b/projects/common/models/elements/button/button.ts @@ -1,6 +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 { + BasicStyles, PositionedUIElement, PositionProperties, UIElement +} from 'common/models/elements/element'; import { ButtonComponent } from 'common/components/button/button.component'; import { ElementComponent } from 'common/directives/element-component.directive'; diff --git a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts index 6ea1db893..7a86b022f 100644 --- a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts +++ b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts @@ -1,5 +1,7 @@ import { ElementFactory } from 'common/util/element.factory'; -import { BasicStyles, DragNDropValueObject, InputElement, UIElementValue } from 'common/models/elements/element'; +import { + BasicStyles, DragNDropValueObject, InputElement, UIElementValue +} from 'common/models/elements/element'; import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { @@ -25,12 +27,15 @@ export class DropListSimpleElement extends InputElement { if (element.connectedTo) this.connectedTo = element.connectedTo; if (element.copyOnDrop) this.copyOnDrop = element.copyOnDrop; if (element.highlightReceivingDropList) this.highlightReceivingDropList = element.highlightReceivingDropList; - if (element.highlightReceivingDropListColor) this.highlightReceivingDropListColor = element.highlightReceivingDropListColor; + if (element.highlightReceivingDropListColor) { + this.highlightReceivingDropListColor = element.highlightReceivingDropListColor; + } this.styling = { ...ElementFactory.initStylingProps({ backgroundColor: '#f4f4f2', itemBackgroundColor: '#c9e0e0', - ...element.styling }) + ...element.styling + }) }; } diff --git a/projects/common/models/elements/compound-elements/likert/likert.ts b/projects/common/models/elements/compound-elements/likert/likert.ts index 47bf26e20..13054281a 100644 --- a/projects/common/models/elements/compound-elements/likert/likert.ts +++ b/projects/common/models/elements/compound-elements/likert/likert.ts @@ -2,7 +2,7 @@ import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, CompoundElement, UIElement, - PositionedUIElement, PositionProperties, UIElementValue, TextImageLabel, OptionElement, Label + PositionedUIElement, PositionProperties, UIElementValue, TextImageLabel, OptionElement } from 'common/models/elements/element'; import { LikertRowElement } from 'common/models/elements/compound-elements/likert/likert-row'; import { ElementComponent } from 'common/directives/element-component.directive'; @@ -20,7 +20,7 @@ export class LikertElement extends CompoundElement implements PositionedUIElemen }; constructor(element: Partial<LikertElement>, ...args: unknown[]) { - super({width: 250, height: 200, ...element}, ...args); + super({ width: 250, height: 200, ...element }, ...args); if (element.options) this.options = [...element.options]; if (element.firstColumnSizeRatio) this.firstColumnSizeRatio = element.firstColumnSizeRatio; this.rows = element.rows !== undefined ? element.rows?.map(row => new LikertRowElement(row, ...args)) : []; diff --git a/projects/common/models/elements/frame/frame.ts b/projects/common/models/elements/frame/frame.ts index 50bfc3a56..14b1ccc76 100644 --- a/projects/common/models/elements/frame/frame.ts +++ b/projects/common/models/elements/frame/frame.ts @@ -1,6 +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 { + 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'; @@ -22,7 +24,7 @@ export class FrameElement extends UIElement implements PositionedUIElement { borderWidth: 1, borderColor: 'black', borderStyle: 'solid', - borderRadius: 0, + borderRadius: 0, ...element.styling }) }; diff --git a/projects/common/models/elements/input-elements/checkbox.ts b/projects/common/models/elements/input-elements/checkbox.ts index 382b8793c..1d9dc42a9 100644 --- a/projects/common/models/elements/input-elements/checkbox.ts +++ b/projects/common/models/elements/input-elements/checkbox.ts @@ -1,6 +1,8 @@ import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; -import { BasicStyles, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; +import { + BasicStyles, InputElement, PositionedUIElement, PositionProperties +} from 'common/models/elements/element'; 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 900c6089d..bb54bf92c 100644 --- a/projects/common/models/elements/input-elements/drop-list.ts +++ b/projects/common/models/elements/input-elements/drop-list.ts @@ -33,8 +33,9 @@ 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 ccf32e0b6..90e4c8f04 100644 --- a/projects/common/models/elements/input-elements/dropdown.ts +++ b/projects/common/models/elements/input-elements/dropdown.ts @@ -1,7 +1,7 @@ import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; import { - BasicStyles, InputElement, TextLabel, PositionedUIElement, PositionProperties, OptionElement, Label + BasicStyles, InputElement, TextLabel, PositionedUIElement, PositionProperties, OptionElement } from 'common/models/elements/element'; 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/slider.ts b/projects/common/models/elements/input-elements/slider.ts index 61b067a78..18204b2b8 100644 --- a/projects/common/models/elements/input-elements/slider.ts +++ b/projects/common/models/elements/input-elements/slider.ts @@ -1,6 +1,8 @@ import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; -import { BasicStyles, InputElement, PositionedUIElement, PositionProperties } from 'common/models/elements/element'; +import { + BasicStyles, InputElement, PositionedUIElement, PositionProperties +} from 'common/models/elements/element'; import { ElementComponent } from 'common/directives/element-component.directive'; import { SliderComponent } from 'common/components/input-elements/slider.component'; diff --git a/projects/common/models/section.ts b/projects/common/models/section.ts index 152367a05..2ae465ae3 100644 --- a/projects/common/models/section.ts +++ b/projects/common/models/section.ts @@ -1,6 +1,8 @@ import { Type } from '@angular/core'; import { IDManager } from 'common/util/id-manager'; -import { PositionedUIElement, UIElement, UIElementValue } from 'common/models/elements/element'; +import { + CompoundElement, 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'; @@ -39,25 +41,25 @@ export class Section { activeAfterID: string | null = null; static ELEMENT_CLASSES: Record<string, Type<UIElement>> = { - 'text': TextElement, - 'button': ButtonElement, + text: TextElement, + button: ButtonElement, 'text-field': TextFieldElement, 'text-field-simple': TextFieldSimpleElement, 'text-area': TextAreaElement, - 'checkbox': CheckboxElement, - 'dropdown': DropdownElement, - 'radio': RadioButtonGroupElement, - 'image': ImageElement, - 'audio': AudioElement, - 'video': VideoElement, - 'likert': LikertElement, + checkbox: CheckboxElement, + dropdown: DropdownElement, + radio: RadioButtonGroupElement, + image: ImageElement, + audio: AudioElement, + video: VideoElement, + likert: LikertElement, 'radio-group-images': RadioButtonGroupComplexElement, 'drop-list': DropListElement, 'drop-list-simple': DropListSimpleElement, - 'cloze': ClozeElement, - 'slider': SliderElement, + cloze: ClozeElement, + slider: SliderElement, 'spell-correct': SpellCorrectElement, - 'frame': FrameElement, + frame: FrameElement, 'toggle-button': ToggleButtonElement }; diff --git a/projects/editor/src/app/app.module.ts b/projects/editor/src/app/app.module.ts index 1d9127584..9fdc90764 100644 --- a/projects/editor/src/app/app.module.ts +++ b/projects/editor/src/app/app.module.ts @@ -70,16 +70,19 @@ import { ButtonPropertiesComponent } from import { SliderPropertiesComponent } from './components/properties-panel/model-properties-tab/input-groups/slider-properties.component'; import { TextFieldElementPropertiesComponent } from - './components/properties-panel/model-properties-tab/input-groups/text-field-element-properties.component'; + './components/properties-panel/model-properties-tab/input-groups/text-field-element-properties.component'; import { ScaleAndZoomPropertiesComponent } from - './components/properties-panel/model-properties-tab/input-groups/scale-and-zoom-properties.component'; + './components/properties-panel/model-properties-tab/input-groups/scale-and-zoom-properties.component'; import { DropListPropertiesComponent } from './components/properties-panel/model-properties-tab/input-groups/drop-list-properties.component'; import { RichTextEditorSimpleComponent } from './text-editor-simple/rich-text-editor-simple.component'; import { RichTextSimpleEditDialogComponent } from './components/dialogs/rich-text-simple-edit-dialog.component'; -import { SelectPropertiesComponent } from './components/properties-panel/model-properties-tab/input-groups/select-properties.component'; -import { InputElementPropertiesComponent } from './components/properties-panel/model-properties-tab/input-groups/input-element-properties.component'; -import { PresetValuePropertiesComponent } from './components/properties-panel/model-properties-tab/input-groups/preset-value-properties.component'; +import { SelectPropertiesComponent } from + './components/properties-panel/model-properties-tab/input-groups/select-properties.component'; +import { InputElementPropertiesComponent } from + './components/properties-panel/model-properties-tab/input-groups/input-element-properties.component'; +import { PresetValuePropertiesComponent } from + './components/properties-panel/model-properties-tab/input-groups/preset-value-properties.component'; import { OptionListPanelComponent } from './components/properties-panel/option-list-panel.component'; import { LikertRowLabelPipe } from './components/properties-panel/likert-row-label.pipe'; import { LabelEditDialogComponent } from './components/dialogs/label-edit-dialog.component'; -- GitLab