import { Component, EventEmitter, Injector, ViewChild, Output,Input } from '@angular/core'; import { AppComponentBase } from '@shared/common/app-component-base'; import { ModalDirective } from 'ngx-bootstrap'; import { ControllerRouteDetailServiceProxy, ControllerGetOrderIdForNoteInput} from '@shared/service-proxies/service-proxies'; import { PrimengTableHelper } from 'shared/helpers/PrimengTableHelper'; import { finalize } from 'rxjs/operators'; import * as jquery from 'jquery'; import * as moment from 'moment'; // import * as DualListbox from 'dual-listbox'; @Component({ templateUrl: './clinic-notes.component.html', selector: 'clinicNotes' }) export class ClinicNotes extends AppComponentBase { @ViewChild('clinicNotesModal', {static: true}) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); @Input() refreshRoute:Function // @Input() orderId: any // @Input() clinicId:any active = false; saving = false; note: string clinicId:number; orderId:number driverVisibility:any params : ControllerGetOrderIdForNoteInput = new ControllerGetOrderIdForNoteInput(); constructor( injector: Injector, private _controllerRouteDetails: ControllerRouteDetailServiceProxy, ) { super(injector); } ngOnInit(){ } show(clinicId ?:number,orderId ?:number){ console.log("this is orderId"+orderId) console.log("this is clinic id"+clinicId) this.clinicId = clinicId this.orderId = orderId this._controllerRouteDetails.getClinicNotes(clinicId,orderId).subscribe(result=>{ this.driverVisibility = result.clinicNotesVisibleToDriver // console.log("Driver Visibility" + this.driverVisibility) this.note = result.clinicNotes // if( orderresult.note == null && result.clinicNotes != null){ // this.note = result.clinicNotes // console.log(this.note) // } // else if(orderresult.note != null && result.clinicNotes == null){ // console.log("order not null") // this.note = orderresult.note.content // console.log("else if "+this.note) // } // else{ // this.note=null // } // console.log(this.driverVisibility) }); this.active = true; this.modal.show(); } save(){ // console.log(this.clinicId) // console.log(this.orderId) // console.log("hello") let params = new ControllerGetOrderIdForNoteInput ({ orderId : this.orderId, clinicId : this.clinicId, visibleToDriver: this.driverVisibility, noteId: undefined, content: String((document.getElementById('note')).value) }); this._controllerRouteDetails.createOrUpdateOrderNotes( params ).subscribe(() => { this.notify.info(this.l('SavedSuccessfully')); this.close(); this.modalSave.emit(null); this.refreshRoute(); }) } visibilityTrigger(){ if(this.driverVisibility==true){ this.driverVisibility=false console.log(this.driverVisibility) } else{ this.driverVisibility=true console.log(this.driverVisibility) } } onShown(): void { } close(){ this.active = false; this.modal.hide(); } }