import { Component, EventEmitter, Injector, Output, ViewChild } from '@angular/core'; import { AppComponentBase } from '@shared/common/app-component-base'; import { FindOrganizationUnitUsersInput, NameValueDto, OrganizationUnitServiceProxy, UsersToOrganizationUnitInput,ClinicsServiceProxy, ContactGroupServiceProxy,CreateOrUpdateContactGroupSettingInputDto, AddContactForGroupInputDto, AddContactToGroupInput, GetClinicForViewDto } from '@shared/service-proxies/service-proxies'; import * as _ from 'lodash'; import { ModalDirective } from 'ngx-bootstrap'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { Paginator } from 'primeng/components/paginator/paginator'; import { Table } from 'primeng/components/table/table'; // import { IUsersWithOrganizationUnit } from './users-with-organization-unit'; import { finalize } from 'rxjs/operators'; import { ICustomerWithGroup } from './customer-with-group.component'; @Component({ selector: 'addSettingsModal', templateUrl: './add-settings.component.html' }) export class AddSettingModalComponent extends AppComponentBase { groupId: number; @Output() membersAdded: EventEmitter = new EventEmitter(); @ViewChild('modal', {static: true}) modal: ModalDirective; @ViewChild('dataTable', {static: true}) dataTable: Table; @ViewChild('paginator', {static: true}) paginator: Paginator; isShown = false; filterText = ''; tenantId?: number; saving = false; selectedMembers: CreateOrUpdateContactGroupSettingInputDto[]; constructor( injector: Injector, private _organizationUnitService: OrganizationUnitServiceProxy, private _clinicsService:ClinicsServiceProxy, private _contactGroupService: ContactGroupServiceProxy ) { super(injector); } show(): void { this.modal.show(); } refreshTable(): void { this.paginator.changePage(this.paginator.getPage()); } close(): void { this.modal.hide(); } shown(): void { this.isShown = true; this.getRecordsIfNeeds(null); } getRecordsIfNeeds(event: LazyLoadEvent): void { if (!this.isShown) { return; } this.getRecords(event); } getRecords(event?: LazyLoadEvent): void { if (this.primengTableHelper.shouldResetPaging(event)) { this.paginator.changePage(0); return; } this.spinnerService.show(); this._contactGroupService .getContactGroupSettingTypes() .pipe(finalize(() => this.spinnerService.hide())) .subscribe(result => { this.primengTableHelper.totalRecordsCount = result.length; this.primengTableHelper.records = result; this.spinnerService.hide(); }); } addSettingsToGroup(): void { // let input = new CreateOrUpdateContactGroupSettingInputDto(); // input.groupId = this.groupId; // input.code=_.map(this.selectedMembers, selectedMember => selectedMember.code); // console.log(this.groupId) // this._contactGroupService // .createOrUpdateContactGroupSetting(input) // .subscribe(() => { // this.notify.success(this.l('SuccessfullyAdded')); // // this.membersAdded.emit({ // // contactIds: input.contactIds, // // ouId: input.contactGroupId // // }); // this.saving = false; // this.close(); // }); } }