File

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

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(utils: UtilsService, datePipe: DatePipe)
Parameters :
Name Type Optional
utils UtilsService No
datePipe DatePipe 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
canceled
canceled()
Returns : void
captureTime
captureTime()
Returns : void
checkForValidation
checkForValidation()
Returns : void
getFutureDate
getFutureDate()
Returns : void
next
next(status?: string)
Parameters :
Name Type Optional
status string Yes
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

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

@Component({
  selector: 'app-date-type-input',
  templateUrl: './date-type-input.component.html',
  styleUrls: ['./date-type-input.component.scss'],
})
export class DateTypeInputComponent implements OnInit {
  @Input() data: any;
  @Input() isLast: boolean;
  @Input() isFirst: boolean;
  @Output() nextCallBack = new EventEmitter();
  @Output() previousCallBack = new EventEmitter()
  @Input() evidenceId: string;
  @Input() schoolId: string;
  @Input() imageLocalCopyId: string;
  @Input() generalQuestion: boolean;
  @Input() submissionId: any;
  @Input() inputIndex;
  @Input() hideButton: boolean;
  @Input() enableQuestionReadOut: boolean;
  questionValid: boolean;
  currentDate;
  futureDate;

  constructor(
    private utils: UtilsService,
    private datePipe: DatePipe
  ) {
    this.getFutureDate();

  }

  next(status?: string) {
    this.data.isCompleted = this.utils.isQuestionComplete(this.data);
    if (!this.data.validation.required) {
      this.data.isCompleted = true;
    }
    this.nextCallBack.emit(status);
  }

  captureTime(): void {
    const parseString = this.data.dateFormat;
    this.data.value = new Date(Date.now()).toISOString();
    this.checkForValidation();
  }

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

  canceled() {
  }

  ngOnInit() {
    const dateTime = new Date();
    this.data.validation.max = this.data.validation.max === "currentDate" ? new Date().toISOString().split('T')[0] : this.data.validation.max;
    this.data.validation.min = this.data.validation.min === "currentDate" ? new Date().toISOString().split('T')[0] : this.data.validation.min;
    this.checkForValidation();
    this.data.startTime = this.data.startTime ? this.data.startTime : Date.now();
  }

  getFutureDate() {
    let currentDate = new Date();
    this.futureDate = currentDate.getFullYear() + 10
  }

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

}
<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" style="position: relative;">
    <ion-item>
      <ion-label floating>{{'FRMELEMENTS_LBL_DATE'| translate}}</ion-label>
      <ion-datetime [disabled]="data?.autoCapture || (data.isEditable!=undefined && !data.isEditable)"
        displayFormat="{{data?.dateFormat}}" *ngIf="data?.validation.max && !data?.validation.min"
        [max]='data?.validation.max ? data?.validation.max : ""' (ionCancel)="canceled()" [(ngModel)]="data.value"
        (ngModelChange)="checkForValidation()"></ion-datetime>

      <ion-datetime [disabled]="data?.autoCapture || (data.isEditable!=undefined && !data.isEditable)"
        displayFormat="{{data?.dateFormat}}" *ngIf="data?.validation.min && !data?.validation.max"
        [min]='(data?.validation.min) ? data?.validation.min : ""' [max]="futureDate" (ionCancel)="canceled()"
        [(ngModel)]="data.value" (ngModelChange)="checkForValidation()"></ion-datetime>

      <ion-datetime [disabled]="data?.autoCapture || (data.isEditable!=undefined && !data.isEditable)"
        displayFormat="{{data?.dateFormat}}" *ngIf="data?.validation.min && data?.validation.max"
        [min]='(data?.validation.min) ? data?.validation.min : ""' (ionCancel)="canceled()" [(ngModel)]="data.value"
        (ngModelChange)="checkForValidation()"></ion-datetime>

      <ion-datetime [disabled]="data?.autoCapture  || (data.isEditable!=undefined && !data.isEditable)"
        displayFormat="{{data?.dateFormat}}" *ngIf="!data?.validation.min && !data?.validation.max"
        (ionCancel)="canceled()" [(ngModel)]="data.value" [max]="futureDate" (ngModelChange)="checkForValidation()">
      </ion-datetime>
    </ion-item>
    <ion-button icon-start clear class="capture ion-float-right custom-btn-txt-transform-none" (click)="captureTime()"
      *ngIf="!data?.value && data?.autoCapture">
      {{'FRMELEMENTS_LBL_CAPTURE'| translate}}
    </ion-button>
    <div style="width: 100%;">
      <app-remarks *ngIf="data?.showRemarks" [data]="data"></app-remarks>
    </div>
    <app-image-upload [data]="data" [generalQuestion]="generalQuestion" [imageLocalCopyId]="imageLocalCopyId"
      [evidenceId]="evidenceId" [submissionId]="submissionId"></app-image-upload>
  </div>
</ion-card>

./date-type-input.component.scss

.capture {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 1;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""