igniteui-react-core
Version:
Ignite UI React Core.
293 lines (292 loc) • 10.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 { 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
*/
export let DataSourcePropertiesComparer = /*@__PURE__*/ (() => {
class DataSourcePropertiesComparer extends Base {
constructor(a, b, c, d) {
super();
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) {
let e = new List$1(String_$type, 0);
for (let g = 0; g < a.length; g++) {
let f = a[g];
let h = this.f;
let i = true;
let j = f.split('.');
for (let k = 0; k < j.length; k++) {
let l = j[k];
let m = "[" + l + "]";
let n = false;
if (h != null) {
for (let 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);
}
let p = new Dictionary$2(String_$type, DataSourceSchemaPropertyType_$type, 0);
for (let q = 0; q < this.f.propertyNames.length; q++) {
p.item(this.f.propertyNames[q], this.f.propertyTypes[q]);
}
if (this.b != null) {
for (let 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]);
}
}
}
}
compare(a, b) {
if (this.b == null) {
if (a == b) {
return 0;
}
return -1;
}
let c = null;
let d = null;
let e = null;
let f = null;
let x_ = a;
if ((x_ != null && x_.$$isSpecialRow !== undefined)) {
e = x_;
}
let y_ = b;
if ((y_ != null && y_.$$isSpecialRow !== undefined)) {
f = y_;
}
let g = null;
let h = false;
let i = this.g;
for (let 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);
}
let 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;
}
h(a, b) {
if (this.b == null) {
for (let c = 0; c < a.length; c++) {
if (a[c] != b[c]) {
return -1;
}
}
return 0;
}
let d = null;
let e = null;
let f = false;
let g = this.g;
for (let h = 0; h < g; h++) {
f = this.a[h] == 1;
d = a[h];
e = b[h];
let i = this.j(d, e, f, this.d[h], this.c[h]);
if (i != 0) {
return i;
}
}
return 0;
}
i(a, b) {
if (this.b == null) {
if (b.length == 1) {
if (a == b[0]) {
return 0;
}
}
return -1;
}
let c = null;
let d = null;
let e = null;
let f = false;
let g = this.g;
for (let h = 0; h < g; h++) {
e = this.b[h];
f = this.a[h] == 1;
c = this.e.getItemProperty(a, e);
d = b[h];
let i = this.j(c, d, f, this.d[h], this.c[h]);
if (i != 0) {
return i;
}
}
return 0;
}
j(a, b, c, d, e) {
if (c) {
let f = a;
a = b;
b = f;
}
let 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;
let xVal_ = a;
let yVal_ = b;
xVal_ = +xVal_;
yVal_ = +yVal_;
let h = typeGetValue(xVal_);
let 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) {
let j = a;
let 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 = /*@__PURE__*/ markType(DataSourcePropertiesComparer, 'DataSourcePropertiesComparer', Base.$, [/*@__PURE__*/ IComparer$1_$type.specialize(Base.$)]);
return DataSourcePropertiesComparer;
})();