Skip to content
Snippets Groups Projects
button.ts 1.29 KiB
Newer Older
import { Type } from '@angular/core';
rhenck's avatar
rhenck committed
import {
  BasicStyles, PositionProperties, UIElement
rhenck's avatar
rhenck committed
} from 'common/models/elements/element';
import { ButtonComponent } from 'common/components/button/button.component';
import { ElementComponent } from 'common/directives/element-component.directive';

export class ButtonElement extends UIElement {
  label: string = 'Navigationsknopf';
  imageSrc: string | null = null;
  asLink: boolean = false;
  action: null | 'unitNav' | 'pageNav' = null;
  actionParam: null | 'previous' | 'next' | 'first' | 'last' | 'end' | number = null;
  position: PositionProperties | undefined;
  styling: BasicStyles & {
    borderRadius: number;
  };

rhenck's avatar
rhenck committed
  constructor(element: Partial<ButtonElement>) {
    super(element);
    if (element.label !== undefined) this.label = element.label;
rhenck's avatar
rhenck committed
    if (element.imageSrc) this.imageSrc = element.imageSrc;
    if (element.asLink) this.asLink = element.asLink;
    if (element.action) this.action = element.action;
    if (element.actionParam) this.actionParam = element.actionParam;
rhenck's avatar
rhenck committed
    this.position = element.position ? UIElement.initPositionProps(element.position) : undefined;
    this.styling = UIElement.initStylingProps({ borderRadius: 0, ...element.styling });
  getElementComponent(): Type<ElementComponent> {
    return ButtonComponent;
  }
}