From 5d23626fad8cc42ff1fbd4978f3e5e258aa335d8 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Tue, 22 Jan 2019 17:10:53 +0530 Subject: [PATCH] pd schedule changes --- .../schedule-pd/schedule-pd.component.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts index 8bc7c87b7..795d78bc0 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Inject, Pipe, PipeTransform } from '@angular/core'; +import { Component, OnInit, Inject, Pipe, PipeTransform, OnDestroy } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms'; import { NotifierService } from 'angular-notifier'; @@ -15,7 +15,8 @@ export interface Timeslot { templateUrl: './schedule-pd.component.html', styleUrls: ['./schedule-pd.component.scss'] }) -export class SchedulePdComponent implements OnInit { +export class SchedulePdComponent implements OnInit, OnDestroy { + public pageTitle: string = "PD Schedule"; pipe = new DatePipe('en-US'); public selectedMoment = new Date(); @@ -55,6 +56,7 @@ export class SchedulePdComponent implements OnInit { // ]; public min = new Date(); + validateTime:any; constructor(notifier: NotifierService, private dialogRef: MatDialogRef, private _pd: PdTrigerService, @Inject(MAT_DIALOG_DATA) public data: any) { @@ -62,9 +64,18 @@ export class SchedulePdComponent implements OnInit { } ngOnInit() { - + this.validateTime = setInterval(() => { + let currentTime:any = new Date(); + currentTime = currentTime.getFullYear()+'-'+currentTime.getMonth()+'-'+currentTime.getDay()+currentTime.getHours()+'-'+currentTime.getMinutes(); + let existTime:any = this.selectedMoment.getFullYear()+'-'+this.selectedMoment.getMonth()+'-'+this.selectedMoment.getDay() +'-'+this.selectedMoment.getHours()+'-'+this.selectedMoment.getMinutes(); + if(existTime < currentTime) { + this.selectedMoment = new Date(); + this.min = new Date(); + + } + },1000); } - + // close pd schedule pop up closeScheduleComponent(): void { this.dialogRef.close(); @@ -72,6 +83,7 @@ export class SchedulePdComponent implements OnInit { // update pd schedule upatePDSchedule(date:any){ + let myFormattedDate = this.pipe.transform(date, 'yyyy-MM-dd HH:mm'); let updateData = { @@ -94,4 +106,7 @@ export class SchedulePdComponent implements OnInit { this.dialogRef.close(); }); } + ngOnDestroy(): void { + clearInterval(this.validateTime); + } }