@refinitiv-ui/efx-grid 6.0.71 → 6.0.72

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.
@@ -570,7 +570,7 @@ Core.prototype._firstRendered = false;
570
570
  * @return {string}
571
571
  */
572
572
  Core.getVersion = function () {
573
- return "5.1.80";
573
+ return "5.1.81";
574
574
  };
575
575
  /** {@link ElementWrapper#dispose}
576
576
  * @override
@@ -5441,7 +5441,7 @@ Core.prototype._onRowHeightChanged = function (e) {
5441
5441
  // TODO: Set row height one by one is not good
5442
5442
  for(var j = 0; j < len; ++j) {
5443
5443
  var evt = evts[j];
5444
- var section = /** @type {ILayoutGrid} */(evt["sender"]);
5444
+ var section = /** @type {ILayoutGrid} */(evt["section"]);
5445
5445
  if(!this._containsSection(section)) {
5446
5446
  continue; // The section is no longer contained in this grid
5447
5447
  }
@@ -676,7 +676,7 @@ class FilterDialog extends BasicElement {
676
676
 
677
677
  if(useUTCTime) {
678
678
  ary2D.forEach(function(itm) {
679
- item[3] = true;
679
+ itm[3] = true;
680
680
  });
681
681
  }
682
682
 
@@ -812,41 +812,84 @@ class FilterDialog extends BasicElement {
812
812
  }
813
813
  }
814
814
 
