igniteui-angular-core
Version:
Ignite UI Angular Core logic used in multiple UI components.
210 lines (208 loc) • 7.56 kB
JavaScript
import { IgxDataSourceSortDescriptionCollection } from "./igx-data-source-sort-description-collection";
import { IgxDataSourceGroupDescriptionCollection } from "./igx-data-source-group-description-collection";
import { IgxDataSourceSummaryDescriptionCollection } from "./igx-data-source-summary-description-collection";
import { IgxFilterExpressionCollection } from "./igx-filter-expression-collection";
import { TypeRegistrar } from "./type";
/**
* The base class for generic data sources.
*/
var IgxBaseGenericDataSource = /** @class */ /*@__PURE__*/ (function () {
function IgxBaseGenericDataSource() {
this._zoneRunner = null;
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
IgxBaseGenericDataSource.prototype.createImplementation = function () {
return null;
};
Object.defineProperty(IgxBaseGenericDataSource.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgxBaseGenericDataSource._createFromInternal = function (internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
var name = internal.$type.name;
var externalName = "Igx" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
};
IgxBaseGenericDataSource.prototype.onImplementationCreated = function () {
};
IgxBaseGenericDataSource.prototype._provideImplementation = function (i) {
this._implementation = i;
this._implementation.externalObject = this;
this.onImplementationCreated();
};
Object.defineProperty(IgxBaseGenericDataSource.prototype, "executionContext", {
/**
* Gets or sets the execution context that the data source should synchronize asynchronous actions with, or use to defer delayed actions.
*/
get: function () {
return this.i.t;
},
set: function (v) {
this.i.t = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxBaseGenericDataSource.prototype, "sortDescriptions", {
/**
* Gets the current sort that is applied to the data source.
*/
get: function () {
var r = this.i.m;
if (r == null) {
return null;
}
if (!r.externalObject) {
var e = new IgxDataSourceSortDescriptionCollection();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxBaseGenericDataSource.prototype, "groupDescriptions", {
/**
* Gets the current grouping that is applied to the data source.
*/
get: function () {
var r = this.i.k;
if (r == null) {
return null;
}
if (!r.externalObject) {
var e = new IgxDataSourceGroupDescriptionCollection();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxBaseGenericDataSource.prototype, "summaryDescriptions", {
/**
* Gets the current summaries that are applied to the data source.
*/
get: function () {
var r = this.i.o;
if (r == null) {
return null;
}
if (!r.externalObject) {
var e = new IgxDataSourceSummaryDescriptionCollection();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxBaseGenericDataSource.prototype, "filterExpressions", {
/**
* Gets the current filter that is applied to the data source.
*/
get: function () {
var r = this.i.q;
if (r == null) {
return null;
}
if (!r.externalObject) {
var e = new IgxFilterExpressionCollection();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
},
enumerable: false,
configurable: true
});
IgxBaseGenericDataSource.prototype.findByName = function (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.
*/
IgxBaseGenericDataSource.prototype.queueAutoRefresh = function () {
this.i.z();
};
IgxBaseGenericDataSource.prototype._runInZone = function (act) {
if (this._zoneRunner != null) {
this._zoneRunner(act);
}
else {
act();
}
};
return IgxBaseGenericDataSource;
}());
export { IgxBaseGenericDataSource };