From 8a9a06a754737536c710c290adb746e99798b374 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Wed, 14 Jul 2021 13:06:59 +0200 Subject: [PATCH] Rename LabelElement to TextElement Since this does not label anything but instead is meant for (longer) texts. --- projects/common/app.module.ts | 6 +++--- projects/common/component-utils.ts | 9 +++++---- .../{label.component.ts => text.component.ts} | 4 ++-- projects/common/unit.ts | 4 ++-- .../page-view/properties/properties.component.html | 11 ++++++++++- .../ui-element-toolbox.component.html | 6 +++--- projects/editor/src/app/id.service.ts | 2 +- projects/editor/src/app/model/UnitFactory.ts | 10 +++++----- projects/editor/src/app/unit.service.ts | 4 ++-- 9 files changed, 33 insertions(+), 23 deletions(-) rename projects/common/element-components/{label.component.ts => text.component.ts} (87%) diff --git a/projects/common/app.module.ts b/projects/common/app.module.ts index 0542e286e..14b81ebc0 100644 --- a/projects/common/app.module.ts +++ b/projects/common/app.module.ts @@ -28,7 +28,7 @@ import { TextFieldComponent } from './element-components/text-field.component'; import { ImageComponent } from './element-components/image.component'; import { VideoComponent } from './element-components/video.component'; import { AudioComponent } from './element-components/audio.component'; -import { LabelComponent } from './element-components/label.component'; +import { TextComponent } from './element-components/text.component'; import { DropdownComponent } from './element-components/dropdown.component'; @NgModule({ @@ -44,7 +44,7 @@ import { DropdownComponent } from './element-components/dropdown.component'; ], declarations: [ ButtonComponent, - LabelComponent, + TextComponent, TextFieldComponent, ImageComponent, AudioComponent, @@ -74,7 +74,7 @@ import { DropdownComponent } from './element-components/dropdown.component'; MatDialogModule, MatFormFieldModule, ButtonComponent, - LabelComponent, + TextComponent, TextFieldComponent, ImageComponent, AudioComponent, diff --git a/projects/common/component-utils.ts b/projects/common/component-utils.ts index 930c5f76f..66ef178ba 100644 --- a/projects/common/component-utils.ts +++ b/projects/common/component-utils.ts @@ -1,6 +1,6 @@ import { ComponentFactory, ComponentFactoryResolver } from '@angular/core'; import { FormElementComponent } from './canvas-element-component.directive'; -import { LabelComponent } from './element-components/label.component'; +import { TextComponent } from './element-components/text.component'; import { ButtonComponent } from './element-components/button.component'; import { TextFieldComponent } from './element-components/text-field.component'; import { CheckboxComponent } from './element-components/checkbox.component'; @@ -13,10 +13,11 @@ import { CorrectionComponent } from './element-components/compound-components/co export function getComponentFactory( elementType: string, - componentFactoryResolver: ComponentFactoryResolver): ComponentFactory<FormElementComponent> { + componentFactoryResolver: ComponentFactoryResolver +): ComponentFactory<FormElementComponent> { switch (elementType) { - case 'label': - return componentFactoryResolver.resolveComponentFactory(LabelComponent); + case 'text': + return componentFactoryResolver.resolveComponentFactory(TextComponent); case 'button': return componentFactoryResolver.resolveComponentFactory(ButtonComponent); case 'text-field': diff --git a/projects/common/element-components/label.component.ts b/projects/common/element-components/text.component.ts similarity index 87% rename from projects/common/element-components/label.component.ts rename to projects/common/element-components/text.component.ts index dd75ac518..32317fd87 100644 --- a/projects/common/element-components/label.component.ts +++ b/projects/common/element-components/text.component.ts @@ -13,8 +13,8 @@ import { FormElementComponent } from '../canvas-element-component.directive'; [style.font-weight]="elementModel.bold ? 'bold' : ''" [style.font-style]="elementModel.italic ? 'italic' : ''" [style.text-decoration]="elementModel.underline ? 'underline' : ''"> - {{$any(elementModel).label}} + {{$any(elementModel).text}} </div> ` }) -export class LabelComponent extends FormElementComponent { } +export class TextComponent extends FormElementComponent { } diff --git a/projects/common/unit.ts b/projects/common/unit.ts index 5755b209a..4cab4f626 100644 --- a/projects/common/unit.ts +++ b/projects/common/unit.ts @@ -45,8 +45,8 @@ export interface CompoundElementCorrection extends UnitUIElement { sentences : string[]; } -export interface LabelElement extends TextUIElement, SurfaceUIElement { - label: string; +export interface TextElement extends TextUIElement, SurfaceUIElement { + text: string; } export interface ButtonElement extends TextUIElement, SurfaceUIElement { diff --git a/projects/editor/src/app/components/unit-view/page-view/properties/properties.component.html b/projects/editor/src/app/components/unit-view/page-view/properties/properties.component.html index 1aa3afb67..ffff96297 100644 --- a/projects/editor/src/app/components/unit-view/page-view/properties/properties.component.html +++ b/projects/editor/src/app/components/unit-view/page-view/properties/properties.component.html @@ -6,22 +6,27 @@ <mat-icon class="example-tab-icon">build</mat-icon> </ng-template> <div fxLayout="column"> + <mat-form-field *ngIf="combinedProperties.hasOwnProperty('id')"> <mat-label>ID</mat-label> <input matInput type="text" *ngIf="selectedElements.length === 1" [value]="combinedProperties.id" (input)="updateModel('id', $any($event.target).value, $event)"> <input matInput type="text" disabled *ngIf="selectedElements.length > 1" [value]="'Muss eindeutig sein'"> </mat-form-field> + <mat-form-field *ngIf="combinedProperties.hasOwnProperty('label')"> <mat-label>Label</mat-label> <input matInput type="text" [value]="combinedProperties.label" (input)="updateModel('label', $any($event.target).value)"> </mat-form-field> + <mat-form-field *ngIf="combinedProperties.hasOwnProperty('text')"> <mat-label>Text</mat-label> - <input matInput type="text" [value]="combinedProperties.text" + <textarea matInput type="text" cdkTextareaAutosize [value]="combinedProperties.text" (input)="updateModel('text', $any($event.target).value)"> + </textarea> </mat-form-field> + <mat-form-field disabled="true" *ngIf="combinedProperties.hasOwnProperty('options')"> <div *ngIf="combinedProperties.options !== undefined"> <mat-label>Optionen</mat-label> @@ -38,6 +43,7 @@ <input #newOption matInput type="text" placeholder="Optionstext"> </div> </mat-form-field> + <mat-form-field *ngIf="combinedProperties.hasOwnProperty('alignment')"> <mat-label>Ausrichtung</mat-label> <mat-select [value]="combinedProperties.alignment" @@ -47,11 +53,13 @@ </mat-option> </mat-select> </mat-form-field> + <mat-checkbox *ngIf="combinedProperties.hasOwnProperty('multiline')" [checked]="$any(combinedProperties.multiline)" (change)="updateModel('multiline', $event.checked)"> Mehrzeilig </mat-checkbox> + <mat-form-field disabled="true" *ngIf="combinedProperties.hasOwnProperty('sentences')"> <div *ngIf="combinedProperties.sentences !== undefined"> <mat-label>Sätze</mat-label> @@ -68,6 +76,7 @@ <input #newOption matInput type="text" placeholder="Optionstext"> </div> </mat-form-field> + </div> <button class="delete-element-button" mat-raised-button (click)="deleteElement()"> Element löschen diff --git a/projects/editor/src/app/components/unit-view/page-view/ui-element-toolbox/ui-element-toolbox.component.html b/projects/editor/src/app/components/unit-view/page-view/ui-element-toolbox/ui-element-toolbox.component.html index 3f3675391..79f516893 100644 --- a/projects/editor/src/app/components/unit-view/page-view/ui-element-toolbox/ui-element-toolbox.component.html +++ b/projects/editor/src/app/components/unit-view/page-view/ui-element-toolbox/ui-element-toolbox.component.html @@ -4,9 +4,9 @@ <mat-icon class="example-tab-icon">highlight_alt</mat-icon> </ng-template> <div fxLayout="column"> - <button mat-raised-button (click)="addUIElement('label')"> - <mat-icon>label</mat-icon> - Label + <button mat-raised-button (click)="addUIElement('text')"> + <mat-icon>text_snippet</mat-icon> + Text </button> <button mat-raised-button (click)="addUIElement('button')"> <mat-icon>smart_button</mat-icon> diff --git a/projects/editor/src/app/id.service.ts b/projects/editor/src/app/id.service.ts index da521b21d..58c63e365 100644 --- a/projects/editor/src/app/id.service.ts +++ b/projects/editor/src/app/id.service.ts @@ -9,7 +9,7 @@ import { export class IdService { private givenIDs: string[] = []; private idCounter: Record<string, number> = { - label: 0, + text: 0, button: 0, 'text-field': 0, checkbox: 0, diff --git a/projects/editor/src/app/model/UnitFactory.ts b/projects/editor/src/app/model/UnitFactory.ts index a3ddcb2b5..045b05b16 100644 --- a/projects/editor/src/app/model/UnitFactory.ts +++ b/projects/editor/src/app/model/UnitFactory.ts @@ -1,7 +1,7 @@ import { AudioElement, ButtonElement, CheckboxElement, CompoundElementCorrection, DropdownElement, - ImageElement, LabelElement, RadioButtonGroupElement, SurfaceUIElement, + ImageElement, TextElement, RadioButtonGroupElement, SurfaceUIElement, TextFieldElement, TextUIElement, Unit, UnitPage, UnitPageSection, UnitUIElement, VideoElement } from '../../../../common/unit'; @@ -61,11 +61,11 @@ export function createSurfaceUIElement(type: string): SurfaceUIElement { }; } -export function createLabelElement(): LabelElement { +export function createTextElement(): TextElement { return { - label: 'Label Text', - ...createTextUIElement('label'), - ...createSurfaceUIElement('label') + text: 'Example Text', + ...createTextUIElement('text'), + ...createSurfaceUIElement('text') }; } diff --git a/projects/editor/src/app/unit.service.ts b/projects/editor/src/app/unit.service.ts index df43460c9..106946806 100644 --- a/projects/editor/src/app/unit.service.ts +++ b/projects/editor/src/app/unit.service.ts @@ -110,8 +110,8 @@ export class UnitService { async addPageElement(elementType: string): Promise<void> { let newElement: UnitUIElement; switch (elementType) { - case 'label': - newElement = UnitFactory.createLabelElement(); + case 'text': + newElement = UnitFactory.createTextElement(); break; case 'button': newElement = UnitFactory.createButtonElement(); -- GitLab