igniteui-webcomponents-datasources
Version:
Reference custom data providers for the Ignite UI Web Components data source.
74 lines (73 loc) • 2.94 kB
JavaScript
import { DataSourceSchemaPropertyType } from "igniteui-webcomponents-core";
var ODataDataSourcePage = /** @class */ /*@__PURE__*/ (function () {
function ODataDataSourcePage(sourceData_, schema, groupInformation, summaryInformation, pageIndex) {
this._actualData = null;
this._schema = null;
this._pageIndex = 0;
this._groupInformation = null;
this._summaryInformation = null;
if (sourceData_ == null) {
this._actualData = null;
}
else {
var count = (sourceData_.value.length);
this._actualData = [];
var dateProps = new Set();
for (var i = 0; i < schema.propertyNames.length; i++) {
if (schema.propertyTypes[i] == DataSourceSchemaPropertyType.DateTimeValue || schema.propertyTypes[i] == DataSourceSchemaPropertyType.DateTimeOffsetValue) {
dateProps.add(schema.propertyNames[i]);
}
}
var value_ = void 0;
var _loop_1 = function (i_) {
var currItem_ = sourceData_.value[i_];
var dict = new Map();
var properties = Array.from(Object.keys(currItem_));
var values = (properties.map(function (k) { return currItem_[k]; }));
for (var i1 = 0; i1 < properties.length; i1++) {
value_ = values[i1];
if (dateProps.has(properties[i1])) {
value_ = new Date(value_);
}
dict.set(properties[i1], value_);
}
this_1._actualData[i_] = dict;
};
var this_1 = this;
for (var i_ = 0; i_ < count; i_++) {
_loop_1(i_);
}
}
this._schema = schema;
this._groupInformation = groupInformation;
this._summaryInformation = summaryInformation;
this._pageIndex = pageIndex;
}
ODataDataSourcePage.prototype.count = function () {
return this._actualData.length;
};
ODataDataSourcePage.prototype.getItemAtIndex = function (index) {
return this._actualData[index];
};
ODataDataSourcePage.prototype.getItemValueAtIndex = function (index, valueName) {
var item = this._actualData[index];
if (!item.has(valueName)) {
return null;
}
return item.get(valueName);
};
ODataDataSourcePage.prototype.pageIndex = function () {
return this._pageIndex;
};
ODataDataSourcePage.prototype.schema = function () {
return this._schema;
};
ODataDataSourcePage.prototype.getGroupInformation = function () {
return this._groupInformation;
};
ODataDataSourcePage.prototype.getSummaryInformation = function () {
return this._summaryInformation;
};
return ODataDataSourcePage;
}());
export { ODataDataSourcePage };