tablefilter 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +15 -15
- package/.esdoc.json +14 -14
- package/.eslintrc +37 -37
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +36 -36
- package/.github/ISSUE_TEMPLATE/support.md +17 -17
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/build-deploy.yml +113 -0
- package/AGENTS.md +36 -0
- package/CONTRIBUTING.md +128 -128
- package/Gruntfile.js +252 -252
- package/LICENSE +21 -21
- package/PULL_REQUEST_TEMPLATE.md +24 -24
- package/README.md +166 -174
- package/ROADMAP/README.md +29 -0
- package/ROADMAP/hybrid-migration-strategy.md +234 -0
- package/ROADMAP/key-decisions-review.md +213 -0
- package/ROADMAP/preliminary-and-milestone-0.8.0-plan.md +308 -0
- package/ROADMAP/v1-webcomponents-investigation.md +516 -0
- package/dist/starter.html +514 -514
- package/dist/tablefilter/tablefilter.js +1 -1
- package/dist/tablefilter/tf-1-d2360db09a424b1ed633.js +1 -0
- package/index.js +3 -3
- package/libs/sortabletable.js +438 -438
- package/package.json +1 -1
- package/src/array.js +22 -22
- package/src/const.js +118 -118
- package/src/cookie.js +57 -57
- package/src/dom.js +192 -192
- package/src/emitter.js +53 -53
- package/src/event.js +124 -124
- package/src/extensions/advancedGrid/adapterEzEditTable.js +509 -509
- package/src/extensions/advancedGrid/advancedGrid.js +2 -2
- package/src/extensions/colOps/colOps.js +474 -480
- package/src/extensions/colsVisibility/colsVisibility.js +725 -725
- package/src/extensions/filtersVisibility/filtersVisibility.js +316 -316
- package/src/extensions/sort/adapterSortabletable.js +537 -537
- package/src/extensions/sort/sort.js +8 -8
- package/src/feature.js +102 -102
- package/src/modules/alternateRows.js +145 -145
- package/src/modules/baseDropdown.js +160 -160
- package/src/modules/checkList.js +519 -519
- package/src/modules/clearButton.js +142 -142
- package/src/modules/dateType.js +157 -157
- package/src/modules/dropdown.js +376 -376
- package/src/modules/gridLayout.js +483 -483
- package/src/modules/hash.js +126 -126
- package/src/modules/help.js +264 -264
- package/src/modules/highlightKeywords.js +180 -180
- package/src/modules/loader.js +183 -183
- package/src/modules/markActiveColumns.js +146 -146
- package/src/modules/noResults.js +193 -193
- package/src/modules/paging.js +916 -916
- package/src/modules/popupFilter.js +461 -461
- package/src/modules/rowsCounter.js +207 -207
- package/src/modules/state.js +545 -545
- package/src/modules/statusBar.js +308 -308
- package/src/modules/storage.js +161 -161
- package/src/modules/toolbar.js +224 -224
- package/src/number.js +96 -32
- package/src/root.js +6 -6
- package/src/settings.js +53 -53
- package/src/sort.js +82 -82
- package/src/string.js +112 -112
- package/src/tablefilter.js +3053 -3053
- package/src/types.js +81 -81
- package/static/partials/books-table-with-images.html +327 -327
- package/static/partials/books.html +272 -272
- package/static/partials/countries-by-continent.html +2592 -2592
- package/static/partials/countries-table-tiny.html +436 -436
- package/static/partials/countries-table.html +12954 -12954
- package/static/partials/dummy-table-with-totals-footer.html +353 -353
- package/static/partials/dummy-table.html +502 -502
- package/static/partials/pre-inline-script.html +17 -17
- package/static/partials/pre.html +1 -1
- package/static/partials/style.html +22 -22
- package/static/partials/table-with-grouped-headers.html +9258 -9258
- package/static/style/active-header.styl +10 -10
- package/static/style/alternating-rows.styl +8 -8
- package/static/style/config.styl +44 -44
- package/static/style/extensions/colsVisibility.styl +71 -71
- package/static/style/extensions/filtersVisibility.styl +18 -18
- package/static/style/ezedittable.styl +93 -93
- package/static/style/filter-checklist.styl +52 -52
- package/static/style/filters.styl +111 -111
- package/static/style/grid-layout.styl +130 -130
- package/static/style/help.styl +57 -57
- package/static/style/keyword.styl +8 -8
- package/static/style/loader.styl +16 -16
- package/static/style/mixins/arrow.styl +63 -63
- package/static/style/mixins/box-shadow.styl +8 -8
- package/static/style/mixins/empty-content.styl +7 -7
- package/static/style/noresults.styl +14 -14
- package/static/style/paging.styl +73 -73
- package/static/style/reset-button.styl +21 -21
- package/static/style/rows-counter.styl +17 -17
- package/static/style/sort.styl +20 -20
- package/static/style/status-bar.styl +16 -16
- package/static/style/table.styl +44 -44
- package/static/style/tablefilter.styl +18 -18
- package/static/style/themes/default/default.styl +137 -137
- package/static/style/themes/mytheme/mytheme.styl +152 -152
- package/static/style/themes/skyblue/skyblue.styl +195 -195
- package/static/style/themes/transparent/transparent.styl +205 -205
- package/static/style/toolbar.styl +58 -58
- package/static/templates/advanced-grid-editable.html +140 -140
- package/static/templates/advanced-grid-selection.html +93 -93
- package/static/templates/auto-filter.html +46 -46
- package/static/templates/columns-visibility.html +67 -67
- package/static/templates/data-types.html +123 -123
- package/static/templates/demo.html +62 -62
- package/static/templates/external-filters-visibility-commad.html +49 -49
- package/static/templates/external-filters.html +125 -125
- package/static/templates/filter-images.html +91 -91
- package/static/templates/filters-visibility.html +45 -45
- package/static/templates/grid-layout.html +51 -51
- package/static/templates/grouped-headers.html +78 -78
- package/static/templates/linked-filters-disabled.html +56 -56
- package/static/templates/linked-filters.html +45 -45
- package/static/templates/load-filters-on-demand.html +42 -42
- package/static/templates/pagination.html +78 -78
- package/static/templates/requirejs.html +53 -53
- package/static/templates/starter.html +61 -61
- package/static/templates/theme-roller.html +106 -106
- package/test/libs/polyfill.js +359 -359
- package/test/libs/qunit/qunit.css +237 -237
- package/test/libs/qunit/qunit.js +2495 -2495
- package/test/test-active-columns.html +80 -80
- package/test/test-active-columns.js +318 -318
- package/test/test-alternate-rows.html +80 -80
- package/test/test-alternate-rows.js +335 -335
- package/test/test-api.html +141 -141
- package/test/test-api.js +795 -795
- package/test/test-auto-filter.html +80 -80
- package/test/test-auto-filter.js +43 -43
- package/test/test-callbacks.html +77 -77
- package/test/test-callbacks.js +58 -58
- package/test/test-case-sensitive-query.html +77 -77
- package/test/test-case-sensitive-query.js +39 -39
- package/test/test-cell-parser.html +109 -109
- package/test/test-cell-parser.js +80 -80
- package/test/test-checklist.html +77 -77
- package/test/test-checklist.js +267 -267
- package/test/test-clear-button.html +79 -79
- package/test/test-clear-button.js +182 -182
- package/test/test-col-ops-grid-layout.html +129 -129
- package/test/test-col-ops-grid-layout.js +134 -134
- package/test/test-col-ops-paging.html +129 -129
- package/test/test-col-ops-paging.js +154 -154
- package/test/test-col-ops.html +129 -129
- package/test/test-col-ops.js +337 -202
- package/test/test-col-widths.html +80 -80
- package/test/test-col-widths.js +40 -40
- package/test/test-cols-visibility-grid-layout.html +80 -80
- package/test/test-cols-visibility-grid-layout.js +165 -165
- package/test/test-cols-visibility.html +80 -80
- package/test/test-cols-visibility.js +121 -121
- package/test/test-custom-options.html +80 -80
- package/test/test-custom-options.js +139 -139
- package/test/test-data-types.html +377 -377
- package/test/test-data-types.js +392 -392
- package/test/test-date-type.html +356 -356
- package/test/test-date-type.js +159 -159
- package/test/test-disable-enter-key.html +77 -77
- package/test/test-disable-enter-key.js +29 -29
- package/test/test-disable-filter-onchange.html +77 -77
- package/test/test-disable-filter-onchange.js +40 -40
- package/test/test-dom-changes.html +77 -77
- package/test/test-dom-changes.js +166 -166
- package/test/test-dropdown.html +77 -77
- package/test/test-dropdown.js +246 -246
- package/test/test-emitter.html +77 -77
- package/test/test-emitter.js +57 -57
- package/test/test-empty-cells-filtering.html +8696 -8696
- package/test/test-empty-cells-filtering.js +45 -45
- package/test/test-exact-query-match.html +77 -77
- package/test/test-exact-query-match.js +56 -56
- package/test/test-excluded-rows.html +92 -92
- package/test/test-excluded-rows.js +129 -129
- package/test/test-external-filters.html +100 -100
- package/test/test-external-filters.js +219 -219
- package/test/test-filter-html-elements.html +88 -88
- package/test/test-filter-html-elements.js +63 -63
- package/test/test-filter-operators.html +80 -80
- package/test/test-filter-operators.js +264 -264
- package/test/test-filtering.html +53 -53
- package/test/test-filtering.js +293 -293
- package/test/test-filters-visibility-grid-layout.html +80 -80
- package/test/test-filters-visibility-grid-layout.js +50 -50
- package/test/test-filters-visibility-with-button.html +80 -80
- package/test/test-filters-visibility-with-button.js +48 -48
- package/test/test-filters-visibility.html +80 -80
- package/test/test-filters-visibility.js +48 -48
- package/test/test-grid-layout.html +7735 -7735
- package/test/test-grid-layout.js +39 -39
- package/test/test-grouped-headers.html +154 -154
- package/test/test-grouped-headers.js +107 -107
- package/test/test-hash.html +78 -78
- package/test/test-hash.js +88 -88
- package/test/test-help-responsive.html +78 -78
- package/test/test-help-responsive.js +70 -70
- package/test/test-help.html +77 -77
- package/test/test-help.js +217 -217
- package/test/test-highlight-keywords.html +77 -77
- package/test/test-highlight-keywords.js +94 -94
- package/test/test-ignore-diacritics.html +67 -57
- package/test/test-ignore-diacritics.js +117 -90
- package/test/test-integration-paging-sort.html +79 -79
- package/test/test-integration-paging-sort.js +60 -60
- package/test/test-linked-filters-disabled-options-grid-layout.html +80 -80
- package/test/test-linked-filters-disabled-options-grid-layout.js +73 -73
- package/test/test-linked-filters-grid-layout.html +80 -80
- package/test/test-linked-filters-grid-layout.js +72 -72
- package/test/test-linked-filters-load-filters-on-demand.html +80 -80
- package/test/test-linked-filters-load-filters-on-demand.js +99 -99
- package/test/test-linked-filters-paging.html +80 -80
- package/test/test-linked-filters-paging.js +99 -99
- package/test/test-linked-filters.html +80 -80
- package/test/test-linked-filters.js +138 -138
- package/test/test-load-filters-on-demand.html +77 -77
- package/test/test-load-filters-on-demand.js +124 -124
- package/test/test-loader.html +79 -79
- package/test/test-loader.js +159 -159
- package/test/test-no-config.html +80 -80
- package/test/test-no-config.js +63 -63
- package/test/test-no-filters.html +80 -80
- package/test/test-no-filters.js +172 -172
- package/test/test-no-headers.html +71 -71
- package/test/test-no-headers.js +99 -99
- package/test/test-no-results-message.html +262 -262
- package/test/test-no-results-message.js +222 -222
- package/test/test-no-rows.html +19 -19
- package/test/test-no-rows.js +10 -10
- package/test/test-one-row.html +29 -29
- package/test/test-one-row.js +18 -18
- package/test/test-paging.html +78 -78
- package/test/test-paging.js +273 -273
- package/test/test-popup-filter-one-row.html +38 -38
- package/test/test-popup-filter-one-row.js +138 -138
- package/test/test-popup-filter.html +78 -78
- package/test/test-popup-filter.js +384 -384
- package/test/test-popup-filters-grouped-headers.html +104 -104
- package/test/test-popup-filters-grouped-headers.js +206 -206
- package/test/test-rows-counter.html +77 -77
- package/test/test-rows-counter.js +112 -112
- package/test/test-single-filter.html +78 -78
- package/test/test-single-filter.js +138 -138
- package/test/test-sort-custom-sorter.html +243 -243
- package/test/test-sort-custom-sorter.js +74 -74
- package/test/test-sort-grid-layout.html +142 -142
- package/test/test-sort-grid-layout.js +86 -86
- package/test/test-sort-key.html +243 -243
- package/test/test-sort-key.js +67 -67
- package/test/test-sort.html +142 -142
- package/test/test-sort.js +126 -126
- package/test/test-state.html +78 -78
- package/test/test-state.js +369 -369
- package/test/test-status-bar.html +79 -79
- package/test/test-status-bar.js +146 -146
- package/test/test-storage-cookie.html +78 -78
- package/test/test-storage-cookie.js +82 -82
- package/test/test-storage-local.html +78 -78
- package/test/test-storage-local.js +82 -82
- package/test/test-tfoot.html +96 -96
- package/test/test-tfoot.js +123 -123
- package/test/test-thead.html +80 -80
- package/test/test-thead.js +69 -69
- package/test/test-toolbar.html +81 -81
- package/test/test-toolbar.js +218 -218
- package/test/test-uneven-rows.html +95 -95
- package/test/test-uneven-rows.js +61 -61
- package/test/test-watermark.html +80 -80
- package/test/test-watermark.js +103 -103
- package/test/test.html +141 -141
- package/test/test.js +162 -162
- package/webpack.config.js +87 -87
- package/webpack.dev.config.js +25 -25
- package/webpack.test.config.js +44 -44
- package/.travis.yml +0 -53
- package/dist/tablefilter/tf-1-2aa33b10e0e549020c12.js +0 -1
|
@@ -1,480 +1,474 @@
|
|
|
1
|
-
import {Feature} from '../../feature';
|
|
2
|
-
import {createText, elm} from '../../dom';
|
|
3
|
-
import {isArray, isEmpty, EMPTY_FN} from '../../types';
|
|
4
|
-
import {numSortAsc} from '../../sort';
|
|
5
|
-
import {FORMATTED_NUMBER} from '../../const';
|
|
6
|
-
import
|
|
7
|
-
import {defaultsFn, defaultsArr} from '../../settings';
|
|
8
|
-
import {bound} from '../../event';
|
|
9
|
-
|
|
10
|
-
const EVENTS = [
|
|
11
|
-
'after-filtering',
|
|
12
|
-
'after-page-change',
|
|
13
|
-
'after-page-length-change'
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const SUM = 'sum';
|
|
17
|
-
const MEAN = 'mean';
|
|
18
|
-
const MIN = 'min';
|
|
19
|
-
const MAX = 'max';
|
|
20
|
-
const MEDIAN = 'median';
|
|
21
|
-
const Q1 = 'q1';
|
|
22
|
-
const Q3 = 'q3';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Column calculations extension
|
|
26
|
-
*/
|
|
27
|
-
export default class ColOps extends Feature {
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Creates an instance of ColOps
|
|
31
|
-
*
|
|
32
|
-
* @param {TableFilter} tf TableFilter instance
|
|
33
|
-
* @param {Object} opts Configuration object
|
|
34
|
-
*/
|
|
35
|
-
constructor(tf, opts) {
|
|
36
|
-
super(tf, ColOps);
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Callback fired before columns operations start
|
|
40
|
-
* @type {Function}
|
|
41
|
-
*/
|
|
42
|
-
this.onBeforeOperation = defaultsFn(opts.on_before_operation, EMPTY_FN);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Callback fired after columns operations are completed
|
|
46
|
-
* @type {Function}
|
|
47
|
-
*/
|
|
48
|
-
this.onAfterOperation = defaultsFn(opts.on_after_operation, EMPTY_FN);
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Configuration options
|
|
52
|
-
* @type {Object}
|
|
53
|
-
*/
|
|
54
|
-
this.opts = opts;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* List of DOM element IDs containing column's calculation result
|
|
58
|
-
* @type {Array}
|
|
59
|
-
*/
|
|
60
|
-
this.labelIds = defaultsArr(opts.id, []);
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* List of columns' indexes for calculations
|
|
64
|
-
* @type {Array}
|
|
65
|
-
*/
|
|
66
|
-
this.colIndexes = defaultsArr(opts.col, []);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* List of operations - possible values: 'sum', 'mean', 'min', 'max',
|
|
70
|
-
* 'median', 'q1', 'q3'
|
|
71
|
-
* @type {Array}
|
|
72
|
-
*/
|
|
73
|
-
this.operations = defaultsArr(opts.operation, []);
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* List of write methods used to write the result - possible values:
|
|
77
|
-
* 'innerHTML', 'setValue', 'createTextNode'
|
|
78
|
-
* @type {Array}
|
|
79
|
-
*/
|
|
80
|
-
this.outputTypes = defaultsArr(opts.write_method, []);
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* List of format objects used for formatting the result -
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* - '
|
|
131
|
-
* - '
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
this.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
*
|
|
250
|
-
* @param {
|
|
251
|
-
* @param {
|
|
252
|
-
* @
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
let
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
*
|
|
264
|
-
* @param {
|
|
265
|
-
* @param {
|
|
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
|
-
* @
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
let
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
*
|
|
363
|
-
* @
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
let
|
|
368
|
-
|
|
369
|
-
posa
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
*
|
|
379
|
-
* @
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
let
|
|
384
|
-
let
|
|
385
|
-
|
|
386
|
-
posa
|
|
387
|
-
|
|
388
|
-
posb
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
*
|
|
397
|
-
* @param {
|
|
398
|
-
* @
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
* @param {
|
|
409
|
-
* @param {
|
|
410
|
-
* @param {
|
|
411
|
-
* @
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
case '
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
this.emitter.off(EVENTS, bound(this.calcAll, this));
|
|
476
|
-
|
|
477
|
-
this.initialized = false;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
}
|
|
1
|
+
import {Feature} from '../../feature';
|
|
2
|
+
import {createText, elm} from '../../dom';
|
|
3
|
+
import {isArray, isEmpty, EMPTY_FN} from '../../types';
|
|
4
|
+
import {numSortAsc} from '../../sort';
|
|
5
|
+
import {FORMATTED_NUMBER} from '../../const';
|
|
6
|
+
import {formatNumberValue} from '../../number';
|
|
7
|
+
import {defaultsFn, defaultsArr} from '../../settings';
|
|
8
|
+
import {bound} from '../../event';
|
|
9
|
+
|
|
10
|
+
const EVENTS = [
|
|
11
|
+
'after-filtering',
|
|
12
|
+
'after-page-change',
|
|
13
|
+
'after-page-length-change'
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const SUM = 'sum';
|
|
17
|
+
const MEAN = 'mean';
|
|
18
|
+
const MIN = 'min';
|
|
19
|
+
const MAX = 'max';
|
|
20
|
+
const MEDIAN = 'median';
|
|
21
|
+
const Q1 = 'q1';
|
|
22
|
+
const Q3 = 'q3';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Column calculations extension
|
|
26
|
+
*/
|
|
27
|
+
export default class ColOps extends Feature {
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of ColOps
|
|
31
|
+
*
|
|
32
|
+
* @param {TableFilter} tf TableFilter instance
|
|
33
|
+
* @param {Object} opts Configuration object
|
|
34
|
+
*/
|
|
35
|
+
constructor(tf, opts) {
|
|
36
|
+
super(tf, ColOps);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Callback fired before columns operations start
|
|
40
|
+
* @type {Function}
|
|
41
|
+
*/
|
|
42
|
+
this.onBeforeOperation = defaultsFn(opts.on_before_operation, EMPTY_FN);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Callback fired after columns operations are completed
|
|
46
|
+
* @type {Function}
|
|
47
|
+
*/
|
|
48
|
+
this.onAfterOperation = defaultsFn(opts.on_after_operation, EMPTY_FN);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Configuration options
|
|
52
|
+
* @type {Object}
|
|
53
|
+
*/
|
|
54
|
+
this.opts = opts;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* List of DOM element IDs containing column's calculation result
|
|
58
|
+
* @type {Array}
|
|
59
|
+
*/
|
|
60
|
+
this.labelIds = defaultsArr(opts.id, []);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* List of columns' indexes for calculations
|
|
64
|
+
* @type {Array}
|
|
65
|
+
*/
|
|
66
|
+
this.colIndexes = defaultsArr(opts.col, []);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* List of operations - possible values: 'sum', 'mean', 'min', 'max',
|
|
70
|
+
* 'median', 'q1', 'q3'
|
|
71
|
+
* @type {Array}
|
|
72
|
+
*/
|
|
73
|
+
this.operations = defaultsArr(opts.operation, []);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* List of write methods used to write the result - possible values:
|
|
77
|
+
* 'innerHTML', 'setValue', 'createTextNode'
|
|
78
|
+
* @type {Array}
|
|
79
|
+
*/
|
|
80
|
+
this.outputTypes = defaultsArr(opts.write_method, []);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* List of format objects used for formatting the result - see
|
|
84
|
+
* formatNumberValue in number.js for the supported options
|
|
85
|
+
* @type {Array}
|
|
86
|
+
*/
|
|
87
|
+
this.formatResults = defaultsArr(opts.format_result, []);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* List of row indexes displaying the results
|
|
91
|
+
* @type {Array}
|
|
92
|
+
*/
|
|
93
|
+
this.totRowIndexes = defaultsArr(opts.tot_row_index, []);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* List of row indexes excluded from calculations
|
|
97
|
+
* @type {Array}
|
|
98
|
+
*/
|
|
99
|
+
this.excludeRows = defaultsArr(opts.exclude_row, []);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* List of decimal precision for calculation results
|
|
103
|
+
* @type {Array}
|
|
104
|
+
*/
|
|
105
|
+
this.decimalPrecisions = defaultsArr(opts.decimal_precision, 2);
|
|
106
|
+
|
|
107
|
+
this.enable();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Initializes ColOps instance
|
|
112
|
+
*/
|
|
113
|
+
init() {
|
|
114
|
+
if (this.initialized) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// subscribe to events
|
|
118
|
+
this.emitter.on(EVENTS, bound(this.calcAll, this));
|
|
119
|
+
|
|
120
|
+
this.calcAll();
|
|
121
|
+
|
|
122
|
+
/** @inherited */
|
|
123
|
+
this.initialized = true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Calculates columns' values
|
|
128
|
+
* Configuration options are stored in 'opts' property
|
|
129
|
+
* - 'id' contains ids of elements showing result (array)
|
|
130
|
+
* - 'col' contains the columns' indexes (array)
|
|
131
|
+
* - 'operation' contains operation type (array, values: 'sum', 'mean',
|
|
132
|
+
* 'min', 'max', 'median', 'q1', 'q3')
|
|
133
|
+
* - 'write_method' array defines which method to use for displaying the
|
|
134
|
+
* result (innerHTML, setValue, createTextNode) - default: 'innerHTML'
|
|
135
|
+
* - 'tot_row_index' defines in which row results are displayed
|
|
136
|
+
* (integers array)
|
|
137
|
+
*
|
|
138
|
+
* - changes made by Nuovella:
|
|
139
|
+
* (1) optimized the routine (now it will only process each column once),
|
|
140
|
+
* (2) added calculations for the median, lower and upper quartile.
|
|
141
|
+
*/
|
|
142
|
+
calcAll() {
|
|
143
|
+
let tf = this.tf;
|
|
144
|
+
if (!tf.isInitialized()) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.onBeforeOperation(tf, this);
|
|
149
|
+
this.emitter.emit('before-column-operation', tf, this);
|
|
150
|
+
|
|
151
|
+
let { colIndexes, operations: colOperations, outputTypes,
|
|
152
|
+
totRowIndexes, excludeRows, formatResults,
|
|
153
|
+
decimalPrecisions } = this;
|
|
154
|
+
|
|
155
|
+
//nuovella: determine unique list of columns to operate on
|
|
156
|
+
let uIndexes = [];
|
|
157
|
+
colIndexes.forEach((val) => {
|
|
158
|
+
if (uIndexes.indexOf(val) === -1) {
|
|
159
|
+
uIndexes.push(val);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
let nbCols = uIndexes.length,
|
|
164
|
+
rows = tf.dom().rows,
|
|
165
|
+
colValues = [];
|
|
166
|
+
|
|
167
|
+
for (let u = 0; u < nbCols; u++) {
|
|
168
|
+
//this retrieves col values
|
|
169
|
+
//use uIndexes because we only want to pass through this loop
|
|
170
|
+
//once for each column get the values in this unique column
|
|
171
|
+
colValues.push(
|
|
172
|
+
tf.getVisibleColumnData(uIndexes[u], false, excludeRows)
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
let curValues = colValues[u];
|
|
176
|
+
|
|
177
|
+
//next: calculate all operations for this column
|
|
178
|
+
let result = 0,
|
|
179
|
+
operations = [],
|
|
180
|
+
precisions = [],
|
|
181
|
+
labels = [],
|
|
182
|
+
writeType,
|
|
183
|
+
formatResult = [],
|
|
184
|
+
idx = 0;
|
|
185
|
+
|
|
186
|
+
for (let k = 0; k < colIndexes.length; k++) {
|
|
187
|
+
if (colIndexes[k] !== uIndexes[u]) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
operations[idx] = (colOperations[k] || 'sum').toLowerCase();
|
|
191
|
+
precisions[idx] = decimalPrecisions[k];
|
|
192
|
+
labels[idx] = this.labelIds[k];
|
|
193
|
+
writeType = isArray(outputTypes) ? outputTypes[k] : null;
|
|
194
|
+
formatResult[idx] =
|
|
195
|
+
this.configureFormat(uIndexes[u], formatResults[k]);
|
|
196
|
+
idx++;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
for (let i = 0; i < idx; i++) {
|
|
200
|
+
// emit values before column calculation
|
|
201
|
+
this.emitter.emit(
|
|
202
|
+
'before-column-calc',
|
|
203
|
+
tf,
|
|
204
|
+
this,
|
|
205
|
+
uIndexes[u],
|
|
206
|
+
curValues,
|
|
207
|
+
operations[i],
|
|
208
|
+
precisions[i]
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
result = Number(this.calc(curValues, operations[i], null));
|
|
212
|
+
|
|
213
|
+
// emit column calculation result
|
|
214
|
+
this.emitter.emit(
|
|
215
|
+
'column-calc',
|
|
216
|
+
tf,
|
|
217
|
+
this,
|
|
218
|
+
uIndexes[u],
|
|
219
|
+
result,
|
|
220
|
+
operations[i],
|
|
221
|
+
precisions[i]
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
// write result in expected DOM element
|
|
225
|
+
this.writeResult(
|
|
226
|
+
result,
|
|
227
|
+
labels[i],
|
|
228
|
+
writeType,
|
|
229
|
+
precisions[i],
|
|
230
|
+
formatResult[i]
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
}//for i
|
|
234
|
+
|
|
235
|
+
// row(s) with result are always visible
|
|
236
|
+
let totRow = totRowIndexes && totRowIndexes[u] ?
|
|
237
|
+
rows[totRowIndexes[u]] : null;
|
|
238
|
+
if (totRow) {
|
|
239
|
+
totRow.style.display = '';
|
|
240
|
+
}
|
|
241
|
+
}//for u
|
|
242
|
+
|
|
243
|
+
this.onAfterOperation(tf, this);
|
|
244
|
+
this.emitter.emit('after-column-operation', tf, this);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Make desired calculation on specified column.
|
|
249
|
+
* @param {Number} colIndex Column index
|
|
250
|
+
* @param {String} [operation=SUM] Operation type
|
|
251
|
+
* @param {Number} precision Decimal precision
|
|
252
|
+
* @returns {Number}
|
|
253
|
+
*/
|
|
254
|
+
columnCalc(colIndex, operation = SUM, precision) {
|
|
255
|
+
let excludeRows = this.excludeRows || [];
|
|
256
|
+
let colValues = tf.getVisibleColumnData(colIndex, false, excludeRows);
|
|
257
|
+
|
|
258
|
+
return Number(this.calc(colValues, operation, precision));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Make calculation on passed values.
|
|
263
|
+
* @param {Array} values List of values
|
|
264
|
+
* @param {String} [operation=SUM] Optional operation type
|
|
265
|
+
* @param {Number} precision Optional result precision
|
|
266
|
+
* @returns {Number}
|
|
267
|
+
* @private
|
|
268
|
+
*/
|
|
269
|
+
calc(colValues, operation = SUM, precision) {
|
|
270
|
+
let result = 0;
|
|
271
|
+
|
|
272
|
+
if (operation === Q1 || operation === Q3 || operation === MEDIAN) {
|
|
273
|
+
colValues = this.sortColumnValues(colValues, numSortAsc);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
switch (operation) {
|
|
277
|
+
case MEAN:
|
|
278
|
+
result = this.calcMean(colValues);
|
|
279
|
+
break;
|
|
280
|
+
case SUM:
|
|
281
|
+
result = this.calcSum(colValues);
|
|
282
|
+
break;
|
|
283
|
+
case MIN:
|
|
284
|
+
result = this.calcMin(colValues);
|
|
285
|
+
break;
|
|
286
|
+
case MAX:
|
|
287
|
+
result = this.calcMax(colValues);
|
|
288
|
+
break;
|
|
289
|
+
case MEDIAN:
|
|
290
|
+
result = this.calcMedian(colValues);
|
|
291
|
+
break;
|
|
292
|
+
case Q1:
|
|
293
|
+
result = this.calcQ1(colValues);
|
|
294
|
+
break;
|
|
295
|
+
case Q3:
|
|
296
|
+
result = this.calcQ3(colValues);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return isEmpty(precision) ? result : result.toFixed(precision);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Calculate the sum of passed values.
|
|
305
|
+
* @param {Array} [values=[]] List of values
|
|
306
|
+
* @returns {Number}
|
|
307
|
+
*/
|
|
308
|
+
calcSum(values = []) {
|
|
309
|
+
if (isEmpty(values)) {
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
let result = values.reduce((x, y) => Number(x) + Number(y));
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Calculate the mean of passed values.
|
|
318
|
+
* @param {Array} [values=[]] List of values
|
|
319
|
+
* @returns {Number}
|
|
320
|
+
*/
|
|
321
|
+
calcMean(values = []) {
|
|
322
|
+
let result = this.calcSum(values) / values.length;
|
|
323
|
+
return Number(result);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Calculate the max value of passed values.
|
|
328
|
+
* @param {Array} [values=[]] List of values
|
|
329
|
+
* @returns {Number}
|
|
330
|
+
*/
|
|
331
|
+
calcMax(values = []) {
|
|
332
|
+
return Math.max.apply(null, values);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Calculate the min value of passed values.
|
|
337
|
+
* @param {Array} [values=[]] List of values
|
|
338
|
+
* @returns {Number}
|
|
339
|
+
*/
|
|
340
|
+
calcMin(values = []) {
|
|
341
|
+
return Math.min.apply(null, values);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Calculate the median of passed values.
|
|
346
|
+
* @param {Array} [values=[]] List of values
|
|
347
|
+
* @returns {Number}
|
|
348
|
+
*/
|
|
349
|
+
calcMedian(values = []) {
|
|
350
|
+
let nbValues = values.length;
|
|
351
|
+
let aux = 0;
|
|
352
|
+
if (nbValues % 2 === 1) {
|
|
353
|
+
aux = Math.floor(nbValues / 2);
|
|
354
|
+
return Number(values[aux]);
|
|
355
|
+
}
|
|
356
|
+
return (Number(values[nbValues / 2]) +
|
|
357
|
+
Number(values[((nbValues / 2) - 1)])) / 2;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Calculate the lower quartile of passed values.
|
|
362
|
+
* @param {Array} [values=[]] List of values
|
|
363
|
+
* @returns {Number}
|
|
364
|
+
*/
|
|
365
|
+
calcQ1(values = []) {
|
|
366
|
+
let nbValues = values.length;
|
|
367
|
+
let posa = 0.0;
|
|
368
|
+
posa = Math.floor(nbValues / 4);
|
|
369
|
+
if (4 * posa === nbValues) {
|
|
370
|
+
return (Number(values[posa - 1]) +
|
|
371
|
+
Number(values[posa])) / 2;
|
|
372
|
+
}
|
|
373
|
+
return Number(values[posa]);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Calculate the upper quartile of passed values.
|
|
378
|
+
* @param {Array} [values=[]] List of values
|
|
379
|
+
* @returns {Number}
|
|
380
|
+
*/
|
|
381
|
+
calcQ3(values = []) {
|
|
382
|
+
let nbValues = values.length;
|
|
383
|
+
let posa = 0.0;
|
|
384
|
+
let posb = 0.0;
|
|
385
|
+
posa = Math.floor(nbValues / 4);
|
|
386
|
+
if (4 * posa === nbValues) {
|
|
387
|
+
posb = 3 * posa;
|
|
388
|
+
return (Number(values[posb]) +
|
|
389
|
+
Number(values[posb - 1])) / 2;
|
|
390
|
+
}
|
|
391
|
+
return Number(values[nbValues - posa - 1]);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Sort passed values with supplied sorter function.
|
|
396
|
+
* @param {Array} [values=[]] List of values to be sorted
|
|
397
|
+
* @param {Function} sorter Sorter function
|
|
398
|
+
* @returns {Array}
|
|
399
|
+
*/
|
|
400
|
+
sortColumnValues(values = [], sorter) {
|
|
401
|
+
return values.sort(sorter);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Write calculation result in passed DOM element with supplied write method
|
|
406
|
+
* and decimal precision.
|
|
407
|
+
* @param {Number} [result=0] Calculation result
|
|
408
|
+
* @param {DOMElement} label DOM element
|
|
409
|
+
* @param {String} [writeType='innerhtml'] Write method
|
|
410
|
+
* @param {Number} [precision=2] Applied decimal precision
|
|
411
|
+
* @private
|
|
412
|
+
*/
|
|
413
|
+
writeResult(result = 0, label, writeType = 'innerhtml',
|
|
414
|
+
precision = 2, format = {}) {
|
|
415
|
+
let labelElm = elm(label);
|
|
416
|
+
|
|
417
|
+
if (!labelElm) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
result = formatNumberValue(result.toFixed(precision), format);
|
|
422
|
+
|
|
423
|
+
switch (writeType.toLowerCase()) {
|
|
424
|
+
case 'innerhtml':
|
|
425
|
+
labelElm.innerHTML = result;
|
|
426
|
+
break;
|
|
427
|
+
case 'setvalue':
|
|
428
|
+
labelElm.value = result;
|
|
429
|
+
break;
|
|
430
|
+
case 'createtextnode':
|
|
431
|
+
let oldNode = labelElm.firstChild;
|
|
432
|
+
let txtNode = createText(result);
|
|
433
|
+
labelElm.replaceChild(txtNode, oldNode);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Configure the format options used to format the operation result based
|
|
440
|
+
* on column type.
|
|
441
|
+
* @param {Number} colIndex Column index
|
|
442
|
+
* @param {Object} [format={}] Format object
|
|
443
|
+
* @returns {Object}
|
|
444
|
+
* @private
|
|
445
|
+
*/
|
|
446
|
+
configureFormat(colIndex, format = {}) {
|
|
447
|
+
let tf = this.tf;
|
|
448
|
+
if (tf.hasType(colIndex, [FORMATTED_NUMBER])) {
|
|
449
|
+
let colType = tf.colTypes[colIndex];
|
|
450
|
+
if (colType.decimal && !format.decimal) {
|
|
451
|
+
format.decimal = colType.decimal;
|
|
452
|
+
}
|
|
453
|
+
if (colType.thousands && !format.integerSeparator) {
|
|
454
|
+
format.integerSeparator = colType.thousands;
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
format.decimal = format.decimal || '';
|
|
458
|
+
format.integerSeparator = format.integerSeparator || '';
|
|
459
|
+
}
|
|
460
|
+
return format;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** Remove extension */
|
|
464
|
+
destroy() {
|
|
465
|
+
if (!this.initialized) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
// unsubscribe to events
|
|
469
|
+
this.emitter.off(EVENTS, bound(this.calcAll, this));
|
|
470
|
+
|
|
471
|
+
this.initialized = false;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
}
|