igniteui-angular-core
Version:
Ignite UI Angular Core logic used in multiple UI components.
747 lines (746 loc) • 24.7 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends, __values } from "tslib";
import { Base, IList_$type, runOn, String_$type, EnumUtil, fromEnum, typeCast, Array_$type, markType } from "./type";
import { IDataSourceLocalDataProvider_$type } from "./IDataSourceLocalDataProvider";
import { IDataSourceSchema_$type } from "./IDataSourceSchema";
import { DataSourceSchemaPropertyType_$type } from "./DataSourceSchemaPropertyType";
import { DefaultDataSourceSchema } from "./DefaultDataSourceSchema";
import { SortDescriptionCollection } from "./SortDescriptionCollection";
import { FilterExpressionCollection } from "./FilterExpressionCollection";
import { SummaryDescriptionCollection } from "./SummaryDescriptionCollection";
import { Dictionary$2 } from "./Dictionary$2";
import { FastReflectionHelper } from "./FastReflectionHelper";
import { HashSet$1 } from "./HashSet$1";
import { DataSourceDataProviderSchemaChangedEventArgs } from "./DataSourceDataProviderSchemaChangedEventArgs";
import { List$1 } from "./List$1";
import { stringStartsWith } from "./string";
/**
* @hidden
*/
var DataSourceLocalDataProvider = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(DataSourceLocalDataProvider, _super);
function DataSourceLocalDataProvider() {
var _this = _super.call(this) || this;
_this.m = null;
_this.l = null;
_this.f = null;
_this.n = null;
_this.e = 0;
_this.z = 5;
_this.aa = null;
_this.t = new Dictionary$2(String_$type, DataSourceSchemaPropertyType_$type, 0);
_this.ac = null;
_this.schemaChanged = null;
_this.s = new Dictionary$2(String_$type, FastReflectionHelper.$, 0);
_this.u = new HashSet$1(String_$type, 0);
_this.i = null;
_this.x = null;
_this.q = false;
_this.h = null;
_this.g = null;
_this.p = false;
_this.a = null;
_this.o = false;
_this.m = new SortDescriptionCollection();
_this.m.n(runOn(_this, _this.as));
_this.l = new SortDescriptionCollection();
_this.n = new SummaryDescriptionCollection();
_this.f = new FilterExpressionCollection();
return _this;
}
DataSourceLocalDataProvider.prototype.as = function (a, b) {
this.queueAutoRefresh();
};
Object.defineProperty(DataSourceLocalDataProvider.prototype, "dataSource", {
get: function () {
return this.aa;
},
set: function (a) {
var b = this.aa;
this.aa = a;
if (b != this.aa) {
this.am("ItemsSource", b, this.aa);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "af", {
get: function () {
return this.ac;
},
set: function (a) {
var b = this.ac;
this.ac = a;
if (b != this.ac) {
this.am("SchemaHints", b, this.ac);
}
},
enumerable: false,
configurable: true
});
DataSourceLocalDataProvider.prototype.an = function () {
if (this.ac == null) {
return;
}
this.t.clear();
var a = this.ac.split(',');
for (var b = 0; b < a.length; b++) {
var c = a[b].trim().split(':');
if (c.length != 2) {
continue;
}
var d = c[0];
var e = this.c(c[1]);
this.t.addItem(d, e);
}
};
DataSourceLocalDataProvider.prototype.c = function (a) {
var b = EnumUtil.parse(DataSourceSchemaPropertyType_$type, a, true);
if (b != null) {
return EnumUtil.getEnumValue(DataSourceSchemaPropertyType_$type, b);
}
return 11;
};
DataSourceLocalDataProvider.prototype.getItemAtIndex = function (a) {
if (this.x == null) {
return null;
}
if (this.q) {
return this.x[a];
}
return this.x.item(a);
};
DataSourceLocalDataProvider.prototype.getItemValue = function (a, b) {
this.aj();
var c;
var d = this.s.tryGetValue(b, c);
c = d.p1;
if (c == null && !this.u.contains(b)) {
var e = b.split('.');
var f = a;
var g = true;
for (var h = 0; h < e.length; h++) {
f = f[e[h]];
if ((f === undefined)) {
g = false;
break;
}
}
if (g) {
c = new FastReflectionHelper(false, b);
this.s.addItem(b, c);
}
else {
this.u.add_1(b);
}
}
if (c == null) {
return null;
}
var val_ = c.getPropertyValue(a);
if ((val_ === undefined)) {
return null;
}
return val_;
};
DataSourceLocalDataProvider.prototype.setItemValue = function (a, b, c) {
this.aj();
var d;
var e = this.s.tryGetValue(b, d);
d = e.p1;
if (d == null) {
return;
}
d.setPropertyValue(a, c);
};
DataSourceLocalDataProvider.prototype.removeItem = function (a) {
if (this.x != null) {
var b = this.x.indexOf(a);
if (this.q) {
this.x.splice(b, 1);
}
else {
this.x.removeAt(b);
}
this.notifyRemoveItem(b, a);
}
};
DataSourceLocalDataProvider.prototype.addItem = function (a) {
if (this.x != null) {
var b = this.actualCount;
if (this.q) {
this.x.splice(b, 0, a);
}
else {
this.x.insert(b, a);
}
this.notifyInsertItem(this.actualCount - 1, a);
}
};
DataSourceLocalDataProvider.prototype.aj = function () {
if (this.i == null) {
this.i = this.actualSchema;
if (this.schemaChanged != null) {
this.schemaChanged(this, new DataSourceDataProviderSchemaChangedEventArgs(this.i, this.actualCount));
}
}
};
Object.defineProperty(DataSourceLocalDataProvider.prototype, "actualCount", {
get: function () {
if (this.x == null) {
return 0;
}
if (this.q) {
return (this.x.length);
}
return this.x.count;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "actualSchema", {
get: function () {
if (this.i == null) {
if (this.x == null) {
this.i = new DefaultDataSourceSchema([], [], null, null, []);
}
else {
this.i = this.k();
}
}
return this.i;
},
enumerable: false,
configurable: true
});
DataSourceLocalDataProvider.prototype.k = function () {
var a = this.ab();
if (a == null) {
return new DefaultDataSourceSchema([], [], null, null, []);
}
this.s.clear();
this.u.clear();
return this.j(a, null, 0);
};
DataSourceLocalDataProvider.prototype.j = function (a, b, c) {
var e_1, _a;
if (c >= this.z) {
return null;
}
if (a == null) {
return null;
}
if ((typeof a === 'function')) {
return null;
}
if ((Array.isArray(a))) {
return null;
}
var check_ = a;
if ((check_ instanceof HTMLElement)) {
return null;
}
var d = new List$1(String_$type, 0);
var e = new HashSet$1(String_$type, 0);
var f = new List$1(DataSourceSchemaPropertyType_$type, 0);
var g = new List$1(List$1.$.specialize(String_$type), 0);
var h = this.v(a);
var i = new List$1(IDataSourceSchema_$type, 0);
for (var j = 0; j < h.count; j++) {
var k = h._inner[j];
if (stringStartsWith(k, "_")) {
continue;
}
if (k == "$hashCode" || k == "$type") {
continue;
}
if (e.contains(k)) {
continue;
}
else {
var l = b == null ? k : b + "." + k;
d.add(k);
e.add_1(k);
this.s.addItem(l, new FastReflectionHelper(false, l));
if (this.t.containsKey(l)) {
f.add(this.t.item(l));
this.t.removeItem(l);
}
else {
f.add(this.b(a, k));
}
g.add(this.w(a, k));
if (f._inner[f.count - 1] == 11) {
i.add(this.j(a[k], l, c + 1));
}
else {
i.add(null);
}
}
}
try {
for (var _b = __values(fromEnum(this.t)), _c = _b.next(); !_c.done; _c = _b.next()) {
var m = _c.value;
var n = m.key.split('.');
for (var o = 0; o < n.length; o++) {
if (e.contains(n[o])) {
continue;
}
else {
d.add(n[o]);
e.add_1(n[o]);
f.add(o == n.length - 1 ? m.value : 11);
g.add(new List$1(String_$type, 0));
}
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
var p = new Array(g.count);
for (var q = 0; q < g.count; q++) {
p[q] = g._inner[q].toArray();
}
return new DefaultDataSourceSchema(d.toArray(), f.toArray(), null, p, i.toArray());
};
DataSourceLocalDataProvider.prototype.resolveSchemaPropertyType = function (a) {
var b = a.split('.');
if (b.length == 1) {
for (var c = 0; c < this.actualSchema.propertyNames.length; c++) {
if (this.actualSchema.propertyNames[c] == b[0]) {
return this.actualSchema.propertyTypes[c];
}
}
return 11;
}
else {
var d = this.ab();
var e = this.getItemValue(d, a);
if (e == null) {
return 11;
}
else {
return DataSourceLocalDataProvider.d(e);
}
}
};
DataSourceLocalDataProvider.prototype.ar = function (a) {
this.i = a;
if (this.schemaChanged != null) {
this.schemaChanged(this, new DataSourceDataProviderSchemaChangedEventArgs(this.i, this.actualCount));
}
};
DataSourceLocalDataProvider.prototype.v = function (schemaItem_) {
var propertyKey_ = null;
var ret_ = new List$1(String_$type, 0);
var exclusions_ = {};
for (propertyKey_ in schemaItem_) {
if (!isNaN(propertyKey_)) {
continue;
}
if (!exclusions_.hasOwnProperty(propertyKey_)) {
ret_.add(propertyKey_);
}
}
;
return ret_;
};
DataSourceLocalDataProvider.prototype.al = function (a, item_, propertyName_, b) {
if ((item_.__dataIntents !== undefined)) {
if ((item_.__dataIntents[propertyName_] !== undefined)) {
this.ak(a, item_, propertyName_);
}
var selfName_ = "self." + propertyName_;
if (!b && (item_.__dataIntents[selfName_] !== undefined)) {
this.ak(a, item_, selfName_);
}
var selfName2_ = "self_" + propertyName_;
if (!b && (item_.__dataIntents[selfName2_] !== undefined)) {
this.ak(a, item_, selfName2_);
}
}
};
DataSourceLocalDataProvider.prototype.ak = function (a, item_, propertyName_) {
var val_ = item_.__dataIntents[propertyName_];
var b = typeCast(Array_$type, val_) !== null;
if (!b) {
b = (Array.isArray(val_));
}
if (b) {
var c = val_;
for (var d = 0; d < c.length; d++) {
if (c[d] != null) {
a.add(c[d].toString());
}
}
}
};
DataSourceLocalDataProvider.prototype.w = function (item_, propertyName_) {
var a = new List$1(String_$type, 0);
var list_ = this.x;
var dataIntents_ = null;
this.al(a, item_, propertyName_, false);
this.al(a, list_, propertyName_, true);
return a;
};
DataSourceLocalDataProvider.prototype.b = function (item_, propertyName_) {
if (item_ == null) {
return 11;
}
if ((item_[propertyName_] == undefined)) {
return 11;
}
var value_ = item_[propertyName_];
return DataSourceLocalDataProvider.d(value_);
};
DataSourceLocalDataProvider.d = function (value_) {
if (value_ == null) {
return 11;
}
if ((typeof value_ == 'number')) {
return 5;
}
if ((typeof value_ == 'boolean')) {
return 2;
}
if ((typeof value_ == 'string')) {
return 0;
}
if ((typeof value_ == 'object')) {
if ((value_ instanceof Date)) {
return 8;
}
}
return 11;
};
DataSourceLocalDataProvider.prototype.ab = function () {
var a = 0;
if (this.q) {
a = (this.x.length);
}
else {
a = this.x.count;
}
for (var b = 0; b < a; b++) {
var c = void 0;
if (this.q) {
c = this.x[b];
}
else {
c = this.x.item(b);
}
if (c != null) {
return c;
}
}
return null;
};
DataSourceLocalDataProvider.prototype.am = function (a, b, c) {
this.ao(a, b, c);
};
Object.defineProperty(DataSourceLocalDataProvider.prototype, "y", {
get: function () {
return this.x;
},
enumerable: false,
configurable: true
});
DataSourceLocalDataProvider.prototype.ao = function (a, b, c) {
switch (a) {
case "ItemsSource":
this.i = null;
if (this.dataSource != null) {
this.q = false;
if (typeCast(Array_$type, this.dataSource) !== null) {
this.q = true;
this.x = this.dataSource;
}
else if (typeCast(IList_$type, this.dataSource) !== null) {
this.x = this.dataSource;
}
if (!this.q && this.x == null) {
var source_ = this.dataSource;
this.q = (Array.isArray(source_));
if (this.q) {
this.x = this.dataSource;
}
}
}
else {
this.x = null;
}
this.aj();
break;
case "DeferAutoRefresh":
if (!c) {
this.queueAutoRefresh();
}
break;
case "SchemaHints":
this.i = null;
this.an();
this.aj();
break;
}
};
Object.defineProperty(DataSourceLocalDataProvider.prototype, "executionContext", {
get: function () {
return this.h;
},
set: function (a) {
this.h = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "r", {
get: function () {
return false;
},
enumerable: false,
configurable: true
});
DataSourceLocalDataProvider.prototype.notifySetItem = function (a, b, c) {
if (this.r) {
if (this.q) {
this.x[a] = c;
}
else {
this.x.item(a, c);
}
}
if (this.updateNotifier != null) {
this.updateNotifier.notifySetItem(a, b, c);
}
};
DataSourceLocalDataProvider.prototype.notifyClearItems = function () {
if (this.r) {
if (this.q) {
this.x.length = 0;
}
else {
this.x.clear();
}
}
if (this.updateNotifier != null) {
this.updateNotifier.notifyClearItems();
}
};
DataSourceLocalDataProvider.prototype.notifyInsertItem = function (a, b) {
if (this.r) {
if (this.q) {
this.x.splice(a, 0, b);
}
else {
this.x.insert(a, b);
}
}
var c = 0;
if (this.q) {
c = (this.x.length);
}
else {
c = this.x.count;
}
if (this.x != null && c == 1 && (this.actualSchema == null || this.actualSchema.propertyNames.length == 0)) {
this.i = null;
this.aj();
}
if (this.updateNotifier != null) {
this.updateNotifier.notifyInsertItem(a, b);
}
};
DataSourceLocalDataProvider.prototype.notifyRemoveItem = function (a, b) {
if (this.r) {
if (this.q) {
this.x.splice(a, 1);
}
else {
this.x.remove(a);
}
}
if (this.updateNotifier != null) {
this.updateNotifier.notifyRemoveItem(a, b);
}
};
Object.defineProperty(DataSourceLocalDataProvider.prototype, "updateNotifier", {
get: function () {
return this.g;
},
set: function (a) {
this.g = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "deferAutoRefresh", {
get: function () {
return this.p;
},
set: function (a) {
var b = this.p;
this.p = a;
if (this.p != b) {
this.am("DeferAutoRefresh", b, this.p);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "isSortingSupported", {
get: function () {
return false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "isFilteringSupported", {
get: function () {
return false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "sortDescriptions", {
get: function () {
return this.m;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "filterExpressions", {
get: function () {
return this.f;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "summaryDescriptions", {
get: function () {
return this.n;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "summaryScope", {
get: function () {
return this.e;
},
set: function (a) {
this.e = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "notifyUsingSourceIndexes", {
get: function () {
return true;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "propertiesRequested", {
get: function () {
return this.a;
},
set: function (a) {
var b = this.a;
this.a = a;
if (b != this.a) {
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "isItemIndexLookupSupported", {
get: function () {
return true;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "isKeyIndexLookupSupported", {
get: function () {
return false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "isGroupingSupported", {
get: function () {
return false;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataSourceLocalDataProvider.prototype, "groupDescriptions", {
get: function () {
return this.l;
},
enumerable: false,
configurable: true
});
DataSourceLocalDataProvider.prototype.queueAutoRefresh = function () {
if (this.deferAutoRefresh) {
return;
}
if (this.o) {
return;
}
if (this.executionContext != null) {
this.o = true;
this.executionContext.enqueueAction(runOn(this, this.ai));
}
};
DataSourceLocalDataProvider.prototype.ai = function () {
if (this.deferAutoRefresh) {
this.o = false;
return;
}
if (!this.o) {
return;
}
this.o = false;
this.ap();
};
DataSourceLocalDataProvider.prototype.ap = function () {
this.aq();
};
DataSourceLocalDataProvider.prototype.aq = function () {
};
DataSourceLocalDataProvider.prototype.flushAutoRefresh = function () {
this.ai();
};
DataSourceLocalDataProvider.prototype.refresh = function () {
this.ap();
};
DataSourceLocalDataProvider.prototype.indexOfItem = function (a) {
if (this.x == null) {
return -1;
}
return this.x.indexOf(a);
};
DataSourceLocalDataProvider.prototype.indexOfKey = function (a) {
return -1;
};
DataSourceLocalDataProvider.$t = markType(DataSourceLocalDataProvider, 'DataSourceLocalDataProvider', Base.$, [IDataSourceLocalDataProvider_$type]);
return DataSourceLocalDataProvider;
}(Base));
export { DataSourceLocalDataProvider };