815
- // Params is an array
816
- if (Array.isArray(userConditions)) {
817
- let conditions = /** @type{Array} */ (userConditions);
818
- const con1 = conditions[0] || [];
819
- const con2 = conditions[1] || [];
820
- const con2Complete = con2.length > 1 && con2[0] && con2[1];
821
- const connector = con1[2] || "";
822
- const firstRadioState = connector !== "OR" || !con2Complete;
823
- const isDateTimeField = toDateTimeType(this.fieldDataType) ? true : false;
824
- if (isDateTimeField) {
825
- if (con1[0]) {
826
- this._dateTimeComboBoxes[0].value = con1[0];
827
- this._dateTimePickers[0].value = con1[1] ? this._getDateString(con1[1]) : "";
828
-
829
- if (con2Complete) {
830
- this._dateTimeComboBoxes[1].value = con2[0];
831
- this._dateTimePickers[1].value = con2[1] ? this._getDateString(con2[1]) : "";
832
- }
815
+ if (!Array.isArray(userConditions)) {
816
+ return;
817
+ }
818
+
819
+ const con1 = userConditions[0];
820
+ var validCon1 = false;
821
+ var conOp1 = "";
822
+ var conVal1 = "";
823
+ var connector = "";
824
+ if(Array.isArray(con1)) {
825
+ conOp1 = con1[0];
826
+ if(con1.length && con1[0]) {
827
+ conVal1 = con1[1];
828
+ if(conVal1 || conVal1 === 0 || conVal1 === false) {
829
+ validCon1 = true;
830
+ connector = con1[2] || "";
831
+ } else {
832
+ conVal1 = "";
833
833
  }
834
- this._dateTimeRadioBtns[0].checked = firstRadioState;
835
- this._dateTimeRadioBtns[1].checked = !firstRadioState;
836
- } else {
837
- if (con1[0]) {
838
- this._generalComboBoxes[0].value = con1[0];
839
- this._generalComboBoxes[1].value = con1[1] || "";
834
+ }
835
+ }
840
836
 
841
- if (con2Complete) {
842
- this._generalComboBoxes[2].value = con2[0];
843
- this._generalComboBoxes[3].value = con2[1] || "";
844
- }
837
+ const con2 = userConditions[1];
838
+ var validCon2 = false;
839
+ var conOp2 = "";
840
+ var conVal2 = "";
841
+ if(validCon1 && Array.isArray(con2)) {
842
+ conOp2 = con2[0];
843
+ if(con2.length && conOp2) {
844
+ conVal2 = con2[1];
845
+ if(conVal2 || conVal2 === 0 || conVal2 === false) {
846
+ validCon2 = true;
847
+ } else {
848
+ conVal2 = "";
845
849
  }
846
- this._generalRadioBtns[0].checked = firstRadioState;
847
- this._generalRadioBtns[1].checked = !firstRadioState;
848
850
  }
849
851
  }
852
+
853
+ var firstRadioState = true;
854
+ if(validCon1 && validCon2) {
855
+ firstRadioState = connector !== "OR";
856
+ }
857
+
858
+ if (toDateTimeType(this.fieldDataType)) {
859
+ if (validCon1) {
860
+ this._updateConditionUIs(this._dateTimeComboBoxes[0], this._dateTimePickers[0], conOp1, this._getDateString(conVal1));
861
+ }
862
+ if (validCon2) {
863
+ this._updateConditionUIs(this._dateTimeComboBoxes[1], this._dateTimePickers[1], conOp2, this._getDateString(conVal2));
864
+ }
865
+ this._updateConnectorUIs(this._dateTimeRadioBtns, firstRadioState);
866
+ } else {
867
+ if (validCon1) {
868
+ this._updateConditionUIs(this._generalComboBoxes[0], this._generalComboBoxes[1], conOp1, conVal1);
869
+ }
870
+ if (validCon2) {
871
+ this._updateConditionUIs(this._generalComboBoxes[2], this._generalComboBoxes[3], conOp2, conVal2);
872
+ }
873
+ this._updateConnectorUIs(this._generalRadioBtns, firstRadioState);
874
+ }
875
+ }
876
+ /** @private
877
+ * @param {Element} opCombobox
878
+ * @param {Element} valuePicker
879
+ * @param {string} opValue
880
+ * @param {string} value
881
+ */
882
+ _updateConditionUIs(opCombobox, valuePicker, opValue, value) {
883
+ opCombobox.value = opValue;
884
+ valuePicker.value = value;
885
+ }
886
+ /** @private
887
+ * @param {Array.<Element>} connectors
888
+ * @param {boolean} connectorValue
889
+ */
890
+ _updateConnectorUIs(connectors, connectorValue) {
891
+ connectors[0].checked = connectorValue;
892
+ connectors[1].checked = !connectorValue;
850
893
  }
851
894
  /** @private
852
895
  * @returns {boolean}
@@ -926,14 +969,10 @@ class FilterDialog extends BasicElement {
926
969
  * @return {string}
927
970
  */
928
971
  _getDateString(date) {
929
- var dateString = "";
930
- var dateFormat = "yyyy-MM-dd";
931
972
  if(!(date instanceof Date)){
932
973
  date = new Date(date);
933
974
  }
934
- dateString = DateTime.format(date.getTime(), dateFormat, this.useUTCTime ? "GMT" : "LOCAL");
935
-
936
- return dateString;
975
+ return DateTime.format(date.getTime(), "yyyy-MM-dd", this.useUTCTime ? "GMT" : "LOCAL");
937
976
  }
938
977
 
939
978
  /**
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.71" };
3
+ window.EFX_GRID = { version: "6.0.72" };
@@ -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)) {
@@ -980,10 +980,13 @@ FilterInputPlugin.prototype._onInputChanged = function (e) {
980
980
  FilterInputPlugin.prototype._onOpenedChanged = function (e) {
981
981
  if (e.detail.value) {
982
982
  //open
983
- e.currentTarget.style.setProperty('pointer-events', 'none');
983
+ e.currentTarget.style.pointerEvents = "none";
984
984
  } else {
985
985
  //close
986
- e.currentTarget.style.removeProperty('pointer-events');
986
+ var ect = e.currentTarget;
987
+ setTimeout(function () {
988
+ ect.style.pointerEvents = "";
989
+ });
987
990
  }
988
991
  };
989
992
  /** @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";
@@ -1787,6 +1787,47 @@ RowFilteringPlugin._getFilteredValue = function (rowData, filters) {
1787
1787
 
1788
1788
  return true;
1789
1789
  };
1790
+ /** @private
1791
+ * @function
1792
+ * @param {Array} exp
1793
+ * @param {string} field
1794
+ * @param {Function} formatter
1795
+ * @returns {Array}
1796
+ */
1797
+
1798
+
1799
+ RowFilteringPlugin._formatArrayExpression = function (exp, field, formatter) {
1800
+ if (Array.isArray(exp)) {
1801
+ var ary = exp.slice(); // Clone to avoid modifying original data
1802
+
1803
+ var formattedVal = ary[1];
1804
+ var val = stringToDateObject(formattedVal);
1805
+
1806
+ if (val !== formattedVal) {
1807
+ ary.rawValue = val;
1808
+ ary.formattedValue = formattedVal;
1809
+ }
1810
+
1811
+ if (field && formatter && typeof val !== "string") {
1812
+ if (val != null) {
1813
+ var dummyRow = {};
1814
+ dummyRow[field] = val;
1815
+ formattedVal = formatter(dummyRow);
1816
+
1817
+ if (formattedVal) {
1818
+ ary.rawValue = val;
1819
+ ary.formattedValue = formattedVal;
1820
+ val = formattedVal;
1821
+ }
1822
+ }
1823
+ }
1824
+
1825
+ ary[1] = val;
1826
+ return ary;
1827
+ }
1828
+
1829
+ return null;
1830
+ };
1790
1831
  /** @public
1791
1832
  * @param {number} colIndex
1792
1833
  * @param {RowFilteringPlugin~FilterDialogOptions=} runtimeDialogOptions
@@ -1939,6 +1980,8 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
1939
1980
  var formattedDataAccessor = cfo._formattedDataAccessor = dialogConfig.formattedDataAccessor || null;
1940
1981
  var sortLogic = dialogConfig.sortLogic || null; // Populate data for filter dialog based on existing states
1941
1982
 
1983
+ var formatter = this._getFormatter(colIndex);
1984
+
1942
1985
  var condition2D = null;
1943
1986
  var filterMode = ""; // default
1944
1987
 
@@ -1948,8 +1991,10 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
1948
1991
  if (exp) {
1949
1992
  if (Array.isArray(exp)) {
1950
1993
  if (exp.length) {
1951
- condition2D = Array.isArray(exp[0]) ? exp : [exp]; // Guaranteed condition2D to be a 2D array
1994
+ condition2D = Array.isArray(exp[0]) ? exp.slice() : [exp]; // Guaranteed condition2D to be a 2D array
1952
1995
 
1996
+ condition2D[0] = RowFilteringPlugin._formatArrayExpression(condition2D[0], field, formatter);
1997
+ condition2D[1] = RowFilteringPlugin._formatArrayExpression(condition2D[1], field, formatter);
1953
1998
  filterMode = "advanced";
1954
1999
  }
1955
2000
  } else if (typeof exp === "function" || typeof exp === "string" || _typeof(exp) === "object") {
@@ -1960,7 +2005,7 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
1960
2005
  }
1961
2006
 
1962
2007
  var selectedItems = {};
1963
- var uniqueValues = cfo.uniqueValues = this.getUniqueValues(field, this._getFormatter(colIndex), "", rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems);
2008
+ var uniqueValues = cfo.uniqueValues = this.getUniqueValues(field, formatter, "", rawDataAccessor, formattedDataAccessor, filterFuncs, selectedItems);
1964
2009
  var keys = Object.keys(uniqueValues);
1965
2010
 
1966
2011
  if (sortLogic) {
@@ -1978,7 +2023,26 @@ RowFilteringPlugin.prototype.openDialog = function (colIndex, runtimeDialogOptio
1978
2023
  nodes: [],
1979
2024
  checked: selectedItems[formattedVal] ? true : false
1980
2025
  };
1981
- }); // Initialize dialog
2026
+ }); // Adding inputs from conditions to uniqueValues for mapping back from the dialog
2027
+
2028
+ if (condition2D) {
2029
+ var cond = condition2D[0];
2030
+
2031
+ if (cond && cond.formattedValue) {
2032
+ if (!uniqueValues[cond.formattedValue]) {
2033
+ uniqueValues[cond.formattedValue] = [cond.rawValue];
2034
+ }
2035
+ }
2036
+
2037
+ cond = condition2D[1];
2038
+
2039
+ if (cond && cond.formattedValue) {
2040
+ if (!uniqueValues[cond.formattedValue]) {
2041
+ uniqueValues[cond.formattedValue] = [cond.rawValue];
2042
+ }
2043
+ }
2044
+ } // Initialize dialog
2045
+
1982
2046
 
1983
2047
  if (this._filterDialog.init) {
1984
2048
  // TODO: support initiailization in v1
@@ -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. true value will be converted to 1
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 };
@@ -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.133",
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",
@@ -17,14 +17,14 @@
17
17
  "tr-grid-conditional-coloring": "1.0.66",
18
18
  "tr-grid-content-wrap": "1.0.20",
19
19
  "tr-grid-contextmenu": "1.0.40",
20
- "tr-grid-filter-input": "0.9.35",
20
+ "tr-grid-filter-input": "0.9.36",
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.63",
27
+ "tr-grid-row-filtering": "1.0.64",
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",
@@ -32,6 +32,6 @@
32
32
  "tr-grid-titlewrap": "1.0.20",
33
33
  "@grid/formatters": "1.0.50",
34
34
  "@grid/column-selection-dialog": "4.0.54",
35
- "@grid/filter-dialog": "4.0.59",
35
+ "@grid/filter-dialog": "4.0.60",
36
36
  "@grid/column-format-dialog": "4.0.44"
37
37
  }
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "version": "6.0.71"
69
+ "version": "6.0.72"
70
70
  }