@datarailsshared/dr_renderer 1.2.8 → 1.2.10

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/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const getPublishedItemsRenderer = require('./published_items_renderer');
1
2
  const getHighchartsRenderer = require('./highcharts_renderer');
2
3
  const initPivotTable = require('./pivottable');
3
4
  const initDRPivotTable = require('./dr_pivottable');
@@ -15,8 +16,13 @@ dr_render_factory.init = function($, window, document, Handsontable){
15
16
  }
16
17
  }
17
18
 
18
- dr_render_factory.getInitHighchartsRenderer = function($, document, Highcharts, default_colors, highchartsRenderer, lodash, moment_lib){
19
- return getHighchartsRenderer($, document, Highcharts, default_colors, highchartsRenderer, DataFormatter, lodash, moment_lib);
19
+ dr_render_factory.getInitHighchartsRenderer = function($, document, Highcharts, default_colors, highchartsRenderer, lodash, moment_lib, isNewAngular){
20
+ return getHighchartsRenderer($, document, Highcharts, default_colors, highchartsRenderer, DataFormatter, lodash, moment_lib, isNewAngular);
20
21
  }
22
+
23
+ dr_render_factory.getInitPublishedItemsRenderer = function (publishedItemsRenderer, bind = {}) {
24
+ return getPublishedItemsRenderer.bind(bind)(publishedItemsRenderer);
25
+ }
26
+
21
27
  //const $ = require( "jquery" )( window );
22
28
  module.exports = dr_render_factory;
@@ -28,8 +28,6 @@ let initNovixRenderer = function($, window, document, Handsontable){
28
28
  const delim = " , ";
29
29
  const subtotal = "subtotalDatarailsPlaceholder";
30
30
  const replaceValue = "SubTotals";
31
- const useNewUx = document.ReportHippo && document.ReportHippo && document.ReportHippo.user &&
32
- document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
33
31
 
34
32
  $.pivotUtilities.novix_renderers = {
35
33
 
@@ -68,6 +66,73 @@ let initNovixRenderer = function($, window, document, Handsontable){
68
66
  }
69
67
  };
70
68
 
69
+ var minColWidth = 50;
70
+ var maxColWidth = 250;
71
+
72
+ var calculateMaxWidths = function(ds) {
73
+ const mc = findMergeCols(ds);
74
+ return ds.data
75
+ .reduce((acc, row, index) => {
76
+ for (let [col, value] of row.entries()) {
77
+ if (value === subtotal) value = "SubTotals";
78
+ value = typeof value === 'number' ? String(value) : value;
79
+ if (
80
+ typeof value !== "undefined" &&
81
+ (!acc[col] || acc[col].len <= value.length) &&
82
+ !(index === ds.totalRows - 1 && col < ds.fixedColumns)
83
+ ) {
84
+ acc[col] = { str: value, len: value.length || 0, lastRow: index === ds.totalRows - 1 };
85
+ }
86
+ };
87
+ return acc;
88
+ }, new Array(ds.totalColumns).fill(null))
89
+ .map((item) => getTdWidth(item))
90
+ .reduce((acc, width, col, arr) => {
91
+ acc[col] = mc[col] ? getMergeColsWidth(arr, col, mc[col]) : width;
92
+ return acc;
93
+ }, {});
94
+ };
95
+
96
+ var getTdWidth = function(item) {
97
+ let tdStyles = {
98
+ borderLeft: 'solid 1px',
99
+ borderRight: 'solid 1px',
100
+ fontSize: '11px',
101
+ fontFamily: '"Open Sans",sans-serif',
102
+ fontWeight: item.lastRow && opts.chartOptions.table_options.show_row_total ? '700' : '400',
103
+ paddingRight: '4px',
104
+ paddingLeft: '4px',
105
+ wrap: 'nowrap',
106
+ visibility: 'hidden',
107
+ };
108
+ let td = document.createElement('td');
109
+ for (let [key, value] of _.entries(tdStyles)) {
110
+ td.style[key] = value;
111
+ };
112
+ td.innerHTML = item.str;
113
+ document.body.appendChild(td);
114
+ let width = Math.min(Math.max(td.offsetWidth, minColWidth), maxColWidth);
115
+ document.body.removeChild(td);
116
+ return width;
117
+ };
118
+
119
+ var findMergeCols = function(ds) {
120
+ return ds.mergeCells
121
+ .filter(cell => cell.row === ds.fixedRows - 1)
122
+ .reduce((acc, val) => {
123
+ if (!acc[val.col] && val.colspan > 1) acc[val.col] = val.colspan - 1;
124
+ return acc;
125
+ }, {});
126
+ };
127
+
128
+ var getMergeColsWidth = function(cw, col, m) {
129
+ let rightColsWidth = 0;
130
+ for (let _col = col + 1; _col <= col + m; _col++) {
131
+ rightColsWidth += cw[_col];
132
+ };
133
+ return rightColsWidth >= cw[col] ? 0 : cw[col] - rightColsWidth;
134
+ };
135
+
71
136
  opts = $.extend(def, opts, true);
72
137
 
73
138
  var headerRenderer = function (cellProperties) {
@@ -237,9 +302,17 @@ let initNovixRenderer = function($, window, document, Handsontable){
237
302
  dataSource.fixedColumns = pvtData.rowAttrs.length + (hasColumnAttr ? 1 : 0);
238
303
  dataSource.fixedRows = pvtData.colAttrs.length + (hasRowAttr ? 1 : 0);
239
304
 
305
+ for (let i = 0; i < pvtData.rowAttrs.length; i++) {
306
+ rowKeys.sort((a,b) => {
307
+ if (_.isEqual(a.slice(0, i), b.slice(0,i)) && a[i] && a[i] === subtotal) return -1;
308
+ if (_.isEqual(a.slice(0, i), b.slice(0,i)) && b[i] && b[i] === subtotal) return 1;
309
+ return 0;
310
+ });
311
+ };
312
+
240
313
  // for extra rows on edit mode. Where show only one dimension on row o column.
241
314
  var extraColumnLabel = "Grand Totals";
242
- var extraRowLabel = "";
315
+ var extraRowLabel = "Grand Totals";
243
316
  if (opts.totalFilterElements && opts.totalFilterElements.row_total) {
244
317
  extraColumnLabel = opts.totalFilterElements.row_total.innerHTML;
245
318
  }
@@ -388,41 +461,34 @@ let initNovixRenderer = function($, window, document, Handsontable){
388
461
 
389
462
  var rowData = [];
390
463
 
464
+ if (rr == 0) {
465
+ for (var cc = 0; cc < dataSource.fixedColumns; cc++) {
466
+ mergeDic[cc] = {
467
+ toMerge: 1,
468
+ row: 0,
469
+ priorText: rowKeys[rr][cc]
470
+ };
471
+ }
472
+ }
473
+
391
474
  //column for row atts
392
475
  for (var cc = 0; cc < pvtData.rowAttrs.length; cc++) {
393
-
394
476
  rowData.push(rowKeys[rr][cc]);
395
-
477
+ if (rowKeys[rr][cc] === subtotal) {
478
+ addMergeCell(rr + pvtData.colAttrs.length + 1, cc, 1, dataSource.fixedColumns - cc, true, true);
479
+ } else if (cc === rowKeys[rr].length - 1 && hasColumnAttr) {
480
+ addMergeCell(rr + pvtData.colAttrs.length + 1, cc, 1, 2, true, true);
481
+ }
396
482
  // merge cell (last column)
397
- if (opts.chartOptions.table_options.show_column_total) {
398
-
399
- if (cc == rowKeys[rr].length - 1 && hasColumnAttr) {
400
- addMergeCell(rr + pvtData.colAttrs.length + 1, cc, 1, 2, true, true);
401
- }
402
- else {
403
- // init mergeDic
404
- if (rr == 0) {
405
- mergeDic[cc] = {
406
- toMerge: 1,
407
- row: 0,
408
- priorText: rowKeys[rr][cc]
409
- };
410
- }
411
- else if (mergeDic[cc]) { // check for merge dic
412
- if (rowKeys[rr][cc] == mergeDic[cc].priorText) {
413
- mergeDic[cc].toMerge++;
414
- }
415
- else { //create merge cell for this column
416
-
417
- if (cc < rowKeys[rr].length - 1) {
418
- addMergeCell(mergeDic[cc].row + pvtData.colAttrs.length + 1, cc, mergeDic[cc].toMerge, 1);
419
- mergeDic[cc].row = rr;
420
- mergeDic[cc].toMerge = 1;
421
- mergeDic[cc].priorText = rowKeys[rr][cc];
422
- }
423
- }
424
-
425
- }
483
+ if (opts.chartOptions.table_options.show_column_total && rr != 0 && mergeDic[cc]) { // check for merge dic
484
+ if (rowKeys[rr][cc] == mergeDic[cc].priorText) {
485
+ mergeDic[cc].toMerge++;
486
+ } else if (cc < rowKeys[rr].length - 1) {
487
+ //create merge cell for this column
488
+ addMergeCell(mergeDic[cc].row + pvtData.colAttrs.length + 1, cc, mergeDic[cc].toMerge, 1);
489
+ mergeDic[cc].row = rr;
490
+ mergeDic[cc].toMerge = 1;
491
+ mergeDic[cc].priorText = rowKeys[rr][cc];
426
492
  }
427
493
  }
428
494
  }
@@ -457,7 +523,7 @@ let initNovixRenderer = function($, window, document, Handsontable){
457
523
  // var rowKeyAtt = rowKeys[rr].join(String.fromCharCode(0));
458
524
  var rowKeyAtt = rowKeys[rr].join(delim);
459
525
  if (pvtData.rowTotals[rowKeyAtt]) {
460
- let agg = pvtData.allTotal;
526
+ let agg = pvtData.getAggregator(rowKeys[rr], []);
461
527
  let preValue = pvtData.rowTotals[rowKeyAtt].value();
462
528
  let cellValue = $.pivotUtilities.getFormattedNumber(preValue, agg, opts);
463
529
  rowData.push(cellValue);
@@ -487,9 +553,6 @@ let initNovixRenderer = function($, window, document, Handsontable){
487
553
  // END DATA
488
554
  // ######
489
555
 
490
-
491
-
492
-
493
556
  // ######
494
557
  // TOTAL
495
558
  // colums totals area
@@ -514,7 +577,7 @@ let initNovixRenderer = function($, window, document, Handsontable){
514
577
 
515
578
  var colKeyAtt = colKeys[cc].join(delim);
516
579
  if (pvtData.colTotals[colKeyAtt]) {
517
- let agg = pvtData.allTotal;
580
+ let agg = pvtData.getAggregator([], colKeys[cc]);
518
581
  let preValue = pvtData.colTotals[colKeyAtt].value();
519
582
  let cellValue = $.pivotUtilities.getFormattedNumber(preValue, agg, opts);
520
583
  rowData.push(cellValue);
@@ -648,6 +711,10 @@ let initNovixRenderer = function($, window, document, Handsontable){
648
711
  td.innerHTML = "";
649
712
  }
650
713
 
714
+ if (opts.chartOptions.table_options.hide_nulls_in_headers && td.innerHTML === '[null]') {
715
+ td.innerHTML = '';
716
+ }
717
+
651
718
  if (opts.chartOptions.table_options.styles) {
652
719
  for (let rule of opts.chartOptions.table_options.styles) {
653
720
 
@@ -690,7 +757,6 @@ let initNovixRenderer = function($, window, document, Handsontable){
690
757
  }
691
758
  }
692
759
  }
693
-
694
760
  return td;
695
761
  };
696
762
 
@@ -758,6 +824,7 @@ let initNovixRenderer = function($, window, document, Handsontable){
758
824
  var $tableArea = opts.$el.find(".widget-id-" + opts.widgetId);
759
825
  $tableArea.empty();
760
826
  console.log('Handsontable data', dataSource);
827
+ var maxWidths = calculateMaxWidths(dataSource);
761
828
  table = new Handsontable($tableArea.get(0), {
762
829
  licenseKey: 'b0eda-7220b-32d15-e4128-c2f4c', //98463-b132b-fcea0-24f22-da020
763
830
  data: dataSource.data,
@@ -770,6 +837,9 @@ let initNovixRenderer = function($, window, document, Handsontable){
770
837
  fixedColumnsLeft: dataSource.fixedColumns,
771
838
  fixedRowsTop: dataSource.fixedRows,
772
839
  mergeCells: dataSource.mergeCells,
840
+ colWidths: function(index) {
841
+ return maxWidths[index];
842
+ },
773
843
  cells: function (row, col, prop) {
774
844
  var cellProperties = {};
775
845
  cellProperties.renderer = genericRenderer;
@@ -817,9 +887,14 @@ let initNovixRenderer = function($, window, document, Handsontable){
817
887
 
818
888
  // inject the widgetId to the class name so we can separate the tables by it
819
889
  // look for the search side on line 653 "opts.$el.find(".widget-id-" + opts.widgetId);"
820
- return `<div class='novixPivot widget-id-${opts.widgetId} ${
821
- useNewUx && opts.chartOptions.table_options.use_new_table_design ? 'handsontable-new' : ''
822
- }' style='overflow:auto'></div>`;
890
+ var tableClasses = ['novixPivot', `widget-id-${opts.widgetId}`];
891
+ if (opts.chartOptions.table_options.use_new_table_design) {
892
+ tableClasses.push('handsontable-new');
893
+ }
894
+ if (!pvtData.aggregator().uniq) {
895
+ tableClasses.push('numbers-to-right');
896
+ }
897
+ return `<div class='${tableClasses.join(' ')}' style='overflow:auto'></div>`;
823
898
  }
824
899
 
825
900
  };
package/src/pivot.css CHANGED
@@ -1,5 +1,9 @@
1
1
  .pvtUi { color: #333; }
2
2
 
3
+ .pivot-wrapper {
4
+ display: flex;
5
+ flex-direction: column;
6
+ }
3
7
 
4
8
  table.pvtTable {
5
9
  font-size: 8pt;
@@ -7,9 +11,8 @@ table.pvtTable {
7
11
  border-collapse: collapse;
8
12
  width: calc(100% - 30px);
9
13
  margin-bottom: 15px;
10
- margin-left: 15px;
11
- margin-right: 15px;
12
- font-family: 'Roboto-Regular',sans-serif;
14
+ font-family: 'Poppins', sans-serif;
15
+ font-weight: 400;
13
16
  user-select: text;
14
17
  }
15
18
  table.pvtTable thead tr th, table.pvtTable tbody tr th {
@@ -17,11 +20,14 @@ table.pvtTable thead tr th, table.pvtTable tbody tr th {
17
20
  border: 1px solid #CDCDCD;
18
21
  font-size: 8pt;
19
22
  padding: 5px;
20
- font-family: 'Roboto-Medium',sans-serif;
23
+ font-family: 'Poppins', sans-serif;
24
+ font-weight: 700;
21
25
  }
22
26
 
23
- table.pvtTable .pvtColLabel {text-align: center;}
24
- table.pvtTable .pvtTotalLabel {text-align: right;}
27
+ table.pvtTable thead tr th > i,
28
+ table.pvtTable tbody tr th > i {
29
+ font-size: 10px;
30
+ }
25
31
 
26
32
  table.pvtTable tbody tr td {
27
33
  color: #3D3D3D;
@@ -34,7 +40,7 @@ table.pvtTable tbody tr td {
34
40
 
35
41
  .pvtTotal, .pvtGrandTotal {
36
42
  font-weight: bold;
37
- font-family: 'Roboto-Bold',sans-serif;
43
+ font-family: 'Poppins', sans-serif;
38
44
  }
39
45
 
40
46
  .pvtVals { text-align: center; white-space: nowrap;}
@@ -140,6 +146,21 @@ table.pvtTable .pvtAxisLabel {
140
146
  white-space: nowrap;
141
147
  }
142
148
 
149
+ table.pvtTable .axis-freeze-pane {
150
+ position: relative;
151
+ z-index: 100;
152
+ }
153
+
154
+ table.pvtTable .vertical-freeze-pane {
155
+ position: relative;
156
+ z-index: 50;
157
+ }
158
+
159
+ table.pvtTable .horizontal-freeze-pane {
160
+ position: relative;
161
+ z-index: 50;
162
+ }
163
+
143
164
  .pvtRowSubtotal {
144
165
  background-color: #EFEFEF !important;
145
166
  font-weight:bold;
@@ -156,7 +177,7 @@ table.pvtTable .pvtAxisLabel {
156
177
 
157
178
 
158
179
  table.pvtTable.colorized thead tr th, table.pvtTable.colorized tbody tr th {
159
- background-color: transparent;
180
+ background-color: transparent ;
160
181
  /*border: none;*/
161
182
  }
162
183
 
@@ -165,7 +186,7 @@ table.pvtTable.colorized tbody tr td {
165
186
  }
166
187
 
167
188
  table.pvtTable.colorized .pvtRowSubtotal, table.pvtTable.colorized .pvtColSubtotal {
168
- background-color: transparent !important;
189
+ background-color: transparent !important;
169
190
  }
170
191
 
171
192
 
@@ -192,13 +213,13 @@ table.pvtTable.newPvtTable {
192
213
  width: calc(100% - 40px);
193
214
  margin-left: 20px;
194
215
  margin-right: 20px;
195
- font-family: 'Roboto',sans-serif;
216
+ font-family: 'Poppins', sans-serif;
196
217
  }
197
218
 
198
219
  table.pvtTable.newPvtTable thead tr th,
199
220
  table.pvtTable.newPvtTable tbody tr th {
200
221
  font-size: 10px;
201
- font-family: 'Roboto', sans-serif;
222
+ font-family: 'Poppins', sans-serif;
202
223
  }
203
224
 
204
225
  table.pvtTable.newPvtTable thead tr th {
@@ -216,6 +237,7 @@ table.pvtTable.newPvtTable thead tr th .dr-icon-minus {
216
237
  margin-right: 2px;
217
238
  margin-left: 1px;
218
239
  font-size: 8px;
240
+ color: #151a41;
219
241
  }
220
242
 
221
243
  table.pvtTable.newPvtTable.colorized tr th.colTotal,
@@ -238,11 +260,6 @@ table.pvtTable.newPvtTable tbody tr td.rowTotal {
238
260
  background-color: #dfe6ec !important;
239
261
  border-color: #ffffff !important;
240
262
  }
241
- table.pvtTable.newPvtTable .pvtColLabel,
242
- table.pvtTable.newPvtTable .pvtTotalLabel,
243
- table.pvtTable.newPvtTable .pvtTotalLabel.rowTotal {
244
- text-align: left;
245
- }
246
263
 
247
264
  table.pvtTable.newPvtTable tbody tr th .fa {
248
265
  padding: 2px;
@@ -262,6 +279,90 @@ table.pvtTable.newPvtTable tbody tr td {
262
279
  padding: 0 5px;
263
280
  vertical-align: middle;
264
281
  }
282
+
283
+ table.pvtTable thead tr th.axis-freeze-pane:before,
284
+ table.pvtTable thead tr th.vertical-freeze-pane:before,
285
+ table.pvtTable.newPvtTable thead tr th.axis-freeze-pane:before,
286
+ table.pvtTable.newPvtTable thead tr th.vertical-freeze-pane:before {
287
+ content: '';
288
+ width: calc(100% + 1px);
289
+ height: 1px;
290
+ background: white;
291
+ position: absolute;
292
+ top: -1px;
293
+ left: 0;
294
+ }
295
+
296
+ table.pvtTable thead tr th.axis-freeze-pane:before,
297
+ table.pvtTable thead tr th.vertical-freeze-pane:before {
298
+ background: #cdcdcd;
299
+ }
300
+
301
+ table.pvtTable thead tr th.axis-freeze-pane:after,
302
+ table.pvtTable thead tr th.vertical-freeze-pane:after,
303
+ table.pvtTable.newPvtTable thead tr th.axis-freeze-pane:after,
304
+ table.pvtTable.newPvtTable thead tr th.vertical-freeze-pane:after {
305
+ content: '';
306
+ width: 1px;
307
+ height: 100%;
308
+ background: white;
309
+ position: absolute;
310
+ right: -1px;
311
+ top: 0;
312
+ }
313
+ table.pvtTable thead tr th.axis-freeze-pane:after,
314
+ table.pvtTable thead tr th.vertical-freeze-pane:after {
315
+ background: #cdcdcd;
316
+ }
317
+
318
+ table.pvtTable tbody tr th.horizontal-freeze-pane:before,
319
+ table.pvtTable tbody tr td.horizontal-freeze-pane:before,
320
+ table.pvtTable.newPvtTable tbody tr th.horizontal-freeze-pane:before,
321
+ table.pvtTable.newPvtTable tbody tr td.horizontal-freeze-pane:before {
322
+ content: '';
323
+ width: calc(100% + 1px);
324
+ height: 1px;
325
+ background: #dfe6ec;
326
+ position: absolute;
327
+ top: -1px;
328
+ left: 0;
329
+ }
330
+ table.pvtTable tbody tr th.horizontal-freeze-pane:before,
331
+ table.pvtTable tbody tr td.horizontal-freeze-pane:before {
332
+ background: #cdcdcd;
333
+ }
334
+ table.pvtTable tbody tr th.colTotal.horizontal-freeze-pane:before,
335
+ table.pvtTable tbody tr td.colTotal.horizontal-freeze-pane:before {
336
+ background: transparent;
337
+ }
338
+
339
+ table.pvtTable tbody tr th.horizontal-freeze-pane:after,
340
+ table.pvtTable tbody tr td.horizontal-freeze-pane:after,
341
+ table.pvtTable.newPvtTable tbody tr th.horizontal-freeze-pane:after,
342
+ table.pvtTable.newPvtTable tbody tr td.horizontal-freeze-pane:after {
343
+ content: '';
344
+ width: 1px;
345
+ height: 100%;
346
+ background: #dfe6ec;
347
+ position: absolute;
348
+ right: -1px;
349
+ top: 0;
350
+ }
351
+
352
+ table.pvtTable tbody tr th.horizontal-freeze-pane:after,
353
+ table.pvtTable tbody tr td.horizontal-freeze-pane:after {
354
+ background: #cdcdcd;
355
+ }
356
+
357
+ table.pvtTable.newPvtTable tbody tr th.horizontal-freeze-pane.colTotal:after {
358
+ background: #fff;
359
+ }
360
+
361
+ table.pvtTable.colorized:not(.newPvtTable) tbody tr th.horizontal-freeze-pane,
362
+ table.pvtTable.newPvtTable.colorized tbody tr th.horizontal-freeze-pane:not(.highlighted):not(.colTotal) {
363
+ background-color: #fff !important;
364
+ }
365
+
265
366
  table.pvtTable.newPvtTable tbody tr th {
266
367
  vertical-align: top;
267
368
  padding-top: 2.5px;
@@ -290,7 +391,7 @@ table.pvtTable.newPvtTable tbody tr td:hover {
290
391
 
291
392
  table.pvtTable.newPvtTable tbody tr td.hover:after,
292
393
  table.pvtTable.newPvtTable tbody tr td:hover:after {
293
- content: "\e90c";
394
+ content: "\e923";
294
395
  width: 2px;
295
396
  color: #85889c;
296
397
  font: normal normal normal 14px/1 DataRails;
@@ -299,3 +400,27 @@ table.pvtTable.newPvtTable tbody tr td:hover:after {
299
400
  top: 4px;
300
401
  font-size: 12px;
301
402
  }
403
+
404
+
405
+ /* Table cells alignment */
406
+ table.pvtTable .pvtColLabel {text-align: center;}
407
+ table.pvtTable .pvtTotalLabel {text-align: right;}
408
+
409
+ table.pvtTable.newPvtTable .pvtColLabel,
410
+ table.pvtTable.newPvtTable .pvtTotalLabel,
411
+ table.pvtTable.newPvtTable .pvtTotalLabel.rowTotal {
412
+ text-align: left;
413
+ }
414
+
415
+ table.pvtTable thead tr th.pvtColLabel,
416
+ table.pvtTable thead tr th.pvtTotalLabel {
417
+ text-align: center !important;
418
+ }
419
+
420
+ table.pvtTable.numbers-to-right tbody tr td.pvtVal,
421
+ table.pvtTable.numbers-to-right tbody tr td.rowTotal.rowTotal,
422
+ table.pvtTable.numbers-to-right tbody tr td.pvtGrandTotal {
423
+ text-align: right;
424
+ padding-right: 9px;
425
+ line-height: 15px;
426
+ }
package/src/pivottable.js CHANGED
@@ -7,7 +7,7 @@ let initPivotTable = function($, window, document) {
7
7
  /*
8
8
  Utilities
9
9
  */
10
- var PivotData, addSeparators, aggregatorTemplates, aggregators, dayNamesEn, derivers, getSort, locales, mthNamesEn, naturalSort, numberFormat, pivotTableRenderer, rd, renderers, rx, rz, sortAs, usFmt, usFmtInt, usFmtPct, zeroPad;
10
+ var PivotData, addSeparators, aggregatorTemplates, aggregators, dayNamesEn, derivers, getSort, locales, mthNamesEn, naturalSort, numberFormat, pivotTableRenderer, rd, renderers, rx, rz, sortAs, usFmt, usFmtInt, usFmtPct, zeroPad, errorHandling;
11
11
  addSeparators = function(nStr, thousandsSep, decimalSep) {
12
12
  var rgx, x, x1, x2;
13
13
  nStr += '';
@@ -20,6 +20,10 @@ let initPivotTable = function($, window, document) {
20
20
  }
21
21
  return x1 + x2;
22
22
  };
23
+ let useTotalsCalculation = false;
24
+ if (document.ReportHippo && document.ReportHippo && document.ReportHippo.user) {
25
+ useTotalsCalculation = _.includes(document.ReportHippo.user.features, 'enable_server_totals_calculation');
26
+ }
23
27
  numberFormat = function(opts) {
24
28
  var defaults;
25
29
  defaults = {
@@ -610,6 +614,47 @@ let initPivotTable = function($, window, document) {
610
614
  }
611
615
  return naturalSort;
612
616
  };
617
+ errorHandling = {
618
+ placeholders: {
619
+ nodata: {
620
+ title: 'No Data Available',
621
+ text: 'This might happen because of a global filter or a change in the underlying data',
622
+ btnText: '',
623
+ class: 'nodata',
624
+ },
625
+ noPermission: {
626
+ title: 'No Permission',
627
+ text: 'You do not have permission to view the data',
628
+ btnText: 'Request Permission',
629
+ class: 'no-permission',
630
+ },
631
+ tooMuchData: {
632
+ title: 'There is too much data. Please edit this widget',
633
+ text: '',
634
+ btnText: 'Edit Widget',
635
+ class: 'too-much-data',
636
+ },
637
+ noPublishItem: {
638
+ title: 'We can’t find the published item in the source file',
639
+ text: '',
640
+ btnText: 'Go to filebox',
641
+ class: 'no-publish-item',
642
+ },
643
+ },
644
+ getErrorPlaceholder: function(placeholder) {
645
+ if (placeholder && typeof placeholder === 'object') {
646
+ return $(`
647
+ <div class="noData">
648
+ <div class="noData-title">${placeholder.title}</div>
649
+ <i class="noData-image ${placeholder.class}"></i>
650
+ <div class="noData-text">${placeholder.text}</div>
651
+ <div class="noData-error-action"></div>
652
+ </div>
653
+ `);
654
+ }
655
+ return null;
656
+ },
657
+ };
613
658
 
614
659
  /*
615
660
  Data Model class
@@ -645,10 +690,11 @@ let initPivotTable = function($, window, document) {
645
690
  this.colTotals = {};
646
691
  this.allTotal = this.aggregator(this, [], []);
647
692
  this.sorted = false;
693
+ this.dateValuesDictionary = opts.dateValuesDictionary;
648
694
  PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
649
695
  return function(record) {
650
696
  if (_this.filter(record)) {
651
- return _this.processRecord(record);
697
+ return _this.processRecord(record, useTotalsCalculation);
652
698
  }
653
699
  };
654
700
  })(this));
@@ -881,6 +927,7 @@ let initPivotTable = function($, window, document) {
881
927
  return PivotData;
882
928
 
883
929
  })();
930
+
884
931
  $.pivotUtilities = {
885
932
  aggregatorTemplates: aggregatorTemplates,
886
933
  aggregators: aggregators,
@@ -890,8 +937,12 @@ let initPivotTable = function($, window, document) {
890
937
  naturalSort: naturalSort,
891
938
  numberFormat: numberFormat,
892
939
  sortAs: sortAs,
893
- PivotData: PivotData
940
+ PivotData: PivotData,
941
+ errorHandling: errorHandling,
894
942
  };
943
+ if (window.$) {
944
+ window.$.pivotUtilities = $.pivotUtilities
945
+ }
895
946
 
896
947
  /*
897
948
  Default Renderer for hierarchical table layout
@@ -1821,4 +1872,4 @@ let initPivotTable = function($, window, document) {
1821
1872
  };
1822
1873
  };
1823
1874
 
1824
- module.exports = initPivotTable;
1875
+ module.exports = initPivotTable;