@datarailsshared/dr_renderer 1.5.41 → 1.5.46
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
|
@@ -9315,12 +9315,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9315
9315
|
if (!keys || !invertedDateStringMap) {
|
|
9316
9316
|
return;
|
|
9317
9317
|
}
|
|
9318
|
+
const dateWidgetFields = lodash.filter(widgetFields, obj => obj.type === 'Date');
|
|
9318
9319
|
const replaceNestedKeys = (nestedKeys) => {
|
|
9319
9320
|
for (let i = 0; i < nestedKeys.length; i++) {
|
|
9320
9321
|
if (Array.isArray(nestedKeys[i])) {
|
|
9321
9322
|
replaceNestedKeys(nestedKeys[i]);
|
|
9322
|
-
}
|
|
9323
|
-
|
|
9323
|
+
}
|
|
9324
|
+
else if (invertedDateStringMap[nestedKeys[i]] && widgetFields[i] && widgetFields[i].type === 'Date') {
|
|
9325
|
+
const getFormat = (obj) => (lodash.get(obj, 'format') ?? '').toUpperCase();
|
|
9326
|
+
const isSameDateFormats = lodash.every(dateWidgetFields, obj => getFormat(obj) === getFormat(dateWidgetFields[0]));
|
|
9327
|
+
|
|
9328
|
+
if (isSameDateFormats) {
|
|
9329
|
+
nestedKeys[i] = invertedDateStringMap[nestedKeys[i]];
|
|
9330
|
+
continue;
|
|
9331
|
+
}
|
|
9332
|
+
|
|
9333
|
+
// Reformatting dates when "widgetFields" array contains fields with different formats
|
|
9334
|
+
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
9335
|
+
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
9336
|
+
const format = (widgetFields[i].format ?? "MM/DD/YYYY").toUpperCase();
|
|
9337
|
+
const date = new Date(parseInt(nestedKeys[i]) * 1000);
|
|
9338
|
+
const formattedDateString = moment_lib(date).utcOffset(0).format(format) + "";
|
|
9339
|
+
nestedKeys[i] = formattedDateString;
|
|
9324
9340
|
}
|
|
9325
9341
|
}
|
|
9326
9342
|
};
|
|
@@ -5964,6 +5964,40 @@ describe('highcharts_renderer', () => {
|
|
|
5964
5964
|
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5965
5965
|
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5966
5966
|
});
|
|
5967
|
+
|
|
5968
|
+
// This test was added to cover an edge case where multiple Date fields have the same date values
|
|
5969
|
+
// but require different formatting based on their individual field settings
|
|
5970
|
+
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
5971
|
+
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
5972
|
+
it('should reformat dates when widget fields have same dates, but different formats', () => {
|
|
5973
|
+
const keysObject = {
|
|
5974
|
+
col_keys: [
|
|
5975
|
+
[1648684800, 1648684800, 1648684800],
|
|
5976
|
+
],
|
|
5977
|
+
row_keys: [],
|
|
5978
|
+
row_keys_by_cols: [],
|
|
5979
|
+
};
|
|
5980
|
+
|
|
5981
|
+
const invertedDateStringMap = {
|
|
5982
|
+
1648684800: '03/31/2022',
|
|
5983
|
+
};
|
|
5984
|
+
|
|
5985
|
+
const widget = {
|
|
5986
|
+
cols: [
|
|
5987
|
+
{ type: 'Date', format: null }, // Default format MM/DD/YYYY
|
|
5988
|
+
{ type: 'Date', format: 'MM-DD-YYYY' },
|
|
5989
|
+
{ type: 'Date', format: 'DD/MM/YYYY' },
|
|
5990
|
+
],
|
|
5991
|
+
rows: [],
|
|
5992
|
+
pivot: { keysObject },
|
|
5993
|
+
};
|
|
5994
|
+
|
|
5995
|
+
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5996
|
+
|
|
5997
|
+
expect(keysObject.col_keys[0][0]).toBe('03/31/2022');
|
|
5998
|
+
expect(keysObject.col_keys[0][1]).toBe('03-31-2022');
|
|
5999
|
+
expect(keysObject.col_keys[0][2]).toBe('31/03/2022');
|
|
6000
|
+
});
|
|
5967
6001
|
});
|
|
5968
6002
|
|
|
5969
6003
|
|