@datarailsshared/dr_renderer 1.2.74 → 1.2.78
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
CHANGED
package/src/dataformatter.js
CHANGED
|
@@ -497,11 +497,11 @@ var DataFormatterImpl = function () {
|
|
|
497
497
|
var minutes = n.getMinutes();
|
|
498
498
|
var seconds = n.getSeconds();
|
|
499
499
|
|
|
500
|
-
var
|
|
501
|
-
if (
|
|
502
|
-
return '0' +
|
|
500
|
+
var padStartTime = function(time) {
|
|
501
|
+
if (time < 10) {
|
|
502
|
+
return '0' + time;
|
|
503
503
|
}
|
|
504
|
-
return
|
|
504
|
+
return time;
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
// Build res
|
|
@@ -513,11 +513,11 @@ var DataFormatterImpl = function () {
|
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
if (fmin) {
|
|
516
|
-
return fmin + _this3.applyNumberPattern(
|
|
516
|
+
return fmin + _this3.applyNumberPattern(padStartTime(minutes), '00');
|
|
517
517
|
}
|
|
518
518
|
|
|
519
519
|
if (fmin2) {
|
|
520
|
-
return _this3.applyNumberPattern(
|
|
520
|
+
return _this3.applyNumberPattern(padStartTime(minutes), '00') + fmin2;
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
if (mmin) {
|
|
@@ -534,7 +534,7 @@ var DataFormatterImpl = function () {
|
|
|
534
534
|
return res.replace(/(ss)|(s)|(hh)|(h)|(dddd)|(ddd)|(dd)|(d)|(mmmmm)|(mmmm)|(mmm)|(mm)|(m)|(yyyy)|(yy)|(\[\])/gi, function (a, ss, s, hh, h, dddd, ddd, dd, d, mmmmm, mmmm, mmm, mm, m, yyyy, yy, ampm) {
|
|
535
535
|
|
|
536
536
|
if (ss) {
|
|
537
|
-
return _this3.applyNumberPattern(seconds, '00');
|
|
537
|
+
return _this3.applyNumberPattern(padStartTime(seconds), '00');
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
if (s) {
|
|
@@ -542,7 +542,7 @@ var DataFormatterImpl = function () {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
if (hh) {
|
|
545
|
-
return _this3.applyNumberPattern(foundAMPM ? hours % 12 : hours, '00');
|
|
545
|
+
return _this3.applyNumberPattern(padStartTime(foundAMPM ? hours % 12 : hours), '00');
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
if (h) {
|
package/src/dr_pivottable.js
CHANGED
|
@@ -197,7 +197,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
197
197
|
}
|
|
198
198
|
} else if (!rowKey.length && colKey.length) {
|
|
199
199
|
if (!this.colTotals[flatColKey]) {
|
|
200
|
-
this.colTotals[flatColKey] = getColAggregator(
|
|
200
|
+
this.colTotals[flatColKey] = getColAggregator(colKey.slice());
|
|
201
201
|
this.colTotals[flatColKey].push(record);
|
|
202
202
|
}
|
|
203
203
|
} else {
|
|
@@ -466,7 +466,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
if (opts && opts.chartOptions && opts.chartOptions.label && opts.chartOptions.label.percentage) {
|
|
469
|
-
return (Math.round((this.y / this.total) *
|
|
469
|
+
return (Math.round((this.y / this.total) * 100)) + '%';
|
|
470
470
|
} else if (opts && opts.chartOptions && opts.chartOptions.label && opts.chartOptions.label.show_percentage) {
|
|
471
471
|
let aggrPercentages = pivotData.getAggregator(rows, [])
|
|
472
472
|
let total = aggrPercentages.value()
|
|
@@ -586,7 +586,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
if (lodash.has(opts, "chartOptions.label.percentage") && opts.chartOptions.label.percentage && this.total) {
|
|
589
|
-
to_return += '<br/>' + (Math.round((this.y / this.total) *
|
|
589
|
+
to_return += '<br/>' + (Math.round((this.y / this.total) * 100)) + '%';
|
|
590
590
|
}
|
|
591
591
|
return to_return;
|
|
592
592
|
|
|
@@ -2017,7 +2017,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
2017
2017
|
};
|
|
2018
2018
|
|
|
2019
2019
|
highchartsRenderer.setTitleAndSubTitle = function (chartOptions, opts, additionOptions) {
|
|
2020
|
-
chartOptions.title = opts.chartOptions.hideChartHeader ? null : {
|
|
2020
|
+
chartOptions.title = opts.chartOptions.hideChartHeader ? { text: null } : {
|
|
2021
2021
|
align: 'center',
|
|
2022
2022
|
text: opts && opts.chart_title ? opts.chart_title : "",
|
|
2023
2023
|
style: {
|
|
@@ -4307,6 +4307,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4307
4307
|
format = format.replace('dd', 'DD');
|
|
4308
4308
|
format = format.replace('yyyy', 'YYYY');
|
|
4309
4309
|
format = format.replace('yy', 'YY');
|
|
4310
|
+
format = lodash.replace(format, /h/g, 'H');
|
|
4310
4311
|
return moment_lib(tryParse).utcOffset(0).format(format) + "";
|
|
4311
4312
|
} else {
|
|
4312
4313
|
return 'Wrong date format';
|
|
@@ -4482,7 +4483,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4482
4483
|
},
|
|
4483
4484
|
seriesOptions: []
|
|
4484
4485
|
}
|
|
4485
|
-
if (options.chartOptions.delta_column && options.chartOptions.delta_column.field === 'series') {
|
|
4486
|
+
if (options.chartOptions && options.chartOptions.delta_column && options.chartOptions.delta_column.field === 'series') {
|
|
4486
4487
|
let deltaColumnSeries = {
|
|
4487
4488
|
series: options.chartOptions.delta_column.name,
|
|
4488
4489
|
secondaryAxis: !options.chartOptions.delta_column.same_yaxis,
|
|
@@ -7374,6 +7375,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7374
7375
|
minHeight: 16,
|
|
7375
7376
|
maxHeight: 45,
|
|
7376
7377
|
x: -3,
|
|
7378
|
+
y: -26,
|
|
7377
7379
|
layout: "horizontal"
|
|
7378
7380
|
} : {
|
|
7379
7381
|
enabled: rowAttrsLength > 0,
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
2
2
|
|
|
3
|
+
this.document = {};
|
|
4
|
+
this.scope = {};
|
|
5
|
+
this.options = {};
|
|
6
|
+
this.isScenarioMode = null;
|
|
7
|
+
|
|
3
8
|
publishedItemsRenderer.formulaCellClicked = function (event, scope, options, window) {
|
|
4
9
|
event.stopPropagation();
|
|
5
10
|
event.preventDefault();
|
|
@@ -88,9 +93,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
publishedItemsRenderer.changedAutoResize = function (
|
|
92
|
-
if (options.autoResize !== new_auto_resize) {
|
|
93
|
-
options.autoResize = new_auto_resize;
|
|
96
|
+
publishedItemsRenderer.changedAutoResize = function (options, window, document) {
|
|
94
97
|
if (!options.autoResize) {
|
|
95
98
|
publishedItemsRenderer.resetTableZoom(document);
|
|
96
99
|
} else {
|
|
@@ -100,7 +103,6 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
100
103
|
}, 100);
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
|
-
}
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
publishedItemsRenderer.changedInputValue = function (firstTime, scope, options) {
|
|
@@ -138,6 +140,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
publishedItemsRenderer.createInputElement = function (tdElement, inputMetaData, formatValue, scope, options, document) {
|
|
143
|
+
const _this = this;
|
|
141
144
|
tdElement.innerHTML = '';
|
|
142
145
|
if (inputMetaData) {
|
|
143
146
|
switch (inputMetaData.type) {
|
|
@@ -151,19 +154,32 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
151
154
|
} else {
|
|
152
155
|
labelEl.innerText = inputMetaData.format ? formatValue('n', inputMetaData.format, inputMetaData.value).value : inputMetaData.value;
|
|
153
156
|
}
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
if (_this.isScenarioMode) {
|
|
158
|
+
labelEl.setAttribute("style", "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;");
|
|
159
|
+
} else {
|
|
160
|
+
labelEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 6px;text-align: inherit;display: block; cursor: pointer;");
|
|
161
|
+
}
|
|
162
|
+
const onLabelClick = function (event, isScenarioMode) {
|
|
156
163
|
event.stopPropagation();
|
|
164
|
+
if (isScenarioMode) {
|
|
165
|
+
inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: block;");
|
|
166
|
+
} else {
|
|
167
|
+
inEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: block;");
|
|
168
|
+
}
|
|
157
169
|
labelEl.style.display = 'none';
|
|
158
|
-
inEl.style.display = 'block';
|
|
159
170
|
setTimeout(function () {
|
|
160
171
|
inEl.focus();
|
|
161
172
|
}, 1)
|
|
162
|
-
}
|
|
173
|
+
}
|
|
174
|
+
labelEl.addEventListener("click", (event) => onLabelClick(event, _this.isScenarioMode));
|
|
163
175
|
|
|
164
176
|
inEl.setAttribute("type", "number");
|
|
165
177
|
inEl.setAttribute("name", inputMetaData.name);
|
|
166
|
-
|
|
178
|
+
if (_this.isScenarioMode) {
|
|
179
|
+
inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: none;");
|
|
180
|
+
} else {
|
|
181
|
+
inEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: none;");
|
|
182
|
+
}
|
|
167
183
|
inEl.value = inputMetaData.type === 'editInputPercent' ? parseFloat(inputMetaData.value.replace('%', '')) : inputMetaData.value;
|
|
168
184
|
inEl.addEventListener("focusout", function (event) {
|
|
169
185
|
event.preventDefault();
|
|
@@ -190,7 +206,11 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
190
206
|
let dateEl = document.createElement("DIV");
|
|
191
207
|
const format = inputMetaData.format ? inputMetaData.format.toUpperCase() : 'MM/DD/YYYY';
|
|
192
208
|
const formattedDate = formatValue('d', format, inputMetaData.value).value
|
|
193
|
-
|
|
209
|
+
if (_this.isScenarioMode) {
|
|
210
|
+
dateEl.innerHTML = '<label class="value dateInput" style="background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;">' + formattedDate + '</label>';
|
|
211
|
+
} else {
|
|
212
|
+
dateEl.innerHTML = '<label class="value dateInput" style="cursor: pointer;">' + formattedDate + '</label>';
|
|
213
|
+
}
|
|
194
214
|
tdElement.appendChild(dateEl);
|
|
195
215
|
tdElement.classList.toggle("input-filter-list-td");
|
|
196
216
|
tdElement.setAttribute("name", inputMetaData.name);
|
|
@@ -223,7 +243,11 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
223
243
|
case "filterList":
|
|
224
244
|
let listHolderEl = document.createElement("DIV");
|
|
225
245
|
listHolderEl.setAttribute("class", "filter_list_holder");
|
|
226
|
-
|
|
246
|
+
if (_this.isScenarioMode) {
|
|
247
|
+
listHolderEl.innerHTML = '<label class="value filterList" style="background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor: pointer;">' + inputMetaData.value + '</label><i class="filter_icon"></i>';
|
|
248
|
+
} else {
|
|
249
|
+
listHolderEl.innerHTML = '<label class="value filterList" style="cursor: pointer;">' + inputMetaData.value + '</label><i class="filter_icon"></i>';
|
|
250
|
+
}
|
|
227
251
|
tdElement.appendChild(listHolderEl);
|
|
228
252
|
tdElement.classList.toggle("input-filter-list-td");
|
|
229
253
|
tdElement.setAttribute("name", inputMetaData.name);
|
|
@@ -252,16 +276,38 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
252
276
|
console.log(tdLabelElement, newValue);
|
|
253
277
|
}
|
|
254
278
|
|
|
255
|
-
publishedItemsRenderer.
|
|
256
|
-
|
|
279
|
+
publishedItemsRenderer.changeStylesForLabel = function (elementsArray, styles, isScenarioMode) {
|
|
280
|
+
if (elementsArray.length) {
|
|
281
|
+
elementsArray.forEach(element => {
|
|
282
|
+
element.setAttribute("style", isScenarioMode ? styles : "cursor:pointer;");
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
publishedItemsRenderer.prepareInputCells = function (document, scope, options, isScenarioMode) {
|
|
288
|
+
const inputCells = document.querySelectorAll('td>a[href="DR_INPUT"], td>div>a[href="DR_INPUT"]');
|
|
289
|
+
const inputs = document.querySelectorAll('td>input');
|
|
290
|
+
const dateInputs = document.querySelectorAll('.dateInput');
|
|
291
|
+
const filterList = document.querySelectorAll('.filterList');
|
|
292
|
+
const styleForLabel = "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;";
|
|
257
293
|
if (!options.inputValuesData) {
|
|
258
294
|
options.inputValuesData = {};
|
|
259
295
|
}
|
|
260
|
-
|
|
296
|
+
publishedItemsRenderer.changeStylesForLabel(filterList, styleForLabel, isScenarioMode);
|
|
297
|
+
publishedItemsRenderer.changeStylesForLabel(dateInputs, styleForLabel, isScenarioMode);
|
|
298
|
+
if (inputs.length) {
|
|
299
|
+
inputs.forEach(element => {
|
|
300
|
+
const labelElement = element.nextSibling;
|
|
301
|
+
labelElement.setAttribute("style", isScenarioMode ?
|
|
302
|
+
"background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;" :
|
|
303
|
+
"background: transparent;width: calc(100% - 15px);border: 0;margin: 6px;text-align: inherit;display: block; cursor: pointer;");
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
if (inputCells.length) {
|
|
261
307
|
for (let i = 0; i < inputCells.length; i++) {
|
|
262
308
|
let tdElement = inputCells[i].parentElement;
|
|
263
309
|
let inputId = inputCells[i].getAttribute('name') || 'no_attribute';
|
|
264
|
-
publishedItemsRenderer.createInputElement(tdElement, options.inputValuesData[inputId], scope.highchartsRenderer.formatValue, scope, options, document);
|
|
310
|
+
publishedItemsRenderer.createInputElement(tdElement, options.inputValuesData[inputId], scope.highchartsRenderer.formatValue, scope, options, document, isScenarioMode);
|
|
265
311
|
}
|
|
266
312
|
}
|
|
267
313
|
}
|
|
@@ -293,8 +339,20 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
|
293
339
|
}
|
|
294
340
|
}
|
|
295
341
|
|
|
342
|
+
publishedItemsRenderer.scenarioModeChange = function (flag, document) {
|
|
343
|
+
this.isScenarioMode = flag;
|
|
344
|
+
publishedItemsRenderer.prepareInputCells(document, this.scope, this.options, this.isScenarioMode);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
publishedItemsRenderer.getInputValues = function () {
|
|
348
|
+
return this.options.inputValuesData;
|
|
349
|
+
}
|
|
350
|
+
|
|
296
351
|
publishedItemsRenderer.initPublishedItem = function (document, window, scope, options) {
|
|
297
|
-
|
|
352
|
+
this.document = document;
|
|
353
|
+
this.scope = scope;
|
|
354
|
+
this.options = options;
|
|
355
|
+
publishedItemsRenderer.prepareInputCells(document, scope, options, this.isScenarioMode);
|
|
298
356
|
publishedItemsRenderer.addEventListeners(document, window, scope, options);
|
|
299
357
|
|
|
300
358
|
setTimeout(function () {
|