blob: 5610e4e1c8c3e2a97e4024cf721f363218fcae02 [file] [log] [blame]
/********************************************************************************
* 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 { CommunicationTypesSandbox } from '@pages/admin/communication-types/communication-types.sandbox';
import { COMMUNICATION_TYPES_COLDEF } from '@pages/admin/communication-types/communication-types-list/communication-types-list-column-definition';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { BaseList } from '@shared/components/base-components/base.list';
import { SetFilterComponent } from '@shared/filters/ag-grid/set-filter/set-filter.component';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-communication-types-list',
templateUrl: './communication-types-list.component.html',
styleUrls: ['./communication-types-list.component.scss'],
})
export class CommunicationTypesListComponent extends BaseList implements OnInit, OnDestroy {
public columnDefinition: any = COMMUNICATION_TYPES_COLDEF;
public frameworkComponents: { setFilterComponent: any };
private _subscription: Subscription;
constructor(public communicationTypesSandbox: CommunicationTypesSandbox) {
super();
this.frameworkComponents = { setFilterComponent: SetFilterComponent };
}
ngOnInit() {
this.gridOptions.context = {
...this.gridOptions.context,
icons: { edit: true, readonly: true, delete: true },
};
this._subscription = this.gridOptions.context.eventSubject.subscribe(event => {
if (event.type === 'edit' || event.type === 'readonly') {
this.communicationTypesSandbox.setDisplayForm(event.type);
this.communicationTypesSandbox.loadCommunicationType(event.data.id);
}
if (event.type === 'delete') {
this.communicationTypesSandbox.deleteCommunicationType(event.data.id);
}
});
}
ngOnDestroy() {
this._subscription.unsubscribe();
}
}