File

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

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(utils: UtilsService, modalCtrl: ModalController)
Parameters :
Name Type Optional
utils UtilsService No
modalCtrl ModalController 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 : string
submissionId
Type : any

Outputs

nextCallBack
Type : EventEmitter
previousCallBack
Type : EventEmitter

Methods

back
back()
Returns : void
checkForValidation
checkForValidation()
Returns : void
next
next(status?: string)
Parameters :
Name Type Optional
status string Yes
Returns : void
ngOnInit
ngOnInit()
Returns : void
Async openHint
openHint(hint)
Parameters :
Name Optional
hint No
Returns : any
updateModelValue
updateModelValue(val)
Parameters :
Name Optional
val No
Returns : void

Properties

text
Type : string
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>

./multiple-type-input.component.scss

.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
Component
Html element with directive

results matching ""

    No results matching ""