Skip to content
Snippets Groups Projects
Commit f87cd5eb authored by rhenck's avatar rhenck
Browse files

[editor] Code cleanup

Use proper types and remove unused vars.
parent 680b0be0
No related branches found
No related tags found
No related merge requests found
......@@ -108,8 +108,8 @@ export class CanvasComponent implements OnInit, OnDestroy {
return this.page.sections.reduce(reduceFct, 0);
}
addSection(index: number | null = null): void {
this.unitService.addSection(this.page, index);
addSection(): void {
this.unitService.addSection(this.page);
this.selectionService.selectedPageSectionIndex = this.page.sections.length - 1;
}
......
......@@ -5,6 +5,7 @@ import { CdkDragDrop } from '@angular/cdk/drag-drop/drag-events';
import { DragItemData, DropListData } from './canvas.component';
import { UnitService } from '../../../unit.service';
import { Section } from '../../../../../../common/models/section';
import { UIElementType } from '../../../../../../common/models/uI-element';
@Component({
selector: 'app-section-dynamic',
......@@ -129,7 +130,7 @@ export class SectionDynamicComponent {
newElementDropped(event: DragEvent, gridX: number, gridY: number): void {
event.preventDefault();
this.unitService.addElementToSection(
event.dataTransfer?.getData('elementType') as string,
event.dataTransfer?.getData('elementType') as UIElementType,
this.section,
{ x: gridX, y: gridY }
);
......
......@@ -3,6 +3,7 @@ import {
} from '@angular/core';
import { UnitService } from '../../../unit.service';
import { Section } from '../../../../../../common/models/section';
import { UIElementType } from '../../../../../../common/models/uI-element';
@Component({
selector: 'app-section-static',
......@@ -33,7 +34,7 @@ export class SectionStaticComponent {
event.preventDefault();
const sectionRect = this.sectionElement.nativeElement.getBoundingClientRect();
this.unitService.addElementToSection(
event.dataTransfer?.getData('elementType') as string,
event.dataTransfer?.getData('elementType') as UIElementType,
this.section,
{ x: event.clientX - Math.round(sectionRect.left), y: event.clientY - Math.round(sectionRect.top) }
);
......
import { Component } from '@angular/core';
import { UnitService } from '../../../unit.service';
import { SelectionService } from '../../../selection.service';
import { UIElementType } from '../../../../../../common/models/uI-element';
@Component({
selector: 'app-ui-element-toolbox',
......@@ -16,7 +17,7 @@ import { SelectionService } from '../../../selection.service';
export class UiElementToolboxComponent {
constructor(private selectionService: SelectionService, public unitService: UnitService) { }
async addUIElement(elementType: string): Promise<void> {
async addUIElement(elementType: UIElementType): Promise<void> {
this.unitService.addElementToSectionByIndex(elementType,
this.selectionService.selectedPageIndex,
this.selectionService.selectedPageSectionIndex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment