// Angular imports // import { Component, OnInit, Input, ElementRef, ViewChild } from '@angular/core'; // Components // // import * as _ from 'underscore'; // Interfaces // // Services // // Directives // // Other classes // import { FbFormBase } from '../fbFormBase'; import * as statics from '@fb/statics'; /** * Visar ett textf�lt f�r text. * * Syntax: * * * @param model Modell * @param label Label att visa. Visas inte om tight eller noLabel �r satt * @param disabled Disabled om satt till true * @param disableReason Anv�nds som tooltip vid disabled * @param noLabel S�tt till true f�r att d�lja label * @param spellcheck Är som default satt till true. Om denna sätts till false görs ingen spellcheck * �vriga param saknas, fyll g�rna p� */ // Todo importera styles enligt wiki /vile @Component({ selector: 'fb-form-textarea', templateUrl: './fb-form-textarea.component.html', styleUrls: [/*'./fb-form-textarea.component.less'*/] }) export class FbFormTextareaComponent extends FbFormBase implements OnInit { @Input() placeholder: string; @Input() largeLabel: boolean = false; @Input() maxlength: number; @Input() spellcheck: boolean = true; @Input() rows: number = 2; @Input() tight: boolean = false; tooltipText: string; textareaId: string = statics.Guid.new(); @ViewChild('textarea') textarea: ElementRef; constructor() { super(); } ngOnInit(): void { super.ngOnInit(); // this.validateInput(); this.setPlaceholderText(); } focus(): void { if (this.textarea && this.textarea.nativeElement) { setTimeout(() => this.textarea.nativeElement.focus(), 5); } } // private validateInput(): void { // // Finns fför mycket exterande kod som inte har en disable-reason för att lägga till detta // if (this.disabled && !this.disableReason) { // throw new Error(this.getStringFromModel() + ': Disabled kan inte användas utan att sätta en anledning. Använd disabled med disableReason.'); // } // } private setPlaceholderText(): void { if (this.label !== undefined && !this.tight) { this.placeholder = ''; } else if (this.label === undefined && this.tight && this.placeholder !== undefined) { this.label = this.placeholder; } } }