@refinitiv-ui/efx-grid 6.0.126 → 6.0.128

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.
@@ -1,8 +1,9 @@
1
- import { Ext } from '../../tr-grid-util/es6/Ext.js';
2
- import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
3
- import { ElfUtil } from '../../tr-grid-util/es6/ElfUtil.js';
4
- import { ElfDate } from '../../tr-grid-util/es6/ElfDate.js';
1
+ import {Ext} from '../../tr-grid-util/es6/Ext.js';
2
+ import {GridPlugin} from '../../tr-grid-util/es6/GridPlugin.js';
3
+ import {ElfUtil} from '../../tr-grid-util/es6/ElfUtil.js';
4
+ import {ElfDate} from '../../tr-grid-util/es6/ElfDate.js';
5
5
  import { CoralItems } from '../../tr-grid-util/es6/CoralItems.js';
6
+
6
7
  /** @typedef {Object} FilterInputPlugin~GridColumn
7
8
  * @description FilterInputPlugin options available in each individual grid's column
8
9
  * @property {FilterInputPlugin~ColumnOptions=} filterInput=null
@@ -51,141 +52,120 @@ import { CoralItems } from '../../tr-grid-util/es6/CoralItems.js';
51
52
  * @param {string} str
52
53
  * @return {string}
53
54
  */
54
-
55
55
  function convertToLowerCase(str) {
56
- if (typeof str === "string") {
57
- return str.toLowerCase();
58
- }
59
-
60
- return "";
56
+ if(typeof str === "string") {
57
+ return str.toLowerCase();
58
+ }
59
+ return "";
61
60
  }
61
+
62
62
  /** @constructor
63
63
  * @extends {GridPlugin}
64
64
  * @param {FilterInputPlugin~Options=} options
65
65
  */
