//Importing the libraries import { Component, OnInit, Input } from '@angular/core'; import { DialogService } from 'primeng/api'; import { trigger, state, style, transition, animate } from '@angular/animations'; import { CookieService } from 'ngx-cookie-service'; //Importing the service classes import { NotesService } from '../../shared/service/notes.service'; //Importing the core classes import { INotes } from '../../shared/core/INotes'; import { IAssociateRecords } from '../../shared/core/IAssociateRecords '; import { Default } from '../../shared/core/Default.enum'; @Component({ selector: 'app-contact-notes', templateUrl: './contact-notes.component.html', styleUrls: ['./contact-notes.component.scss'], providers: [DialogService], 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 ContactNotesComponent implements OnInit { // Contact Id this should be contactId: number; // notes collections INotes: INotes[]; // Associated Recored contactName: string; companyName: string; associateRecoredCount: number; //Login staff Id loginStaffId: number; //Variables for company detail slide in companyDetailPageState: string = 'out'; createNotePageState: string = 'out'; @Input('showShortcut') showShortcut: number; @Input('companyId') companyId: number; @Input('contactIdParam') contactIdParam: number; @Input('autoNewNote') autoNewNote: boolean; // Associate Records IAssociateRecords: IAssociateRecords[]; // Notes filter:number; //Snapzing variable showLoading:boolean = false; constructor(public dialogService: DialogService, private notesService: NotesService, private cookieService: CookieService) { } ngOnChanges(){ // pass to Filter section this.filter = Default.Notes; if (this.autoNewNote == true) { this.showCreateNote(); } } ngOnInit() { this.loginStaffId = +this.cookieService.get('LoggedUserId'); // All notes this.GetAllNotesByContactId(); } //show the create note popup showCreateNote() { // const ref = this.dialogService.open(ContactCreateNoteComponent, { // header: 'Create new note', // width: '50%' // }); //this.showCreateNotes = !this.showCreateNotes; if (this.createNotePageState == 'in') { this.createNotePageState = 'out' } else { this.createNotePageState = 'in' } } // Pin ChangeOrderOfNotes(noteId: any) { this.showLoading = true; this.notesService.ChangeOrderOfNotes(noteId, this.loginStaffId).subscribe( result => { if (result != null) { // Get All Notes this.GetAllNotesByContactId(); } else { //console.log(" Error: GetAllNotesDetails "); } } ); } // Get Notes Associated Record GetNoteAssociateRecords(noteId) { // console.log(noteId); // Get All notes // debugger; this.notesService.GetNoteAssociateRecords(noteId).subscribe( result => { if (result != null) { // console.log(result); this.IAssociateRecords = result; // console.log('Note Associate Records'); // console.log(this.IAssociateRecords); } else { //console.log(" Error: GetAllNotesDetails "); } } ); } closePopup() { this.showLoading = true; this.createNotePageState = "out"; this.GetAllNotesByContactId(); } // Get All Notes details GetAllNotesByContactId() { // this shoud be assing // this shoud be assing this.contactId = this.contactIdParam; // Get All notes this.notesService.GetAllNotesDetails(this.contactId).subscribe( result => { if (result != null) { // console.log(result); this.INotes = result; this.showLoading = false; // console.log(' Get All Notes By ContactId : ' + this.INotes); // console.log(this.INotes); // console.log(this.INotes[0].CompanyDetails.length); // console.log(this.INotes[0].ContactDetails.length); // this.associateRecoredCount = this.INotes[0].CompanyDetails.length + this.INotes[0].ContactDetails.length; } else { //console.log(" Error: GetAllNotesByContactId "); } } ); } onChangeDataSet(dataset:INotes[]){ this.INotes = dataset; } }