File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Outputs
|
|
Constructor
constructor(utils: UtilsService, modalCtrl: ModalController)
|
|
Parameters :
Name |
Type |
Optional |
utils |
UtilsService
|
No
|
modalCtrl |
ModalController
|
No
|
|
enableQuestionReadOut
|
Type : boolean
|
|
imageLocalCopyId
|
Type : string
|
|
Outputs
nextCallBack
|
Type : EventEmitter
|
|
previousCallBack
|
Type : EventEmitter
|
|
Methods
checkForValidation
|
checkForValidation()
|
|
|
next
|
next(status?: string)
|
|
Parameters :
Name |
Type |
Optional |
status |
string
|
Yes
|
|
Async
openHint
|
openHint(hint)
|
|
|
updateModelValue
|
updateModelValue(val)
|
|
|
import { Component, Input, EventEmitter, Output, OnInit } from '@angular/core';
import { UtilsService } from '@app/app/manage-learn/core';
import { ModalController } from '@ionic/angular';
import { HintComponent } from '../hint/hint.component';
@Component({
selector: 'app-multiple-type-input',
templateUrl: './multiple-type-input.component.html',
styleUrls: ['./multiple-type-input.component.scss'],
})
export class MultipleTypeInputComponent implements OnInit {
text: string;
@Input() data: any;
@Input() isLast: boolean;
@Input() isFirst: boolean;
@Output() nextCallBack = new EventEmitter();
@Output() previousCallBack = new EventEmitter();
@Input() evidenceId: string;
@Input() hideButton: boolean;
@Input() schoolId: string;
@Input() imageLocalCopyId: string;
@Input() generalQuestion: boolean;
@Input() submissionId: any;
@Input() inputIndex;
@Input() enableQuestionReadOut: boolean;
constructor(
private utils: UtilsService,
// private hintService: HintProvider
private modalCtrl:ModalController
) {
this.text = "Hello World";
}
ngOnInit() {
this.data.value = this.data.value ? this.data.value : [];
this.data.startTime = this.data.startTime
? this.data.startTime
: Date.now();
if (
!this.data.validation.required ||
(this.data.value && this.data.value.length)
) {
this.data.isCompleted = true;
}
}
updateModelValue(val) {
if (this.data.value.indexOf(val) > -1) {
let index = this.data.value.indexOf(val);
this.data.value.splice(index, 1);
} else {
this.data.value.push(val);
}
this.checkForValidation();
}
next(status?: string) {
this.data.isCompleted = this.utils.isQuestionComplete(this.data);
this.nextCallBack.emit(status);
}
back() {
this.data.isCompleted = this.utils.isQuestionComplete(this.data);
this.previousCallBack.emit("previous");
}
checkForValidation(): void {
this.data.isCompleted = this.utils.isQuestionComplete(this.data);
this.data.endTime = this.data.isCompleted ? Date.now() : "";
}
async openHint(hint) {
let hintModal = await this.modalCtrl.create({
component: HintComponent,
componentProps: {
hint,
},
});
hintModal.present();
}
}
<ion-card class="_cardBg ion-padding">
<ion-col class="_flex-box _justify-content-center _flex-direction-column">
<h4 [ngClass]="{'_validQuestion': data?.value?.length}" 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-list>
<ion-item *ngFor="let option of data?.options" class="ion-text-wrap ds-item">
<ion-label class="_flex-box label ion-text-wrap ds-m0">
<ion-icon name="bulb" class="help" (click)="openHint(option?.hint)" *ngIf="option?.hint"></ion-icon>
<div style="flex: 1;" [ngStyle]="{ 'margin-left': option?.hint ? '35px' : '0px' }" class="ds-m0">
{{option?.label}}
</div>
</ion-label>
<ion-checkbox [checked]="data?.value?.indexOf(option?.value) >-1" class="checkbox"
(ionChange)="updateModelValue(option?.value)" [disabled]="data.isEditable!=undefined && !data.isEditable">
</ion-checkbox>
</ion-item>
</ion-list>
<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>
.help {
font-size: 1.875rem;
z-index: 557;
margin-right: 15px;
position: absolute;
color: grey;
// right: 0;
}
.label {
justify-content: flex-start;
font-size: 0.875rem;
}
Legend
Html element with directive