igniteui-react-core
Version:
Ignite UI React Core.
295 lines (294 loc) • 9.96 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 } from "tslib";
import { Base, String_$type, typeGetValue, markType } from "./type";
import { IComparer$1_$type } from "./IComparer$1";
import { Dictionary$2 } from "./Dictionary$2";
import { DataSourceSchemaPropertyType_$type } from "./DataSourceSchemaPropertyType";
import { List$1 } from "./List$1";
import { boolCompare } from "./bool";
import { dateMinValue } from "./date";
import { CompareUtil } from "./compareUtil";
import { stringCompare } from "./string";
/**
* @hidden
*/
var DataSourcePropertiesComparer = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(DataSourcePropertiesComparer, _super);
function DataSourcePropertiesComparer(a, b, c, d) {
var _this = _super.call(this) || this;
_this.e = null;
_this.b = null;
_this.a = null;
_this.g = 0;
_this.f = null;
_this.d = null;
_this.c = null;
_this.a = b;
_this.e = d;
_this.f = d.actualSchema;
if (a != null) {
var e = new List$1(String_$type, 0);
for (var g = 0; g < a.length; g++) {
var f = a[g];
var h = _this.f;
var i = true;
var j = f.split('.');
for (var k = 0; k < j.length; k++) {
var l = j[k];
var m = "[" + l + "]";
var n = false;
if (h != null) {
for (var o = 0; o < h.propertyNames.length; o++) {
if (l == h.propertyNames[o] || m == h.propertyNames[o]) {
n = true;
if (h.subSchemas != null && h.subSchemas.length > o) {
h = h.subSchemas[o];
}
else {
h = null;
}
break;
}
}
}
if (!n) {
i = false;
break;
}
}
if (i) {
e.add(f);
}
}
a = e.toArray();
}
_this.b = a;
if (_this.b != null) {
_this.g = _this.b.length;
}
if (_this.b != null) {
_this.d = new Array(_this.g);
}
_this.c = c;
if (_this.c == null) {
_this.c = new Array(_this.g);
}
var p = new Dictionary$2(String_$type, DataSourceSchemaPropertyType_$type, 0);
for (var q = 0; q < _this.f.propertyNames.length; q++) {
p.item(_this.f.propertyNames[q], _this.f.propertyTypes[q]);
}
if (_this.b != null) {
for (var r = 0; r < _this.b.length; r++) {
if (p.containsKey(_this.b[r])) {
_this.d[r] = p.item(_this.b[r]);
}
else {
_this.d[r] = d.resolveSchemaPropertyType(_this.b[r]);
}
}
}
return _this;
}
DataSourcePropertiesComparer.prototype.compare = function (a, b) {
if (this.b == null) {
if (a == b) {
return 0;
}
return -1;
}
var c = null;
var d = null;
var e = null;
var f = null;
var x_ = a;
if ((x_ != null && x_.$$isSpecialRow !== undefined)) {
e = x_;
}
var y_ = b;
if ((y_ != null && y_.$$isSpecialRow !== undefined)) {
f = y_;
}
var g = null;
var h = false;
var i = this.g;
for (var j = 0; j < i; j++) {
g = this.b[j];
h = this.a[j] == 1;
if (e != null && e.rowType == 4) {
return 1;
}
if (e != null) {
c = e.getValue(g);
}
else {
c = this.e.getItemProperty(a, g);
}
if (f != null) {
d = f.getValue(g);
}
else {
d = this.e.getItemProperty(b, g);
}
var k = this.j(c, d, h, this.d[j], this.c[j]);
if (j == i - 1) {
if (e != null && e.rowType == 5 && k == 0) {
if (this.e.isSectionSummaryRowsAtBottom) {
k = h ? -1 : 1;
}
else {
k = h ? 1 : -1;
}
}
}
if (k != 0) {
return k;
}
}
return 0;
};
DataSourcePropertiesComparer.prototype.h = function (a, b) {
if (this.b == null) {
for (var c = 0; c < a.length; c++) {
if (a[c] != b[c]) {
return -1;
}
}
return 0;
}
var d = null;
var e = null;
var f = false;
var g = this.g;
for (var h = 0; h < g; h++) {
f = this.a[h] == 1;
d = a[h];
e = b[h];
var i = this.j(d, e, f, this.d[h], this.c[h]);
if (i != 0) {
return i;
}
}
return 0;
};
DataSourcePropertiesComparer.prototype.i = function (a, b) {
if (this.b == null) {
if (b.length == 1) {
if (a == b[0]) {
return 0;
}
}
return -1;
}
var c = null;
var d = null;
var e = null;
var f = false;
var g = this.g;
for (var h = 0; h < g; h++) {
e = this.b[h];
f = this.a[h] == 1;
c = this.e.getItemProperty(a, e);
d = b[h];
var i = this.j(c, d, f, this.d[h], this.c[h]);
if (i != 0) {
return i;
}
}
return 0;
};
DataSourcePropertiesComparer.prototype.j = function (a, b, c, d, e) {
if (c) {
var f = a;
a = b;
b = f;
}
var g = 0;
switch (d) {
case 2:
a = a == null ? false : a;
b = b == null ? false : b;
g = boolCompare(a, b);
break;
case 8:
a = a == null ? dateMinValue() : a;
b = b == null ? dateMinValue() : b;
var xVal_ = a;
var yVal_ = b;
xVal_ = +xVal_;
yVal_ = +yVal_;
var h = typeGetValue(xVal_);
var i = typeGetValue(yVal_);
g = Base.compareSimple(h, i);
break;
case 5:
a = a == null ? -1.7976931348623157E+308 : a;
b = b == null ? -1.7976931348623157E+308 : b;
g = Base.compareSimple(a, b);
break;
case 10:
a = a == null ? 0 : a;
b = b == null ? 0 : b;
g = Base.compareSimple(a, b);
break;
case 6:
a = a == null ? -7.9228162514264338E+28 : a;
b = b == null ? -7.9228162514264338E+28 : b;
g = Base.compareSimple(a, b);
break;
case 7:
a = a == null ? -3.4028230607370965E+38 : a;
b = b == null ? -3.4028230607370965E+38 : b;
g = Base.compareSimple(b, b);
break;
case 1:
a = a == null ? -2147483648 : a;
b = b == null ? -2147483648 : b;
g = Base.compareSimple((typeGetValue(a)), typeGetValue(b));
break;
case 3:
a = a == null ? -9.2233720368547758E+18 : a;
b = b == null ? -9.2233720368547758E+18 : b;
g = Base.compareSimple((typeGetValue(a)), typeGetValue(b));
break;
case 11:
if (e) {
var j = a;
var k = b;
if (j != null) {
g = CompareUtil.compareToObject(j, k);
}
else if (k != null) {
g = -1;
}
else {
g = 0;
}
}
else {
a = a == null ? "" : a;
b = b == null ? "" : b;
g = stringCompare(a.toString(), b.toString());
}
break;
case 4:
a = a == null ? -32768 : a;
b = b == null ? -32768 : b;
g = Base.compareSimple((typeGetValue(a)), typeGetValue(b));
break;
case 0:
a = a == null ? "" : a;
b = b == null ? "" : b;
g = stringCompare(a, b);
break;
}
return g;
};
DataSourcePropertiesComparer.$t = markType(DataSourcePropertiesComparer, 'DataSourcePropertiesComparer', Base.$, [IComparer$1_$type.specialize(Base.$)]);
return DataSourcePropertiesComparer;
}(Base));
export { DataSourcePropertiesComparer };