@refinitiv-ui/efx-grid 6.0.71 → 6.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/column-selection-dialog/lib/column-selection-dialog.js +9 -7
- package/lib/column-selection-dialog/themes/base.less +4 -8
- package/lib/column-selection-dialog/themes/elemental/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/column-selection-dialog.less +3 -0
- package/lib/column-selection-dialog/themes/halo/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/column-selection-dialog.less +5 -1
- package/lib/column-selection-dialog/themes/solar/pearl/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/core/dist/core.js +2 -2
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.js +2 -2
- package/lib/filter-dialog/lib/filter-dialog.js +75 -36
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +33 -14
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +1 -1
- package/lib/rt-grid/es6/Grid.js +24 -12
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +27 -24
- package/lib/tr-grid-filter-input/es6/FilterInput.d.ts +2 -0
- package/lib/tr-grid-filter-input/es6/FilterInput.js +49 -13
- package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +1 -1
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +103 -15
- package/lib/tr-grid-util/es6/FilterBuilder.d.ts +3 -1
- package/lib/tr-grid-util/es6/FilterBuilder.js +26 -2
- package/lib/types/es6/FilterInput.d.ts +2 -0
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +1 -1
- package/lib/types/es6/RowFiltering.d.ts +1 -1
- package/lib/versions.json +6 -6
- package/package.json +1 -1
@@ -188,7 +188,7 @@ declare class Grid extends EventDispatcher {
|
|
188
188
|
|
189
189
|
public addStaticDataRows(dataRows: any[]|null, fields?: (string)[]|null): void;
|
190
190
|
|
191
|
-
public updateDataSet(records: (any)[]|null, rowIdentifier
|
191
|
+
public updateDataSet(records: (any)[]|null, rowIdentifier?: string|null): void;
|
192
192
|
|
193
193
|
public removeRow(rowRef: Grid.RowReference|null): RowDefinition|null;
|
194
194
|
|
package/lib/rt-grid/es6/Grid.js
CHANGED
@@ -2402,7 +2402,7 @@ Grid.prototype.addStaticDataRows = function(dataRows, fields) {
|
|
2402
2402
|
/** Insert, update, remove and reorder data based on the given array of records
|
2403
2403
|
* @public
|
2404
2404
|
* @param {Array.<Object>} records Array of records for insert, remove, update, reorder in one operation
|
2405
|
-
* @param {string} rowIdentifier Check difference data with the row identifier map property for operate record.
|
2405
|
+
* @param {string=} rowIdentifier Check difference data with the row identifier map property for operate record.
|
2406
2406
|
* @example
|
2407
2407
|
* // Grid data set will be updated to 3 records. All rows in the grid will be cleared and new rows will be inserted
|
2408
2408
|
* grid.updateDataSet([
|
@@ -2454,14 +2454,25 @@ Grid.prototype.updateDataSet = function(records, rowIdentifier) {
|
|
2454
2454
|
var rowDef, id, record, i;
|
2455
2455
|
var rowDefs = this.getAllRowDefinitions(); // Include the filter/hidden rows
|
2456
2456
|
var rowDefCount = rowDefs.length;
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2457
|
+
if(rowIdentifier) {
|
2458
|
+
for (i = 0; i < rowDefCount; i++) {
|
2459
|
+
rowDef = rowDefs[i];
|
2460
|
+
if(rowDef) {
|
2461
|
+
id = rowDef.getRowData()[rowIdentifier];
|
2462
|
+
if(id || id === 0) {
|
2463
|
+
oldDataMap[id] = rowDef;
|
2464
|
+
} else { // Any existing rowDef without row identifier should be removed
|
2465
|
+
this.removeRow(rowDef); // Slow
|
2466
|
+
}
|
2467
|
+
}
|
2468
|
+
}
|
2469
|
+
} else {
|
2470
|
+
for (i = 0; i < rowDefCount; i++) {
|
2471
|
+
record = records[i];
|
2472
|
+
if(record) {
|
2473
|
+
oldDataMap[i] = rowDefs[i]; // Use index instead of rowIdentifier
|
2474
|
+
} else {
|
2475
|
+
this.removeRow(rowDefs[i]); // Need to use rowRef, can't use index in view
|
2465
2476
|
}
|
2466
2477
|
}
|
2467
2478
|
}
|
@@ -2471,7 +2482,7 @@ Grid.prototype.updateDataSet = function(records, rowIdentifier) {
|
|
2471
2482
|
var newDataMap = {};
|
2472
2483
|
for (i = recordCount - 1; i >= 0; i--) {
|
2473
2484
|
record = records[i];
|
2474
|
-
id = record[rowIdentifier];
|
2485
|
+
id = rowIdentifier ? record[rowIdentifier] : i;
|
2475
2486
|
rowDef = oldDataMap[id];
|
2476
2487
|
newDataMap[id] = record; // Assign a new data map to compare to the previous data
|
2477
2488
|
record[fieldSorting] = i;
|
@@ -2493,8 +2504,9 @@ Grid.prototype.updateDataSet = function(records, rowIdentifier) {
|
|
2493
2504
|
}
|
2494
2505
|
}
|
2495
2506
|
|
2496
|
-
|
2497
|
-
|
2507
|
+
if(rowIdentifier) {
|
2508
|
+
this._dt.sortOnce(ROW_DEF, "a", compareNumber, fieldSorting);
|
2509
|
+
}
|
2498
2510
|
};
|
2499
2511
|
/** @private
|
2500
2512
|
* @param {Array|Object} item
|
@@ -1156,8 +1156,8 @@ ConditionalColoringPlugin.prototype._onSectionBinding = function (e) {
|
|
1156
1156
|
return; // dataRows could be empty in case of no column is presented
|
1157
1157
|
}
|
1158
1158
|
|
1159
|
-
var c, r, cell, painter, changedCols, rowDef, rid, changedRow, changedRows
|
1160
|
-
var dataRow, insertedId, colData,
|
1159
|
+
var c, r, cell, painter, changedCols, rowDef, rid, changedRow, changedRows;
|
1160
|
+
var dataRow, insertedId, colData, cachedValues, updatePrev;
|
1161
1161
|
var section = e["section"];
|
1162
1162
|
var colCount = section.getColumnCount();
|
1163
1163
|
var fromR = /** @type{number} */(e["fromRowIndex"]);
|
@@ -1182,27 +1182,28 @@ ConditionalColoringPlugin.prototype._onSectionBinding = function (e) {
|
|
1182
1182
|
if (!dataRow) continue; // prevent from null value access when using with RowGroupingExtension
|
1183
1183
|
|
1184
1184
|
changedCols = null;
|
1185
|
+
var allowBlinking = false;
|
1186
|
+
var insertedRow = null;
|
1185
1187
|
if (blinkingEnabled) {
|
1186
1188
|
if (this._realTimeGrid) {
|
1187
1189
|
// TODO: check rid from e.rids
|
1188
1190
|
rowDef = /** @type{RowDefinition} */(dataRow["ROW_DEF"]);
|
1189
|
-
|
1190
|
-
|
1191
|
-
allowBlinking = !insertedRow || this._insertionBlinking;
|
1192
|
-
if (rid && allowBlinking) {
|
1191
|
+
if(rowDef){
|
1192
|
+
rid = rowDef.getRowId();
|
1193
1193
|
changedCols = rowDef.getUpdates();
|
1194
1194
|
}
|
1195
1195
|
} else { // composite grid
|
1196
1196
|
changedRow = changedRows[r];
|
1197
1197
|
if (changedRow) {
|
1198
1198
|
rid = changedRow.rid;
|
1199
|
-
|
1200
|
-
allowBlinking = !insertedRow || this._insertionBlinking;
|
1201
|
-
if (allowBlinking) {
|
1202
|
-
changedCols = changedRow.changed;
|
1203
|
-
}
|
1199
|
+
changedCols = changedRow.changed;
|
1204
1200
|
}
|
1205
1201
|
}
|
1202
|
+
insertedRow = rid ? insertedId[rid] : null;
|
1203
|
+
allowBlinking = !insertedRow || this._insertionBlinking;
|
1204
|
+
if (!allowBlinking) {
|
1205
|
+
changedCols = null;
|
1206
|
+
}
|
1206
1207
|
}
|
1207
1208
|
|
1208
1209
|
if (!rid) {
|
@@ -1225,24 +1226,26 @@ ConditionalColoringPlugin.prototype._onSectionBinding = function (e) {
|
|
1225
1226
|
painter = this.getColumnPainter(c);
|
1226
1227
|
if (painter) {
|
1227
1228
|
colData = this._getColumnData(c);
|
1228
|
-
bgBlinking = false;
|
1229
|
-
blinking
|
1230
|
-
|
1229
|
+
var bgBlinking = false;
|
1230
|
+
if (colData["blinking"] && actualUpdate) {
|
1231
|
+
var blinking = false;
|
1231
1232
|
var field = colData["blinkingField"] || this._getField(c);
|
1232
1233
|
var newValue = dataRow[field];
|
1233
|
-
if
|
1234
|
-
|
1235
|
-
|
1236
|
-
if (
|
1234
|
+
if(allowBlinking){
|
1235
|
+
if (prevDataRow) {
|
1236
|
+
var prevValue = prevDataRow[field];
|
1237
|
+
if (prevValue != null) {
|
1238
|
+
if (changedCols && changedCols[field]) {
|
1239
|
+
blinking = true;
|
1240
|
+
bgBlinking = painter.blinkCell(cell, newValue, prevValue, dataRow, dataRow);
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
} else {
|
1244
|
+
if(prevRowCount && insertedRow){
|
1237
1245
|
blinking = true;
|
1238
|
-
bgBlinking = painter.blinkCell(cell, newValue,
|
1246
|
+
bgBlinking = painter.blinkCell(cell, newValue, newValue, dataRow, dataRow);
|
1239
1247
|
}
|
1240
1248
|
}
|
1241
|
-
} else {
|
1242
|
-
if(prevRowCount && insertedRow){
|
1243
|
-
blinking = true;
|
1244
|
-
bgBlinking = painter.blinkCell(cell, newValue, newValue, dataRow, dataRow);
|
1245
|
-
}
|
1246
1249
|
}
|
1247
1250
|
|
1248
1251
|
if (!blinking) {
|
@@ -48,6 +48,8 @@ declare class FilterInputPlugin extends GridPlugin {
|
|
48
48
|
|
49
49
|
public removeColumnFilter(colIndex?: (null|number)|null): void;
|
50
50
|
|
51
|
+
public setInputValue(colIndex: number, value: any): void;
|
52
|
+
|
51
53
|
public refresh(delayMs?: number|null): void;
|
52
54
|
|
53
55
|
public setFilterLogic(colIndex: number, func: ((...params: any[]) => any)|null, ctx?: any): void;
|
@@ -663,6 +663,13 @@ FilterInputPlugin.prototype._retrieveColumnOption = function (colIndex, colDef)
|
|
663
663
|
var option = this._newExtColumnOption(colIndex);
|
664
664
|
|
665
665
|
if (filterOption) {
|
666
|
+
var type = filterOption["type"];
|
667
|
+
|
668
|
+
if (typeof type == "string") {
|
669
|
+
type = type.toLowerCase();
|
670
|
+
option["type"] = type;
|
671
|
+
}
|
672
|
+
|
666
673
|
var defaultLogic = filterOption["filterLogic"] || filterOption["defaultLogic"];
|
667
674
|
|
668
675
|
if (defaultLogic != null) {
|
@@ -673,6 +680,10 @@ FilterInputPlugin.prototype._retrieveColumnOption = function (colIndex, colDef)
|
|
673
680
|
}
|
674
681
|
}
|
675
682
|
|
683
|
+
if (type == "multiselect" && option._comparingLogic === FilterInputPlugin._containingFilter) {
|
684
|
+
option._comparingLogic = FilterInputPlugin._multiSelectionFilter;
|
685
|
+
}
|
686
|
+
|
676
687
|
var disabled = filterOption["disabled"];
|
677
688
|
|
678
689
|
if (disabled != null) {
|
@@ -685,17 +696,6 @@ FilterInputPlugin.prototype._retrieveColumnOption = function (colIndex, colDef)
|
|
685
696
|
option["placeholder"] = placeholder;
|
686
697
|
}
|
687
698
|
|
688
|
-
var type = filterOption["type"];
|
689
|
-
|
690
|
-
if (typeof type == "string") {
|
691
|
-
type = type.toLowerCase();
|
692
|
-
option["type"] = type;
|
693
|
-
|
694
|
-
if (type == "multiselect") {
|
695
|
-
option._comparingLogic = FilterInputPlugin._multiSelectionFilter;
|
696
|
-
}
|
697
|
-
}
|
698
|
-
|
699
699
|
var entries = filterOption["entries"];
|
700
700
|
|
701
701
|
if (Array.isArray(entries)) {
|
@@ -837,11 +837,44 @@ FilterInputPlugin.prototype.removeColumnFilters = function (colIndex) {
|
|
837
837
|
|
838
838
|
|
839
839
|
FilterInputPlugin.prototype.removeColumnFilter = FilterInputPlugin.prototype.removeColumnFilters;
|
840
|
+
/** @public
|
841
|
+
* @param {number} colIndex
|
842
|
+
* @param {*} value
|
843
|
+
*/
|
844
|
+
|
845
|
+
FilterInputPlugin.prototype.setInputValue = function (colIndex, value) {
|
846
|
+
var inputElem = this.getColumnInput(colIndex);
|
847
|
+
|
848
|
+
if (!inputElem) {
|
849
|
+
return;
|
850
|
+
}
|
851
|
+
|
852
|
+
var colOpt = this._getExtColumnOption(colIndex);
|
853
|
+
|
854
|
+
var type = colOpt.type ? colOpt.type.toLowerCase() : "";
|
855
|
+
|
856
|
+
if (type == "date") {
|
857
|
+
var dateObj = ElfDate.from(value);
|
858
|
+
value = dateObj ? dateObj.toDateString().substr(4) : "";
|
859
|
+
}
|
860
|
+
|
861
|
+
if (type == "multiselect") {
|
862
|
+
inputElem.values = value;
|
863
|
+
|
864
|
+
var textMap = FilterInputPlugin._createMapObject(value);
|
865
|
+
|
866
|
+
this.filterColumn(colIndex, "", textMap);
|
867
|
+
} else {
|
868
|
+
inputElem.value = value;
|
869
|
+
this.filterColumn(colIndex, value);
|
870
|
+
}
|
871
|
+
};
|
840
872
|
/** Force filtering for every column
|
841
873
|
* @public
|
842
874
|
* @param {number=} delayMs=0 Set delay in millisecond to avoid repeatedly filtering
|
843
875
|
*/
|
844
876
|
|
877
|
+
|
845
878
|
FilterInputPlugin.prototype.refresh = function (delayMs) {
|
846
879
|
if (delayMs) {
|
847
880
|
if (!this._refreshTimer) {
|
@@ -980,10 +1013,13 @@ FilterInputPlugin.prototype._onInputChanged = function (e) {
|
|
980
1013
|
FilterInputPlugin.prototype._onOpenedChanged = function (e) {
|
981
1014
|
if (e.detail.value) {
|
982
1015
|
//open
|
983
|
-
e.currentTarget.style.
|
1016
|
+
e.currentTarget.style.pointerEvents = "none";
|
984
1017
|
} else {
|
985
1018
|
//close
|
986
|
-
e.currentTarget
|
1019
|
+
var ect = e.currentTarget;
|
1020
|
+
setTimeout(function () {
|
1021
|
+
ect.style.pointerEvents = "";
|
1022
|
+
});
|
987
1023
|
}
|
988
1024
|
};
|
989
1025
|
/** @private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {Ext} from "../../tr-grid-util/es6/Ext.js";
|
2
2
|
import {GridPlugin} from "../../tr-grid-util/es6/GridPlugin.js";
|
3
|
-
import {FilterBuilder} from "../../tr-grid-util/es6/FilterBuilder.js";
|
3
|
+
import {FilterBuilder, stringToDateObject} from "../../tr-grid-util/es6/FilterBuilder.js";
|
4
4
|
import {FilterOperators} from "../../tr-grid-util/es6/FilterOperators.js";
|
5
5
|
import {ElfUtil} from "../../tr-grid-util/es6/ElfUtil.js";
|
6
6
|
import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
@@ -2,7 +2,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
2
2
|
|
3
3
|
import { Ext } from "../../tr-grid-util/es6/Ext.js";
|
4
4
|
import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
|
5
|
-
import { FilterBuilder } from "../../tr-grid-util/es6/FilterBuilder.js";
|
5
|
+
import { FilterBuilder, stringToDateObject } from "../../tr-grid-util/es6/FilterBuilder.js";
|
6
6
|
import { FilterOperators } from "../../tr-grid-util/es6/FilterOperators.js";
|
7
7
|
import { ElfUtil } from "../../tr-grid-util/es6/ElfUtil.js";
|
8
8
|
import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
@@ -209,7 +209,7 @@ RowFilteringPlugin.prototype._uiTimerId = 0;
|
|
209
209
|
* @private
|
210
210
|
*/
|
211
211
|
|
212
|
-
RowFilteringPlugin.prototype.
|
212
|
+
RowFilteringPlugin.prototype._filterTimerId = 0;
|
213
213
|
/** @type {Function}
|
214
214
|
* @private
|
215
215
|
*/
|
@@ -315,6 +315,16 @@ RowFilteringPlugin.prototype.unload = function (host) {
|
|
315
315
|
host.unlisten("columnRemoved", this._onColumnRemoved);
|
316
316
|
|
317
317
|
if (!this._hosts.length) {
|
318
|
+
if (this._uiTimerId) {
|
319
|
+
clearTimeout(this._uiTimerId);
|
320
|
+
this._uiTimerId = 0;
|
321
|
+
}
|
322
|
+
|
323
|
+
if (this._filterTimerId) {
|
324
|
+
clearTimeout(this._filterTimerId);
|
325
|
+
this._filterTimerId = 0;
|
326
|
+
}
|
327
|
+
|
318
328
|
this._hasPendingFilter = false;
|
319
329
|
|
320
330
|
if (this._filterDialog) {
|
@@ -688,6 +698,18 @@ RowFilteringPlugin.prototype._parseFilter = function (exp, colIndex, ctx) {
|
|
688
698
|
|
689
699
|
|
690
700
|
RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
|
701
|
+
if (colIndex < 0 || colIndex >= this.getColumnCount()) {
|
702
|
+
return false;
|
703
|
+
}
|
704
|
+
|
705
|
+
var cfo = this._getColumnFilterOption(colIndex);
|
706
|
+
|
707
|
+
if (cfo) {
|
708
|
+
if (cfo._expressions[0] === exp) {
|
709
|
+
return false; // The same expression is getting added on the same column twice
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
691
713
|
var func = null;
|
692
714
|
|
693
715
|
if (typeof exp === "function") {
|
@@ -706,10 +728,6 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
|
|
706
728
|
return false;
|
707
729
|
}
|
708
730
|
|
709
|
-
if (colIndex < 0 || colIndex >= this.getColumnCount()) {
|
710
|
-
return false;
|
711
|
-
}
|
712
|
-
|
713
731
|
var colSettings = this._getUserColumnSettings(colIndex);
|
714
732
|
|
715
733
|
colSettings.expression = exp; // WARNING: Only the last expression are saved (previous one is overwritten)
|
@@ -728,8 +746,7 @@ RowFilteringPlugin.prototype.addColumnFilter = function (colIndex, exp, ctx) {
|
|
728
746
|
ctx["field"] = field;
|
729
747
|
}
|
730
748
|
|
731
|
-
|
732
|
-
|
749
|
+
cfo = this._initColumnFilterOption(colIndex);
|
733
750
|
cfo._field = field; // TODO: Handle fieldDataType
|
734
751
|
|
735
752
|
cfo._filters.push(func);
|
@@ -811,6 +828,7 @@ RowFilteringPlugin.prototype._getColumnExpression = function (colIndex) {
|
|
811
828
|
* @private
|
812
829
|
* @param {number} colIndex
|
813
830
|
* @param {RowFilteringPlugin~ColumnOptions} userObj
|
831
|
+
* @returns {boolean} Returns true if there is an active filter in the column options
|
814
832
|
* @example
|
815
833
|
* var colDef1 = {
|
816
834
|
* "field": "PCTCHNG",
|
@@ -861,6 +879,8 @@ RowFilteringPlugin.prototype._setColumnOptions = function (colIndex, userObj) {
|
|
861
879
|
if (iconActivation == "always" || iconActivation == "onHover") {
|
862
880
|
this._updateColumnIcon(colIndex);
|
863
881
|
}
|
882
|
+
|
883
|
+
return exp != null;
|
864
884
|
};
|
865
885
|
/** @private
|
866
886
|
* @param {number} colIndex
|
@@ -1374,8 +1394,8 @@ RowFilteringPlugin.prototype._filterLogic = function (rid, rowData) {
|
|
1374
1394
|
|
1375
1395
|
|
1376
1396
|
RowFilteringPlugin.prototype._requestFilterRefresh = function () {
|
1377
|
-
if (!this.
|
1378
|
-
this.
|
1397
|
+
if (!this._filterTimerId) {
|
1398
|
+
this._filterTimerId = setTimeout(this.refresh, 10);
|
1379
1399
|
}
|
1380
1400
|
};
|
1381
1401
|
/** @private */
|
@@ -1398,7 +1418,7 @@ RowFilteringPlugin.prototype._setTimerForUpdatingIcons = function () {
|
|
1398
1418
|
|
1399
1419
|
|
1400
1420
|
RowFilteringPlugin.prototype.refresh = function () {
|
1401
|
-
this.
|
1421
|
+
this._filterTimerId = 0;
|
1402
1422
|
this._activeColFilters = this._columnFilters; //check cstp
|
1403
1423
|
|
1404
1424
|
var cstkp = this._getPlugin("ColumnStackPlugin");
|
@@ -1787,6 +1807,47 @@ RowFilteringPlugin._getFilteredValue = function (rowData, filters) {
|
|
1787
1807
|
|
1788
1808
|
return true;
|
1789
1809
|
};
|
1810
|
+
/** @private
|
1811
|
+
* @function
|
1812
|
+
* @param {Array} exp
|
1813
|
+
* @param {string} field
|
1814
|
+
* @param {Function} formatter
|
1815
|
+
* @returns {Array}
|
1816
|
+
*/
|
1817
|
+
|
1818
|
+
|
1819
|
+
RowFilteringPlugin._formatArrayExpression = function (exp, field, formatter) {
|
1820
|
+
if (Array.isArray(exp)) {
|
1821
|
+
var ary = exp.slice(); // Clone to avoid modifying original data
|
1822
|
+
|
1823
|
+
var formattedVal = ary[1];
|
1824
|
+
var val = stringToDateObject(formattedVal);
|
1825
|
+
|
1826
|
+
if (val !== formattedVal) {
|
1827
|
+
ary.rawValue = val;
|
1828
|
+
ary.formattedValue = formattedVal;
|
1829
|
+
}
|
1830
|
+
|
1831
|
+
if (field && formatter && typeof val !== "string") {
|
1832
|
+
if (val != null) {
|
1833
|
+
var dummyRow = {};
|
1834
|
+
dummyRow[field] = val;
|
1835
|
+
formattedVal = formatter(dummyRow);
|
1836
|
+
|
1837
|
+
if (formattedVal) {
|
1838
|
+
ary.rawValue = val;
|
1839
|
+
ary.formattedValue = formattedVal;
|
1840
|
+
val = formattedVal;
|
1841
|
+
}
|
1842
|
+
}
|
1843
|
+
}
|
1844
|
+
|
1845
|
+
ary[1] = val;
|
1846
|
+
return ary;
|
1847
|
+
}
|
1848
|
+
|
1849
|
+
return null;
|
1850
|
+
};
|
1790
1851
|
/** @public
|
1791
1852
|
* @param {number} colIndex
|
1792
1853
|
* @param {RowFilteringPlugin~FilterDialogOptions=} runtimeDialogOptions
|
@@ -1939,6 +2000,8 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
|
|
1939
2000
|
var formattedDataAccessor = cfo._formattedDataAccessor = dialogConfig.formattedDataAccessor || null;
|
1940
2001
|
var sortLogic = dialogConfig.sortLogic || null; // Populate data for filter dialog based on existing states
|
1941
2002
|
|
2003
|
+
var formatter = this._getFormatter(colIndex);
|
2004
|
+
|
1942
2005
|
var condition2D = null;
|
1943
2006
|
var filterMode = ""; // default
|
1944
2007
|
|
@@ -1948,8 +2011,10 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
|
|
1948
2011
|
if (exp) {
|
1949
2012
|
if (Array.isArray(exp)) {
|
1950
2013
|
if (exp.length) {
|
1951
|
-
condition2D = Array.isArray(exp[0]) ? exp : [exp]; // Guaranteed condition2D to be a 2D array
|
2014
|
+
condition2D = Array.isArray(exp[0]) ? exp.slice() : [exp]; // Guaranteed condition2D to be a 2D array
|
1952
2015
|
|
2016
|
+
condition2D[0] = RowFilteringPlugin._formatArrayExpression(condition2D[0], field, formatter);
|
2017
|
+
condition2D[1] = RowFilteringPlugin._formatArrayExpression(condition2D[1], field, formatter);
|
1953
2018
|
filterMode = "advanced";
|
1954
2019
|
}
|
1955
2020
|
} else if (typeof exp === "function" || typeof exp === "string" || _typeof(exp) === "object") {
|
@@ -1960,7 +2025,7 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
|
|
1960
2025
|
}
|
1961
2026
|
|
1962
2027
|
var selectedItems = {};
|
1963
|
-
var uniqueValues = cfo.uniqueValues = this.getUniqueValues(field,
|
2028
|
+
var uniqueValues = cfo.uniqueValues = this.getUniqueValues(field, formatter, "", rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems);
|
1964
2029
|
var keys = Object.keys(uniqueValues);
|
1965
2030
|
|
1966
2031
|
if (sortLogic) {
|
@@ -1978,7 +2043,26 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
|
|
1978
2043
|
nodes: [],
|
1979
2044
|
checked: selectedItems[formattedVal] ? true : false
|
1980
2045
|
};
|
1981
|
-
}); //
|
2046
|
+
}); // Adding inputs from conditions to uniqueValues for mapping back from the dialog
|
2047
|
+
|
2048
|
+
if (condition2D) {
|
2049
|
+
var cond = condition2D[0];
|
2050
|
+
|
2051
|
+
if (cond && cond.formattedValue) {
|
2052
|
+
if (!uniqueValues[cond.formattedValue]) {
|
2053
|
+
uniqueValues[cond.formattedValue] = [cond.rawValue];
|
2054
|
+
}
|
2055
|
+
}
|
2056
|
+
|
2057
|
+
cond = condition2D[1];
|
2058
|
+
|
2059
|
+
if (cond && cond.formattedValue) {
|
2060
|
+
if (!uniqueValues[cond.formattedValue]) {
|
2061
|
+
uniqueValues[cond.formattedValue] = [cond.rawValue];
|
2062
|
+
}
|
2063
|
+
}
|
2064
|
+
} // Initialize dialog
|
2065
|
+
|
1982
2066
|
|
1983
2067
|
if (this._filterDialog.init) {
|
1984
2068
|
// TODO: support initiailization in v1
|
@@ -2228,7 +2312,11 @@ RowFilteringPlugin.prototype._onDialogSortChanged = function (e) {
|
|
2228
2312
|
|
2229
2313
|
RowFilteringPlugin.prototype._onColumnAdded = function (e) {
|
2230
2314
|
if (e["context"]) {
|
2231
|
-
this._setColumnOptions(e["colIndex"], e["context"]);
|
2315
|
+
var hasFilter = this._setColumnOptions(e["colIndex"], e["context"]);
|
2316
|
+
|
2317
|
+
if (hasFilter) {
|
2318
|
+
this._applyPendingFilter();
|
2319
|
+
}
|
2232
2320
|
}
|
2233
2321
|
};
|
2234
2322
|
/** @private
|
@@ -46,7 +46,9 @@ declare class FilterBuilder {
|
|
46
46
|
|
47
47
|
}
|
48
48
|
|
49
|
+
declare function stringToDateObject(str: any): any;
|
50
|
+
|
49
51
|
declare function buildFilterFromObjectMap(obj: any, field: string, rawDataAccessor?: ((...params: any[]) => any)|null): ((...params: any[]) => any)|null;
|
50
52
|
|
51
53
|
export default FilterBuilder;
|
52
|
-
export { FilterBuilder, buildFilterFromObjectMap };
|
54
|
+
export { FilterBuilder, buildFilterFromObjectMap, stringToDateObject };
|
@@ -44,8 +44,9 @@ var convertToNumber = function(val) {
|
|
44
44
|
}
|
45
45
|
if(val) {
|
46
46
|
// WARNING: spaces (" ") and newline ("\n") characters could be parsed as 0
|
47
|
+
// Date object will have value of Date.getTime(). True value will be converted to 1
|
47
48
|
// TODO: Check if we need to use parseFloat instead of Number
|
48
|
-
return Number(val); // Could return NaN.
|
49
|
+
return Number(val); // Could return NaN.
|
49
50
|
}
|
50
51
|
if(val === false) {
|
51
52
|
return 0;
|
@@ -53,6 +54,28 @@ var convertToNumber = function(val) {
|
|
53
54
|
return NaN; // null, NaN, undefined, empty string
|
54
55
|
};
|
55
56
|
/** @private
|
57
|
+
* @type {RegExp}
|
58
|
+
*/
|
59
|
+
var _dateStringRule = /^\w{3} \w{3}/;
|
60
|
+
/** Convert default string natively generated from a Date object to a Date object. For instance, string "Sun Sep 09 2001 08:46:40 GMT+0700 (Indochina Time)" can be converted, while string "2001-09-09" cannot be converted.
|
61
|
+
* @public
|
62
|
+
* @function
|
63
|
+
* @param {*} str
|
64
|
+
* @return {*} Return Date object for successful conversion, otherwise the same input string
|
65
|
+
*/
|
66
|
+
var stringToDateObject = function(str) {
|
67
|
+
if(typeof str === "string") {
|
68
|
+
var dateObj = new Date(str);
|
69
|
+
var t = dateObj.getTime();
|
70
|
+
if(t === t) {
|
71
|
+
if(_dateStringRule.test(str)) {
|
72
|
+
return dateObj;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return str; // Return the user input for unsuccessful conversion
|
77
|
+
};
|
78
|
+
/** @private
|
56
79
|
* @function
|
57
80
|
* @param {*} val
|
58
81
|
* @return {string}
|
@@ -441,6 +464,7 @@ FilterBuilder.prototype.buildFilter = function() {
|
|
441
464
|
var value = cond.origValue;
|
442
465
|
|
443
466
|
if(opType === "number") {
|
467
|
+
value = stringToDateObject(value);
|
444
468
|
value = convertToNumber(value);
|
445
469
|
} else if(opType === "date") {
|
446
470
|
var dateObj = null;
|
@@ -554,4 +578,4 @@ FilterBuilder.prototype.parse = function(condition, field, formatter, formattedF
|
|
554
578
|
};
|
555
579
|
|
556
580
|
export default FilterBuilder;
|
557
|
-
export { FilterBuilder, buildFilterFromObjectMap };
|
581
|
+
export { FilterBuilder, buildFilterFromObjectMap, stringToDateObject };
|
@@ -48,6 +48,8 @@ declare class FilterInputPlugin extends GridPlugin {
|
|
48
48
|
|
49
49
|
public removeColumnFilter(colIndex?: (null|number)|null): void;
|
50
50
|
|
51
|
+
public setInputValue(colIndex: number, value: any): void;
|
52
|
+
|
51
53
|
public refresh(delayMs?: number|null): void;
|
52
54
|
|
53
55
|
public setFilterLogic(colIndex: number, func: ((...params: any[]) => any)|null, ctx?: any): void;
|
@@ -190,7 +190,7 @@ declare class Grid extends EventDispatcher {
|
|
190
190
|
|
191
191
|
public addStaticDataRows(dataRows: any[]|null, fields?: (string)[]|null): void;
|
192
192
|
|
193
|
-
public updateDataSet(records: (any)[]|null, rowIdentifier
|
193
|
+
public updateDataSet(records: (any)[]|null, rowIdentifier?: string|null): void;
|
194
194
|
|
195
195
|
public removeRow(rowRef: Grid.RowReference|null): RowDefinition|null;
|
196
196
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {Ext} from "../../tr-grid-util/es6/Ext.js";
|
2
2
|
import {GridPlugin} from "../../tr-grid-util/es6/GridPlugin.js";
|
3
|
-
import {FilterBuilder} from "../../tr-grid-util/es6/FilterBuilder.js";
|
3
|
+
import {FilterBuilder, stringToDateObject} from "../../tr-grid-util/es6/FilterBuilder.js";
|
4
4
|
import {FilterOperators} from "../../tr-grid-util/es6/FilterOperators.js";
|
5
5
|
import {ElfUtil} from "../../tr-grid-util/es6/ElfUtil.js";
|
6
6
|
import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
package/lib/versions.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"tr-grid-util": "1.3.
|
2
|
+
"tr-grid-util": "1.3.134",
|
3
3
|
"tr-grid-printer": "1.0.17",
|
4
4
|
"@grid/column-dragging": "1.0.14",
|
5
5
|
"@grid/row-segmenting": "1.0.29",
|
@@ -14,24 +14,24 @@
|
|
14
14
|
"tr-grid-column-resizing": "1.0.28",
|
15
15
|
"tr-grid-column-selection": "1.0.31",
|
16
16
|
"tr-grid-column-stack": "1.0.73",
|
17
|
-
"tr-grid-conditional-coloring": "1.0.
|
17
|
+
"tr-grid-conditional-coloring": "1.0.67",
|
18
18
|
"tr-grid-content-wrap": "1.0.20",
|
19
19
|
"tr-grid-contextmenu": "1.0.40",
|
20
|
-
"tr-grid-filter-input": "0.9.
|
20
|
+
"tr-grid-filter-input": "0.9.37",
|
21
21
|
"tr-grid-heat-map": "1.0.29",
|
22
22
|
"tr-grid-in-cell-editing": "1.0.81",
|
23
23
|
"tr-grid-pagination": "1.0.24",
|
24
24
|
"tr-grid-percent-bar": "1.0.22",
|
25
25
|
"tr-grid-range-bar": "2.0.5",
|
26
26
|
"tr-grid-row-dragging": "1.0.31",
|
27
|
-
"tr-grid-row-filtering": "1.0.
|
27
|
+
"tr-grid-row-filtering": "1.0.65",
|
28
28
|
"tr-grid-row-grouping": "1.0.82",
|
29
29
|
"tr-grid-row-selection": "1.0.25",
|
30
30
|
"tr-grid-rowcoloring": "1.0.25",
|
31
31
|
"tr-grid-textformatting": "1.0.46",
|
32
32
|
"tr-grid-titlewrap": "1.0.20",
|
33
33
|
"@grid/formatters": "1.0.50",
|
34
|
-
"@grid/column-selection-dialog": "4.0.
|
35
|
-
"@grid/filter-dialog": "4.0.
|
34
|
+
"@grid/column-selection-dialog": "4.0.55",
|
35
|
+
"@grid/filter-dialog": "4.0.60",
|
36
36
|
"@grid/column-format-dialog": "4.0.44"
|
37
37
|
}
|
package/package.json
CHANGED