UNPKG

igniteui-react-core

Version:
182 lines (180 loc) 5.65 kB
import { IgrDataSourceSortDescriptionCollection } from "./igr-data-source-sort-description-collection"; import { IgrDataSourceGroupDescriptionCollection } from "./igr-data-source-group-description-collection"; import { IgrDataSourceSummaryDescriptionCollection } from "./igr-data-source-summary-description-collection"; import { IgrFilterExpressionCollection } from "./igr-filter-expression-collection"; import { TypeRegistrar } from "./type"; /** * The base class for generic data sources. */ export class IgrBaseGenericDataSource { createImplementation() { return null; } get nativeElement() { return this._implementation.nativeElement; } /** * @hidden */ get i() { return this._implementation; } /** * @hidden */ static _createFromInternal(internal) { if (!internal) { return null; } if (!internal.$type) { return null; } let name = internal.$type.name; let externalName = "Igr" + name; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); } onImplementationCreated() { } constructor() { this.mounted = false; this._implementation = this.createImplementation(); this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } } _provideImplementation(i) { this._implementation = i; this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } } /** * Gets or sets the execution context that the data source should synchronize asynchronous actions with, or use to defer delayed actions. */ get executionContext() { return this.i.t; } set executionContext(v) { this.i.t = v; } /** * Gets the current sort that is applied to the data source. */ get sortDescriptions() { const r = this.i.m; if (r == null) { return null; } if (!r.externalObject) { let e = new IgrDataSourceSortDescriptionCollection(); if (r.$type) { e._implementation = r; } else { if (e.i.setNativeElement) { e.i.setNativeElement(r); } } r.externalObject = e; } return r.externalObject; } /** * Gets the current grouping that is applied to the data source. */ get groupDescriptions() { const r = this.i.k; if (r == null) { return null; } if (!r.externalObject) { let e = new IgrDataSourceGroupDescriptionCollection(); if (r.$type) { e._implementation = r; } else { if (e.i.setNativeElement) { e.i.setNativeElement(r); } } r.externalObject = e; } return r.externalObject; } /** * Gets the current summaries that are applied to the data source. */ get summaryDescriptions() { const r = this.i.o; if (r == null) { return null; } if (!r.externalObject) { let e = new IgrDataSourceSummaryDescriptionCollection(); if (r.$type) { e._implementation = r; } else { if (e.i.setNativeElement) { e.i.setNativeElement(r); } } r.externalObject = e; } return r.externalObject; } /** * Gets the current filter that is applied to the data source. */ get filterExpressions() { const r = this.i.q; if (r == null) { return null; } if (!r.externalObject) { let e = new IgrFilterExpressionCollection(); if (r.$type) { e._implementation = r; } else { if (e.i.setNativeElement) { e.i.setNativeElement(r); } } r.externalObject = e; } return r.externalObject; } findByName(name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.sortDescriptions != null && this.sortDescriptions.findByName && this.sortDescriptions.findByName(name)) { return this.sortDescriptions.findByName(name); } if (this.groupDescriptions != null && this.groupDescriptions.findByName && this.groupDescriptions.findByName(name)) { return this.groupDescriptions.findByName(name); } if (this.summaryDescriptions != null && this.summaryDescriptions.findByName && this.summaryDescriptions.findByName(name)) { return this.summaryDescriptions.findByName(name); } if (this.filterExpressions != null && this.filterExpressions.findByName && this.filterExpressions.findByName(name)) { return this.filterExpressions.findByName(name); } return null; } /** * Called to manually queue a refresh of the data source. */ queueAutoRefresh() { this.i.z(); } }