Skip to content
Snippets Groups Projects
checkbox.ts 1.32 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { Type } from '@angular/core';
    
    rhenck's avatar
    rhenck committed
      BasicStyles, InputElement, PositionedUIElement, PositionProperties, AnswerScheme, AnswerSchemeValue, UIElement
    
    } from 'common/models/elements/element';
    
    import { ElementComponent } from 'common/directives/element-component.directive';
    import { CheckboxComponent } from 'common/components/input-elements/checkbox.component';
    
    export class CheckboxElement extends InputElement implements PositionedUIElement {
      position: PositionProperties;
      styling: BasicStyles;
    
    
    rhenck's avatar
    rhenck committed
      constructor(element: Partial<CheckboxElement>) {
        super({ width: 215, ...element });
    
    rhenck's avatar
    rhenck committed
        this.position = UIElement.initPositionProps(element.position);
        this.styling = UIElement.initStylingProps(element.styling);
    
      hasAnswerScheme(): boolean {
    
        return Boolean(this.getAnswerScheme);
    
      getAnswerScheme(): AnswerScheme {
    
        return {
          id: this.id,
          type: 'boolean',
          format: '',
          multiple: false,
          nullable: false,
    
          values: this.getAnswerSchemeValues(),
    
      private getAnswerSchemeValues(): AnswerSchemeValue[] {
    
        return [
          { value: 'true', label: `Angekreuzt: ${this.label}` },
          { value: 'false', label: `Nicht Angekreuzt: ${this.label}` }
        ];
      }
    
    
      getElementComponent(): Type<ElementComponent> {
    
        return CheckboxComponent;
      }
    }