blob: 985bdc28956d99943c08d623454c713e0271f4b4 [file] [log] [blame]
import { PERSON_TYPES_COLDEF } from '@pages/admin/person-types/person-types-list/person-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 { PersonTypesSandbox } from '@pages/admin/person-types/person-types.sandbox';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-person-types-list',
templateUrl: './person-types-list.component.html',
styleUrls: ['./person-types-list.component.scss']
})
export class PersonTypesListComponent extends BaseList implements OnInit, OnDestroy {
public columnDefinition: any = PERSON_TYPES_COLDEF;
public frameworkComponents: { setFilterComponent: any };
private _subscription: Subscription;
constructor(public sandbox: PersonTypesSandbox) {
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') {
this.sandbox.setDisplayForm();
this.sandbox.loadPersonType(event.data.id);
}
if (event.type === 'delete') {
this.sandbox.deletePersonType(event.data.id);
}
});
}
ngOnDestroy() {
this._subscription.unsubscribe();
}
}