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