@refinitiv-ui/efx-grid 6.0.131 → 6.0.133
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/filter-dialog/lib/checkbox-list.js +5 -0
- package/lib/filter-dialog/lib/filter-dialog.js +10 -8
- package/lib/filter-dialog/themes/base.less +12 -0
- package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
- package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/filter-dialog.less +7 -1
- package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/tr-grid-auto-tooltip/es6/AutoTooltip.js +69 -66
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +5 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +37 -5
- package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +0 -2
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +47 -49
- package/lib/tr-grid-row-selection/es6/RowSelection.js +37 -32
- package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +0 -2
- package/lib/tr-grid-textformatting/es6/TextFormatting.js +352 -333
- package/lib/types/es6/RowFiltering.d.ts +0 -2
- package/lib/types/es6/TextFormatting.d.ts +0 -1
- package/lib/versions.json +6 -6
- package/package.json +1 -1
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
import {
|
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
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
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
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
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
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
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
|
391
|
-
|
392
|
-
|
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
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
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
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
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
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
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
|
-
|
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
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
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
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
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
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
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 };
|