igniteui-react-grids
Version:
Ignite UI React grid components.
495 lines (494 loc) • 16.6 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 { GridColumnOptionsViewBase } from "./GridColumnOptionsViewBase";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
import { GridColumnOptionsUtilities } from "./GridColumnOptionsUtilities";
import { EventArgs, runOn, delegateCombine, markType, enumGetBox, fromEnum, toNullable, typeCast } from "igniteui-react-core";
import { Size } from "igniteui-react-core";
import { GridColumnOptionsSectionBase } from "./GridColumnOptionsSectionBase";
import { StringComparer } from "igniteui-react-core";
import { ColumnComparisonConditionOperatorType_$type } from "./ColumnComparisonConditionOperatorType";
import { List$1 } from "igniteui-react-core";
import { ColumnComparisonFilterCondition } from "./ColumnComparisonFilterCondition";
import { PrimaryKeyValue } from "./PrimaryKeyValue";
import { ColumnFilterConditionGroup } from "./ColumnFilterConditionGroup";
import { SortDescription } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { nullableEquals } from "igniteui-react-core";
/**
* @hidden
*/
export let GridColumnFilterOptionsView = /*@__PURE__*/ (() => {
class GridColumnFilterOptionsView extends GridColumnOptionsViewBase {
constructor() {
super(...arguments);
this.y = null;
this.z = null;
this.u = null;
this.x = null;
this.aa = null;
this.t = null;
this.v = null;
this.w = null;
this.q = null;
this.o = null;
this.p = null;
this.applyButtonClick = null;
this.cancelButtonClick = null;
}
m() {
super.m();
let a = this.n;
a.bh(this.q);
a.bh(this.o);
a.bh(this.p);
if (null != this.w && null != this.x) {
this.w.setStyleProperty("padding-bottom", "5px");
this.w.setStyleProperty("margin", "0 -8px");
switch (this.q.q) {
case 2:
this.x.setStyleProperty("margin", "0 -.25rem");
break;
case 1:
case 4:
case 3:
this.x.setStyleProperty("margin", "0 -.5rem");
break;
}
this.x.setRawText(a.b7);
this.x.setStyleProperty("font", a.aa.fontString);
}
if (null != this.aa) {
this.aa.setRawText(a.cg);
this.aa.setStyleProperty("font", a.aa.fontString);
GridColumnOptionsUtilities.j(this.aa, false);
}
}
get n() {
return this.b;
}
al(a) {
if (this.o != null) {
this.o.disabled = !a;
}
}
am(a) {
if (null != this.q) {
this.q.disabled = !a;
}
}
ah(a) {
let b = this.e;
let c = this.n;
this.y = a;
let d;
let e;
this.w = ((() => { let f = GridColumnOptionsUtilities.f(this.n, b, GridColumnFilterOptionsView.ab, 1, c.p, c.j, new Size(1, 24, 24), this.q, d, this.x, e, false, true); this.q = f.p7; d = f.p8; this.x = f.p9; e = f.p10; return f.ret; })());
let f = this.q;
f.clicked = delegateCombine(f.clicked, runOn(this, this.ae));
this.y.append(this.w);
}
aj(a) {
let b = this.e;
this.z = a;
this.aa = b.createElement("span");
this.aa.setRawText(this.n.cg);
this.z.append(this.aa);
}
ai(a) {
}
ak(a) {
this.h(a);
}
af() {
if (null != this.applyButtonClick) {
this.applyButtonClick(this, EventArgs.empty);
}
}
ag() {
if (null != this.cancelButtonClick) {
this.cancelButtonClick(this, EventArgs.empty);
}
}
ac(a, b) {
this.af();
}
ad(a, b) {
this.ag();
}
ae(a, b) {
this.n.cl();
}
}
GridColumnFilterOptionsView.$t = /*@__PURE__*/ markType(GridColumnFilterOptionsView, 'GridColumnFilterOptionsView', GridColumnOptionsViewBase.$);
GridColumnFilterOptionsView.ab = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";
return GridColumnFilterOptionsView;
})();
/**
* @hidden
*/
export let GridColumnFilterOptions = /*@__PURE__*/ (() => {
class GridColumnFilterOptions extends GridColumnOptionsSectionBase {
constructor() {
super();
this.bx = null;
this.b6 = "Clear column filters";
this.cb = "Search";
this.bz = 0;
this.by = 0;
this.cf = "Text filter";
}
f() {
return new GridColumnFilterOptionsView();
}
bs() {
if (null == this.column) {
return false;
}
if (this.c != null && this.c.filterUIType != 0) {
return false;
}
if (!this.column.jn) {
return false;
}
if (this.c == null || this.c.actualDataSource == null || !this.c.actualDataSource.isGroupingSupported || !this.c.actualDataSource.isFilteringSupported) {
return false;
}
if (this.c.isPagerVisible && this.c.pager != null) {
let a = this.c.pager.actualDataSource;
if (a == null || !a.isGroupingSupported || !a.isFilteringSupported) {
return false;
}
}
return true;
}
a6() {
super.a6();
this.co();
this.cu();
}
a7(a, b) {
super.a7(a, b);
switch (b.propertyName) {
case "Filter":
this.cu();
break;
}
}
onViewInitialized() {
super.onViewInitialized();
}
be(a, b, c) {
super.be(a, b, c);
switch (a) {
case "ClearColumnFiltersCaption":
case "TextFilterCaption":
this.bw.m();
break;
case "ActualBaseTheme":
case "ActualDensity":
case "ActualFilterListDensity":
case "FilterListPlaceholderText":
case "BackgroundColor":
case "TextColor":
this.cw();
break;
case "FilterListDensity":
this.b0 = this.b2 == 0 ? this.q : this.b2;
break;
}
}
bt() {
this.cj();
}
get bw() {
return this.e;
}
get b7() {
return this.b6;
}
set b7(a) {
if (0 == StringComparer.b.compare(a, this.b6)) {
return;
}
let b = this.b6;
this.b6 = a;
this.bc("ClearColumnFiltersCaption", b, this.b6);
}
get cc() {
return this.cb;
}
set cc(a) {
if (0 == StringComparer.b.compare(a, this.cb)) {
return;
}
let b = this.cb;
this.cb = a;
this.bc("FilterListPlaceholderText", b, this.cb);
}
get b2() {
return this.bz;
}
set b2(a) {
let b = this.bz;
this.bz = a;
if (b != this.bz) {
this.bc("FilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
}
}
get b0() {
return this.by;
}
set b0(a) {
let b = this.by;
this.by = a;
if (b != this.by) {
this.bc("ActualFilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
}
}
get cg() {
return this.cf;
}
set cg(a) {
if (0 == StringComparer.b.compare(a, this.cf)) {
return;
}
let b = this.cf;
this.cf = a;
this.bc("TextFilterCaption", b, this.cf);
}
cu() {
let a = this.bx.ap();
this.bw.al(!a);
let b = this.b3();
this.bw.am(b);
}
cj() {
if (0 == this.bx.keys.count) {
this.cl();
return;
}
let a;
let b;
if (this.bx.indexType == 0) {
b = false;
a = 1;
}
else {
b = true;
a = 0;
}
let c = new List$1(ColumnComparisonFilterCondition.$, 0);
let d = this.bx.keys;
for (let e = 0; e < d.count; e++) {
let f = d._inner[e];
let g = f.value[0];
let h = GridColumnFilterOptions.bv(a, g);
c.add(h);
}
if (c.count == 1) {
this.column.g1 = c._inner[0];
}
else {
let i = new ColumnFilterConditionGroup();
i.usesOrOperator = b;
for (let j of fromEnum(c)) {
i.add(j);
}
this.column.g1 = i;
}
this.column.mz("Filtered");
}
provideClearFiltersSection(a) {
this.bw.ah(a);
}
provideFilterSection(a) {
this.bw.aj(a);
}
provideFilterCheckboxListSection(a) {
this.bx = a;
this.cw();
let b = this.bx;
b.selectAllCheckboxChanged = delegateCombine(b.selectAllCheckboxChanged, runOn(this, this.ck));
let c = this.bx;
c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.cn));
}
provideFilterButtonSection(a) {
this.bw.ai(a);
}
provideMainDiv(a) {
this.bw.ak(a);
}
cl() {
this.column.g1 = null;
this.cv();
}
static bv(a, b) {
let c = new ColumnComparisonFilterCondition();
c.operator = a;
c.value = b;
return c;
}
b3() {
let a = this.column;
if (null == a) {
return false;
}
return null != a.g1;
}
co() {
let a = this.column;
let b = this.c;
let c = (null != a) ? a.lo : null;
let d = null;
let e = null;
if (b != null) {
if (b.isPagerVisible && b.pager != null && b.pager.actualDataSource != null) {
d = b.pager.actualDataSource;
e = b.pager.actualDataSource.clone();
}
else {
d = b.actualDataSource;
e = b.actualDataSource.clone();
}
}
if (null != e) {
this.cx(d, e);
e.summaryDescriptions.clear();
e.sortDescriptions.clear();
e.groupDescriptions.clear();
let f = new SortDescription();
f.propertyName = c;
f.direction = 0;
e.groupDescriptions.add(f);
let g = b.z(a);
let h = e.filterExpressions;
for (let i = h.k.count - 1; i >= 0; i--) {
let j = h.k.item(i);
if (j.isAutoGenerated) {
if (null != g) {
h.k.item(i, g);
}
else {
e.filterExpressions.removeAt(i);
}
break;
}
}
this.bx.itemsSource = e;
this.bx.dataMemberPath = c;
this.bx.primaryKey = [c];
e.shouldEmitSectionHeaders = true;
e.isSectionHeaderNormalRow = true;
e.isSectionExpandedDefault = false;
e.isSectionCollapsable = true;
e.isSectionContentVisible = false;
this.cv();
}
}
cx(a, b) {
if (a != null && a.actualSchema != null && b != null && b.actualSchema != null) {
let c = b.actualSchema.propertyTypes;
let d = a.actualSchema.propertyTypes;
for (let e = 0; e < c.length; e++) {
if (c[e] != d[e]) {
c[e] = d[e];
}
}
}
}
cv() {
let a = this.column;
let b = (null != a) ? a.lo : null;
let c = true;
let d = toNullable(ColumnComparisonConditionOperatorType_$type, null);
let e = this.b4();
for (let f = e.count - 1; f >= 0; f--) {
let g = e._inner[f];
switch (g.operator) {
case 0:
case 1: break;
default:
e.removeAt(f);
continue;
}
if (nullableEquals(d, null)) {
d = toNullable(ColumnComparisonConditionOperatorType_$type, g.operator);
}
else if (d.value != g.operator) {
c = false;
break;
}
}
if (e.count == 0 || !c) {
this.bx.dd();
return;
}
switch (d.value) {
case 0:
this.bx.ci();
break;
case 1:
this.bx.dd();
break;
}
let h = this.bx.keys;
for (let i of fromEnum(e)) {
h.add(new PrimaryKeyValue([b], [i.value]));
}
this.cu();
}
b4() {
let a = new List$1(ColumnComparisonFilterCondition.$, 0);
let b = this.column;
if (null == b) {
return a;
}
if (null != b.g1) {
let c = GridColumnFilterOptions.cm(b.g1, a);
a = c.p1;
}
return a;
}
static cm(a, b) {
let c = typeCast(ColumnFilterConditionGroup.$, a);
if (null != c) {
for (let d = 0; d < c.count; d++) {
let e = c.item(d);
let f = GridColumnFilterOptions.cm(e, b);
b = f.p1;
}
}
else if (null != a) {
if (typeCast(ColumnComparisonFilterCondition.$, a) !== null) {
b.add(a);
}
}
return {
p1: b
};
}
cw() {
if (null != this.bx) {
this.bx.density = this.b0;
this.bx.bm = this.cc;
this.bx.backgroundColor = this.bo;
this.bx.eg = this.br;
this.bx.baseTheme = this.i;
this.bx.updateHrMargin(new Thickness(1, -7, 3, -7, 3));
}
}
ck(a, b) {
this.cu();
}
cn(a, b) {
this.cu();
}
}
GridColumnFilterOptions.$t = /*@__PURE__*/ markType(GridColumnFilterOptions, 'GridColumnFilterOptions', GridColumnOptionsSectionBase.$);
return GridColumnFilterOptions;
})();