UNPKG

@rxap/data-source

Version:

Provides a set of classes and decorators for creating and managing data sources in Angular applications, including base classes, static data sources, observable data sources, and method data sources. It also includes a component for displaying data source

93 lines (88 loc) 4.4 kB
import * as i0 from '@angular/core'; import { Directive, Input } from '@angular/core'; import { AbstractTableDataSource, RxapTableDataSourceError, DynamicTableDataSource } from '@rxap/data-source/table'; import { DataSourceCollectionDirective } from '@rxap/data-source/directive'; import 'rxjs'; class TableDataSourceDirective extends DataSourceCollectionDirective { constructor() { super(...arguments); this.viewer = { id: '[rxapTableDataSource]' }; } set rxapTableDataSourceTrackBy(fn) { this.rxapDataSourceCollectionTrackBy = fn; } loadDataSource() { const dataSource = super.loadDataSource(); if (dataSource) { if (!(dataSource instanceof AbstractTableDataSource)) { throw new RxapTableDataSourceError('The data source is not a AbstractTableDataSource', ''); } if (this.viewer.id && dataSource instanceof DynamicTableDataSource) { dataSource.setPaginator(this.paginator, this.viewer.id); dataSource.setSort(this.sort, this.viewer.id); dataSource.setFilter(this.filter, this.viewer.id); dataSource.setParameters(this.parameters, this.viewer.id); } else { if (dataSource.paginator !== this.paginator) { dataSource.paginator = this.paginator; } if (dataSource.sort !== this.sort) { dataSource.sort = this.sort; } if (dataSource.filter !== this.filter) { dataSource.filter = this.filter; } if (dataSource.parameters !== this.parameters) { dataSource.parameters = this.parameters; } } } return dataSource; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: TableDataSourceDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.16", type: TableDataSourceDirective, isStandalone: true, selector: "[rxapTableDataSource]", inputs: { paginator: ["rxapTableDataSourcePaginator", "paginator"], sort: ["rxapTableDataSourceSort", "sort"], parameters: ["rxapTableDataSourceParameters", "parameters"], filter: ["rxapTableDataSourceFilter", "filter"], dataSourceOrIdOrToken: ["rxapTableDataSourceFrom", "dataSourceOrIdOrToken"], viewer: ["rxapTableDataSourceViewer", "viewer"], emptyTemplate: ["rxapTableDataSourceEmpty", "emptyTemplate"], errorTemplate: ["rxapTableDataSourceErrorTemplate", "errorTemplate"], rxapTableDataSourceTrackBy: "rxapTableDataSourceTrackBy" }, usesInheritance: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: TableDataSourceDirective, decorators: [{ type: Directive, args: [{ selector: '[rxapTableDataSource]', standalone: true, }] }], propDecorators: { paginator: [{ type: Input, args: ['rxapTableDataSourcePaginator'] }], sort: [{ type: Input, args: ['rxapTableDataSourceSort'] }], parameters: [{ type: Input, args: ['rxapTableDataSourceParameters'] }], filter: [{ type: Input, args: ['rxapTableDataSourceFilter'] }], dataSourceOrIdOrToken: [{ type: Input, args: [{ required: true, alias: 'rxapTableDataSourceFrom', }] }], viewer: [{ type: Input, args: ['rxapTableDataSourceViewer'] }], emptyTemplate: [{ type: Input, args: ['rxapTableDataSourceEmpty'] }], errorTemplate: [{ type: Input, args: ['rxapTableDataSourceErrorTemplate'] }], rxapTableDataSourceTrackBy: [{ type: Input }] } }); // region // endregion /** * Generated bundle index. Do not edit. */ export { TableDataSourceDirective }; //# sourceMappingURL=rxap-data-source-table-directives.mjs.map