File

src/app/manage-learn/shared/components/text-type-input/text-type-input.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(utils: UtilsService)
Parameters :
Name Type Optional
utils UtilsService No

Inputs

data
Type : any
enableQuestionReadOut
Type : boolean
evidenceId
Type : string
generalQuestion
Type : boolean
hideButton
Type : boolean
imageLocalCopyId
Type : string
inputIndex
Type : any
isFirst
Type : boolean
isLast
Type : boolean
schoolId
Type : any
submissionId
Type : any

Outputs

nextCallBack
Type : EventEmitter
previousCallBack
Type : EventEmitter

Methods

back
back()
Returns : void
checkForValidation
checkForValidation()
Returns : void
getErrorMsg
getErrorMsg()
Returns : string
isaNumber
isaNumber()
Returns : void
next
next(status?: any)
Parameters :
Name Type Optional
status any Yes
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

notNumber
Type : boolean
questionValid
Type : boolean
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { UtilsService } from '@app/app/manage-learn/core';

@Component({
  selector: 'app-text-type-input',
  templateUrl: './text-type-input.component.html',
  styleUrls: ['./text-type-input.component.scss'],
})
export class TextTypeInputComponent implements OnInit {

  @Input() inputIndex;
  @Input() data: any;
  @Input() isLast: boolean;
  @Input() isFirst: boolean;
  @Output() nextCallBack = new EventEmitter();
  @Output() previousCallBack = new EventEmitter()
  @Input() evidenceId: string;
  @Input() hideButton: boolean;
  @Input() submissionId: any;
  @Input() imageLocalCopyId: string;
  @Input() generalQuestion: boolean;
  @Input() schoolId;
  @Input() enableQuestionReadOut: boolean;
  notNumber: boolean;
  questionValid: boolean;

  constructor(private utils: UtilsService) { }

  ngOnInit() {
    this.isaNumber();
    this.data.startTime = this.data.startTime ? this.data.startTime : Date.now();
    if (!this.data.validation.required) {
      this.data.isCompleted = true;
    }
    this.getErrorMsg();
  }

  next(status?: any) {
    this.data.isCompleted = this.utils.isQuestionComplete(this.data);
    this.nextCallBack.emit(status);
  }

  isaNumber() {
    this.notNumber = this.utils.testRegex(this.data.validation.regex, this.data.value);
  }

  back() {
    this.data.isCompleted = this.utils.isQuestionComplete(this.data);
    this.previousCallBack.emit('previous');
  }

  // checkForValidation(): void {
  //   this.questionValid = this.utils.isQuestionComplete(this.data);
  // }
  checkForValidation(): void {
    this.data.isCompleted = this.utils.isQuestionComplete(this.data);
    this.data.endTime = this.data.isCompleted ? Date.now() : "";
    this.isaNumber();
  }

  getErrorMsg() {
    if (this.data.validation.regex) {
      let string = this.data.validation.regex.split("[");
      string = string[1].split("]")[0];
      return "Should contain only values " + string;
    }
  }

}
<ion-card class="_cardBg ion-padding">
  <ion-col class="_flex-box _justify-content-center _flex-direction-column">
    <h4 [ngClass]="{'_validQuestion': (data?.value || !data?.validation?.required)}" class="flexbox">
      <app-question-heading [inputIndex]="inputIndex" [data]="data" [enableQuestionReadOut]="enableQuestionReadOut">
      </app-question-heading>
    </h4>
  </ion-col>
  <div class="_tip _flex-box">{{data?.tip}}</div>
  <div class="ion-margin-top">
    <ion-item text-center no-padding *ngIf="data?.responseType != 'text'">
      <ion-input type="{{data?.responseType}}" (input)="isaNumber()" (keyup.enter)="keyboard.hide()"
        [(ngModel)]="data.value" (ngModelChange)="checkForValidation()"
        [disabled]="data.isEditable!=undefined && !data.isEditable"></ion-input>
    </ion-item>
    <ion-item text-center no-padding *ngIf="data?.responseType == 'text'">
      <ion-textarea (keyup.enter)="keyboard.hide()" [(ngModel)]="data.value" (ngModelChange)="checkForValidation()"
        [disabled]="data.isEditable!=undefined && !data.isEditable"></ion-textarea>
    </ion-item>
    <div *ngIf="!notNumber" class="_errorMsg">{{getErrorMsg()}}</div>

    <app-remarks *ngIf="data?.showRemarks" [data]="data"></app-remarks>
    <app-image-upload [data]="data" [generalQuestion]="generalQuestion" [imageLocalCopyId]="imageLocalCopyId"
      [evidenceId]="evidenceId" [submissionId]="submissionId"></app-image-upload>
  </div>
</ion-card>

./text-type-input.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""