//Importing the libraries import { Component, OnInit, Input } from '@angular/core'; import { DialogService } from 'primeng/api'; import { CookieService } from 'ngx-cookie-service'; import { trigger, state, style, transition, animate } from '@angular/animations'; import { ActivatedRoute } from '@angular/router'; //Importing the components import { ContactCreateTaskComponent } from '../popups/contact-create-task/contact-create-task.component'; //Importing the service classes import { TasksService } from '../../shared/service/tasks.service'; //Importing the core classes import { ITaskDetails } from '../../shared/core/ITaskDetails'; import { IAssociateRecords } from '../../shared/core/IAssociateRecords '; import { Default } from '../../shared/core/Default.enum'; @Component({ selector: 'app-contact-tasks', templateUrl: './contact-tasks.component.html', styleUrls: ['./contact-tasks.component.scss'], animations: [ trigger('slideInOut', [ state('in', style({ transform: 'translate3d(0, 0, 0)' })), state('out', style({ transform: 'translate3d(104%, 0, 0)' })), transition('in => out', animate('400ms ease-in-out')), transition('out => in', animate('400ms ease-in-out')) ]), ] }) export class ContactTasksComponent implements OnInit { // Contact Id this should be contactId: number; // Tasks collections ITaskDetails: ITaskDetails[] // Associated Recored contactName: string; companyName: string; associateRecoredCount: number; //Login staff Id loginStaffId: number; //Slide in state createTaskPageState: string = 'out'; @Input('showShortcut') showShortcut: number; @Input('companyId') companyId: number; @Input('contactIdParam') contactIdParam: number; // Associate Records IAssociateRecords: IAssociateRecords[]; // Notes filter: number; //Snapzing variable showLoading:boolean = false; constructor(public dialogService: DialogService, private tasksService: TasksService, private cookieService: CookieService, private route: ActivatedRoute) { } ngOnChanges(){ this.filter = Default.Tasks; } ngOnInit() { // pass to Filter section this.filter = Default.Tasks; this.loginStaffId = +this.cookieService.get('LoggedUserId'); // Get All Tasks this.GetAllTasksDetailsByContactId(); } // Pin ChangeOrderOfTasks(taskId: any) { this.showLoading = true; this.tasksService.ChangeOrderOfTasks(taskId, this.loginStaffId).subscribe( result => { if (result != null) { // Get All Tasks this.GetAllTasksDetailsByContactId(); } else { //console.log(" Error: GetAllNotesDetails "); } } ); } // GetTaskAssociateRecords(task.TaskDetailsId) GetTaskAssociateRecords(TaskDetailsId) { // console.log(noteId); // Get All Tasks // debugger; this.tasksService.GetTasksAssociateRecords(TaskDetailsId).subscribe( result => { if (result != null) { // console.log(result); this.IAssociateRecords = result; // console.log('Task Associate Records'); // console.log(this.IAssociateRecords); } else { //console.log(" Error: GetAllNotesDetails "); } } ); } //show the create task popup showCreateTask() { if (this.createTaskPageState == 'in') { this.createTaskPageState = 'out' } else { this.createTaskPageState = 'in' } } closePopup() { this.showLoading = true; this.createTaskPageState = "out"; this.GetAllTasksDetailsByContactId(); } // Task Complete checkEvent(event, taskDetailsId) { if (event == true) { // console.log(taskDetailsId) this.tasksService.CompleteTasksRecords(taskDetailsId).subscribe( result => { if (result != null) { // Get All Tasks this.GetAllTasksDetailsByContactId(); } else { //console.log(" Error: GetAllNotesDetails "); } } ); } } // Get all task by Contact ID GetAllTasksDetailsByContactId() { // this shoud be assing /** get parameter contactId */ this.route.paramMap.subscribe(params => { this.contactId = +params.get("contactId") }) if (this.contactId == undefined && this.contactId == null) { this.contactId = this.contactIdParam; } // Taks by Id this.tasksService.GetAllTasksDetailsByContactId(this.contactId).subscribe( result => { if (result != null) { // console.log(result); this.ITaskDetails = result; this.showLoading = false; // console.log('Task Details '); // console.log(this.ITaskDetails); // this.associateRecoredCount = this.ITaskDetails[0].CompanyDetails.length + this.ITaskDetails[0].ContactDetails.length; // console.log(this.associateRecoredCount); } else { //console.log(" Error: GetAllNotesDetails "); } } ); } onChangeTask(event : ITaskDetails[]) { this.ITaskDetails = event; } }