| /******************************************************************************** |
| * Copyright (c) 2020 Contributors to the Eclipse Foundation |
| * |
| * See the NOTICE file(s) distributed with this work for additional |
| * information regarding copyright ownership. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| ********************************************************************************/ |
| import { DistributionGroupSandbox } from '@grid-failure-information-app/app/pages/distribution-group/distribution-group.sandbox'; |
| import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; |
| import { BaseList } from '@grid-failure-information-app/shared/components/base-components/base.list'; |
| import { DISTRIBUTION_GROUP_MEMBER_COLDEF } from '@grid-failure-information-app/app/pages/distribution-group/distribution-group-members/distribution-group-members-col-def'; |
| import { SetFilterComponent } from '@grid-failure-information-app/shared/filters/ag-grid/set-filter/set-filter.component'; |
| import { Subscription } from 'rxjs'; |
| |
| @Component({ |
| selector: 'app-distribution-group-members', |
| templateUrl: './distribution-group-members.component.html', |
| styleUrls: ['./distribution-group-members.component.scss'], |
| }) |
| export class DistributionGroupMembersComponent extends BaseList implements OnInit { |
| @ViewChild('searchInput', { static: true }) searchInput: ElementRef; |
| public columnDefinition: any = DISTRIBUTION_GROUP_MEMBER_COLDEF; |
| public frameworkComponents: { setFilterComponent: any }; |
| private _subscription: Subscription; |
| |
| constructor(public sandbox: DistributionGroupSandbox) { |
| super(); |
| this.frameworkComponents = { setFilterComponent: SetFilterComponent }; |
| } |
| |
| ngOnInit() { |
| this.gridOptions.context = { |
| ...this.gridOptions.context, |
| icons: { delete: true }, |
| }; |
| this._subscription = this.gridOptions.context.eventSubject.subscribe(event => { |
| if (event.type === 'delete') { |
| this.sandbox.deleteDistributionGroupMember(event.data.distributionGroupUuid, event.data.id); |
| } |
| }); |
| } |
| |
| public clearSearchInput() { |
| this.searchInput.nativeElement.value = ''; |
| } |
| |
| public isContactSelected(): boolean { |
| return this.searchInput.nativeElement.value && this.searchInput.nativeElement.value.trim().length > 0; |
| } |
| |
| ngOnDestroy(): void { |
| this._subscription.unsubscribe(); |
| } |
| } |