@datarailsshared/dr_renderer 1.2.308 → 1.2.309

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.308",
3
+ "version": "1.2.309",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -5042,7 +5042,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5042
5042
  };
5043
5043
 
5044
5044
  highchartsRenderer.isSystemField = function (field) {
5045
- var regex = new RegExp("^(Calc_Model_Name|Calc_Model_ID|Parent_Name|Parent_Id|FileBox_ID|FileBox_Name|DataMapper_Name|Doc_ID|Doc_version|Label|Submission_Date|User|table_id|Latest_In_Dim|Tab_name|CP_Name|DT_.+|VT_.+|System_.+)$", "m");
5045
+ const features = lodash.get(document, 'ReportHippo.user.features', []);
5046
+ const dynamicSystemFields = [];
5047
+
5048
+ const areMultipleAndScenarioTags = lodash.includes(features, 'multiple_dimension_tags')
5049
+ && lodash.includes(features, 'use_new_scenario_tag');
5050
+
5051
+ if (areMultipleAndScenarioTags) {
5052
+ dynamicSystemFields.push('Scenario', 'Budget Cycle');
5053
+ }
5054
+
5055
+ const regexDelimer = '|';
5056
+ const dynamicSystemFieldsRegex = dynamicSystemFields.length ? dynamicSystemFields.join(regexDelimer) + regexDelimer : '';
5057
+ var regex = new RegExp(`^(${dynamicSystemFieldsRegex}Calc_Model_Name|Calc_Model_ID|Parent_Name|Parent_Id|FileBox_ID|FileBox_Name|DataMapper_Name|Doc_ID|Doc_version|Label|Submission_Date|User|table_id|Latest_In_Dim|Tab_name|CP_Name|DT_.+|VT_.+|System_.+)$`, "m");
5046
5058
 
5047
5059
  return (field.category && field.category.includes("")) || regex.test(field.name)
5048
5060
  };
@@ -1154,6 +1154,18 @@ describe('highcharts_renderer', () => {
1154
1154
  };
1155
1155
  expect(highchartsRenderer.isSystemField(field)).toBe(false);
1156
1156
  });
1157
+
1158
+ describe('dynamic system fields', () => {
1159
+ it('should count Scenario & Budget Cycle as system field', () => {
1160
+ lodash.set(document, 'ReportHippo.user.features', ['multiple_dimension_tags', 'use_new_scenario_tag']);
1161
+
1162
+ const fieldWithScenario = { name: 'Scenario' };
1163
+ expect(highchartsRenderer.isSystemField(fieldWithScenario)).toBe(true);
1164
+
1165
+ const fieldWithBudgetCycle = { name: 'Budget Cycle' };
1166
+ expect(highchartsRenderer.isSystemField(fieldWithBudgetCycle)).toBe(true);
1167
+ });
1168
+ });
1157
1169
  });
1158
1170
 
1159
1171
  describe('function getFieldColorClass', () => {