import { Component, OnInit,Input } from '@angular/core';
import { Router } from '@angular/router';
import { CommonService, toastPayload } from '../common/service/common.service';
import { TableHeader } from '../model/uam.models';
import { ApplicationService } from '../application/application.service';
import { DataservicesService } from '../common/dataservice/dataservices.service';
import { LecturScheduleAddService} from './lectur-schedule-add.service';
import { LecturScheduleAdd } from './lectur-schedule-add';
import { FormControl, FormGroup , ReactiveFormsModule, Validators} from '@angular/forms';
import { IndividualConfig } from 'ngx-toastr';
import { takeUntil } from 'rxjs';
@Component({
selector: 'app-lecture-schedule-add',
templateUrl: './lecture-schedule-add.component.html',
styleUrls: ['./lecture-schedule-add.component.css']
})
export class LectureScheduleAddComponent implements OnInit {
toast!: toastPayload;
Id!:any;
access_id:any;
Division:any;
Sessionid:any;
DivisionId:any;
PeriodId:any;
Period:any;
LectureTypeId:any;
LectureTypeName:any;
SubjectId:any;
SubjectName:any;
TeacherId:any;
TeacherName:any;
LectureName:any;
StandardId:any;
Standard:any;
SessionName:any;
lectList:any=[];
stdList:Object;
divList:Object;
sessList:Object;
periodList:any=[];
teachList:Object;
subList:Object;
Day:any;
message: any;
masterForm : FormGroup;
constructor(private router: Router, public service: LecturScheduleAddService,
public commonService: CommonService, public dataService:DataservicesService) { }
ngOnInit(): void {
debugger;
$('#dlllectureType').val('selectedvalue');
this.GetLectureTypeMasterById();
this.getApplicationList();
this.masterForm = new FormGroup({
'lectureName' : new FormControl(null,[Validators.required, Validators.pattern(/^(\s+\S+\s*)*(?!\s).*$/)]),
'standardId' : new FormControl(null, Validators.required),
'divisionId' : new FormControl(null),
'lectureTypeId' : new FormControl(null),
'day' : new FormControl(null),
'sessionId' : new FormControl(null),
'periodId' : new FormControl(null),
'teacherId' : new FormControl(null),
'subjectId' : new FormControl(null),
});
}
getRequestParam(){
const obj:LecturScheduleAdd= new LecturScheduleAdd();
obj.Id = this.dataService.id;
obj.StandardId=this.dataService.StandardId;
obj.PeriodId=this.dataService.PeriodId;
// this.row=this.dataService.rowData;
return obj;
}
public GetLectureTypeMasterById() {
if (this.dataService.id !== "00000000-0000-0000-0000-000000000000" && this.dataService.id !== undefined) {
const val = new LecturScheduleAdd();
val.Id = this.dataService.id;
this.service.GetLectureScheduleById(val).pipe(takeUntil(this.router.events)).subscribe((result: any) => {
this.Id = result.id;
this.StandardId = result.standardId;
this.LectureName = result.lectureName;
this.DivisionId = result.divisionId;
this.Day = result.day;
this.Sessionid = result.sessionId;
this.SubjectId = result.subjectId;
this.LectureTypeId = result.lectureTypeId;
this.TeacherId = result.teacherId;
console.log(result);
});
}
else{
this.StandardId = '';
this.LectureName = '';
this.DivisionId = '';
this.Day = 'Monday';
this.Sessionid = '';
this.SubjectId = '';
this.LectureTypeId = '';
this.TeacherId = '';
}
}
getStandard()
{
const obj : LecturScheduleAdd = new LecturScheduleAdd();
obj.dType = "Standard"; return obj;
}
getLectureType()
{
const obj : LecturScheduleAdd = new LecturScheduleAdd();
obj.dType = "LectureType"; return obj;
}
getPeriod()
{
const obj : LecturScheduleAdd = new LecturScheduleAdd();
obj.dType = "Period"; return obj;
}
getDivision()
{
const obj : LecturScheduleAdd = new LecturScheduleAdd();
obj.dType = "Division"; return obj;
}
getTeacher()
{
const obj : LecturScheduleAdd = new LecturScheduleAdd();
obj.dType = "Teacher"; return obj;
}
getSession()
{
const obj : LecturScheduleAdd = new LecturScheduleAdd();
obj.dType = "Session"; return obj;
}
getSubject()
{
const obj : LecturScheduleAdd = new LecturScheduleAdd();
obj.dType = "Subject"; return obj;
}
backtoList()
{
this.router.navigate(['/lecture-schedule'])
}
clearData()
{
this.Id = '00000000-0000-0000-0000-000000000000';
this.PeriodId ='';
this.StandardId='';
this.SubjectId='';
this.LectureName='';
this.LectureTypeId='';
this.TeacherId='';
this.DivisionId='';
this.Sessionid='';
this.dataService.Standard ='';
}
get breadCrumb(){
return this.LectureName =this.dataService.LectureName;
}
closeModal()
{
$('#messegeBox').hide();
}
getApplicationList(){
debugger;
const objStandard = this.getStandard();
const objDivision = this.getDivision();
const objSub = this.getSubject();
const objsessiom = this.getSession();
const objteacher = this.getTeacher();
const objPeriod = this.getPeriod();
const objLecture = this.getLectureType();
console.log("obj",objStandard);
this.StandardId = this.service.getStandard().subscribe(results => { this.stdList =(results as any).results
this.stdList = results
});
this.PeriodId = this.service.getPeriod().subscribe(results => { this.periodList = (results as any).results
this.periodList = results
});
this.DivisionId = this.service.getDivision().subscribe(results => this.divList = results);
this.Sessionid = this.service.getSession().subscribe(results => this.sessList = results);
this.SubjectId = this.service.getSubject().subscribe(results => this.subList = results);
this.TeacherId = this.service.getTeacher().subscribe(results => this.teachList = results);
this.LectureTypeId = this.service.getdrpList(objLecture).subscribe(results => this.lectList = results);
}
get sessionId(){
return this.masterForm.get('sessionId');
}
get lectureTypeId(){
return this.masterForm.get('lectureTypeId');
}
get periodId(){
return this.masterForm.get('periodId');
}
get lectureName(){
return this.masterForm.get('lectureName');
}
get standardId(){
return this.masterForm.get('teacherId');
}
get divisionId(){
return this.masterForm.get('teacherId');
}
get day(){
return this.masterForm.get('day');
}
get subjectId(){
return this.masterForm.get('subjectId');
}
get teacherId(){
return this.masterForm.get('teacherId');
}
Update(){
debugger;
var val = {Id:this.Id,
LectureName:this.LectureName,
StandardId:this.StandardId,
PeriodId:this.PeriodId,
DivisionId:this.DivisionId,
Sessionid:this.Sessionid,
SubjectId:this.SubjectId,
TeacherId:this.TeacherId,
LectureTypeId:this.LectureTypeId,
Day:this.Day
};
this.service.Update(val).subscribe({
next: ((result:any) => {
this.message= result.message;
this.toast = {
message: this.message,
title: 'Success',
type: 'success',
ic: {
timeOut: 2500,
closeButton: true,
} as IndividualConfig,
};
this.commonService.showToast(this.toast);
}),
error: (error => {
this.toast = {
message: 'Error occurred',
title: 'Error',
type: 'error',
ic: {
timeOut: 2500,
closeButton: true,
} as IndividualConfig,
};
this.commonService.showToast(this.toast);
})
});
}
onStdChange(e: any) {
debugger;
if(e.target.value !="null" || e.target.value !="undefined")
{
this.StandardId =e.target.value;
}
else
{
this.StandardId =null;
}
}
onPeriodChange(e: any) {
debugger;
if(e.target.value !="null" || e.target.value !="undefined")
{
this.PeriodId =e.target.value;
}
else
{
this.PeriodId =null;
}
}
ondivChange(e: any) {
debugger;
if(e.target.value !="null" || e.target.value !="undefined")
{
this.DivisionId =e.target.value;
}
else
{
this.DivisionId =null;
}
}
onsessionChange(e: any) {
debugger;
if(e.target.value !="null" || e.target.value !="undefined")
{
this.Sessionid =e.target.value;
}
else
{
this.Sessionid =null;
}
}
onteachersChange(e: any) {
debugger;
if(e.target.value !="null" || e.target.value !="undefined")
{
if(this.TeacherId=='00000000-0000-0000-0000-000000000000'|| e.target.value =="undefined")
{
this.TeacherId='71288AB6-4177-4AD5-BC2D-0AC06B7ED306';
}
this.TeacherId =e.target.value;
}
else
{
this.TeacherId =null;
}
}
onsubChange(e: any) {
debugger;
if(e.target.value !="null" || e.target.value !="undefined")
{
this.SubjectId =e.target.value;
}
else
{
this.SubjectId =null;
}
}
onLectChange(e: any) {
debugger;
if(e.target.value !="null" || e.target.value !="undefined")
{
this.LectureTypeId =e.target.value;
}
else
{
this.LectureTypeId =null;
}
}
public onDaysSelected(event: any) {
const selectedValue = event.target.value;
}
}

Guest UserPosted Aug 5, 2022, 9:21 AM
Vishal JoshiPosted Aug 4, 2022, 7:13 AM