@datarailsshared/dr_renderer 1.2.42-beta → 1.2.44-beta
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/package.json +1 -1
- package/src/dataformatter.js +4 -0
- package/src/dr_pivottable.js +69 -12
- package/src/highcharts_renderer.js +64 -4
- package/src/pivottable.js +3 -2
- package/src/published_items_renderer.js +5 -5
package/package.json
CHANGED
package/src/dataformatter.js
CHANGED
package/src/dr_pivottable.js
CHANGED
|
@@ -133,21 +133,75 @@ let initDRPivotTable = function($, window, document) {
|
|
|
133
133
|
return key;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
let newProcessKey = function (record, totals, keys, attrs, getAggregator) {
|
|
137
|
+
var addKey, attr, flatKey, k, key, len, ref;
|
|
138
|
+
key = [];
|
|
139
|
+
addKey = false;
|
|
140
|
+
for (k = 0, len = attrs.length; k < len; k++) {
|
|
141
|
+
attr = attrs[k];
|
|
142
|
+
if (record.hasOwnProperty(attr)) {
|
|
143
|
+
key.push((ref = record[attr]));
|
|
144
|
+
flatKey = key.join(delim);
|
|
145
|
+
}
|
|
146
|
+
if (totals[flatKey] && totals[flatKey].isChangeable) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (!flatKey) return [];
|
|
150
|
+
if (!totals[flatKey]) {
|
|
151
|
+
totals[flatKey] = getAggregator(key.slice());
|
|
152
|
+
addKey = true;
|
|
153
|
+
} else {
|
|
154
|
+
totals[flatKey] = getAggregator(key.slice());
|
|
155
|
+
totals[flatKey].push(record);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (addKey) {
|
|
159
|
+
keys.push(key);
|
|
160
|
+
}
|
|
161
|
+
return key;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
DRPivotData.prototype.processRecord = function(record, isUserHasPermission) {
|
|
137
165
|
var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
|
|
138
166
|
rowKey = [];
|
|
139
167
|
colKey = [];
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
168
|
+
if (isUserHasPermission) {
|
|
169
|
+
rowKey = newProcessKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, (function(_this) {
|
|
170
|
+
return function(key) {
|
|
171
|
+
return _this.aggregator(_this, key, []);
|
|
172
|
+
};
|
|
173
|
+
})(this));
|
|
174
|
+
colKey = newProcessKey(record, this.colTotals, this.colKeys, this.colAttrs, (function(_this) {
|
|
175
|
+
return function(key) {
|
|
176
|
+
return _this.aggregator(_this, [], key);
|
|
177
|
+
};
|
|
178
|
+
})(this));
|
|
179
|
+
|
|
180
|
+
if (!colKey.length && !rowKey.length) {
|
|
181
|
+
this.allTotal.push(record);
|
|
182
|
+
}
|
|
183
|
+
if (!colKey.length && rowKey.length === 1) {
|
|
184
|
+
this.rowTotals[rowKey[0]].push(record);
|
|
185
|
+
this.rowTotals[rowKey[0]].isChangeable = true;
|
|
186
|
+
}
|
|
187
|
+
if (!rowKey.length && colKey.length === 1) {
|
|
188
|
+
this.colTotals[colKey[0]].push(record);
|
|
189
|
+
this.colTotals[colKey[0]].isChangeable = true;
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
this.allTotal.push(record);
|
|
193
|
+
rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, (function(_this) {
|
|
194
|
+
return function(key) {
|
|
195
|
+
return _this.aggregator(_this, key, []);
|
|
196
|
+
};
|
|
197
|
+
})(this));
|
|
198
|
+
colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, (function(_this) {
|
|
199
|
+
return function(key) {
|
|
200
|
+
return _this.aggregator(_this, [], key);
|
|
201
|
+
};
|
|
202
|
+
})(this));
|
|
203
|
+
}
|
|
204
|
+
|
|
151
205
|
m = rowKey.length - 1;
|
|
152
206
|
n = colKey.length - 1;
|
|
153
207
|
if (m < 0 || n < 0) {
|
|
@@ -384,6 +438,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
384
438
|
pvtData.rowKeys = [];
|
|
385
439
|
pvtData.colKeys = [];
|
|
386
440
|
tooMuch = true;
|
|
441
|
+
opts.error_has_occurred = true;
|
|
387
442
|
}
|
|
388
443
|
return SubtotalRenderer(pvtData, opts, charttype, tooMuch);
|
|
389
444
|
}
|
|
@@ -2001,6 +2056,8 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2001
2056
|
|
|
2002
2057
|
handleFreezePanesScroll = function(freezableElements) {
|
|
2003
2058
|
return function(event) {
|
|
2059
|
+
if (event.target.dataset.canFreezePanes) return;
|
|
2060
|
+
|
|
2004
2061
|
const wrapper = event.target;
|
|
2005
2062
|
|
|
2006
2063
|
const translateY = `translate(0px, ${wrapper.scrollTop}px)`;
|
|
@@ -822,6 +822,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
822
822
|
result = highchartsRenderer.getNoDataResult(chartOptions);
|
|
823
823
|
} else if (!chartOptions.onlyText && chartOptions.series && toMatch) {
|
|
824
824
|
result = highchartsRenderer.getNoDataResult(chartOptions, toMatch);
|
|
825
|
+
opts.error_has_occurred = true;
|
|
825
826
|
} else {
|
|
826
827
|
chartOptions = highchartsRenderer.updateChartOptions(chartOptions, opts);
|
|
827
828
|
chartOptions = highchartsRenderer.updateChartOptions(chartOptions, {credits: {enabled: false}});
|
|
@@ -2547,7 +2548,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
2547
2548
|
style = {};
|
|
2548
2549
|
}
|
|
2549
2550
|
}
|
|
2551
|
+
|
|
2552
|
+
if(typeof style !== 'object' || style === null){
|
|
2553
|
+
style = {};
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2550
2556
|
style.fontWeight = useNewUx ? 'normal' : 'bold';
|
|
2557
|
+
|
|
2551
2558
|
return style;
|
|
2552
2559
|
}
|
|
2553
2560
|
|
|
@@ -2984,6 +2991,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
2984
2991
|
has_errors: false,
|
|
2985
2992
|
widget_values_format: widget_values_format,
|
|
2986
2993
|
calculated_formats: calculated_info.formats,
|
|
2994
|
+
isChangeable: false,
|
|
2987
2995
|
push: function (record) {
|
|
2988
2996
|
if (record.hasOwnProperty('data_types') && record['data_types']) {
|
|
2989
2997
|
if (record['data_types'].length > 0) {
|
|
@@ -3016,7 +3024,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3016
3024
|
this.ignoreValue = true;
|
|
3017
3025
|
}
|
|
3018
3026
|
|
|
3019
|
-
|
|
3027
|
+
if (data.isUserHasPermission) {
|
|
3028
|
+
return this.sum = val;
|
|
3029
|
+
} else {
|
|
3030
|
+
return this.sum += val;
|
|
3031
|
+
}
|
|
3020
3032
|
} else {
|
|
3021
3033
|
return this.sum = NaN;
|
|
3022
3034
|
}
|
|
@@ -3459,6 +3471,30 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3459
3471
|
filter = (a) => a > bottomx;
|
|
3460
3472
|
}
|
|
3461
3473
|
break;
|
|
3474
|
+
case "filter_smallest":
|
|
3475
|
+
const smallest_sumOfFields = lodash.reduce(totals, (acc, curr) => acc += curr.sum, 0);
|
|
3476
|
+
const smallest = Math.floor((smallest_sumOfFields * vals[0])/100);
|
|
3477
|
+
|
|
3478
|
+
if (is_absolute)
|
|
3479
|
+
filter = (a) => Math.abs(a) > smallest;
|
|
3480
|
+
else
|
|
3481
|
+
filter = (a) => a > smallest;
|
|
3482
|
+
break;
|
|
3483
|
+
case "filter_largest":
|
|
3484
|
+
const largest_sumOfFields = lodash.reduce(totals, (acc, curr) => acc += curr.sum, 0);
|
|
3485
|
+
const largest = Math.floor((largest_sumOfFields * vals[0])/100);
|
|
3486
|
+
|
|
3487
|
+
if (is_absolute)
|
|
3488
|
+
filter = (a) => Math.abs(a) < largest;
|
|
3489
|
+
else
|
|
3490
|
+
filter = (a) => a < largest;
|
|
3491
|
+
break;
|
|
3492
|
+
case "filter_out_zero":
|
|
3493
|
+
if (is_absolute)
|
|
3494
|
+
filter = (a) => Math.abs(a) == 0;
|
|
3495
|
+
else
|
|
3496
|
+
filter = (a) => a == 0;
|
|
3497
|
+
break;
|
|
3462
3498
|
default:
|
|
3463
3499
|
|
|
3464
3500
|
}
|
|
@@ -3709,6 +3745,30 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3709
3745
|
return to_return;
|
|
3710
3746
|
};
|
|
3711
3747
|
|
|
3748
|
+
highchartsRenderer.checkFreezePanesAvaliable = function (pivotView) {
|
|
3749
|
+
if (!pivotView || !pivotView.querySelector) {
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
const tableContainer = pivotView.querySelector('.pivot-div');
|
|
3754
|
+
const tableHead = pivotView.querySelector('table.pvtTable thead');
|
|
3755
|
+
const tableHeadChildren = tableHead ? tableHead.children[0] : null;
|
|
3756
|
+
const trChildren = tableHeadChildren ? tableHeadChildren.children : [];
|
|
3757
|
+
let thWidth = 0;
|
|
3758
|
+
|
|
3759
|
+
for (let th of trChildren) {
|
|
3760
|
+
if (th.classList.contains('axis-freeze-pane') || th.classList.contains('horizontal-freeze-pane')) {
|
|
3761
|
+
thWidth += th.offsetWidth;
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
if (thWidth >= tableContainer.offsetWidth) {
|
|
3766
|
+
tableContainer.dataset.canFreezePanes = 'false';
|
|
3767
|
+
} else if (thWidth < tableContainer.offsetWidth && tableContainer.dataset.canFreezePanes) {
|
|
3768
|
+
delete tableContainer.dataset.canFreezePanes;
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
|
|
3712
3772
|
highchartsRenderer.rhPivotView = function (rowData, options, isTable = false) {
|
|
3713
3773
|
if (!rowData || !rowData) {
|
|
3714
3774
|
if (options.onlyOptions) {
|
|
@@ -4168,7 +4228,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4168
4228
|
options.chartOptions.legends_position = { value: 'none' };
|
|
4169
4229
|
delete options.chartOptions.chart.hideLegends;
|
|
4170
4230
|
}
|
|
4171
|
-
if (['pie-chart', 'pie-chart-drilldown']
|
|
4231
|
+
if (lodash.includes(['pie-chart', 'pie-chart-drilldown'], type)) {
|
|
4172
4232
|
if (options.chartOptions && options.chartOptions.label) {
|
|
4173
4233
|
if (options.chartOptions.label.only_value) {
|
|
4174
4234
|
options.chartOptions.label.show_percentage_in_labels = false;
|
|
@@ -6579,7 +6639,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6579
6639
|
const isCustomSorting = widget.options.sortingFields && Array.isArray(widget.options.sortingFields) && widget.options.sortingFields.length > 0;
|
|
6580
6640
|
if (isCustomSorting) {
|
|
6581
6641
|
lodash.forEach(datesFields, function (field) {
|
|
6582
|
-
const fieldToSort = widget.options.sortingFields
|
|
6642
|
+
const fieldToSort = lodash.find(widget.options.sortingFields, element => element.id === field.id);
|
|
6583
6643
|
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
|
6584
6644
|
});
|
|
6585
6645
|
}
|
|
@@ -6626,7 +6686,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6626
6686
|
|
|
6627
6687
|
if (isCustomSorting) {
|
|
6628
6688
|
lodash.forEach(rowsAndCols, function (field) {
|
|
6629
|
-
const fieldToSort = widget.options.sortingFields
|
|
6689
|
+
const fieldToSort = lodash.find(widget.options.sortingFields, element => element.id === field.id);
|
|
6630
6690
|
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
|
6631
6691
|
});
|
|
6632
6692
|
}
|
package/src/pivottable.js
CHANGED
|
@@ -626,6 +626,7 @@ let initPivotTable = function($, window, document) {
|
|
|
626
626
|
this.sortKeys = bind(this.sortKeys, this);
|
|
627
627
|
this.arrSort = bind(this.arrSort, this);
|
|
628
628
|
this.input = input;
|
|
629
|
+
this.isUserHasPermission = opts.userHasPermission;
|
|
629
630
|
this.aggregator = (ref = opts.aggregator) != null ? ref : aggregatorTemplates.count()();
|
|
630
631
|
this.aggregatorName = (ref1 = opts.aggregatorName) != null ? ref1 : "Count";
|
|
631
632
|
this.colAttrs = (ref2 = opts.cols) != null ? ref2 : [];
|
|
@@ -648,7 +649,7 @@ let initPivotTable = function($, window, document) {
|
|
|
648
649
|
PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
|
|
649
650
|
return function(record) {
|
|
650
651
|
if (_this.filter(record)) {
|
|
651
|
-
return _this.processRecord(record);
|
|
652
|
+
return _this.processRecord(record, _this.isUserHasPermission);
|
|
652
653
|
}
|
|
653
654
|
};
|
|
654
655
|
})(this));
|
|
@@ -1821,4 +1822,4 @@ let initPivotTable = function($, window, document) {
|
|
|
1821
1822
|
};
|
|
1822
1823
|
};
|
|
1823
1824
|
|
|
1824
|
-
module.exports = initPivotTable;
|
|
1825
|
+
module.exports = initPivotTable;
|
|
@@ -15,9 +15,9 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
15
15
|
|
|
16
16
|
publishedItemsRenderer.resizeTable = function (options, window) {
|
|
17
17
|
options.alreadySetTimeout = null;
|
|
18
|
-
const publish_item_image = document.getElementById('publish_item_image');
|
|
19
|
-
const table = document.getElementsByTagName("table")[0];
|
|
20
|
-
const body = document.getElementsByTagName("body")[0];
|
|
18
|
+
const publish_item_image = window.document.getElementById('publish_item_image');
|
|
19
|
+
const table = window.document.getElementsByTagName("table")[0];
|
|
20
|
+
const body = window.document.getElementsByTagName("body")[0];
|
|
21
21
|
let body_zoom = body.style.zoom;
|
|
22
22
|
body_zoom = parseFloat(body_zoom);
|
|
23
23
|
|
|
@@ -190,7 +190,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
190
190
|
break;
|
|
191
191
|
case "dateInput":
|
|
192
192
|
let dateEl = document.createElement("DIV");
|
|
193
|
-
const format = inputMetaData.format
|
|
193
|
+
const format = inputMetaData.format ? inputMetaData.format.toUpperCase() : 'MM/DD/YYYY';
|
|
194
194
|
const formattedDate = formatValue('d', format, inputMetaData.value).value
|
|
195
195
|
dateEl.innerHTML = '<label class="value" style="cursor: pointer;">' + formattedDate + '</label>';
|
|
196
196
|
tdElement.appendChild(dateEl);
|
|
@@ -305,4 +305,4 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
module.exports = getPublishedItemsRenderer;
|
|
308
|
+
module.exports = getPublishedItemsRenderer;
|