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 } 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: 'assignModal', templateUrl: './assign-modal.component.html' }) export class AssignModalComponent extends AppComponentBase { @ViewChild('createModal', {static: false}) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); id: any; creator: string; today: any; users: UserListDto[] = []; //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, assignId?) : void { //$('.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.modal.show(); } onShown(): void { //document.getElementById('valueInput').focus(); } init(): void { } save(): void { let ticketId = this.id; 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(); }); } 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; }); } }