import { Component, EventEmitter, ElementRef, Injector, Output, ViewChild, ViewContainerRef } from '@angular/core'; import { AppComponentBase } from '@shared/common/app-component-base'; import { AppSessionService } from '@shared/common/session/app-session.service'; import { SupportTicketServiceProxy, UserListDto, UpdateTicketTenant } from '@shared/service-proxies/service-proxies'; //import { AppSessionService } from '@shared/common/session/app-session.service'; import * as _ from 'lodash'; import { ModalDirective } from 'ngx-bootstrap'; import { finalize } from 'rxjs/operators'; import { AppConsts } from '@shared/AppConsts'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import * as moment from 'moment'; @Component({ selector: 'deleteRoutesModal', templateUrl: './delete-routes.modal.component.html' }) export class DeleteRoutesModalComponent extends AppComponentBase { @ViewChild('createModal', {static: false}) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); id: any; creator: string; today: any; users: UserListDto[] = []; tenants: any; //resolve: boolean = false; active: boolean = false; saving: boolean = false; assignId: any; constructor( injector: Injector, private viewContainerRef: ViewContainerRef, private _appSessionService: AppSessionService, private _supportTicketServiceProxy: SupportTicketServiceProxy, ) { super(injector); } show(id) : void { // console.log('DATA : '); // console.log(data); // //$('.kt-select2').select2(); // this.today = new Date(); // this.creator = this._appSessionService.user.name + ' ' + this._appSessionService.user.surname; // this.id = id; // this.assignId = assignId; // //alert(this.assignId); // this.active = true; // this.init(); // this.showAllUsers(); // this._supportTicketServiceProxy.getTenantTicket() // .pipe() // .subscribe(result=> { // this.tenants = result; // this.modal.show(); // // $('#select2-assignTenant-container').html(data.tenant); // // alert(data.tenantId); // // $('#assign').val(data.tenantId); // }); this.modal.show(); } onShown(): void { //document.getElementById('valueInput').focus(); } init(): void { } save(): void { let ticketId = this.id; let input: any; input = {'tenantId': Number($('#assignTenant').val()), 'ticketId': ticketId}; // let userId = Number($('#assign').val()); // let userName = $('#assign option:selected').text(); // this._supportTicketServiceProxy.assignedUser( // ticketId, // userId, // userName // ).pipe().subscribe(result => { // this.notify.info(this.l('SavedSuccessfully')); // this.modalSave.emit(null); // this.close(); // }); this._supportTicketServiceProxy.updateTenantTicket(input).pipe().subscribe(result => { this.notify.info(this.l('SavedSuccessfully')); this.modalSave.emit(null); this.close(); }); } close(): void { this.active = false; this.modal.hide(); } showAllUsers() : void { //this.active = true; jQuery(document).ready(function () { $('.kt-select2').select2(); $('.select2-container').css('width', '100%'); }); this._supportTicketServiceProxy.getUsersForDropDown().subscribe((result) => { this.users = result.items; }); } }