@refinitiv-ui/efx-grid 6.0.132 → 6.0.134

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.
Files changed (28) hide show
  1. package/lib/filter-dialog/lib/checkbox-list.js +5 -0
  2. package/lib/filter-dialog/lib/filter-dialog.js +10 -8
  3. package/lib/filter-dialog/themes/base.less +12 -0
  4. package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
  5. package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
  6. package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +1 -1
  7. package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
  8. package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +1 -1
  9. package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
  10. package/lib/filter-dialog/themes/halo/filter-dialog.less +7 -1
  11. package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +1 -1
  12. package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
  13. package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
  14. package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
  15. package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
  16. package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
  17. package/lib/grid/index.js +1 -1
  18. package/lib/tr-grid-heat-map/es6/HeatMap.d.ts +2 -2
  19. package/lib/tr-grid-heat-map/es6/HeatMap.js +55 -56
  20. package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +0 -2
  21. package/lib/tr-grid-row-filtering/es6/RowFiltering.js +47 -49
  22. package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +0 -2
  23. package/lib/tr-grid-textformatting/es6/TextFormatting.js +352 -333
  24. package/lib/types/es6/HeatMap.d.ts +2 -2
  25. package/lib/types/es6/RowFiltering.d.ts +0 -2
  26. package/lib/types/es6/TextFormatting.d.ts +0 -1
  27. package/lib/versions.json +4 -4
  28. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- import { Ext } from '../../tr-grid-util/es6/Ext.js';
3
- import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
4
- import { NumberFormatter } from '../../tr-grid-util/es6/NumberFormatter.js';
1
+ import {Ext} from '../../tr-grid-util/es6/Ext.js';
2
+ import {GridPlugin} from '../../tr-grid-util/es6/GridPlugin.js';
3
+ import {NumberFormatter} from '../../tr-grid-util/es6/NumberFormatter.js';
5
4
  import { FieldFormatter } from '../../tr-grid-util/es6/FieldFormatter.js';
6
5
  import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
7
6
 
7
+
8
8
  /** @event TextFormattingPlugin#formatChanged
9
9
  * @description Fired only when a user click OK from the format dialog, that is generated from this extension
10
10
  * @type {Object}
@@ -24,7 +24,6 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
24
24
  /** @typedef {Object} TextFormattingPlugin~FormatOptions
25
25
  * @description Available options that can be specified in the `formatType` property of each column configuration object
26
26
  * @property {string=} formatType Available options are: number, scaled, percent, and datetime
27
- * @property {string=} type Alias to formatType
28
27
  * @property {string=} field Field is required but can be defined in the column definition object
29
28
  * @property {(number|boolean)=} decimalPlaces=2
30
29
  * @property {boolean=} precisionEnabled=true If disabled, number of decimal will remain as original.
@@ -33,7 +32,6 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
33
32
  * @property {boolean=} percentSign=false If the formatType is percent and the value of percentSign is not specified, the percentSign is set to true by default
34
33
  * @property {string=} scalingUnit=million Value can be million or billion
35
34
  * @property {boolean=} multiplyBy100=false
36
- * @property {boolean=} mutiplyBy100=false Alias of multiplyBy100
37
35
  * @property {string=} dateTimeFormat="MM/DD/YYYY"
38
36
  * @property {boolean=} useUTCTime=true
39
37
  * @property {boolean=} autoTextFormatting=true If disabled, the extension's automatic formatting will not be triggered, including `formatLogic`
@@ -63,10 +61,11 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
63
61
  /** @constructor
64
62
  * @extends {GridPlugin}
65
63
  */