66
-
67
-
68
- var FilterInputPlugin = function FilterInputPlugin(options) {
69
- this._onInputChanged = this._onInputChanged.bind(this);
70
- this._onOpenedChanged = this._onOpenedChanged.bind(this);
71
- this._onDateChanged = this._onDateChanged.bind(this);
72
- this._onPostDataSourceChanged = this._onPostDataSourceChanged.bind(this);
73
- this._onColumnAdded = this._onColumnAdded.bind(this);
74
- this._onRowFilteringRetrieved = this._onRowFilteringRetrieved.bind(this);
75
- this._onRowFilteringFailed = this._onRowFilteringFailed.bind(this);
76
- this._onColumnFilterFailed = this._onColumnFilterFailed.bind(this);
77
- this.refresh = this.refresh.bind(this);
78
- this._updateUIs = this._updateUIs.bind(this);
79
- this._hosts = [];
80
-
81
- if (options) {
82
- this.config({
83
- "filterInput": options
84
- });
85
- }
66
+ var FilterInputPlugin = function (options) {
67
+ this._onInputChanged = this._onInputChanged.bind(this);
68
+ this._onOpenedChanged = this._onOpenedChanged.bind(this);
69
+ this._onDateChanged = this._onDateChanged.bind(this);
70
+ this._onPostDataSourceChanged = this._onPostDataSourceChanged.bind(this);
71
+ this._onColumnAdded = this._onColumnAdded.bind(this);
72
+ this._onRowFilteringRetrieved = this._onRowFilteringRetrieved.bind(this);
73
+ this._onRowFilteringFailed = this._onRowFilteringFailed.bind(this);
74
+ this._onColumnFilterFailed = this._onColumnFilterFailed.bind(this);
75
+ this.refresh = this.refresh.bind(this);
76
+ this._updateUIs = this._updateUIs.bind(this);
77
+
78
+ this._hosts = [];
79
+ if(options) {
80
+ this.config({"filterInput": options});
81
+ }
86
82
  };
87
-
88
83
  Ext.inherits(FilterInputPlugin, GridPlugin);
84
+
89
85
  /** Filter Processor used to perform actual filtering (This extension provides only UIs).
90
86
  * @type {*}
91
87
  * @private
92
88
  */
93
-
94
89
  FilterInputPlugin.prototype._filterProc = null;
95
90
  /** @type {Object}
96
91
  * @private
97
92
  */
98
-
99
93
  FilterInputPlugin.prototype._gridConfig = null;
94
+
100
95
  /** Array of grid sections
101
96
  * @type {Array.<Object>}
102
97
  * @private
103
98
  */
104
-
105
99
  FilterInputPlugin.prototype._inputSects = null;
100
+
106
101
  /** @type {number}
107
102
  * @private
108
103
  */
109
-
110
104
  FilterInputPlugin.prototype._refreshTimer = 0;
111
105
  /** @type {number}
112
106
  * @private
113
107
  */
114
-
115
108
  FilterInputPlugin.prototype._uiTimer = 0;
116
109
  /** @type {boolean}
117
110
  * @private
118
111
  */
119
-
120
112
  FilterInputPlugin.prototype._freezeInputValue = false;
121
113
  /** @type {string|boolean}
122
114
  * @private
123
115
  */
124
-
125
116
  FilterInputPlugin.prototype._inputTrigger = "keyup";
117
+
126
118
  /** @public
127
119
  * @return {string}
128
120
  */
129
-
130
121
  FilterInputPlugin.prototype.getName = function () {
131
- return "FilterInputPlugin"; // Read Only
122
+ return "FilterInputPlugin"; // Read Only
132
123
  };
133
124
  /** @public
134
125
  * @param {Object} host core grid object
135
126
  * @param {Object=} options
136
127
  */
137
-
138
-
139
128
  FilterInputPlugin.prototype.initialize = function (host, options) {
140
- if (this._hosts.indexOf(host) >= 0) {
141
- return;
142
- }
143
-
144
- this._hosts.push(host);
145
-
146
- host.listen("postDataSourceChanged", this._onPostDataSourceChanged);
147
- host.listen("columnAdded", this._onColumnAdded);
148
- this.config(options); // In case of lazy loading
149
- // var title = host.getSection("title");
150
- // if(title) {
151
- // this._onPostDataSourceChanged();
152
- // }
129
+ if(this._hosts.indexOf(host) >= 0) { return; }
130
+ this._hosts.push(host);
131
+
132
+ host.listen("postDataSourceChanged", this._onPostDataSourceChanged);
133
+ host.listen("columnAdded", this._onColumnAdded);
134
+
135
+ this.config(options);
136
+ // In case of lazy loading
137
+ // var title = host.getSection("title");
138
+ // if(title) {
139
+ // this._onPostDataSourceChanged();
140
+ // }
153
141
  };
154
142
  /** @public
155
143
  * @param {Object} host core grid object
156
144
  */
157
-
158
-
159
145
  FilterInputPlugin.prototype.unload = function (host) {
160
- var at = this._hosts.indexOf(host);
161
-
162
- if (at < 0) {
163
- return;
164
- }
165
-
166
- host.unlisten("postDataSourceChanged", this._onPostDataSourceChanged);
167
-
168
- this._hosts.splice(at, 1);
169
-
170
- if (this._inputSects && at < this._inputSects.length) {
171
- this._inputSects.splice(at, 1);
172
- }
173
-
174
- if (!this._hosts.length) {
175
- this._compositeGrid = this._realTimeGrid = this._filterBuilder = null;
176
- this._filterProc = this._gridConfig = this._inputSects = null;
177
-
178
- if (this._refreshTimer) {
179
- clearTimeout(this._refreshTimer);
180
- this._refreshTimer = 0;
181
- }
182
-
183
- if (this._uiTimer) {
184
- clearTimeout(this._uiTimer);
185
- this._uiTimer = 0;
186
- }
187
- }
146
+ var at = this._hosts.indexOf(host);
147
+ if(at < 0) { return; }
148
+
149
+ host.unlisten("postDataSourceChanged", this._onPostDataSourceChanged);
150
+ this._hosts.splice(at, 1);
151
+ if(this._inputSects && at < this._inputSects.length) {
152
+ this._inputSects.splice(at, 1);
153
+ }
154
+ if(!this._hosts.length) {
155
+ this._compositeGrid = this._realTimeGrid = this._filterBuilder = null;
156
+ this._filterProc = this._gridConfig = this._inputSects = null;
157
+
158
+ if(this._refreshTimer) {
159
+ clearTimeout(this._refreshTimer);
160
+ this._refreshTimer = 0;
161
+ }
162
+ if(this._uiTimer) {
163
+ clearTimeout(this._uiTimer);
164
+ this._uiTimer = 0;
165
+ }
166
+ }
188
167
  };
168
+
189
169
  /** Prevent built-in config
190
170
  * @public
191
171
  * @ignore
@@ -193,758 +173,636 @@ FilterInputPlugin.prototype.unload = function (host) {
193
173
  * @param {Object} options
194
174
  * @return {*}
195
175
  */
196
-
197
-
198
- FilterInputPlugin.prototype.beforeProcessOption = function (optionName, options) {
199
- if (optionName === 'filterRow' || optionName === 'FilterRow') {
200
- return false; // eslint-disable-line
201
- }
202
-
203
- return; // eslint-disable-line
176
+ FilterInputPlugin.prototype.beforeProcessOption = function(optionName, options) {
177
+ if (optionName === 'filterRow' || optionName === 'FilterRow') {
178
+ return false; // eslint-disable-line
179
+ }
180
+ return; // eslint-disable-line
204
181
  };
205
182
  /** @private
206
183
  * @param {string} optionName
207
184
  * @param {Object} options
208
185
  */
209
-
210
-
211
- FilterInputPlugin.prototype._afterInit = function () {
212
- // Retrieve RowFilteringPlugin is async operation
213
- // onPostDataSourceChange has logic to apply default filter, which need to be done after RowFilteringPlugin is loaded
214
- this._requestPlugin(this._hosts[0], "RowFilteringPlugin", this._gridConfig).then(this._onRowFilteringRetrieved)["catch"](this._onRowFilteringFailed)["finally"](this._onPostDataSourceChanged);
186
+ FilterInputPlugin.prototype._afterInit = function() {
187
+ // Retrieve RowFilteringPlugin is async operation
188
+ // onPostDataSourceChange has logic to apply default filter, which need to be done after RowFilteringPlugin is loaded
189
+ this._requestPlugin(this._hosts[0], "RowFilteringPlugin", this._gridConfig)
190
+ .then(this._onRowFilteringRetrieved)
191
+ .catch(this._onRowFilteringFailed)
192
+ .finally(this._onPostDataSourceChanged);
215
193
  };
194
+
216
195
  /** @public
217
196
  * @param {Object=} options
218
197
  */
219
-
220
-
221
198
  FilterInputPlugin.prototype.config = function (options) {
222
- if (!options) {
223
- return;
224
- }
225
-
226
- this._gridConfig = options; // For loading dependency
227
-
228
- var filterInputOptions = options["filterInput"];
229
- this.addListener(filterInputOptions, "inputCreated");
230
-
231
- if (filterInputOptions) {
232
- if (filterInputOptions["trigger"] != null) {
233
- this._inputTrigger = filterInputOptions["trigger"];
234
- }
235
- }
236
-
237
- var columns = options["columns"];
238
- var len = columns ? columns.length : 0;
239
-
240
- for (var c = 0; c < len; ++c) {
241
- this._retrieveColumnOption(c, columns[c]);
242
- }
199
+ if(!options) { return; }
200
+ this._gridConfig = options; // For loading dependency
201
+
202
+ var filterInputOptions = options["filterInput"];
203
+ this.addListener(filterInputOptions, "inputCreated");
204
+
205
+ if(filterInputOptions){
206
+ if(filterInputOptions["trigger"] != null){
207
+ this._inputTrigger = filterInputOptions["trigger"];
208
+ }
209
+ }
210
+
211
+ var columns = options["columns"];
212
+ var len = columns ? columns.length : 0;
213
+ for(var c = 0; c < len; ++c) {
214
+ this._retrieveColumnOption(c, columns[c]);
215
+ }
243
216
  };
217
+
244
218
  /** Get a current state of grid and extension config
245
219
  * @public
246
220
  * @param {Object=} out_obj
247
221
  * @returns {!Object}
248
222
  */
249
-
250
-
251
223
  FilterInputPlugin.prototype.getConfigObject = function (out_obj) {
252
- var obj = out_obj || {};
253
- var columns = obj.columns;
254
-
255
- if (!columns) {
256
- columns = obj.columns = [];
257
- }
258
-
259
- var len = this.getColumnCount();
260
-
261
- for (var i = 0; i < len; ++i) {
262
- var col = columns[i];
263
-
264
- if (!col) {
265
- col = columns[i] = {};
266
- }
267
-
268
- var filterInput = col.filterInput = {};
269
-
270
- var opt = this._getExtColumnOption(i);
271
-
272
- if (!opt) {
273
- continue;
274
- }
275
-
276
- if (opt.disabled != null) {
277
- filterInput.disabled = opt.disabled;
278
- }
279
-
280
- if (opt.placeholder != null) {
281
- filterInput.placeholder = opt.placeholder;
282
- }
283
-
284
- if (opt.type != null) {
285
- filterInput.type = opt.type;
286
- }
287
-
288
- if (opt.entries != null) {
289
- filterInput.entries = opt.entries;
290
- }
291
-
292
- if (opt.defaultValue != null) {
293
- filterInput.defaultValue = opt.defaultValue;
294
- }
295
-
296
- if (opt.trigger != null) {
297
- filterInput.trigger = opt.trigger;
298
- }
299
- }
300
-
301
- return obj;
224
+ var obj = out_obj || {};
225
+
226
+ var columns = obj.columns;
227
+ if (!columns) {
228
+ columns = obj.columns = [];
229
+ }
230
+
231
+ var len = this.getColumnCount();
232
+ for(var i = 0; i < len; ++i) {
233
+ var col = columns[i];
234
+ if (!col) {
235
+ col = columns[i] = {};
236
+ }
237
+
238
+ var filterInput = col.filterInput = {};
239
+
240
+ var opt = this._getExtColumnOption(i);
241
+
242
+ if (!opt) { continue; }
243
+ if (opt.disabled != null) {
244
+ filterInput.disabled = opt.disabled;
245
+ }
246
+ if (opt.placeholder != null) {
247
+ filterInput.placeholder = opt.placeholder;
248
+ }
249
+ if (opt.type != null) {
250
+ filterInput.type = opt.type;
251
+ }
252
+ if (opt.entries != null) {
253
+ filterInput.entries = opt.entries;
254
+ }
255
+
256
+ if (opt.defaultValue != null) {
257
+ filterInput.defaultValue = opt.defaultValue;
258
+ }
259
+
260
+ if (opt.trigger != null) {
261
+ filterInput.trigger = opt.trigger;
262
+ }
263
+ }
264
+ return obj;
302
265
  };
266
+
303
267
  /** @private
304
268
  * @param {*} proc Filter Processor
305
269
  */
306
-
307
-
308
270
  FilterInputPlugin.prototype._onRowFilteringRetrieved = function (proc) {
309
- this._gridConfig = null;
310
-
311
- if (proc) {
312
- this._filterProc = proc;
313
- this.refresh();
314
- }
271
+ this._gridConfig = null;
272
+ if(proc) {
273
+ this._filterProc = proc;
274
+ this.refresh();
275
+ }
315
276
  };
316
277
  /** @private
317
278
  * @param {*} proc Filter Processor
318
279
  * @returns {*}
319
280
  */
320
-
321
-
322
281
  FilterInputPlugin.prototype._onRowFilteringFailed = function () {
323
- return this._requestPlugin(this._hosts[0], "ColumnFilterPlugin", this._gridConfig).then(this._onRowFilteringRetrieved)["catch"](this._onColumnFilterFailed); // Gracefully resolve if we fail this time
282
+ return this._requestPlugin(this._hosts[0], "ColumnFilterPlugin", this._gridConfig)
283
+ .then(this._onRowFilteringRetrieved)
284
+ .catch(this._onColumnFilterFailed); // Gracefully resolve if we fail this time
324
285
  };
325
286
  /** @private */
326
-
327
-
328
287
  FilterInputPlugin.prototype._onColumnFilterFailed = function () {
329
- this._gridConfig = null;
288
+ this._gridConfig = null;
330
289
  };
290
+
331
291
  /** @private
332
292
  * @param {Object=} e
333
293
  */
334
-
335
-
336
294
  FilterInputPlugin.prototype._onColumnAdded = function (e) {
337
- if (e.context && e.colIndex != null) {
338
- this._retrieveColumnOption(e.colIndex, e.context);
339
- }
340
-
341
- this._requestUIUpdate();
295
+ if(e.context && e.colIndex != null) {
296
+ this._retrieveColumnOption(e.colIndex, e.context);
297
+ }
298
+ this._requestUIUpdate();
342
299
  };
343
- /** @private */
344
-
345
300
 
301
+ /** @private */
346
302
  FilterInputPlugin.prototype._requestUIUpdate = function () {
347
- if (!this._uiTimer) {
348
- // HACK: To wait for other plugins receive columnAdded and avoid removing the wrong column filter
349
- this._uiTimer = setTimeout(this._updateUIs, 50);
350
- }
303
+ if(!this._uiTimer) { // HACK: To wait for other plugins receive columnAdded and avoid removing the wrong column filter
304
+ this._uiTimer = setTimeout(this._updateUIs, 50);
305
+ }
351
306
  };
352
307
  /** @private */
353
-
354
-
355
308
  FilterInputPlugin.prototype._updateUIs = function () {
356
- this._uiTimer = 0;
357
-
358
- if (this._inputSects) {
359
- var len = this._inputSects.length;
360
-
361
- for (var i = 0; i < len; ++i) {
362
- this._createColumnInputs(this._inputSects[i], this._hosts[i]);
363
- }
364
- }
309
+ this._uiTimer = 0;
310
+ if(this._inputSects) {
311
+ var len = this._inputSects.length;
312
+ for(var i = 0; i < len; ++i) {
313
+ this._createColumnInputs(this._inputSects[i], this._hosts[i]);
314
+ }
315
+ }
365
316
  };
366
317
  /** @private
367
318
  * @param {Object=} e
368
319
  */
369
-
370
-
371
320
  FilterInputPlugin.prototype._onPostDataSourceChanged = function (e) {
372
- if (this._inputSects) {
373
- // TODO: Handle multiple hosts
374
- return;
375
- }
321
+ if(this._inputSects) { // TODO: Handle multiple hosts
322
+ return;
323
+ }
376
324
 
377
- var len = this._hosts.length;
325
+ var len = this._hosts.length;
326
+ if (!len) {
327
+ return;
328
+ }
378
329
 
379
- if (!len) {
380
- return;
381
- }
330
+ this._inputSects = [];
382
331
 
383
- this._inputSects = [];
384
- var rowHeight = window.getComputedStyle(this._hosts[0].getElement()).getPropertyValue('--grid-row-height'); // TODO: This should be retrieved from core grid
332
+ var rowHeight = window.getComputedStyle(this._hosts[0].getElement()).getPropertyValue('--grid-row-height'); // TODO: This should be retrieved from core grid
333
+ if (rowHeight) {
334
+ rowHeight = parseInt(rowHeight, 10);
335
+ }
385
336
 
386
- if (rowHeight) {
387
- rowHeight = parseInt(rowHeight, 10);
388
- }
337
+ var host;
389
338
 
390
- var host;
339
+ for(var i = 0; i < len; ++i) {
340
+ host = this._hosts[i];
341
+ var titles = host.getAllSections("title");
342
+ var lastTitle = titles[titles.length - 1];
343
+ var at = lastTitle ? lastTitle.getIndex() + 1 : 0;
344
+ var section = this._inputSects[i] = host.addSectionAt(at, "title", "filterInputs");
391
345
 
392
- for (var i = 0; i < len; ++i) {
393
- host = this._hosts[i];
394
- var titles = host.getAllSections("title");
395
- var lastTitle = titles[titles.length - 1];
396
- var at = lastTitle ? lastTitle.getIndex() + 1 : 0;
397
- var section = this._inputSects[i] = host.addSectionAt(at, "title", "filterInputs");
346
+ if (rowHeight) {
347
+ section.setDefaultRowHeight(rowHeight);
348
+ }
398
349
 
399
- if (rowHeight) {
400
- section.setDefaultRowHeight(rowHeight);
401
- }
350
+ section.enableClass("filter-inputs");
351
+ section.addRow(1);
352
+ }
402
353
 
403
- section.enableClass("filter-inputs");
404
- section.addRow(1);
405
- }
354
+ if(!host.getVScrollStartIndex || host.getVScrollStartIndex() >= 0) {
355
+ host.freezeSection(at);
356
+ }
406
357
 
407
- if (!host.getVScrollStartIndex || host.getVScrollStartIndex() >= 0) {
408
- host.freezeSection(at);
409
- }
410
-
411
- this._requestUIUpdate();
358
+ this._requestUIUpdate();
412
359
  };
360
+
413
361
  /** @private
414
362
  * @param {Object=} e
415
363
  */
416
-
417
-
418
364
  FilterInputPlugin.prototype._onDateChanged = function (e) {
419
- var host = this.getRelativeGrid(e);
420
-
421
- if (host) {
422
- var pos = host.getRelativePosition(e);
423
- var colIndex = pos.colIndex;
424
- var dateObj = ElfDate.getDate(e.detail) || e.target.value; // TODO: Date object should be used for filtering instead of string
425
-
426
- var dateStr = dateObj ? dateObj.toDateString().substr(4) : "";
427
- this.filterColumn(colIndex, dateStr);
428
- }
365
+ var host = this.getRelativeGrid(e);
366
+
367
+ if(host) {
368
+ var pos = host.getRelativePosition(e);
369
+ var colIndex = pos.colIndex;
370
+ var dateObj = ElfDate.getDate(e.detail) || e.target.value;
371
+ // TODO: Date object should be used for filtering instead of string
372
+ var dateStr = dateObj ? dateObj.toDateString().substr(4) : "";
373
+ this.filterColumn(colIndex, dateStr);
374
+ }
429
375
  };
376
+
430
377
  /** @private
431
378
  * @param {Object} section ILayoutGrid
432
379
  * @param {Object} host core grid object
433
380
  */
434
-
435
-
436
- FilterInputPlugin.prototype._createColumnInputs = function (section, host) {
437
- var colCount = section.getColumnCount();
438
-
439
- for (var c = 0; c < colCount; ++c) {
440
- var cell = section.getCell(c, 0);
441
- var elem = cell.getContent();
442
-
443
- if (elem) {
444
- continue;
445
- }
446
-
447
- cell.enableClass("no-sort"); // Prevent sorting
448
-
449
- var colOpt = this._newExtColumnOption(c);
450
-
451
- if (colOpt["disabled"]) {
452
- continue;
453
- }
454
-
455
- elem = this._createFilterUI(colOpt);
456
- cell.setContent(elem);
457
- var arg = colOpt._filterArguments = {};
458
- arg.input = elem;
459
- arg.field = this._getField(c);
460
- arg.cell = cell;
461
- arg.grid = host;
462
- var inputArgs = {
463
- "input": elem,
464
- "cell": cell,
465
- "colIndex": c,
466
- "rowIndex": 0,
467
- "grid": host,
468
- "section": section
469
- };
470
-
471
- if (this._compositeGrid) {
472
- inputArgs['colId'] = this._compositeGrid.getColumnId(c);
473
- }
474
-
475
- this._dispatch("inputCreated", inputArgs); // To apply default filter, colOpt._filterArguments needs to be initailzed
476
-
477
-
478
- var defaultValue = colOpt.defaultValue;
479
-
480
- if (defaultValue) {
481
- var elemType = convertToLowerCase(colOpt.type);
482
-
483
- if (elemType === "date") {
484
- var dateObj = ElfDate.from(defaultValue);
485
- defaultValue = dateObj ? dateObj.toDateString().substr(4) : "";
486
- }
487
-
488
- if (elemType === "multiselect") {
489
- var textMap = FilterInputPlugin._createMapObject(defaultValue);
490
-
491
- this.filterColumn(c, "", textMap);
492
- } else {
493
- this.filterColumn(c, defaultValue);
494
- }
495
- }
496
- }
381
+ FilterInputPlugin.prototype._createColumnInputs = function(section, host) {
382
+ var colCount = section.getColumnCount();
383
+
384
+ for(var c = 0; c < colCount; ++c) {
385
+ var cell = section.getCell(c, 0);
386
+ var elem = cell.getContent();
387
+ if(elem) {
388
+ continue;
389
+ }
390
+ cell.enableClass("no-sort"); // Prevent sorting
391
+ var colOpt = this._newExtColumnOption(c);
392
+ if(colOpt["disabled"]) {
393
+ continue;
394
+ }
395
+ elem = this._createFilterUI(colOpt);
396
+
397
+ cell.setContent(elem);
398
+
399
+ var arg = colOpt._filterArguments = {};
400
+ arg.input = elem;
401
+ arg.field = this._getField(c);
402
+ arg.cell = cell;
403
+ arg.grid = host;
404
+
405
+ var inputArgs = {
406
+ "input": elem,
407
+ "cell": cell,
408
+ "colIndex": c,
409
+ "rowIndex": 0,
410
+ "grid": host,
411
+ "section": section
412
+ };
413
+ if (this._compositeGrid) {
414
+ inputArgs['colId'] = this._compositeGrid.getColumnId(c);
415
+ }
416
+
417
+ this._dispatch("inputCreated", inputArgs);
418
+
419
+ // To apply default filter, colOpt._filterArguments needs to be initailzed
420
+ var defaultValue = colOpt.defaultValue;
421
+ if(defaultValue){
422
+ var elemType = convertToLowerCase(colOpt.type);
423
+ if(elemType === "date"){
424
+ var dateObj = ElfDate.from(defaultValue);
425
+ defaultValue = dateObj ? dateObj.toDateString().substr(4) : "";
426
+ }
427
+
428
+ if(elemType === "multiselect"){
429
+ var textMap = FilterInputPlugin._createMapObject(defaultValue);
430
+ this.filterColumn(c, "", textMap);
431
+ } else {
432
+ this.filterColumn(c, defaultValue);
433
+ }
434
+ }
435
+ }
497
436
  };
437
+
498
438
  /** @type {Object.<string, string>=}
499
439
  * @private
500
440
  */
501
-
502
-
503
441
  FilterInputPlugin._uiMap = {
504
- number: "ef-input",
505
- select: "ef-select",
506
- multiselect: "ef-combo-box",
507
- dropdown: "ef-select",
508
- date: "ef-datetime-picker"
442
+ number: "ef-input",
443
+ select: "ef-select",
444
+ multiselect: "ef-combo-box",
445
+ dropdown: "ef-select",
446
+ date: "ef-datetime-picker"
509
447
  };
448
+
510
449
  /** @private
511
450
  * @param {Object} colOpt
512
451
  * @return {!Element}
513
452
  */
514
-
515
- FilterInputPlugin.prototype._createFilterUI = function (colOpt) {
516
- var elemType = convertToLowerCase(colOpt.type);
517
- var defaultValue = colOpt.defaultValue;
518
- var elemTrigger = colOpt.trigger != null ? colOpt.trigger : this._inputTrigger;
519
- var uiTag = FilterInputPlugin._uiMap[elemType] || "input";
520
-
521
- if (uiTag == "ef-input") {
522
- if (ElfUtil.hasComponent("ef-number-field")) {
523
- uiTag = "ef-number-field";
524
- }
525
- } else if (uiTag == "input") {
526
- if (ElfUtil.hasComponent("ef-search-field")) {
527
- uiTag = "ef-search-field";
528
- }
529
- }
530
-
531
- var elem = document.createElement(uiTag);
532
- elem.className = "filter-input";
533
- elem.style.width = "100%";
534
- elem.style.margin = "0";
535
- elem.setAttribute("aria-label", "column filtering");
536
- var placeholder = colOpt["placeholder"];
537
-
538
- if (placeholder) {
539
- elem.setAttribute("placeholder", placeholder);
540
- } // Prevent trigering other actions when a user interacts with filter input
541
-
542
-
543
- elem.addEventListener("keydown", FilterInputPlugin._stopPropagation, false);
544
- elem.addEventListener("click", FilterInputPlugin._stopPropagation, false);
545
-
546
- switch (uiTag) {
547
- case "ef-input":
548
- elem.setAttribute("type", "number");
549
-
550
- if (elemTrigger != false && elemTrigger != "") {
551
- elem.addEventListener("value-changed", this._onInputChanged, false);
552
- }
553
-
554
- break;
555
-
556
- case "ef-number-field":
557
- if (elemTrigger != false && elemTrigger != "") {
558
- elem.addEventListener("value-changed", this._onInputChanged, false);
559
- }
560
-
561
- break;
562
-
563
- case "ef-select":
564
- elem.data = CoralItems.create(colOpt.entries);
565
- elem.addEventListener("opened-changed", this._onOpenedChanged, false);
566
-
567
- if (elemTrigger != false && elemTrigger != "") {
568
- elem.addEventListener("value-changed", this._onInputChanged, false);
569
- }
570
-
571
- break;
572
-
573
- case "ef-combo-box":
574
- elem.multiple = true;
575
- elem.data = CoralItems.create(colOpt.entries);
576
-
577
- if (elemTrigger != false && elemTrigger != "") {
578
- elem.addEventListener("value-changed", this._onInputChanged, false);
579
- }
580
-
581
- break;
582
-
583
- case "ef-datetime-picker":
584
- if (elemTrigger != false && elemTrigger != "") {
585
- elem.addEventListener("value-changed", this._onDateChanged, false);
586
- }
587
-
588
- break;
589
-
590
- case "ef-search-field":
591
- if (elemTrigger != false && elemTrigger != "") {
592
- if (elemTrigger == "enter") {
593
- var plugin = this;
594
- elem.addEventListener("keyup", function (e) {
595
- if (e.key == "Enter") {
596
- plugin._onInputChanged(e);
597
- }
598
- }, false);
599
- } else {
600
- elem.addEventListener("value-changed", this._onInputChanged, false);
601
- }
602
- }
603
-
604
- break;
605
-
606
- default:
607
- elem.setAttribute("type", "search");
608
-
609
- if (elemTrigger != false && elemTrigger != "") {
610
- if (elemTrigger == "enter") {
611
- var fip = this;
612
- elem.addEventListener("keyup", function (e) {
613
- if (e.key == "Enter") {
614
- fip._onInputChanged(e);
615
- }
616
- }, false);
617
- } else {
618
- elem.addEventListener("keyup", this._onInputChanged, false);
619
- }
620
- }
621
-
622
- break;
623
- }
624
-
625
- if (defaultValue) {
626
- if (elemType === "multiselect") {
627
- elem.values = defaultValue;
628
- } else {
629
- elem.value = defaultValue;
630
- }
631
- }
632
-
633
- return elem;
453
+ FilterInputPlugin.prototype._createFilterUI = function(colOpt) {
454
+ var elemType = convertToLowerCase(colOpt.type);
455
+ var defaultValue = colOpt.defaultValue;
456
+ var elemTrigger = colOpt.trigger != null ? colOpt.trigger : this._inputTrigger;
457
+ var uiTag = FilterInputPlugin._uiMap[elemType] || "input";
458
+ if (uiTag == "ef-input") {
459
+ if(ElfUtil.hasComponent("ef-number-field")) {
460
+ uiTag = "ef-number-field";
461
+ }
462
+ } else if (uiTag == "input") {
463
+ if (ElfUtil.hasComponent("ef-search-field")) {
464
+ uiTag = "ef-search-field";
465
+ }
466
+ }
467
+
468
+ var elem = document.createElement(uiTag);
469
+ elem.className = "filter-input";
470
+ elem.style.width = "100%";
471
+ elem.style.margin = "0";
472
+ elem.setAttribute("aria-label", "column filtering");
473
+ var placeholder = colOpt["placeholder"];
474
+ if(placeholder) {
475
+ elem.setAttribute("placeholder", placeholder);
476
+ }
477
+
478
+ // Prevent trigering other actions when a user interacts with filter input
479
+ elem.addEventListener("keydown", FilterInputPlugin._stopPropagation, false);
480
+ elem.addEventListener("click", FilterInputPlugin._stopPropagation, false);
481
+
482
+ switch(uiTag) {
483
+ case "ef-input":
484
+ elem.setAttribute("type", "number");
485
+ if(elemTrigger != false && elemTrigger != ""){
486
+ elem.addEventListener("value-changed", this._onInputChanged, false);
487
+ }
488
+ break;
489
+ case "ef-number-field":
490
+ if(elemTrigger != false && elemTrigger != ""){
491
+ elem.addEventListener("value-changed", this._onInputChanged, false);
492
+ }
493
+ break;
494
+ case "ef-select":
495
+ elem.data = CoralItems.create(colOpt.entries);
496
+ elem.addEventListener("opened-changed", this._onOpenedChanged, false);
497
+ if(elemTrigger != false && elemTrigger != ""){
498
+ elem.addEventListener("value-changed", this._onInputChanged, false);
499
+ }
500
+ break;
501
+ case "ef-combo-box":
502
+ elem.multiple = true;
503
+ elem.data = CoralItems.create(colOpt.entries);
504
+ if(elemTrigger != false && elemTrigger != ""){
505
+ elem.addEventListener("value-changed", this._onInputChanged, false);
506
+ }
507
+ break;
508
+ case "ef-datetime-picker":
509
+ if(elemTrigger != false && elemTrigger != ""){
510
+ elem.addEventListener("value-changed", this._onDateChanged, false);
511
+ }
512
+ break;
513
+ case "ef-search-field":
514
+ if(elemTrigger != false && elemTrigger != ""){
515
+ if(elemTrigger == "enter"){
516
+ var plugin = this;
517
+ elem.addEventListener("keyup", function(e){
518
+ if(e.key == "Enter"){
519
+ plugin._onInputChanged(e);
520
+ }
521
+ }, false);
522
+ } else {
523
+ elem.addEventListener("value-changed", this._onInputChanged, false);
524
+ }
525
+ }
526
+ break;
527
+ default:
528
+ elem.setAttribute("type", "search");
529
+ if(elemTrigger != false && elemTrigger != ""){
530
+ if(elemTrigger == "enter"){
531
+ var fip = this;
532
+ elem.addEventListener("keyup", function(e){
533
+ if(e.key == "Enter"){
534
+ fip._onInputChanged(e);
535
+ }
536
+ }, false);
537
+ } else {
538
+ elem.addEventListener("keyup", this._onInputChanged, false);
539
+ }
540
+ }
541
+ break;
542
+ }
543
+
544
+ if(defaultValue){
545
+ if(elemType === "multiselect"){
546
+ elem.values = defaultValue;
547
+ } else {
548
+ elem.value = defaultValue;
549
+ }
550
+ }
551
+
552
+ return elem;
634
553
  };
554
+
635
555
  /** @private
636
556
  * @param {number} colIndex
637
557
  * @return {Object}
638
558
  */
639
-
640
-
641
- FilterInputPlugin.prototype._getExtColumnOption = function (colIndex) {
642
- return this._getColumnOption(colIndex, "filterInputOption") || null;
559
+ FilterInputPlugin.prototype._getExtColumnOption = function(colIndex) {
560
+ return this._getColumnOption(colIndex, "filterInputOption") || null;
643
561
  };
644
562
  /** @private
645
563
  * @param {number} colIndex
646
564
  * @return {!Object}
647
565
  */
648
-
649
-
650
- FilterInputPlugin.prototype._newExtColumnOption = function (colIndex) {
651
- var colData = this._newColumnData(colIndex);
652
-
653
- var option = colData["filterInputOption"];
654
-
655
- if (!option) {
656
- option = colData["filterInputOption"] = {};
657
- option._comparingLogic = FilterInputPlugin._containingFilter;
658
- }
659
-
660
- return option;
566
+ FilterInputPlugin.prototype._newExtColumnOption = function(colIndex) {
567
+ var colData = this._newColumnData(colIndex);
568
+ var option = colData["filterInputOption"];
569
+ if(!option) {
570
+ option = colData["filterInputOption"] = {};
571
+ option._comparingLogic = FilterInputPlugin._containingFilter;
572
+ }
573
+ return option;
661
574
  };
662
575
  /** @private
663
576
  * @param {number} colIndex
664
577
  * @param {Object} colDef
665
578
  */
666
-
667
-
668
- FilterInputPlugin.prototype._retrieveColumnOption = function (colIndex, colDef) {
669
- var filterOption = colDef ? colDef["filterInput"] : null;
670
-
671
- if (filterOption != null) {
672
- var option = this._newExtColumnOption(colIndex);
673
-
674
- if (filterOption) {
675
- var elemType = convertToLowerCase(filterOption["type"]);
676
-
677
- if (elemType) {
678
- option["type"] = elemType;
679
- }
680
-
681
- var defaultLogic = filterOption["filterLogic"] || filterOption["defaultLogic"];
682
-
683
- if (defaultLogic != null) {
684
- if (typeof defaultLogic === "function") {
685
- option._comparingLogic = defaultLogic;
686
- } else if (!defaultLogic) {
687
- option._comparingLogic = null;
688
- }
689
- }
690
-
691
- if (elemType === "multiselect" && option._comparingLogic === FilterInputPlugin._containingFilter) {
692
- option._comparingLogic = FilterInputPlugin._multiSelectionFilter;
693
- }
694
-
695
- var disabled = filterOption["disabled"];
696
-
697
- if (disabled != null) {
698
- option["disabled"] = disabled ? true : false;
699
- }
700
-
701
- var placeholder = filterOption["placeholder"];
702
-
703
- if (typeof placeholder == "string") {
704
- option["placeholder"] = placeholder;
705
- }
706
-
707
- var entries = filterOption["entries"];
708
-
709
- if (Array.isArray(entries)) {
710
- // Add Clear filter option
711
- if (elemType === "select") {
712
- entries.push({
713
- label: 'No Filter',
714
- value: 'No Filter'
715
- });
716
- }
717
-
718
- option["entries"] = entries;
719
- }
720
-
721
- var defaultValue = filterOption["defaultValue"];
722
-
723
- if (defaultValue) {
724
- option["defaultValue"] = defaultValue;
725
- }
726
-
727
- var trigger = filterOption["trigger"];
728
-
729
- if (typeof trigger == "string" || trigger == false) {
730
- option["trigger"] = trigger;
731
- }
732
- } else {
733
- option["disabled"] = true;
734
- }
735
- } else if (this._getExtColumnOption(colIndex)) {
736
- // Reset everything to default
737
- this._getColumnData(colIndex)["filterInputOption"] = null;
738
- }
579
+ FilterInputPlugin.prototype._retrieveColumnOption = function(colIndex, colDef) {
580
+ var filterOption = colDef ? colDef["filterInput"] : null;
581
+ if(filterOption != null) {
582
+ var option = this._newExtColumnOption(colIndex);
583
+ if(filterOption) {
584
+ var elemType = convertToLowerCase(filterOption["type"]);
585
+ if(elemType) {
586
+ option["type"] = elemType;
587
+ }
588
+
589
+ var defaultLogic = filterOption["filterLogic"] || filterOption["defaultLogic"];
590
+ if(defaultLogic != null) {
591
+ if(typeof defaultLogic === "function") {
592
+ option._comparingLogic = defaultLogic;
593
+ } else if(!defaultLogic) {
594
+ option._comparingLogic = null;
595
+ }
596
+ }
597
+ if(elemType === "multiselect" && option._comparingLogic === FilterInputPlugin._containingFilter){
598
+ option._comparingLogic = FilterInputPlugin._multiSelectionFilter;
599
+ }
600
+
601
+ var disabled = filterOption["disabled"];
602
+ if(disabled != null) {
603
+ option["disabled"] = disabled ? true : false;
604
+ }
605
+ var placeholder = filterOption["placeholder"];
606
+ if(typeof placeholder == "string") {
607
+ option["placeholder"] = placeholder;
608
+ }
609
+
610
+ var entries = filterOption["entries"];
611
+ if (Array.isArray(entries)) {
612
+ // Add Clear filter option
613
+ if(elemType === "select") {
614
+ entries.push({
615
+ label: 'No Filter',
616
+ value: 'No Filter'
617
+ });
618
+ }
619
+ option["entries"] = entries;
620
+ }
621
+
622
+ var defaultValue = filterOption["defaultValue"];
623
+ if(defaultValue) {
624
+ option["defaultValue"] = defaultValue;
625
+ }
626
+
627
+ var trigger = filterOption["trigger"];
628
+ if(typeof trigger == "string" || trigger == false) {
629
+ option["trigger"] = trigger;
630
+ }
631
+ } else {
632
+ option["disabled"] = true;
633
+ }
634
+ } else if(this._getExtColumnOption(colIndex)) {
635
+ // Reset everything to default
636
+ this._getColumnData(colIndex)["filterInputOption"] = null;
637
+ }
739
638
  };
639
+
740
640
  /** @public
741
641
  * @ignore
742
642
  * @param {number} colIndex
743
643
  * @param {string} text
744
644
  */
745
-
746
-
747
645
  FilterInputPlugin.prototype.updateUI = function (colIndex, text) {
748
- if (this._freezeInputValue) return;
749
- var input = this.getColumnInput(colIndex);
646
+ if (this._freezeInputValue) return;
750
647
 
751
- if (input) {
752
- input.value = text;
753
- }
648
+ var input = this.getColumnInput(colIndex);
649
+ if (input) {
650
+ input.value = text;
651
+ }
754
652
 
755
- this._updateColumnOption(colIndex, text);
653
+ this._updateColumnOption(colIndex, text);
756
654
  };
655
+
757
656
  /** @private
758
657
  * @param {number} colIndex
759
658
  * @param {string|number} text
760
659
  * @param {Object=} textMap
761
660
  * @return {Object} Column option
762
661
  */
763
-
764
-
765
662
  FilterInputPlugin.prototype._updateColumnOption = function (colIndex, text, textMap) {
766
- var option = this._getExtColumnOption(colIndex);
767
-
768
- if (!option) {
769
- return null;
770
- }
771
-
772
- var inputText = "";
773
-
774
- if (text || text === 0) {
775
- inputText = typeof text !== "string" ? text + "" : text;
776
- }
777
-
778
- var arg = option._filterArguments;
779
-
780
- if (arg) {
781
- arg.inputText = option.inputText = inputText;
782
- arg.lowerCasedText = inputText.toLowerCase();
783
- arg.colIndex = colIndex;
784
-
785
- if (textMap && !Object.keys(textMap).length) {
786
- textMap = null;
787
- }
788
-
789
- arg.textMap = option.textMap = textMap;
790
- }
791
-
792
- return option;
663
+ var option = this._getExtColumnOption(colIndex);
664
+ if (!option) { return null; }
665
+
666
+ var inputText = "";
667
+ if (text || text === 0) {
668
+ inputText = typeof text !== "string" ? text + "" : text;
669
+ }
670
+ var arg = option._filterArguments;
671
+ if (arg) {
672
+ arg.inputText = option.inputText = inputText;
673
+ arg.lowerCasedText = inputText.toLowerCase();
674
+ arg.colIndex = colIndex;
675
+ if(textMap && !Object.keys(textMap).length){
676
+ textMap = null;
677
+ }
678
+ arg.textMap = option.textMap = textMap;
679
+ }
680
+ return option;
793
681
  };
682
+
794
683
  /** @public
795
684
  * @param {number} colIndex
796
685
  * @return {Element} Input element
797
686
  */
798
-
799
-
800
- FilterInputPlugin.prototype.getColumnInput = function (colIndex) {
801
- if (this._inputSects) {
802
- var sect = this._inputSects[0]; // TODO: Handle multi-grids
803
-
804
- var cell = sect.getCell(colIndex, 0);
805
-
806
- if (cell && cell.getElement()) {
807
- return cell.getContent();
808
- }
809
- }
810
-
811
- return null;
687
+ FilterInputPlugin.prototype.getColumnInput = function(colIndex) {
688
+ if(this._inputSects) {
689
+ var sect = this._inputSects[0]; // TODO: Handle multi-grids
690
+ var cell = sect.getCell(colIndex, 0);
691
+ if(cell && cell.getElement()) {
692
+ return cell.getContent();
693
+ }
694
+ }
695
+ return null;
812
696
  };
697
+
813
698
  /** Clear input UI and remove all filters from the specified column
814
699
  * @public
815
700
  * @param {(null|number)=} colIndex=null clear filter input at specific colIndex, if null then all input will be clear.
816
701
  */
817
-
818
-
819
702
  FilterInputPlugin.prototype.removeColumnFilters = function (colIndex) {
820
- var sect = this._inputSects && this._inputSects[0]; // TODO: Handle multi-grids
821
-
822
- if (sect) {
823
- if (colIndex != null) {
824
- this.updateUI(colIndex, '');
825
- } else {
826
- var count = this.getColumnCount();
827
-
828
- for (var index = 0; index < count; index++) {
829
- this.updateUI(index, '');
830
- }
831
- }
832
- }
833
-
834
- this._freezeInputValue = true;
835
-
836
- this._filterProc.removeColumnFilters(colIndex);
837
-
838
- this._freezeInputValue = false;
703
+ var sect = this._inputSects && this._inputSects[0]; // TODO: Handle multi-grids
704
+ if (sect) {
705
+ if (colIndex != null) {
706
+ this.updateUI(colIndex, '');
707
+ } else {
708
+ var count = this.getColumnCount();
709
+ for (var index = 0; index < count; index++) {
710
+ this.updateUI(index, '');
711
+ }
712
+ }
713
+ }
714
+ this._freezeInputValue = true;
715
+ this._filterProc.removeColumnFilters(colIndex);
716
+ this._freezeInputValue = false;
839
717
  };
718
+
840
719
  /** Alias to {@link FilterInputPlugin#removeColumnFilters} Clear input UI and remove all filters from the specified column
841
720
  * @public
842
721
  * @function
843
722
  * @param {(null|number)=} colIndex=null clear filter input at specific colIndex, if null then all input will be clear.
844
723
  */
845
-
846
-
847
724
  FilterInputPlugin.prototype.removeColumnFilter = FilterInputPlugin.prototype.removeColumnFilters;
725
+
848
726
  /** @public
849
727
  * @param {number} colIndex
850
728
  * @param {*} value
851
729
  */
730
+ FilterInputPlugin.prototype.setInputValue = function(colIndex, value) {
731
+ var inputElem = this.getColumnInput(colIndex);
732
+ if(!inputElem){
733
+ return;
734
+ }
735
+ var colOpt = this._getExtColumnOption(colIndex);
736
+ var elemType = convertToLowerCase(colOpt.type);
737
+
738
+ var dateValue;
739
+ if(elemType === "date"){
740
+ var dateObj = ElfDate.from(value);
741
+ dateValue = dateObj ? dateObj.toDateString().substr(4) : "";
742
+ }
743
+
744
+ if(elemType === "multiselect"){
745
+ inputElem.values = value;
746
+ var textMap = FilterInputPlugin._createMapObject(value);
747
+ this.filterColumn(colIndex, "", textMap);
748
+ } else {
749
+ inputElem.value = value;
750
+ this.filterColumn(colIndex, elemType === "date" ? dateValue : value);
751
+ }
852
752
 
853
- FilterInputPlugin.prototype.setInputValue = function (colIndex, value) {
854
- var inputElem = this.getColumnInput(colIndex);
855
-
856
- if (!inputElem) {
857
- return;
858
- }
859
-
860
- var colOpt = this._getExtColumnOption(colIndex);
861
-
862
- var elemType = convertToLowerCase(colOpt.type);
863
- var dateValue;
864
-
865
- if (elemType === "date") {
866
- var dateObj = ElfDate.from(value);
867
- dateValue = dateObj ? dateObj.toDateString().substr(4) : "";
868
- }
869
-
870
- if (elemType === "multiselect") {
871
- inputElem.values = value;
872
-
873
- var textMap = FilterInputPlugin._createMapObject(value);
874
-
875
- this.filterColumn(colIndex, "", textMap);
876
- } else {
877
- inputElem.value = value;
878
- this.filterColumn(colIndex, elemType === "date" ? dateValue : value);
879
- }
880
753
  };
881
754
  /** @public
882
755
  * @param {number} colIndex
883
756
  * @param {boolean=} disabled
884
757
  */
885
-
886
-
887
- FilterInputPlugin.prototype.disableColumnInput = function (colIndex, disabled) {
888
- var inputElem = this.getColumnInput(colIndex);
889
-
890
- if (inputElem) {
891
- disabled = disabled != null ? disabled : true;
892
-
893
- if (disabled) {
894
- inputElem.setAttribute("disabled", "");
895
- } else {
896
- inputElem.removeAttribute("disabled");
897
- }
898
- }
758
+ FilterInputPlugin.prototype.disableColumnInput = function(colIndex, disabled) {
759
+ var inputElem = this.getColumnInput(colIndex);
760
+ if(inputElem) {
761
+ disabled = disabled != null ? disabled : true;
762
+ if(disabled) {
763
+ inputElem.setAttribute("disabled", "");
764
+ } else {
765
+ inputElem.removeAttribute("disabled");
766
+ }
767
+ }
899
768
  };
900
769
  /** @public
901
770
  * @ignore
902
771
  * @param {number} colIndex
903
772
  * @return {Object}
904
773
  */
905
-
906
-
907
- FilterInputPlugin.prototype.getColumnFilter = function (colIndex) {
908
- var proc = this._filterProc;
909
-
910
- if (proc) {
911
- return proc.getColumnFilterState(colIndex);
912
- }
913
-
914
- return null;
774
+ FilterInputPlugin.prototype.getColumnFilter = function(colIndex) {
775
+ var proc = this._filterProc;
776
+ if(proc){
777
+ return proc.getColumnFilterState(colIndex);
778
+ }
779
+ return null;
915
780
  };
916
781
  /** @public
917
782
  * @ignore
918
783
  * @param {number} colIndex
919
784
  * @return {Function}
920
785
  */
921
-
922
-
923
- FilterInputPlugin.prototype.getFilterLogic = function (colIndex) {
924
- var option = this._getExtColumnOption(colIndex);
925
-
926
- return option._comparingLogic;
786
+ FilterInputPlugin.prototype.getFilterLogic = function(colIndex) {
787
+ var option = this._getExtColumnOption(colIndex);
788
+ return option._comparingLogic;
927
789
  };
928
790
  /** Force filtering for every column
929
791
  * @public
930
792
  * @param {number=} delayMs=0 Set delay in millisecond to avoid repeatedly filtering
931
793
  */
932
-
933
-
934
- FilterInputPlugin.prototype.refresh = function (delayMs) {
935
- if (delayMs) {
936
- if (!this._refreshTimer) {
937
- this._refreshTimer = setTimeout(this.refresh, delayMs);
938
- }
939
-
940
- return;
941
- }
942
-
943
- this._refreshTimer = 0;
944
-
945
- if (this._filterProc) {
946
- this._filterProc.refresh();
947
- }
794
+ FilterInputPlugin.prototype.refresh = function(delayMs) {
795
+ if(delayMs) {
796
+ if(!this._refreshTimer) {
797
+ this._refreshTimer = setTimeout(this.refresh, delayMs);
798
+ }
799
+ return;
800
+ }
801
+ this._refreshTimer = 0;
802
+
803
+ if(this._filterProc) {
804
+ this._filterProc.refresh();
805
+ }
948
806
  };
949
807
  /** Change filter logic or context
950
808
  * @public
@@ -952,216 +810,166 @@ FilterInputPlugin.prototype.refresh = function (delayMs) {
952
810
  * @param {Function} func
953
811
  * @param {*=} ctx Context object that will be provided as the first parameter of the filter function
954
812
  */
955
-
956
-
957
- FilterInputPlugin.prototype.setFilterLogic = function (colIndex, func, ctx) {
958
- if (colIndex < 0) {
959
- return;
960
- }
961
-
962
- var option = this._newExtColumnOption(colIndex);
963
-
964
- var inputText = option.inputText;
965
- var textMap = option.textMap;
966
-
967
- if (func) {
968
- if (ctx != null) {
969
- option._filterArguments = ctx; // WARNING: This replaces all existing argument
970
- }
971
- } else {
972
- func = null;
973
- }
974
-
975
- option._comparingLogic = func;
976
-
977
- if (inputText || textMap) {
978
- this.filterColumn(colIndex, inputText, textMap);
979
- }
813
+ FilterInputPlugin.prototype.setFilterLogic = function(colIndex, func, ctx) {
814
+ if(colIndex < 0) { return; }
815
+
816
+ var option = this._newExtColumnOption(colIndex);
817
+ var inputText = option.inputText;
818
+ var textMap = option.textMap;
819
+
820
+ if(func) {
821
+ if(ctx != null) {
822
+ option._filterArguments = ctx; // WARNING: This replaces all existing argument
823
+ }
824
+ } else {
825
+ func = null;
826
+ }
827
+ option._comparingLogic = func;
828
+ if(inputText || textMap) {
829
+ this.filterColumn(colIndex, inputText, textMap);
830
+ }
980
831
  };
832
+
981
833
  /** Force filtering for a single column by changing filtering text
982
834
  * @public
983
835
  * @param {number} colIndex
984
836
  * @param {string} text
985
837
  * @param {Object=} textMap
986
838
  */
987
-
988
-
989
839
  FilterInputPlugin.prototype.filterColumn = function (colIndex, text, textMap) {
990
- var option = this._updateColumnOption(colIndex, text, textMap);
991
-
992
- if (!option) {
993
- return;
994
- } // This is because we need to toggle the icon
995
-
840
+ var option = this._updateColumnOption(colIndex, text, textMap);
841
+ if (!option) { return; }
996
842
 
997
- this._setColumnFilter(colIndex, option);
843
+ // This is because we need to toggle the icon
844
+ this._setColumnFilter(colIndex, option);
998
845
  };
999
846
  /** @private
1000
847
  * @param {number} colIndex
1001
848
  * @param {Object} filterOptions
1002
849
  */
850
+ FilterInputPlugin.prototype._setColumnFilter = function(colIndex, filterOptions) {
851
+ var proc = this._filterProc;
852
+ if (proc) {
853
+ this._freezeInputValue = true;
854
+ if (proc.hasColumnFilter()) { // TODO: There should be a way to get column filters
855
+ proc.removeColumnFilters(colIndex); // TODO: this is slow
856
+ }
857
+ var hasFilterContent = filterOptions.inputText || filterOptions.textMap;
858
+ if(filterOptions._comparingLogic && hasFilterContent) {
859
+ var columnFilter = filterOptions._columnFilter;
860
+ if(!columnFilter) {
861
+ // The given rowData for the filter function has already been converted by RowFiltering Extension
862
+ columnFilter = filterOptions._columnFilter = FilterInputPlugin._compareRow.bind(null, filterOptions);
863
+ }
864
+
865
+ proc.addColumnFilter(colIndex, columnFilter);
866
+ }
867
+ this._freezeInputValue = false;
868
+ }
869
+ };
1003
870
 
1004
871
 
1005
- FilterInputPlugin.prototype._setColumnFilter = function (colIndex, filterOptions) {
1006
- var proc = this._filterProc;
1007
-
1008
- if (proc) {
1009
- this._freezeInputValue = true;
1010
-
1011
- if (proc.hasColumnFilter()) {
1012
- // TODO: There should be a way to get column filters
1013
- proc.removeColumnFilters(colIndex); // TODO: this is slow
1014
- }
1015
-
1016
- var hasFilterContent = filterOptions.inputText || filterOptions.textMap;
1017
-
1018
- if (filterOptions._comparingLogic && hasFilterContent) {
1019
- var columnFilter = filterOptions._columnFilter;
1020
-
1021
- if (!columnFilter) {
1022
- columnFilter = this._realTimeGrid ? FilterInputPlugin._rtCompareRow : FilterInputPlugin._compareRow;
1023
- columnFilter = filterOptions._columnFilter = columnFilter.bind(null, filterOptions);
1024
- }
1025
-
1026
- proc.addColumnFilter(colIndex, columnFilter);
1027
- }
1028
-
1029
- this._freezeInputValue = false;
1030
- }
1031
- };
1032
872
  /** @private
1033
873
  * @param {Object=} e
1034
874
  */
1035
-
1036
-
1037
875
  FilterInputPlugin.prototype._onInputChanged = function (e) {
1038
- FilterInputPlugin._stopPropagation(e);
1039
-
1040
- var host = this.getRelativeGrid(e);
1041
-
1042
- if (!host) {
1043
- return;
1044
- }
1045
-
1046
- var pos = host.getRelativePosition(e);
1047
- var colIndex = pos.colIndex;
1048
- var input =
1049
- /** @type{Element} */
1050
- e.currentTarget;
1051
- var filterValue = input.value;
1052
- var textMap; // If selected No Filter option - remove select filter
1053
-
1054
- if (filterValue === "No Filter" && input.tagName.indexOf("SELECT") >= 0) {
1055
- filterValue = null;
1056
- } else if (input.tagName.indexOf("COMBO-BOX") >= 0) {
1057
- textMap = FilterInputPlugin._createMapObject(input.values);
1058
- }
1059
-
1060
- this.filterColumn(colIndex, filterValue, textMap);
876
+ FilterInputPlugin._stopPropagation(e);
877
+
878
+ var host = this.getRelativeGrid(e);
879
+ if(!host) { return; }
880
+ var pos = host.getRelativePosition(e);
881
+ var colIndex = pos.colIndex;
882
+
883
+ var input = /** @type{Element} */(e.currentTarget);
884
+ var filterValue = input.value;
885
+ var textMap;
886
+
887
+ // If selected No Filter option - remove select filter
888
+ if (filterValue === "No Filter" && input.tagName.indexOf("SELECT") >= 0) {
889
+ filterValue = null;
890
+ }
891
+ else if(input.tagName.indexOf("COMBO-BOX") >= 0){
892
+ textMap = FilterInputPlugin._createMapObject(input.values);
893
+ }
894
+
895
+ this.filterColumn(colIndex, filterValue, textMap);
1061
896
  };
1062
897
  /** @private
1063
898
  * @param {Object=} e
1064
899
  * @description WORKAROUND:: set pointer events none to ef-select when options popup opened.
1065
900
  * this will make ef-select can close popup when click at ef-select
1066
901
  */
1067
-
1068
-
1069
902
  FilterInputPlugin.prototype._onOpenedChanged = function (e) {
1070
- if (e.detail.value) {
1071
- //open
1072
- e.currentTarget.style.pointerEvents = "none";
1073
- } else {
1074
- //close
1075
- var ect = e.currentTarget;
1076
- setTimeout(function () {
1077
- ect.style.pointerEvents = "";
1078
- });
1079
- }
903
+ if (e.detail.value) { //open
904
+ e.currentTarget.style.pointerEvents = "none";
905
+ } else { //close
906
+ var ect = e.currentTarget;
907
+ setTimeout(function(){
908
+ ect.style.pointerEvents = "";
909
+ });
910
+ }
1080
911
  };
912
+
1081
913
  /** @private
1082
914
  * @param {Object=} e
1083
915
  */
1084
-
1085
-
1086
916
  FilterInputPlugin._stopPropagation = function (e) {
1087
- if (e) {
1088
- e.stopPropagation();
1089
- }
917
+ if(e) {
918
+ e.stopPropagation();
919
+ }
1090
920
  };
1091
- /** @private
1092
- * @function
1093
- * @param {Object} filterOptions
1094
- * @param {Object} rowData
1095
- * @param {string|number} rid
1096
- * @return {boolean}
1097
- */
1098
921
 
1099
-
1100
- FilterInputPlugin._compareRow = function (filterOptions, rowData, rid) {
1101
- return filterOptions._comparingLogic(filterOptions._filterArguments, rowData);
1102
- };
1103
922
  /** @private
1104
923
  * @function
1105
924
  * @param {Object} filterOptions
1106
- * @param {Object} rowData
925
+ * @param {Object} rowData The given rowData has already been converted by RowFiltering Extension
1107
926
  * @param {string|number} rid
1108
927
  * @return {boolean}
1109
928
  */
1110
-
1111
-
1112
- FilterInputPlugin._rtCompareRow = function (filterOptions, rowData, rid) {
1113
- return filterOptions._comparingLogic(filterOptions._filterArguments, rowData["ROW_DEF"].getRowData());
929
+ FilterInputPlugin._compareRow = function(filterOptions, rowData, rid) {
930
+ return filterOptions._comparingLogic(filterOptions._filterArguments, rowData);
1114
931
  };
932
+
1115
933
  /** @private
1116
934
  * @function
1117
935
  * @param {Array<string|number>} ary
1118
936
  * @return {Object}
1119
937
  */
1120
-
1121
-
1122
- FilterInputPlugin._createMapObject = function (ary) {
1123
- var textMap = {};
1124
-
1125
- if (ary) {
1126
- var count = ary.length;
1127
-
1128
- for (var i = 0; i < count; i++) {
1129
- var key = ary[i];
1130
-
1131
- if (key == null || key === "") {
1132
- continue;
1133
- }
1134
-
1135
- var str = FilterInputPlugin._transformToLowercaseString(key);
1136
-
1137
- textMap[str] = true;
1138
- }
1139
- }
1140
-
1141
- return textMap;
938
+ FilterInputPlugin._createMapObject = function(ary) {
939
+ var textMap = {};
940
+ if(ary){
941
+ var count = ary.length;
942
+ for(var i = 0; i < count; i++){
943
+ var key = ary[i];
944
+ if(key == null || key === ""){
945
+ continue;
946
+ }
947
+ var str = FilterInputPlugin._transformToLowercaseString(key);
948
+ textMap[str] = true;
949
+ }
950
+ }
951
+ return textMap;
1142
952
  };
953
+
1143
954
  /** @private
1144
955
  * @function
1145
956
  * @param {Object} data
1146
957
  * @return {string}
1147
958
  */
1148
-
1149
-
1150
- FilterInputPlugin._transformToLowercaseString = function (data) {
1151
- var dataStr = "";
1152
-
1153
- if (typeof data != "string") {
1154
- if (data instanceof Date) {
1155
- dataStr = data.toDateString().toLowerCase();
1156
- } else {
1157
- dataStr = (data + "").toLocaleLowerCase();
1158
- }
1159
- } else if (data) {
1160
- dataStr = data.toLowerCase();
1161
- }
1162
-
1163
- return dataStr;
959
+ FilterInputPlugin._transformToLowercaseString = function(data) {
960
+ var dataStr = "";
961
+ if(typeof data != "string") {
962
+ if(data instanceof Date) {
963
+ dataStr = data.toDateString().toLowerCase();
964
+ } else {
965
+ dataStr = (data + "").toLocaleLowerCase();
966
+ }
967
+ } else if(data) {
968
+ dataStr = data.toLowerCase();
969
+ }
970
+ return dataStr;
1164
971
  };
972
+
1165
973
  /** Default Filter Logic
1166
974
  * @private
1167
975
  * @function
@@ -1169,34 +977,28 @@ FilterInputPlugin._transformToLowercaseString = function (data) {
1169
977
  * @param {Object} rowData
1170
978
  * @return {boolean}
1171
979
  */
1172
-
1173
-
1174
- FilterInputPlugin._containingFilter = function (e, rowData) {
1175
- var str = e.lowerCasedText || e.inputText;
1176
- var eventType = e.input && e.input.type;
1177
-
1178
- if (str) {
1179
- var data = rowData[e.field];
1180
-
1181
- if (data != null) {
1182
- var dataStr = FilterInputPlugin._transformToLowercaseString(data);
1183
-
1184
- if (dataStr) {
1185
- if (eventType === "number") {
1186
- // Custom check if type is number
1187
- return Number(dataStr) === Number(str);
1188
- } else {
1189
- // Normal check if type is not a number
1190
- return dataStr.indexOf(str) >= 0;
1191
- }
1192
- }
1193
- }
1194
-
1195
- return false;
1196
- }
1197
-
1198
- return true;
980
+ FilterInputPlugin._containingFilter = function(e, rowData) {
981
+ var str = e.lowerCasedText || e.inputText;
982
+ var eventType = e.input && e.input.type;
983
+ if(str) {
984
+ var data = rowData[e.field];
985
+ if(data != null) {
986
+ var dataStr = FilterInputPlugin._transformToLowercaseString(data);
987
+ if (dataStr) {
988
+ if (eventType === "number") {
989
+ // Custom check if type is number
990
+ return Number(dataStr) === Number(str);
991
+ } else {
992
+ // Normal check if type is not a number
993
+ return dataStr.indexOf(str) >= 0;
994
+ }
995
+ }
996
+ }
997
+ return false;
998
+ }
999
+ return true;
1199
1000
  };
1001
+
1200
1002
  /** Filter Logic for multi selection input
1201
1003
  * @private
1202
1004
  * @function
@@ -1204,27 +1006,22 @@ FilterInputPlugin._containingFilter = function (e, rowData) {
1204
1006
  * @param {Object} rowData
1205
1007
  * @return {boolean}
1206
1008
  */
1009
+ FilterInputPlugin._multiSelectionFilter = function(e, rowData) {
1010
+ var inputMap = e.textMap;
1011
+ if(inputMap) {
1012
+ var data = rowData[e.field];
1013
+ if(data != null) {
1014
+ var dataStr = FilterInputPlugin._transformToLowercaseString(data);
1015
+ if (dataStr) {
1016
+ return inputMap[dataStr] ? true : false;
1017
+ }
1018
+ }
1019
+ return false;
1020
+ }
1021
+ return true;
1022
+ };
1207
1023
 
1208
1024
 
1209
- FilterInputPlugin._multiSelectionFilter = function (e, rowData) {
1210
- var inputMap = e.textMap;
1211
-
1212
- if (inputMap) {
1213
- var data = rowData[e.field];
1214
-
1215
- if (data != null) {
1216
- var dataStr = FilterInputPlugin._transformToLowercaseString(data);
1217
-
1218
- if (dataStr) {
1219
- return inputMap[dataStr] ? true : false;
1220
- }
1221
- }
1222
-
1223
- return false;
1224
- }
1225
-
1226
- return true;
1227
- };
1228
1025
 
1229
1026
  export default FilterInputPlugin;
1230
- export { FilterInputPlugin, FilterInputPlugin as FilterInput, FilterInputPlugin as FilterInputExtension };
1027
+ export { FilterInputPlugin, FilterInputPlugin as FilterInput, FilterInputPlugin as FilterInputExtension };