File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Outputs
|
|
enableQuestionReadOut
|
Type : boolean
|
|
imageLocalCopyId
|
Type : string
|
|
Outputs
nextCallBack
|
Type : EventEmitter
|
|
previousCallBack
|
Type : EventEmitter
|
|
Methods
checkForValidation
|
checkForValidation()
|
|
|
getErrorMsg
|
getErrorMsg()
|
|
|
next
|
next(status?: any)
|
|
Parameters :
Name |
Type |
Optional |
status |
any
|
Yes
|
|
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>
Legend
Html element with directive