UNPKG

igniteui-webcomponents-datasources

Version:

Reference custom data providers for the Ignite UI Web Components data source.

74 lines (73 loc) 3.01 kB
import { DataSourceSchemaPropertyType } from "igniteui-webcomponents-core"; var RestVirtualDataSourcePage = /** @class */ /*@__PURE__*/ (function () { function RestVirtualDataSourcePage(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_.items.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_.items[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; } RestVirtualDataSourcePage.prototype.count = function () { return this._actualData.length; }; RestVirtualDataSourcePage.prototype.getItemAtIndex = function (index) { return this._actualData[index]; }; RestVirtualDataSourcePage.prototype.getItemValueAtIndex = function (index, valueName) { var item = this._actualData[index]; if (!item.has(valueName)) { return null; } return item.get(valueName); }; RestVirtualDataSourcePage.prototype.pageIndex = function () { return this._pageIndex; }; RestVirtualDataSourcePage.prototype.schema = function () { return this._schema; }; RestVirtualDataSourcePage.prototype.getGroupInformation = function () { return this._groupInformation; }; RestVirtualDataSourcePage.prototype.getSummaryInformation = function () { return this._summaryInformation; }; return RestVirtualDataSourcePage; }()); export { RestVirtualDataSourcePage };