66
- var TextFormattingPlugin = function TextFormattingPlugin() {
67
- this._onSectionBinding = this._onSectionBinding.bind(this);
68
- this._onColumnAdded = this._onColumnAdded.bind(this);
69
- this._hosts = [];
64
+ var TextFormattingPlugin = function () {
65
+ this._onSectionBinding = this._onSectionBinding.bind(this);
66
+ this._onColumnAdded = this._onColumnAdded.bind(this);
67
+
68
+ this._hosts = [];
70
69
  };
71
70
  Ext.inherits(TextFormattingPlugin, GridPlugin);
72
71
 
@@ -87,7 +86,7 @@ TextFormattingPlugin.prototype._idnSource = "";
87
86
  * @return {string}
88
87
  */
89
88
  TextFormattingPlugin.prototype.getName = function () {
90
- return "TextFormattingPlugin"; // Read Only
89
+ return "TextFormattingPlugin"; // Read Only
91
90
  };
92
91
 
93
92
  /** Plugin that has multi-table support means that it can have multiple hosts/tables and share its states across those hosts/tables.
@@ -95,7 +94,7 @@ TextFormattingPlugin.prototype.getName = function () {
95
94
  * @return {boolean}
96
95
  */
97
96
  TextFormattingPlugin.prototype.hasMultiTableSupport = function () {
98
- return true;
97
+ return true;
99
98
  };
100
99
 
101
100
  /** @public
@@ -103,72 +102,75 @@ TextFormattingPlugin.prototype.hasMultiTableSupport = function () {
103
102
  * @param {Object=} options
104
103
  */
105
104
  TextFormattingPlugin.prototype.initialize = function (host, options) {
106
- if (this._hosts.indexOf(host) >= 0) return;
107
- this._hosts.push(host);
108
- host.listen("postSectionDataBinding", this._onSectionBinding);
109
- if (this._hosts.length === 1) {
110
- host.listen("columnAdded", this._onColumnAdded);
111
- this.config(options);
112
- }
105
+ if (this._hosts.indexOf(host) >= 0) return;
106
+ this._hosts.push(host);
107
+
108
+ host.listen("postSectionDataBinding", this._onSectionBinding);
109
+ if(this._hosts.length === 1) {
110
+ host.listen("columnAdded", this._onColumnAdded);
111
+
112
+ this.config(options);
113
+ }
113
114
  };
114
115
  /** @override
115
116
  * @ignore
116
117
  */
117
118
  TextFormattingPlugin.prototype._afterInit = function () {
118
- // WOWRKAROUND : In test-resource and tr-grid-util, avoid using static variables. duplicating DateTime
119
- var rtGrid = this._realTimeGrid;
120
- if (rtGrid && rtGrid.setDateTimeUtil) {
121
- rtGrid.setDateTimeUtil(DateTime);
122
- }
119
+ // WOWRKAROUND : In test-resource and tr-grid-util, avoid using static variables. duplicating DateTime
120
+ var rtGrid = this._realTimeGrid;
121
+ if(rtGrid && rtGrid.setDateTimeUtil) {
122
+ rtGrid.setDateTimeUtil(DateTime);
123
+ }
123
124
  };
124
125
  /** @public
125
126
  * @param {Object} host core grid instance
126
127
  */
127
128
  TextFormattingPlugin.prototype.unload = function (host) {
128
- var at = this._hosts.indexOf(host);
129
- if (at < 0) {
130
- return;
131
- }
132
- host.unlisten("postSectionDataBinding", this._onSectionBinding);
133
- host.unlisten("columnAdded", this._onColumnAdded);
134
- this._hosts.splice(at, 1);
129
+ var at = this._hosts.indexOf(host);
130
+ if(at < 0) { return; }
131
+
132
+ host.unlisten("postSectionDataBinding", this._onSectionBinding);
133
+ host.unlisten("columnAdded", this._onColumnAdded);
134
+
135
+ this._hosts.splice(at, 1);
135
136
  };
136
137
 
138
+
137
139
  /** @public
138
140
  * @param {Object=} options
139
141
  */
140
142
  TextFormattingPlugin.prototype.config = function (options) {
141
- if (!options) {
142
- return;
143
- }
144
- this._idnSource = options["idnSource"] ? "idn" : "";
145
- var bool = options["autoTextFormatting"];
146
- if (bool != null) {
147
- this._disabled = !bool;
148
- }
149
- var columns = options.columns;
150
- if (!columns) {
151
- return;
152
- }
153
- // WARNING: Name colliding between column definition and format option can occur
154
-
155
- var dirty = 0;
156
- var len = columns.length;
157
- for (var i = 0; i < len; ++i) {
158
- dirty |= this._setColumnFormat(i, columns[i]);
159
- }
160
-
161
- // WOWRKAROUND : In test-resource and tr-grid-util, avoid using static variables. duplicating DateTime
162
- var lang = options["lang"];
163
- if (lang) {
164
- DateTime.setLocale(lang);
165
- }
166
- if (dirty) {
167
- len = this._hosts.length;
168
- for (i = 0; i < len; ++i) {
169
- this._hosts[i]["requestRowRefresh"]();
170
- }
171
- }
143
+ if(!options) { return; }
144
+
145
+ this._idnSource = (options["idnSource"]) ? "idn" : "";
146
+
147
+ var bool = options["autoTextFormatting"];
148
+ if(bool != null) {
149
+ this._disabled = !bool;
150
+ }
151
+
152
+ var columns = options.columns;
153
+ if(!columns) { return; }
154
+ // WARNING: Name colliding between column definition and format option can occur
155
+
156
+ var dirty = 0;
157
+ var len = columns.length;
158
+ for(var i = 0; i < len; ++i) {
159
+ dirty |= this._setColumnFormat(i, columns[i]);
160
+ }
161
+
162
+ // WOWRKAROUND : In test-resource and tr-grid-util, avoid using static variables. duplicating DateTime
163
+ var lang = options["lang"];
164
+ if(lang) {
165
+ DateTime.setLocale(lang);
166
+ }
167
+
168
+ if(dirty) {
169
+ len = this._hosts.length;
170
+ for(i = 0; i < len; ++i) {
171
+ this._hosts[i]["requestRowRefresh"]();
172
+ }
173
+ }
172
174
  };
173
175
 
174
176
  /** @public
@@ -176,28 +178,30 @@ TextFormattingPlugin.prototype.config = function (options) {
176
178
  * @return {!Object}
177
179
  */
178
180
  TextFormattingPlugin.prototype.getConfigObject = function (gridOptions) {
179
- var obj = gridOptions || {};
180
- if (this._idnSource) {
181
- obj.idnSource = true;
182
- }
183
- if (this._disabled) {
184
- obj.autoTextFormatting = false;
185
- }
186
- var columns = obj.columns;
187
- if (!columns) {
188
- columns = obj.columns = [];
189
- }
190
- var len = this.getColumnCount();
191
- for (var i = 0; i < len; ++i) {
192
- var column = columns[i];
193
- if (!column) {
194
- column = columns[i] = {};
195
- }
196
- this.getColumnFormatOptions(i, column);
197
- // TODO: move the formatting option (column level) into formatting property (column extension option level)
198
- }
199
-
200
- return obj;
181
+ var obj = gridOptions || {};
182
+ if(this._idnSource) {
183
+ obj.idnSource = true;
184
+ }
185
+ if(this._disabled) {
186
+ obj.autoTextFormatting = false;
187
+ }
188
+
189
+ var columns = obj.columns;
190
+ if(!columns) {
191
+ columns = obj.columns = [];
192
+ }
193
+
194
+ var len = this.getColumnCount();
195
+ for(var i = 0; i < len; ++i) {
196
+ var column = columns[i];
197
+ if(!column) {
198
+ column = columns[i] = {};
199
+ }
200
+ this.getColumnFormatOptions(i, column);
201
+ // TODO: move the formatting option (column level) into formatting property (column extension option level)
202
+ }
203
+
204
+ return obj;
201
205
  };
202
206
 
203
207
  /** @public
@@ -205,12 +209,12 @@ TextFormattingPlugin.prototype.getConfigObject = function (gridOptions) {
205
209
  * @param {TextFormattingPlugin~FormatOptions} formatOptions
206
210
  */
207
211
  TextFormattingPlugin.prototype.setColumnFormat = function (colIndex, formatOptions) {
208
- if (this._setColumnFormat(colIndex, formatOptions)) {
209
- var len = this._hosts.length;
210
- for (var i = 0; i < len; ++i) {
211
- this._hosts[i]["requestRowRefresh"]();
212
- }
213
- }
212
+ if(this._setColumnFormat(colIndex, formatOptions)) {
213
+ var len = this._hosts.length;
214
+ for(var i = 0; i < len; ++i) {
215
+ this._hosts[i]["requestRowRefresh"]();
216
+ }
217
+ }
214
218
  };
215
219
  /** @private
216
220
  * @param {number} colIndex
@@ -218,133 +222,137 @@ TextFormattingPlugin.prototype.setColumnFormat = function (colIndex, formatOptio
218
222
  * @return {boolean} Returns true if there is any change
219
223
  */
220
224
  TextFormattingPlugin.prototype._setColumnFormat = function (colIndex, userObj) {
221
- var colData = this._newColumnData(colIndex);
222
- var colDef = userObj;
223
- var fo = null; // Actual Format Options
224
-
225
- var field;
226
- if (colDef) {
227
- // Extract field and format type
228
- // Extract options from column definition object first
229
- field = colDef["field"];
230
- var autoTextFormatting = colDef["autoTextFormatting"];
231
- if (autoTextFormatting != null) {
232
- colData["autoTextFormatting"] = autoTextFormatting ? true : false;
233
- }
234
- var formatLogic = colDef["formatLogic"];
235
- if (typeof formatLogic === "function") {
236
- colData["formatLogic"] = formatLogic;
237
- }
238
-
239
- // Fallback
240
- fo = colDef["formatType"] || colDef["type"];
241
- // Format type may be an format option object at this point
242
- if (fo && _typeof(fo) === "object") {
243
- // The formatType can be the format options (object) itself
244
- if (fo["field"]) {
245
- field = fo["field"];
246
- }
247
- autoTextFormatting = fo["autoTextFormatting"];
248
- if (autoTextFormatting != null) {
249
- colData["autoTextFormatting"] = autoTextFormatting ? true : false;
250
- }
251
- formatLogic = fo["formatLogic"];
252
- if (typeof formatLogic === "function") {
253
- colData["formatLogic"] = formatLogic;
254
- }
255
- } else {
256
- fo = colDef;
257
- // colDef = null;
258
- }
259
- }
260
-
261
- var prevFO = colData["formatOptions"]; // For later use
262
-
263
- // Clear previously stored data
264
- colData["formatOptions"] = null;
265
- colData["textFormatter"] = null;
266
- colData["numberFormatter"] = null;
267
-
268
- // Check if the provided arguments are valid and sufficient
269
- if (!fo) {
270
- return prevFO ? true : false;
271
- }
272
- var fot = fo["formatType"] || fo["type"];
273
- if (!fot || typeof fot != "string") {
274
- // Format type must be string
275
- return prevFO ? true : false;
276
- }
277
- fot = fot.toLowerCase(); // Guaranteed that all format types are case insensitive
278
- if (fot === "general") {
279
- // "general" type means no formatting
280
- return prevFO ? true : false;
281
- }
282
- if (!field) {
283
- // The field is not given try our best to get it
284
- field = this._getField(colIndex);
285
- if (!field) {
286
- if (prevFO) {
287
- field = prevFO["field"];
288
- }
289
- }
290
- }
291
-
292
- // Format option is valid after this point
293
- this._noFormatting = false; // Quick workaround
294
-
295
- // WARNING: We directly store and modify user data. This may inadvertently cause some bugs
296
- fo["field"] = field;
297
- fo["formatType"] = fot;
298
- if (!fo["formattedField"]) {
299
- fo["formattedField"] = field + "_FORMATTED";
300
- }
301
- if (fo["idnSource"] == null) {
302
- fo["idnSource"] = this._idnSource;
303
- }
304
- var ff = new FieldFormatter(fo); // FieldFormatter will be used for rendering
305
- var nf = null;
306
- if (fot == "number" || fot == "scaled" || fot == "percent") {
307
- var precision = fo["decimalPlaces"];
308
- var precisionEnabled = fo["precisionEnabled"];
309
- if (typeof precision == "number") {
310
- colData["precision"] = precision;
311
- if (precisionEnabled == null) {
312
- precisionEnabled = true;
313
- }
314
- } else if (precision == true) {
315
- colData["precision"] = null;
316
- precision = 2;
317
- precisionEnabled = true;
318
- } else if (precision === false) {
319
- colData["precision"] = null;
320
- precision = 0;
321
- precisionEnabled = false;
322
- } else {
323
- colData["precision"] = null;
324
- precision = 2;
325
- if (precisionEnabled == null) {
326
- precisionEnabled = true;
327
- }
328
- }
329
- fo["decimalPlaces"] = precision;
330
- fo["precisionEnabled"] = precisionEnabled;
331
- if (fot === "percent") {
332
- var percentSign = fo["percentSign"];
333
- if (percentSign == null) {
334
- fo["percentSign"] = true;
335
- } else {
336
- colData["percentSign"] = percentSign;
337
- }
338
- }
339
- nf = new NumberFormatter(fo);
340
- ff.setNumberFormatter(nf.format);
341
- }
342
- colData["formatOptions"] = fo;
343
- colData["textFormatter"] = ff;
344
- colData["numberFormatter"] = nf;
345
-
346
- // Everything is done. Request for re-rendering
347
- return true;
225
+ var colData = this._newColumnData(colIndex);
226
+ var colDef = userObj;
227
+ var fo = null; // Actual Format Options
228
+
229
+ var field;
230
+ if(colDef) { // Extract field and format type
231
+ // Extract options from column definition object first
232
+ field = colDef["field"];
233
+
234
+ var autoTextFormatting = colDef["autoTextFormatting"];
235
+ if(autoTextFormatting != null) {
236
+ colData["autoTextFormatting"] = autoTextFormatting ? true : false;
237
+ }
238
+ var formatLogic = colDef["formatLogic"];
239
+ if(typeof formatLogic === "function") {
240
+ colData["formatLogic"] = formatLogic;
241
+ }
242
+
243
+ // Fallback
244
+ fo = colDef["formatType"] || colDef["type"];
245
+ // Format type may be an format option object at this point
246
+ if(fo && typeof fo === "object") { // The formatType can be the format options (object) itself
247
+ if(fo["field"]) {
248
+ field = fo["field"];
249
+ }
250
+
251
+ autoTextFormatting = fo["autoTextFormatting"];
252
+ if(autoTextFormatting != null) {
253
+ colData["autoTextFormatting"] = autoTextFormatting ? true : false;
254
+ }
255
+ formatLogic = fo["formatLogic"];
256
+ if(typeof formatLogic === "function") {
257
+ colData["formatLogic"] = formatLogic;
258
+ }
259
+ } else {
260
+ fo = colDef;
261
+ // colDef = null;
262
+ }
263
+ }
264
+ var prevFO = colData["formatOptions"]; // For later use
265
+
266
+ // Clear previously stored data
267
+ colData["formatOptions"] = null;
268
+ colData["textFormatter"] = null;
269
+ colData["numberFormatter"] = null;
270
+
271
+ // Check if the provided arguments are valid and sufficient
272
+ if(!fo) {
273
+ return (prevFO) ? true : false;
274
+ }
275
+
276
+ var fot = fo["formatType"] || fo["type"];
277
+ if(!fot || typeof fot != "string") { // Format type must be string
278
+ return (prevFO) ? true : false;
279
+ }
280
+
281
+ fot = fot.toLowerCase(); // Guaranteed that all format types are case insensitive
282
+ if(fot === "general") { // "general" type means no formatting
283
+ return (prevFO) ? true : false;
284
+ }
285
+ if(!field) { // The field is not given try our best to get it
286
+ field = this._getField(colIndex);
287
+ if(!field) {
288
+ if(prevFO) {
289
+ field = prevFO["field"];
290
+ }
291
+ }
292
+ }
293
+
294
+ // Format option is valid after this point
295
+ this._noFormatting = false; // Quick workaround
296
+
297
+ // WARNING: We directly store and modify user data. This may inadvertently cause some bugs
298
+ fo["field"] = field;
299
+ fo["formatType"] = fot;
300
+ if(!fo["formattedField"]) {
301
+ fo["formattedField"] = field + "_FORMATTED";
302
+ }
303
+ if(fo["idnSource"] == null) {
304
+ fo["idnSource"] = this._idnSource;
305
+ }
306
+
307
+ var ff = new FieldFormatter(fo); // FieldFormatter will be used for rendering
308
+ var nf = null;
309
+ if(fot == "number" || fot == "scaled" || fot == "percent") {
310
+ var precision = fo["decimalPlaces"];
311
+ var precisionEnabled = fo["precisionEnabled"];
312
+ if(typeof precision == "number"){
313
+ colData["precision"] = precision;
314
+ if(precisionEnabled == null){
315
+ precisionEnabled = true;
316
+ }
317
+ } else if(precision == true){
318
+ colData["precision"] = null;
319
+ precision = 2;
320
+ precisionEnabled = true;
321
+ } else if(precision === false) {
322
+ colData["precision"] = null;
323
+ precision = 0;
324
+ precisionEnabled = false;
325
+ } else {
326
+ colData["precision"] = null;
327
+ precision = 2;
328
+ if(precisionEnabled == null){
329
+ precisionEnabled = true;
330
+ }
331
+ }
332
+
333
+ fo["decimalPlaces"] = precision;
334
+ fo["precisionEnabled"] = precisionEnabled;
335
+
336
+ if(fot === "percent") {
337
+ var percentSign = fo["percentSign"];
338
+ if(percentSign == null) {
339
+ fo["percentSign"] = true;
340
+ } else {
341
+ colData["percentSign"] = percentSign;
342
+ }
343
+ }
344
+
345
+ nf = new NumberFormatter(fo);
346
+ ff.setNumberFormatter(nf.format);
347
+
348
+ }
349
+
350
+ colData["formatOptions"] = fo;
351
+ colData["textFormatter"] = ff;
352
+ colData["numberFormatter"] = nf;
353
+
354
+ // Everything is done. Request for re-rendering
355
+ return true;
348
356
  };
349
357
  /** @public
350
358
  * @param {number} colIndex
@@ -352,45 +360,46 @@ TextFormattingPlugin.prototype._setColumnFormat = function (colIndex, userObj) {
352
360
  * @return {!Object}
353
361
  */
354
362
  TextFormattingPlugin.prototype.getColumnFormatOptions = function (colIndex, options) {
355
- if (!options) {
356
- options = {};
357
- }
358
- var colData = this._getColumnData(colIndex);
359
- if (colData) {
360
- var formatOptions = colData["formatOptions"];
361
- var textFormatter = colData["textFormatter"];
362
- var numberFormatter = colData["numberFormatter"];
363
- if (colData["autoTextFormatting"] != null) {
364
- options["autoTextFormatting"] = colData["autoTextFormatting"];
365
- }
366
- if (formatOptions) {
367
- options["formatType"] = formatOptions.formatType || formatOptions.type;
368
- }
369
- if (textFormatter) {
370
- textFormatter.getOptions(options);
371
- }
372
- if (numberFormatter) {
373
- numberFormatter.getOptions(options);
374
- var precision = colData["precision"];
375
- if (precision != null) {
376
- options["decimalPlaces"] = precision;
377
- } else {
378
- delete options["decimalPlaces"];
379
- }
380
- if (options["formatType"] === "percent" && colData["percentSign"] != null) {
381
- options["percentSign"] = colData["percentSign"];
382
- }
383
- }
384
- }
385
- return options;
363
+ if(!options) { options = {}; }
364
+
365
+ var colData = this._getColumnData(colIndex);
366
+ if(colData) {
367
+ var formatOptions = colData["formatOptions"];
368
+ var textFormatter = colData["textFormatter"];
369
+ var numberFormatter = colData["numberFormatter"];
370
+
371
+ if(colData["autoTextFormatting"] != null) {
372
+ options["autoTextFormatting"] = colData["autoTextFormatting"];
373
+ }
374
+ if(formatOptions) {
375
+ options["formatType"] = formatOptions.formatType || formatOptions.type;
376
+ }
377
+ if(textFormatter) {
378
+ textFormatter.getOptions(options);
379
+ }
380
+ if(numberFormatter) {
381
+ numberFormatter.getOptions(options);
382
+ var precision = colData["precision"];
383
+ if(precision != null){
384
+ options["decimalPlaces"] = precision;
385
+ } else {
386
+ delete options["decimalPlaces"];
387
+ }
388
+
389
+ if(options["formatType"] === "percent" && colData["percentSign"] != null) {
390
+ options["percentSign"] = colData["percentSign"];
391
+ }
392
+ }
393
+ }
394
+ return options;
386
395
  };
387
396
  /** @private
388
397
  * @param {Object} e
389
398
  */
390
- TextFormattingPlugin.prototype._onColumnAdded = function (e) {
391
- if (e.context) {
392
- this._setColumnFormat(e.colIndex, e.context);
393
- }
399
+ TextFormattingPlugin.prototype._onColumnAdded = function(e) {
400
+ if(e.context) {
401
+ this._setColumnFormat(e.colIndex, e.context);
402
+ }
394
403
  };
395
404
 
396
405
  /** @private
@@ -398,58 +407,64 @@ TextFormattingPlugin.prototype._onColumnAdded = function (e) {
398
407
  * @return {boolean}
399
408
  */
400
409
  TextFormattingPlugin._hasAutoFormatting = function (colData) {
401
- if (colData) {
402
- if (colData["autoTextFormatting"] === false || colData["percentBar"] || colData["rangeBar"]) {
403
- return false;
404
- }
405
- return true;
406
- }
407
- return false;
410
+ if(colData) {
411
+ if(
412
+ colData["autoTextFormatting"] === false ||
413
+ colData["percentBar"] ||
414
+ colData["rangeBar"]
415
+ ) {
416
+ return false;
417
+ }
418
+ return true;
419
+ }
420
+ return false;
408
421
  };
409
422
 
410
423
  /** @private
411
424
  * @param {Object} e
412
425
  */
413
426
  TextFormattingPlugin.prototype._onSectionBinding = function (e) {
414
- if (this._noFormatting || this._disabled) {
415
- return;
416
- }
417
- var section = e["section"];
418
- var dataRows = e["dataRows"];
419
- var colCount = section.getColumnCount();
420
- var fromR = /** @type{number} */e["fromRowIndex"];
421
- var toR = /** @type{number} */e["toRowIndex"];
422
- var arg = {};
423
- for (var c = 0; c < colCount; ++c) {
424
- var colData = this._getColumnData(c); // will get column data from hosts[0] only
425
- if (!TextFormattingPlugin._hasAutoFormatting(colData)) {
426
- continue;
427
- }
428
- var formatOptions = /** @type{TextFormattingPlugin~FormatOptions} */colData["formatOptions"];
429
- if (!formatOptions) {
430
- continue;
431
- }
432
- var formatter = colData["textFormatter"];
433
- var formatLogic = colData["formatLogic"];
434
- arg.colIndex = c;
435
- arg.field = formatter.getField();
436
- arg.format = formatter.format; // WARNING: Accessing private member
437
- for (var r = fromR; r < toR; ++r) {
438
- var cell = section.getCell(c, r, false);
439
- if (cell) {
440
- var rowData = this._getRowData(dataRows[r]);
441
- arg.formattedText = TextFormattingPlugin._getFormattedText(formatter, rowData, cell);
442
- if (formatLogic) {
443
- arg.rowIndex = r;
444
- arg.cell = cell;
445
- arg.rowData = rowData;
446
- formatLogic(arg);
447
- } else {
448
- cell.setTextContent(arg.formattedText);
449
- }
450
- }
451
- }
452
- }
427
+ if(this._noFormatting || this._disabled) { return; }
428
+
429
+ var section = e["section"];
430
+ var dataRows = e["dataRows"];
431
+ var colCount = section.getColumnCount();
432
+ var fromR = /** @type{number} */(e["fromRowIndex"]);
433
+ var toR = /** @type{number} */(e["toRowIndex"]);
434
+ var arg = {};
435
+
436
+ for (var c = 0; c < colCount; ++c) {
437
+ var colData = this._getColumnData(c); // will get column data from hosts[0] only
438
+ if(!TextFormattingPlugin._hasAutoFormatting(colData)) {
439
+ continue;
440
+ }
441
+
442
+ var formatOptions = /** @type{TextFormattingPlugin~FormatOptions} */(colData["formatOptions"]);
443
+
444
+ if(!formatOptions) { continue; }
445
+
446
+ var formatter = colData["textFormatter"];
447
+ var formatLogic = colData["formatLogic"];
448
+
449
+ arg.colIndex = c;
450
+ arg.field = formatter.getField();
451
+ arg.format = formatter.format; // WARNING: Accessing private member
452
+ for (var r = fromR; r < toR; ++r) {
453
+ var cell = section.getCell(c, r, false);
454
+ if(cell) {
455
+ var rowData = this._getRowData(dataRows[r]);
456
+ arg.formattedText = TextFormattingPlugin._getFormattedText(formatter, rowData, cell);
457
+ if(formatLogic) {
458
+ arg.rowIndex = r;
459
+ arg.cell = cell;
460
+ arg.rowData = rowData;
461
+ formatLogic(arg);
462
+ } else {
463
+ cell.setTextContent(arg.formattedText);
464
+ }
465
+ }
466
+ }
467
+ }
453
468
  };
454
469
 
455
470
  /** @private
@@ -458,16 +473,16 @@ TextFormattingPlugin.prototype._onSectionBinding = function (e) {
458
473
  * @param {Object} cell Grid cell instance
459
474
  * @return {string}
460
475
  */
461
- TextFormattingPlugin._getFormattedText = function (formatter, rowData, cell) {
462
- if (rowData) {
463
- return formatter.formatRowData(rowData);
464
- } else {
465
- var content = cell.getContent();
466
- if (content) {
467
- return formatter.formatValue(content.textContent);
468
- }
469
- }
470
- return "";
476
+ TextFormattingPlugin._getFormattedText = function(formatter, rowData, cell) {
477
+ if(rowData) {
478
+ return formatter.formatRowData(rowData);
479
+ } else {
480
+ var content = cell.getContent();
481
+ if(content) {
482
+ return formatter.formatValue(content.textContent);
483
+ }
484
+ }
485
+ return "";
471
486
  };
472
487
 
473
488
  /** @public
@@ -475,7 +490,7 @@ TextFormattingPlugin._getFormattedText = function (formatter, rowData, cell) {
475
490
  * @return {FieldFormatter}
476
491
  */
477
492
  TextFormattingPlugin.prototype.getFormatter = function (colIndex) {
478
- return this._getColumnOption(colIndex, "textFormatter") || null;
493
+ return this._getColumnOption(colIndex, "textFormatter") || null;
479
494
  };
480
495
  /** Format the given object by the formatter from the specified column. The object is converted to string, if no formatter is specified
481
496
  * @public
@@ -484,41 +499,45 @@ TextFormattingPlugin.prototype.getFormatter = function (colIndex) {
484
499
  * @return {string}
485
500
  */
486
501
  TextFormattingPlugin.prototype.formatText = function (colIndex, obj) {
487
- if (obj != null) {
488
- var formatter = this.getFormatter(colIndex);
489
- return formatter ? formatter.formatValue(obj) : obj + "";
490
- }
491
- return "";
502
+ if(obj != null) {
503
+ var formatter = this.getFormatter(colIndex);
504
+ return (formatter) ? formatter.formatValue(obj) : obj + "";
505
+ }
506
+ return "";
492
507
  };
493
508
 
494
509
  /** @public
495
510
  * @param {number} colIndex
496
511
  */
497
512
  TextFormattingPlugin.prototype.openDialog = function (colIndex) {
498
- if (!this._formatDialog) {
499
- this._formatDialog = document.createElement('tr-grid-format-dialog');
500
- this._formatDialog.addEventListener('data-change', this._onFormatDialogDataChange.bind(this));
501
- }
502
- if (this._formatDialog.is === 'tr-grid-format-dialog') {
503
- // Check that tr-grid-format-dialog is imported
504
- var options = this.getColumnFormatOptions(colIndex);
505
- this._formatDialog.data = {
506
- valueFormatTab: options
507
- };
508
- this._formatDialog.colIndex = colIndex;
509
- this._formatDialog.show();
510
- }
513
+ if (!this._formatDialog) {
514
+ this._formatDialog = document.createElement('tr-grid-format-dialog');
515
+ this._formatDialog.addEventListener('data-change', this._onFormatDialogDataChange.bind(this));
516
+ }
517
+
518
+ if (this._formatDialog.is === 'tr-grid-format-dialog') { // Check that tr-grid-format-dialog is imported
519
+ var options = this.getColumnFormatOptions(colIndex);
520
+ this._formatDialog.data = {
521
+ valueFormatTab: options
522
+ };
523
+ this._formatDialog.colIndex = colIndex;
524
+ this._formatDialog.show();
525
+ }
511
526
  };
512
527
 
513
528
  /** @private
514
529
  * @param {Object} e
515
530
  */
516
531
  TextFormattingPlugin.prototype._onFormatDialogDataChange = function (e) {
517
- var colIndex = this._formatDialog.colIndex;
518
- var obj = e.detail.data.valueFormatTab;
519
- this.setColumnFormat(colIndex, obj);
520
- obj.colIndex = colIndex;
521
- this._dispatch("formatChanged", obj);
532
+ var colIndex = this._formatDialog.colIndex;
533
+ var obj = e.detail.data.valueFormatTab;
534
+ this.setColumnFormat(colIndex, obj);
535
+
536
+ obj.colIndex = colIndex;
537
+ this._dispatch("formatChanged", obj);
522
538
  };
539
+
540
+
541
+
523
542
  export default TextFormattingPlugin;
524
- export { TextFormattingPlugin, TextFormattingPlugin as TextFormatting, TextFormattingPlugin as TextFormattingExtension };
543
+ export { TextFormattingPlugin, TextFormattingPlugin as TextFormatting, TextFormattingPlugin as TextFormattingExtension };