diff --git a/projects/common/form-element-component.directive.ts b/projects/common/form-element-component.directive.ts index d6581bd7bc43db04ea3666cf2c26bac9fba96a9f..8f20b02bc8cfb1d267ad6e5e5d59e514046e13e2 100644 --- a/projects/common/form-element-component.directive.ts +++ b/projects/common/form-element-component.directive.ts @@ -9,7 +9,7 @@ import { pairwise, startWith, takeUntil } from 'rxjs/operators'; import { FormService } from './form.service'; import { ValueChangeElement } from './form'; import { ElementComponent } from './element-component.directive'; -import { InputUIElement } from './unit'; +import { InputElement } from './classes/uIElement'; @Directive() export abstract class FormElementComponent extends ElementComponent implements OnInit, OnDestroy { @@ -27,11 +27,11 @@ export abstract class FormElementComponent extends ElementComponent implements O ngOnInit(): void { this.formService.registerFormControl({ id: this.elementModel.id, - formControl: new FormControl(this.elementModel.value), + formControl: new FormControl((this.elementModel as InputElement).value), formGroup: this.parentForm }); this.elementFormControl = this.formControl; - this.updateFormValue((this.elementModel as InputUIElement).value); + this.updateFormValue((this.elementModel as InputElement).value); this.formService.setValidators({ id: this.elementModel.id, validators: this.validators, @@ -39,7 +39,7 @@ export abstract class FormElementComponent extends ElementComponent implements O }); this.elementFormControl.valueChanges .pipe( - startWith(this.elementModel.value), + startWith((this.elementModel as InputElement).value), pairwise(), takeUntil(this.ngUnsubscribe) ) @@ -52,7 +52,7 @@ export abstract class FormElementComponent extends ElementComponent implements O get validators(): ValidatorFn[] { const validators: ValidatorFn[] = []; - if (this.elementModel.required) { + if ((this.elementModel as InputElement).required) { validators.push(Validators.required); } return validators; diff --git a/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts b/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts index cdd435c116899c79de770992d49eaa919dfc5131..a925bb8ad667bc7ac88ea0934bb96bc62af44dfe 100644 --- a/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts +++ b/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts @@ -7,16 +7,16 @@ import { import { Subject } from 'rxjs'; import { take, takeUntil } from 'rxjs/operators'; import { UnitService } from '../../../../unit.service'; -import { UnitUIElement } from '../../../../../../../common/unit'; import * as ComponentUtils from '../../../../../../../common/component-utils'; import { FormElementComponent } from '../../../../../../../common/form-element-component.directive'; import { ValueChangeElement } from '../../../../../../../common/form'; import { ElementComponent } from '../../../../../../../common/element-component.directive'; import { SelectionService } from '../../../../selection.service'; +import { InputElement, UIElement } from '../../../../../../../common/classes/uIElement'; @Directive() export abstract class CanvasElementOverlay implements OnInit, OnDestroy { - @Input() element!: UnitUIElement; + @Input() element!: UIElement; @Input() viewMode: boolean = false; @ViewChild('elementContainer', { read: ViewContainerRef, static: true }) private elementContainer!: ViewContainerRef; isSelected = false; @@ -46,7 +46,7 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy { .pipe(takeUntil(this.ngUnsubscribe)) .subscribe(() => { (this.childComponent.instance as FormElementComponent).updateFormValue( - this.element.value as string | number | boolean | undefined + (this.element as InputElement).value as string | number | boolean | undefined ); }); } @@ -59,7 +59,7 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy { event.key === 'Delete') { this.selectionService.selectedElements .pipe(take(1)) - .subscribe((selectedElements: UnitUIElement[]) => { + .subscribe((selectedElements: UIElement[]) => { this.unitService.deleteElementsFromSectionByIndex( selectedElements, this.selectionService.selectedPageIndex, diff --git a/projects/editor/src/app/components/unit-view/page-view/canvas/dynamic-canvas-overlay.component.ts b/projects/editor/src/app/components/unit-view/page-view/canvas/dynamic-canvas-overlay.component.ts index 7458064d221c76fee1f7acf131faece101d87cd8..c61e9c90055d2effeb15c0ba2e44246ec103ecf5 100644 --- a/projects/editor/src/app/components/unit-view/page-view/canvas/dynamic-canvas-overlay.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/canvas/dynamic-canvas-overlay.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { CdkDragMove } from '@angular/cdk/drag-drop'; import { CanvasElementOverlay } from './canvas-element-overlay'; -import { UnitUIElement } from '../../../../../../../common/unit'; +import { UIElement } from '../../../../../../../common/classes/uIElement'; @Component({ selector: 'app-dynamic-canvas-overlay', @@ -49,7 +49,7 @@ export class DynamicCanvasOverlayComponent extends CanvasElementOverlay { }); } - resizeElement(event: CdkDragMove<{ dragType: string; element: UnitUIElement }>): void { + resizeElement(event: CdkDragMove<{ dragType: string; element: UIElement }>): void { this.resize.emit({ dragging: true, elementWidth: this.gridElementWidth + event.distance.x, diff --git a/projects/editor/src/app/components/unit-view/page-view/canvas/page-canvas.component.ts b/projects/editor/src/app/components/unit-view/page-view/canvas/page-canvas.component.ts index 0b05c56f2f92d73665861d60db247e0a6a594c57..3aec4b106ab51d15b7df80db34ad525add259879 100644 --- a/projects/editor/src/app/components/unit-view/page-view/canvas/page-canvas.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/canvas/page-canvas.component.ts @@ -1,12 +1,14 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; +import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import { UnitPage, UnitPageSection, UnitUIElement } from '../../../../../../../common/unit'; import { UnitService } from '../../../../unit.service'; import { SelectionService } from '../../../../selection.service'; +import { Page } from '../../../../../../../common/classes/page'; +import { UIElement } from '../../../../../../../common/classes/uIElement'; +import { Section } from '../../../../../../../common/classes/section'; @Component({ selector: 'app-page-canvas', @@ -21,7 +23,7 @@ import { SelectionService } from '../../../../selection.service'; ] }) export class PageCanvasComponent implements OnInit, OnDestroy { - @Input() page!: UnitPage; + @Input() page!: Page; dropListList: string[] = []; hoveredSection: number = -1; private ngUnsubscribe = new Subject<void>(); @@ -52,7 +54,7 @@ export class PageCanvasComponent implements OnInit, OnDestroy { */ generateDropListList(): void { this.dropListList = []; - this.page.sections.forEach((section: UnitPageSection, index: number) => { + this.page.sections.forEach((section: Section, index: number) => { if (!section.dynamicPositioning) { this.dropListList.push(`section-${index}`); } else { @@ -65,13 +67,14 @@ export class PageCanvasComponent implements OnInit, OnDestroy { }); } - moveElementsBetweenSections(elements: UnitUIElement[], previousSectionIndex: number, newSectionIndex: number): void { + moveElementsBetweenSections(elements: UIElement[], previousSectionIndex: number, newSectionIndex: number): void { this.unitService.transferElement(elements, this.page.sections[previousSectionIndex], this.page.sections[newSectionIndex]); } elementDropped(event: CdkDragDrop<DropListData>): void { + console.log('elementDropped'); const selectedElements = this.selectionService.getSelectedElements(); if (event.previousContainer !== event.container) { @@ -79,7 +82,7 @@ export class PageCanvasComponent implements OnInit, OnDestroy { event.previousContainer.data.sectionIndex, event.container.data.sectionIndex); } else { - selectedElements.forEach((element: UnitUIElement) => { + selectedElements.forEach((element: UIElement) => { let newXPosition = element.xPosition + event.distance.x; if (newXPosition < 0) { newXPosition = 0; @@ -102,7 +105,7 @@ export class PageCanvasComponent implements OnInit, OnDestroy { } getPageHeight(): number { // TODO weg - const reduceFct = (accumulator: number, currentValue: UnitPageSection) => accumulator + currentValue.height; + const reduceFct = (accumulator: number, currentValue: Section) => accumulator + currentValue.height; return this.page.sections.reduce(reduceFct, 0); } @@ -124,7 +127,7 @@ export class PageCanvasComponent implements OnInit, OnDestroy { export interface DragItemData { dragType: string; - element: UnitUIElement; + element: UIElement; } export interface DropListData { diff --git a/projects/editor/src/app/components/unit-view/page-view/canvas/section-dynamic.component.ts b/projects/editor/src/app/components/unit-view/page-view/canvas/section-dynamic.component.ts index db66842a7b5296f7fb050146244603a19964feee..4b289e1d63160a860f81bce3b0efdbb8c33d8c9f 100644 --- a/projects/editor/src/app/components/unit-view/page-view/canvas/section-dynamic.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/canvas/section-dynamic.component.ts @@ -3,8 +3,8 @@ import { } from '@angular/core'; import { CdkDragDrop } from '@angular/cdk/drag-drop/drag-events'; import { DragItemData, DropListData } from './page-canvas.component'; -import { UnitPageSection } from '../../../../../../../common/unit'; import { UnitService } from '../../../../unit.service'; +import { Section } from '../../../../../../../common/classes/section'; @Component({ selector: 'app-section-dynamic', @@ -64,7 +64,7 @@ import { UnitService } from '../../../../unit.service'; ] }) export class SectionDynamicComponent { - @Input() section!: UnitPageSection; + @Input() section!: Section; @Input() sectionIndex!: number; @Input() dropListList!: string[]; @Input() isSelected!: boolean; diff --git a/projects/editor/src/app/components/unit-view/page-view/canvas/section-menu.component.ts b/projects/editor/src/app/components/unit-view/page-view/canvas/section-menu.component.ts index 3f730746b97cbb1066d957a499fb0ea308c5562c..a3dfb3497d45fa5c4283177b4df79304cca411a9 100644 --- a/projects/editor/src/app/components/unit-view/page-view/canvas/section-menu.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/canvas/section-menu.component.ts @@ -4,10 +4,10 @@ import { } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import { UnitPageSection } from '../../../../../../../common/unit'; import { UnitService } from '../../../../unit.service'; import { DialogService } from '../../../../dialog.service'; import { SelectionService } from '../../../../selection.service'; +import { Section } from '../../../../../../../common/classes/section'; @Component({ selector: 'app-section-menu', @@ -120,7 +120,7 @@ import { SelectionService } from '../../../../selection.service'; ] }) export class SectionMenuComponent implements OnInit, OnDestroy { - @Input() section!: UnitPageSection; + @Input() section!: Section; @Input() sectionIndex!: number; @Input() allowMoveUp!: boolean; @Input() allowMoveDown!: boolean; diff --git a/projects/editor/src/app/components/unit-view/page-view/canvas/section-static.component.ts b/projects/editor/src/app/components/unit-view/page-view/canvas/section-static.component.ts index 7c1218459e365911d2186881123dc56534f6562d..5c2d2bf9bba774d115adeea3d66058d75c879a77 100644 --- a/projects/editor/src/app/components/unit-view/page-view/canvas/section-static.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/canvas/section-static.component.ts @@ -1,8 +1,8 @@ import { Component, ElementRef, Input, ViewChild } from '@angular/core'; -import { UnitPageSection } from '../../../../../../../common/unit'; import { UnitService } from '../../../../unit.service'; +import { Section } from '../../../../../../../common/classes/section'; @Component({ selector: 'app-section-static', @@ -23,7 +23,7 @@ import { UnitService } from '../../../../unit.service'; ] }) export class SectionStaticComponent { - @Input() section!: UnitPageSection; + @Input() section!: Section; @Input() isSelected!: boolean; @ViewChild('sectionElement') sectionElement!: ElementRef; diff --git a/projects/editor/src/app/components/unit-view/page-view/page-view.component.ts b/projects/editor/src/app/components/unit-view/page-view/page-view.component.ts index ecf2c1a52a165152af24c1e099fc6d2e3828304b..06487976e7d4c3eb25ea0347052f63c2d571e480 100644 --- a/projects/editor/src/app/components/unit-view/page-view/page-view.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/page-view.component.ts @@ -1,7 +1,7 @@ import { Component, Input } from '@angular/core'; -import { UnitPage } from '../../../../../../common/unit'; +import { Page } from '../../../../../../common/classes/page'; @Component({ selector: 'app-page-view', @@ -13,5 +13,5 @@ import { UnitPage } from '../../../../../../common/unit'; ] }) export class PageViewComponent { - @Input() page!: UnitPage; + @Input() page!: Page; } diff --git a/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts b/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts index f1f43c1bf0c6fe7e890b519db446f98320478e24..9d737cda9d9a14d379dc9752841445451047953c 100644 --- a/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts @@ -18,7 +18,7 @@ import { FileService } from '../../../../../../../common/file.service'; styleUrls: ['./element-properties.component.css'] }) export class ElementPropertiesComponent implements OnInit, OnDestroy { - selectedElements!: UnitUIElement[]; + selectedElements!: UIElement[]; combinedProperties: Record<string, string | number | boolean | string[] | undefined> = {}; private ngUnsubscribe = new Subject<void>(); @@ -37,7 +37,7 @@ export class ElementPropertiesComponent implements OnInit, OnDestroy { this.selectionService.selectedElements .pipe(takeUntil(this.ngUnsubscribe)) .subscribe( - (selectedElements: UnitUIElement[]) => { + (selectedElements: UIElement[]) => { this.selectedElements = selectedElements; this.createCombinedProperties(); } diff --git a/projects/editor/src/app/components/unit-view/unit-view.component.ts b/projects/editor/src/app/components/unit-view/unit-view.component.ts index e34e8bf74b3ffd5fa03265fdf9ced5f29020ff52..ee996937fc1cdced68b024c8edf1dc3d842d73c9 100644 --- a/projects/editor/src/app/components/unit-view/unit-view.component.ts +++ b/projects/editor/src/app/components/unit-view/unit-view.component.ts @@ -4,8 +4,9 @@ import { takeUntil } from 'rxjs/operators'; import { UnitService } from '../../unit.service'; import { DialogService } from '../../dialog.service'; import { SelectionService } from '../../selection.service'; -import { Unit, UnitPage } from '../../../../../common/unit'; import { MessageService } from '../../../../../common/message.service'; +import { Page } from '../../../../../common/classes/page'; +import { Unit } from '../../../../../common/classes/unit'; @Component({ selector: 'app-unit-view', @@ -68,11 +69,11 @@ export class UnitViewComponent implements OnInit, OnDestroy { this.selectionService.selectedPageSectionIndex = 0; } - movePage(page: UnitPage, direction: 'up' | 'down'): void { + movePage(page: Page, direction: 'up' | 'down'): void { this.unitService.movePage(page, direction); } - deletePage(page: UnitPage): void { + deletePage(page: Page): void { this.dialogService.showConfirmDialog('Seite löschen?') .pipe(takeUntil(this.ngUnsubscribe)) .subscribe((result: boolean) => { @@ -85,7 +86,7 @@ export class UnitViewComponent implements OnInit, OnDestroy { this.selectionService.selectedPageSectionIndex = 0; } - updateModel(page: UnitPage, property: string, value: number | boolean, isInputValid: boolean | null = true): void { + updateModel(page: Page, property: string, value: number | boolean, isInputValid: boolean | null = true): void { if (isInputValid && value != null) { this.unitService.updatePageProperty(page, property, value); if (property === 'alwaysVisible') { diff --git a/projects/editor/src/app/selection.service.ts b/projects/editor/src/app/selection.service.ts index 2d476a84168771c2e0f53b8ae54a59669933c3f3..ebcdee736abcb8ae83fe66e4d1401ad150ffc6cd 100644 --- a/projects/editor/src/app/selection.service.ts +++ b/projects/editor/src/app/selection.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; -import { UnitUIElement } from '../../../common/unit'; +import { UIElement } from '../../../common/classes/uIElement'; @Injectable({ providedIn: 'root' @@ -8,18 +8,18 @@ import { UnitUIElement } from '../../../common/unit'; export class SelectionService { selectedPageIndex: number = 0; selectedPageSectionIndex: number = 0; - private _selectedElements!: BehaviorSubject<UnitUIElement[]>; + private _selectedElements!: BehaviorSubject<UIElement[]>; selectedElementComponents: any[] = []; constructor() { - this._selectedElements = new BehaviorSubject([] as UnitUIElement[]); + this._selectedElements = new BehaviorSubject([] as UIElement[]); } - get selectedElements(): Observable<UnitUIElement[]> { + get selectedElements(): Observable<UIElement[]> { return this._selectedElements.asObservable(); } - getSelectedElements(): UnitUIElement[] { + getSelectedElements(): UIElement[] { return this._selectedElements.value; }