import { EventEmitter, OnInit } from '@angular/core'; import { Observable, Subscription } from 'rxjs'; import { ListErrorType } from '../../enums'; import { ListParameters } from '../../interfaces'; import { ListObject } from '../../models'; import { CoreService } from '../../services/core.service'; import { PaginatableComponent } from '../paginatable/paginatable.component'; /** * This is the abstract main component base of the list components. * It has the most features, that is necessary for a listing component. * * @export * @abstract * @class ListComponent * @extends {BaseComponent} * @template T Type of the selected list objects. */ export declare abstract class ListComponent extends PaginatableComponent implements OnInit { protected readonly coreService: CoreService; /** * Public getter of the error state. * * @readonly * @type {boolean} * @memberof ListComponent */ readonly hasError: boolean; /** * This getter gives the object, that contains: Filters, orders, searchtext, paginator datas * for the API call. This can be used as query data. * * @readonly * @protected * @type {object} * @memberof ListComponent */ protected readonly parameters: ListParameters; /** * This variable stores the array of T instances. * * @memberof ListComponent * @type T[] * @default null */ list?: T[]; /** * This property stores the type of the previous error. * * @type {ListErrorType} * @memberof ListComponent */ errorType: ListErrorType; /** * This property represents the searching text. * * @type {string} * @memberof ListComponent */ searchText: string; /** * This event fires, when the list is loaded. * * @type {EventEmitter} * @memberof ListComponent */ onListLoaded: EventEmitter; /** * This subscription stores the loding observable of the list. * * @protected * @type {Subscription} * @memberof ListComponent */ protected subscription: Subscription; /** * This variable shows if there is any error happend lately. * * @memberof ListComponent * @type boolean * @default false */ private error; /** * Creates an instance of ListComponent. * @memberof ListComponent */ constructor(coreService: CoreService); /** * Sets the searchText * * @param {string} value * @memberof ListComponent */ setSearchText(value: string): void; /** * A lifecycle hook that is called after Angular has initialized all data-bound properties of a directive. * Define an ngOnInit() method to handle any additional initialization tasks. * * @memberof ListComponent */ ngOnInit(): void; /** * This function reloads the list content. This can be called from the search input. * * @memberof ListComponent */ onChange(): void; /** * This is the must have function of this component. This contains the main source of the model list. * * @protected * @abstract * @returns {Observable>} * @memberof ListComponent */ protected abstract getList(): Observable | T[]>; /** * This function loads the list from the API call. * * @protected * @memberof ListComponent */ protected loadList(): void; /** * This function fills the list property and stops the loader. * * @private * @param {ListObject} response * @memberof ListComponent */ private setList; /** * Simple error handler. * * @private * @param {any} error Error * @param {ListErrorType} errorType Type of error * @memberof ListComponent */ private errorHandler; } /** * This interface contains the optional functions of the ListComponent * * @export * @interface ListComponent * @template T */ export interface ListComponent { /** * @returns {EventEmitter>} * @memberof ListComponent */ onListChanged?(): EventEmitter>; /** * This function calls, when the list is loaded. * * @memberof ListComponent */ afterListLoaded?(): void; }