@dhis2/analytics 26.2.0-alpha.2 → 26.2.0-cumulative-values-alpha.1

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.
Files changed (49) hide show
  1. package/build/cjs/__demo__/PivotTable.stories.js +69 -29
  2. package/build/cjs/api/analytics/Analytics.js +0 -7
  3. package/build/cjs/api/analytics/AnalyticsBase.js +6 -24
  4. package/build/cjs/api/analytics/AnalyticsRequest.js +10 -33
  5. package/build/cjs/api/analytics/AnalyticsRequestBase.js +1 -3
  6. package/build/cjs/api/analytics/AnalyticsRequestPropertiesMixin.js +0 -19
  7. package/build/cjs/api/analytics/__tests__/AnalyticsTrackedEntities.spec.js +44 -0
  8. package/build/cjs/api/analytics/__tests__/__snapshots__/AnalyticsTrackedEntities.spec.js.snap +3 -0
  9. package/build/cjs/api/analytics/utils.js +2 -23
  10. package/build/cjs/components/Options/VisualizationOptions.js +1 -1
  11. package/build/cjs/components/Options/styles/VisualizationOptions.style.js +8 -1
  12. package/build/cjs/components/RichText/Editor.bk/Editor.js +40 -0
  13. package/build/cjs/components/RichText/Editor.bk/__tests__/Editor.spec.js +29 -0
  14. package/build/cjs/components/RichText/Editor.bk/__tests__/convertCtrlKey.spec.js +205 -0
  15. package/build/cjs/components/RichText/Editor.bk/convertCtrlKey.js +87 -0
  16. package/build/cjs/components/RichText/Parser.bk/MdParser.js +107 -0
  17. package/build/cjs/components/RichText/Parser.bk/Parser.js +34 -0
  18. package/build/cjs/components/RichText/Parser.bk/__tests__/MdParser.spec.js +34 -0
  19. package/build/cjs/components/RichText/Parser.bk/__tests__/Parser.spec.js +41 -0
  20. package/build/cjs/modules/layout/dimension.js +2 -9
  21. package/build/cjs/modules/layout/dimensionCreate.js +0 -3
  22. package/build/cjs/modules/pivotTable/PivotTableEngine.js +119 -57
  23. package/build/cjs/visualizations/config/generators/dhis/singleValue.js.xp1 +478 -0
  24. package/build/es/__demo__/PivotTable.stories.js +69 -29
  25. package/build/es/api/analytics/Analytics.js +0 -7
  26. package/build/es/api/analytics/AnalyticsBase.js +6 -24
  27. package/build/es/api/analytics/AnalyticsRequest.js +10 -33
  28. package/build/es/api/analytics/AnalyticsRequestBase.js +1 -3
  29. package/build/es/api/analytics/AnalyticsRequestPropertiesMixin.js +0 -19
  30. package/build/es/api/analytics/__tests__/AnalyticsTrackedEntities.spec.js +41 -0
  31. package/build/es/api/analytics/__tests__/__snapshots__/AnalyticsTrackedEntities.spec.js.snap +3 -0
  32. package/build/es/api/analytics/utils.js +1 -20
  33. package/build/es/components/Options/VisualizationOptions.js +2 -2
  34. package/build/es/components/Options/styles/VisualizationOptions.style.js +6 -0
  35. package/build/es/components/RichText/Editor.bk/Editor.js +30 -0
  36. package/build/es/components/RichText/Editor.bk/__tests__/Editor.spec.js +26 -0
  37. package/build/es/components/RichText/Editor.bk/__tests__/convertCtrlKey.spec.js +202 -0
  38. package/build/es/components/RichText/Editor.bk/convertCtrlKey.js +80 -0
  39. package/build/es/components/RichText/Parser.bk/MdParser.js +99 -0
  40. package/build/es/components/RichText/Parser.bk/Parser.js +24 -0
  41. package/build/es/components/RichText/Parser.bk/__tests__/MdParser.spec.js +31 -0
  42. package/build/es/components/RichText/Parser.bk/__tests__/Parser.spec.js +38 -0
  43. package/build/es/modules/layout/dimension.js +1 -7
  44. package/build/es/modules/layout/dimensionCreate.js +1 -4
  45. package/build/es/modules/pivotTable/PivotTableEngine.js +119 -57
  46. package/build/es/visualizations/config/generators/dhis/singleValue.js.xp1 +478 -0
  47. package/package.json +1 -1
  48. package/build/cjs/api/analytics/AnalyticsTrackedEntities.js +0 -31
  49. package/build/es/api/analytics/AnalyticsTrackedEntities.js +0 -24
@@ -830,14 +830,15 @@ ResizingPivotTable.propTypes = {
830
830
  visualization: visualization
831
831
  }));
832
832
  });
833
- (0, _react.storiesOf)('PivotTable', module).add('empty columns (weekly) - hidden', (_, _ref36) => {
833
+ (0, _react.storiesOf)('PivotTable', module).add('cumulative + empty columns (weekly) - shown', (_, _ref36) => {
834
834
  let {
835
835
  pivotTableOptions
836
836
  } = _ref36;
837
837
  const visualization = {
838
838
  ..._weeklyColumnsVisualization.default,
839
839
  ...pivotTableOptions,
840
- hideEmptyColumns: true
840
+ hideEmptyColumns: false,
841
+ cumulativeValues: true
841
842
  };
842
843
  return /*#__PURE__*/_react2.default.createElement("div", {
843
844
  style: {
@@ -849,10 +850,49 @@ ResizingPivotTable.propTypes = {
849
850
  visualization: visualization
850
851
  }));
851
852
  });
852
- (0, _react.storiesOf)('PivotTable', module).add('empty columns + assigned cats (shown)', (_, _ref37) => {
853
+ (0, _react.storiesOf)('PivotTable', module).add('empty columns (weekly) - hidden', (_, _ref37) => {
853
854
  let {
854
855
  pivotTableOptions
855
856
  } = _ref37;
857
+ const visualization = {
858
+ ..._weeklyColumnsVisualization.default,
859
+ ...pivotTableOptions,
860
+ hideEmptyColumns: true
861
+ };
862
+ return /*#__PURE__*/_react2.default.createElement("div", {
863
+ style: {
864
+ width: 800,
865
+ height: 600
866
+ }
867
+ }, /*#__PURE__*/_react2.default.createElement(_index.PivotTable, {
868
+ data: weeklyColumnsData,
869
+ visualization: visualization
870
+ }));
871
+ });
872
+ (0, _react.storiesOf)('PivotTable', module).add('cumulative + empty columns (weekly) - hidden', (_, _ref38) => {
873
+ let {
874
+ pivotTableOptions
875
+ } = _ref38;
876
+ const visualization = {
877
+ ..._weeklyColumnsVisualization.default,
878
+ ...pivotTableOptions,
879
+ hideEmptyColumns: true,
880
+ cumulativeValues: true
881
+ };
882
+ return /*#__PURE__*/_react2.default.createElement("div", {
883
+ style: {
884
+ width: 800,
885
+ height: 600
886
+ }
887
+ }, /*#__PURE__*/_react2.default.createElement(_index.PivotTable, {
888
+ data: weeklyColumnsData,
889
+ visualization: visualization
890
+ }));
891
+ });
892
+ (0, _react.storiesOf)('PivotTable', module).add('empty columns + assigned cats (shown)', (_, _ref39) => {
893
+ let {
894
+ pivotTableOptions
895
+ } = _ref39;
856
896
  const visualization = {
857
897
  ..._emptyColumnsVisualization.default,
858
898
  ...visualizationReset,
@@ -869,10 +909,10 @@ ResizingPivotTable.propTypes = {
869
909
  visualization: visualization
870
910
  }));
871
911
  });
872
- (0, _react.storiesOf)('PivotTable', module).add('empty columns + assigned cats (hidden)', (_, _ref38) => {
912
+ (0, _react.storiesOf)('PivotTable', module).add('empty columns + assigned cats (hidden)', (_, _ref40) => {
873
913
  let {
874
914
  pivotTableOptions
875
- } = _ref38;
915
+ } = _ref40;
876
916
  const visualization = {
877
917
  ..._emptyColumnsVisualization.default,
878
918
  ...visualizationReset,
@@ -889,10 +929,10 @@ ResizingPivotTable.propTypes = {
889
929
  visualization: visualization
890
930
  }));
891
931
  });
892
- (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (light fill)', (_, _ref39) => {
932
+ (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (light fill)', (_, _ref41) => {
893
933
  let {
894
934
  pivotTableOptions
895
- } = _ref39;
935
+ } = _ref41;
896
936
  const visualization = {
897
937
  ..._targetWithLegendVisualization.default,
898
938
  ...visualizationReset,
@@ -917,10 +957,10 @@ ResizingPivotTable.propTypes = {
917
957
  legendSets: [_underAbove100LegendSet.default]
918
958
  }));
919
959
  });
920
- (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (dark fill)', (_, _ref40) => {
960
+ (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (dark fill)', (_, _ref42) => {
921
961
  let {
922
962
  pivotTableOptions
923
- } = _ref40;
963
+ } = _ref42;
924
964
  const visualization = {
925
965
  ..._targetWithLegendVisualization.default,
926
966
  ...visualizationReset,
@@ -946,10 +986,10 @@ ResizingPivotTable.propTypes = {
946
986
  legendSets: [legendSet]
947
987
  }));
948
988
  });
949
- (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (text)', (_, _ref41) => {
989
+ (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (text)', (_, _ref43) => {
950
990
  let {
951
991
  pivotTableOptions
952
- } = _ref41;
992
+ } = _ref43;
953
993
  const visualization = {
954
994
  ..._targetWithLegendVisualization.default,
955
995
  ...visualizationReset,
@@ -970,10 +1010,10 @@ ResizingPivotTable.propTypes = {
970
1010
  legendSets: [_underAbove100LegendSet.default]
971
1011
  }));
972
1012
  });
973
- (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (% row)', (_, _ref42) => {
1013
+ (0, _react.storiesOf)('PivotTable', module).add('legend - fixed (% row)', (_, _ref44) => {
974
1014
  let {
975
1015
  pivotTableOptions
976
- } = _ref42;
1016
+ } = _ref44;
977
1017
  const visualization = {
978
1018
  ..._targetWithLegendVisualization.default,
979
1019
  ...visualizationReset,
@@ -997,10 +1037,10 @@ ResizingPivotTable.propTypes = {
997
1037
  legendSets: [_underAbove100LegendSet.default]
998
1038
  }));
999
1039
  });
1000
- (0, _react.storiesOf)('PivotTable', module).add('legend - by data item', (_, _ref43) => {
1040
+ (0, _react.storiesOf)('PivotTable', module).add('legend - by data item', (_, _ref45) => {
1001
1041
  let {
1002
1042
  pivotTableOptions
1003
- } = _ref43;
1043
+ } = _ref45;
1004
1044
  const visualization = {
1005
1045
  ..._targetWithLegendVisualization.default,
1006
1046
  ...visualizationReset,
@@ -1028,10 +1068,10 @@ ResizingPivotTable.propTypes = {
1028
1068
  legendSets: [_underAbove100LegendSet.default, customLegendSet]
1029
1069
  }));
1030
1070
  });
1031
- (0, _react.storiesOf)('PivotTable', module).add('hierarchy - none', (_, _ref44) => {
1071
+ (0, _react.storiesOf)('PivotTable', module).add('hierarchy - none', (_, _ref46) => {
1032
1072
  let {
1033
1073
  pivotTableOptions
1034
- } = _ref44;
1074
+ } = _ref46;
1035
1075
  const visualization = {
1036
1076
  ..._hierarchyVisualization.default,
1037
1077
  ...visualizationReset,
@@ -1052,10 +1092,10 @@ ResizingPivotTable.propTypes = {
1052
1092
  visualization: visualization
1053
1093
  }));
1054
1094
  });
1055
- (0, _react.storiesOf)('PivotTable', module).add('hierarchy - rows', (_, _ref45) => {
1095
+ (0, _react.storiesOf)('PivotTable', module).add('hierarchy - rows', (_, _ref47) => {
1056
1096
  let {
1057
1097
  pivotTableOptions
1058
- } = _ref45;
1098
+ } = _ref47;
1059
1099
  const visualization = {
1060
1100
  ..._hierarchyVisualization.default,
1061
1101
  ...visualizationReset,
@@ -1075,10 +1115,10 @@ ResizingPivotTable.propTypes = {
1075
1115
  visualization: visualization
1076
1116
  }));
1077
1117
  });
1078
- (0, _react.storiesOf)('PivotTable', module).add('hierarchy - columns', (_, _ref46) => {
1118
+ (0, _react.storiesOf)('PivotTable', module).add('hierarchy - columns', (_, _ref48) => {
1079
1119
  let {
1080
1120
  pivotTableOptions
1081
- } = _ref46;
1121
+ } = _ref48;
1082
1122
  const visualization = {
1083
1123
  ..._hierarchyVisualization.default,
1084
1124
  ...visualizationReset,
@@ -1100,10 +1140,10 @@ ResizingPivotTable.propTypes = {
1100
1140
  visualization: visualization
1101
1141
  }));
1102
1142
  });
1103
- (0, _react.storiesOf)('PivotTable', module).add('narrative', (_, _ref47) => {
1143
+ (0, _react.storiesOf)('PivotTable', module).add('narrative', (_, _ref49) => {
1104
1144
  let {
1105
1145
  pivotTableOptions
1106
- } = _ref47;
1146
+ } = _ref49;
1107
1147
  const visualization = {
1108
1148
  ..._narrativeVisualization.default,
1109
1149
  ...visualizationReset,
@@ -1121,10 +1161,10 @@ ResizingPivotTable.propTypes = {
1121
1161
  visualization: visualization
1122
1162
  }));
1123
1163
  });
1124
- (0, _react.storiesOf)('PivotTable', module).add('narrative - data as filter', (_, _ref48) => {
1164
+ (0, _react.storiesOf)('PivotTable', module).add('narrative - data as filter', (_, _ref50) => {
1125
1165
  let {
1126
1166
  pivotTableOptions
1127
- } = _ref48;
1167
+ } = _ref50;
1128
1168
  const visualization = {
1129
1169
  ..._narrativeVisualization.default,
1130
1170
  ...visualizationReset,
@@ -1148,10 +1188,10 @@ ResizingPivotTable.propTypes = {
1148
1188
  visualization: visualization
1149
1189
  }));
1150
1190
  });
1151
- (0, _react.storiesOf)('PivotTable', module).add('DEGS', (_, _ref49) => {
1191
+ (0, _react.storiesOf)('PivotTable', module).add('DEGS', (_, _ref51) => {
1152
1192
  let {
1153
1193
  pivotTableOptions
1154
- } = _ref49;
1194
+ } = _ref51;
1155
1195
  const visualization = {
1156
1196
  ..._degsVisualization.default,
1157
1197
  ...visualizationReset,
@@ -1167,10 +1207,10 @@ ResizingPivotTable.propTypes = {
1167
1207
  visualization: visualization
1168
1208
  }));
1169
1209
  });
1170
- (0, _react.storiesOf)('PivotTable', module).add('Truncated header cell', (_, _ref50) => {
1210
+ (0, _react.storiesOf)('PivotTable', module).add('Truncated header cell', (_, _ref52) => {
1171
1211
  let {
1172
1212
  pivotTableOptions
1173
- } = _ref50;
1213
+ } = _ref52;
1174
1214
  const widths = [250, 200, 500];
1175
1215
  const [width, setWidth] = (0, _react2.useState)(250);
1176
1216
  const toggleWidth = () => setWidth(currentWidth => {
@@ -9,7 +9,6 @@ var _AnalyticsEnrollments = _interopRequireDefault(require("./AnalyticsEnrollmen
9
9
  var _AnalyticsEvents = _interopRequireDefault(require("./AnalyticsEvents.js"));
10
10
  var _AnalyticsRequest = _interopRequireDefault(require("./AnalyticsRequest.js"));
11
11
  var _AnalyticsResponse = _interopRequireDefault(require("./AnalyticsResponse.js"));
12
- var _AnalyticsTrackedEntities = _interopRequireDefault(require("./AnalyticsTrackedEntities.js"));
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
  /**
15
14
  * @module analytics
@@ -20,8 +19,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
20
19
  * Analytics class used to request analytics data from Web API.
21
20
  *
22
21
  * @requires analytics.AnalyticsAggregate
23
- * @requires analytics.AnalyticsTrackedEntities
24
- * @requires analytics.AnalyticsEnrollments
25
22
  * @requires analytics.AnalyticsEvents
26
23
  * @requires analytics.AnalyticsRequest
27
24
  * @requires analytics.AnalyticsResponse
@@ -41,7 +38,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
41
38
  class Analytics {
42
39
  /**
43
40
  * @param {!module:analytics.AnalyticsAggregate} analyticsAggregate The AnalyticsAggregate instance
44
- * @param {!module:analytics.AnalyticsTrackedEntities} analyticsTrackedEntities The AnalyticsTrackedEntities instance
45
41
  * @param {!module:analytics.AnalyticsEnrollments} analyticsEnrollments The AnalyticsEnrollments instance
46
42
  * @param {!module:analytics.AnalyticsEvents} analyticsEvents The AnalyticsEvents instance
47
43
  * @param {!module:analytics.AnalyticsRequest} analyticsRequest The AnalyticsRequest class
@@ -50,14 +46,12 @@ class Analytics {
50
46
  constructor(_ref) {
51
47
  let {
52
48
  aggregate,
53
- trackedEntities,
54
49
  enrollments,
55
50
  events,
56
51
  request,
57
52
  response
58
53
  } = _ref;
59
54
  this.aggregate = aggregate;
60
- this.trackedEntities = trackedEntities;
61
55
  this.enrollments = enrollments;
62
56
  this.events = events;
63
57
  this.request = request;
@@ -80,7 +74,6 @@ class Analytics {
80
74
  if (!Analytics.getAnalytics.analytics) {
81
75
  Analytics.getAnalytics.analytics = new Analytics({
82
76
  aggregate: new _AnalyticsAggregate.default(dataEngine),
83
- trackedEntities: new _AnalyticsTrackedEntities.default(dataEngine),
84
77
  enrollments: new _AnalyticsEnrollments.default(dataEngine),
85
78
  events: new _AnalyticsEvents.default(dataEngine),
86
79
  request: _AnalyticsRequest.default,
@@ -6,21 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
8
8
  var _AnalyticsRequest = _interopRequireDefault(require("./AnalyticsRequest.js"));
9
- var _utils = require("./utils.js");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
10
  const analyticsQuery = {
12
11
  resource: 'analytics',
13
12
  id: _ref => {
14
13
  let {
15
14
  path,
16
- program,
17
- trackedEntityType
15
+ program
18
16
  } = _ref;
19
- return (0, _utils.formatRequestPath)({
20
- path,
21
- program,
22
- trackedEntityType
23
- });
17
+ return [path, program].filter(Boolean).join('/');
24
18
  },
25
19
  params: _ref2 => {
26
20
  let {
@@ -40,14 +34,9 @@ const analyticsDataQuery = {
40
34
  id: _ref3 => {
41
35
  let {
42
36
  path,
43
- program,
44
- trackedEntityType
37
+ program
45
38
  } = _ref3;
46
- return (0, _utils.formatRequestPath)({
47
- path,
48
- program,
49
- trackedEntityType
50
- });
39
+ return [path, program].filter(Boolean).join('/');
51
40
  },
52
41
  params: _ref4 => {
53
42
  let {
@@ -69,14 +58,9 @@ const analyticsMetaDataQuery = {
69
58
  id: _ref5 => {
70
59
  let {
71
60
  path,
72
- program,
73
- trackedEntityType
61
+ program
74
62
  } = _ref5;
75
- return (0, _utils.formatRequestPath)({
76
- path,
77
- program,
78
- trackedEntityType
79
- });
63
+ return [path, program].filter(Boolean).join('/');
80
64
  },
81
65
  params: _ref6 => {
82
66
  let {
@@ -168,7 +152,6 @@ class AnalyticsBase {
168
152
  variables: {
169
153
  path: req.path,
170
154
  program: req.program,
171
- trackedEntityType: req.trackedEntityType,
172
155
  dimensions: generateDimensionStrings(req.dimensions),
173
156
  filters: generateDimensionStrings(req.filters),
174
157
  parameters: req.parameters,
@@ -211,7 +194,6 @@ class AnalyticsBase {
211
194
  variables: {
212
195
  path: req.path,
213
196
  program: req.program,
214
- trackedEntityType: req.trackedEntityType,
215
197
  dimensions: generateDimensionStrings(req.dimensions, options),
216
198
  filters: generateDimensionStrings(req.filters, options),
217
199
  parameters: req.parameters
@@ -10,7 +10,6 @@ var _AnalyticsRequestBase = _interopRequireDefault(require("./AnalyticsRequestBa
10
10
  var _AnalyticsRequestDimensionsMixin = _interopRequireDefault(require("./AnalyticsRequestDimensionsMixin.js"));
11
11
  var _AnalyticsRequestFiltersMixin = _interopRequireDefault(require("./AnalyticsRequestFiltersMixin.js"));
12
12
  var _AnalyticsRequestPropertiesMixin = _interopRequireDefault(require("./AnalyticsRequestPropertiesMixin.js"));
13
- var _utils = require("./utils.js");
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  /**
16
15
  * @description
@@ -48,7 +47,6 @@ class AnalyticsRequest extends (0, _AnalyticsRequestDimensionsMixin.default)((0,
48
47
  fromVisualization(visualization) {
49
48
  let passFilterAsDimension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
50
49
  let request = this;
51
- const outputType = visualization.outputType;
52
50
 
53
51
  // extract dimensions from visualization
54
52
  const columns = visualization.columns || [];
@@ -59,28 +57,19 @@ class AnalyticsRequest extends (0, _AnalyticsRequestDimensionsMixin.default)((0,
59
57
  if ((_d$legendSet = d.legendSet) !== null && _d$legendSet !== void 0 && _d$legendSet.id) {
60
58
  dimension += `-${d.legendSet.id}`;
61
59
  }
60
+ if ((_d$programStage = d.programStage) !== null && _d$programStage !== void 0 && _d$programStage.id) {
61
+ dimension = `${d.programStage.id}.${dimension}`;
62
+ }
62
63
  if (d.filter) {
63
64
  dimension += `:${d.filter}`;
64
65
  }
65
- const programStageId = (_d$programStage = d.programStage) === null || _d$programStage === void 0 ? void 0 : _d$programStage.id;
66
66
  if ((_d$repetition = d.repetition) !== null && _d$repetition !== void 0 && (_d$repetition$indexes = _d$repetition.indexes) !== null && _d$repetition$indexes !== void 0 && _d$repetition$indexes.length) {
67
67
  d.repetition.indexes.forEach(index => {
68
- var _d$program;
69
- request = request.addDimension((0, _utils.formatDimension)({
70
- programId: (_d$program = d.program) === null || _d$program === void 0 ? void 0 : _d$program.id,
71
- programStageId: `${programStageId}[${index}]`,
72
- dimension,
73
- outputType
74
- }));
68
+ request = request.addDimension(dimension.replace(/\./, `[${index}].`));
75
69
  });
76
70
  } else {
77
- var _d$program2, _d$items;
78
- request = request.addDimension((0, _utils.formatDimension)({
79
- programId: (_d$program2 = d.program) === null || _d$program2 === void 0 ? void 0 : _d$program2.id,
80
- programStageId,
81
- dimension,
82
- outputType
83
- }), (_d$items = d.items) === null || _d$items === void 0 ? void 0 : _d$items.map(item => item.id));
71
+ var _d$items;
72
+ request = request.addDimension(dimension, (_d$items = d.items) === null || _d$items === void 0 ? void 0 : _d$items.map(item => item.id));
84
73
  }
85
74
  });
86
75
 
@@ -95,29 +84,17 @@ class AnalyticsRequest extends (0, _AnalyticsRequestDimensionsMixin.default)((0,
95
84
  request = request.addDimension(f.dimension, (_f$items = f.items) === null || _f$items === void 0 ? void 0 : _f$items.map(item => item.id));
96
85
  } else {
97
86
  var _f$programStage, _f$repetition, _f$repetition$indexes;
98
- let filterString = f.dimension;
87
+ let filterString = (_f$programStage = f.programStage) !== null && _f$programStage !== void 0 && _f$programStage.id ? `${f.programStage.id}.${f.dimension}` : f.dimension;
99
88
  if (f.filter) {
100
89
  filterString += `:${f.filter}`;
101
90
  }
102
- const programStageId = (_f$programStage = f.programStage) === null || _f$programStage === void 0 ? void 0 : _f$programStage.id;
103
91
  if ((_f$repetition = f.repetition) !== null && _f$repetition !== void 0 && (_f$repetition$indexes = _f$repetition.indexes) !== null && _f$repetition$indexes !== void 0 && _f$repetition$indexes.length) {
104
92
  f.repetition.indexes.forEach(index => {
105
- var _f$program;
106
- request = request.addFilter((0, _utils.formatDimension)({
107
- programId: (_f$program = f.program) === null || _f$program === void 0 ? void 0 : _f$program.id,
108
- programStageId: `${programStageId}[${index}]`,
109
- dimension: filterString,
110
- outputType
111
- }));
93
+ request = request.addFilter(filterString.replace(/\./, `[${index}].`));
112
94
  });
113
95
  } else {
114
- var _f$program2, _f$items2;
115
- request = request.addFilter((0, _utils.formatDimension)({
116
- programId: (_f$program2 = f.program) === null || _f$program2 === void 0 ? void 0 : _f$program2.id,
117
- programStageId,
118
- dimension: filterString,
119
- outputType
120
- }), (_f$items2 = f.items) === null || _f$items2 === void 0 ? void 0 : _f$items2.map(item => item.id));
96
+ var _f$items2;
97
+ request = request.addFilter(filterString, (_f$items2 = f.items) === null || _f$items2 === void 0 ? void 0 : _f$items2.map(item => item.id));
121
98
  }
122
99
  }
123
100
  });
@@ -24,7 +24,6 @@ class AnalyticsRequestBase {
24
24
  format = 'json',
25
25
  path,
26
26
  program,
27
- trackedEntityType,
28
27
  dimensions = [],
29
28
  filters = [],
30
29
  parameters = {}
@@ -33,7 +32,6 @@ class AnalyticsRequestBase {
33
32
  this.format = format.toLowerCase();
34
33
  this.path = path;
35
34
  this.program = program;
36
- this.trackedEntityType = trackedEntityType;
37
35
  this.dimensions = dimensions;
38
36
  this.filters = filters;
39
37
  this.parameters = {
@@ -72,7 +70,7 @@ class AnalyticsRequestBase {
72
70
  }
73
71
  return dimension;
74
72
  });
75
- const endPoint = [this.endPoint, this.path, this.program, this.trackedEntityType].filter(Boolean).join('/');
73
+ const endPoint = [this.endPoint, this.path, this.program].filter(e => !!e).join('/');
76
74
  return `${endPoint}.${this.format}?dimension=${encodedDimensions.join('&dimension=')}`;
77
75
  }
78
76
 
@@ -497,25 +497,6 @@ class extends base {
497
497
  return new _AnalyticsRequest.default(this);
498
498
  }
499
499
 
500
- /**
501
- * Sets the tracked entity type for the request.
502
- * It appends the tracked entity type id to the request's path.
503
- *
504
- * @param {!String} trackedEntityType The tracked entity type id
505
- *
506
- * @returns {AnalyticsRequest} A new instance of the class for chaining purposes
507
- *
508
- * @example
509
- * const req = new analytics.request()
510
- * .withTrackedEntityType('nEenWmSyUEp');
511
- */
512
- withTrackedEntityType(trackedEntityType) {
513
- if (trackedEntityType) {
514
- this.trackedEntityType = trackedEntityType;
515
- }
516
- return new _AnalyticsRequest.default(this);
517
- }
518
-
519
500
  /**
520
501
  * Sets the program for the request.
521
502
  * It appends the program id to the request's path.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _fixtures = _interopRequireDefault(require("../../../__fixtures__/fixtures.js"));
4
+ var _DataEngine = _interopRequireDefault(require("../__mocks__/DataEngine.js"));
5
+ var _AnalyticsRequest = _interopRequireDefault(require("../AnalyticsRequest.js"));
6
+ var _AnalyticsTrackedEntities = _interopRequireDefault(require("../AnalyticsTrackedEntities.js"));
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ describe.skip('analytics.trackedEntity', () => {
9
+ let enrollments;
10
+ let request;
11
+ let dataEngineMock;
12
+ let fixture;
13
+ beforeEach(() => {
14
+ dataEngineMock = new _DataEngine.default();
15
+ _DataEngine.default.mockClear();
16
+ enrollments = new _AnalyticsTrackedEntities.default();
17
+ });
18
+ it('should not be allowed to be called without new', () => {
19
+ expect(() => (0, _AnalyticsTrackedEntities.default)()).toThrowErrorMatchingSnapshot();
20
+ });
21
+ it('should use the dataEngine object when it is passed', () => {
22
+ const dataEngineMockObject = {};
23
+ enrollments = new _AnalyticsTrackedEntities.default(dataEngineMockObject);
24
+ expect(enrollments.dataEngine).toBe(dataEngineMockObject);
25
+ });
26
+ describe('.getQuery()', () => {
27
+ beforeEach(() => {
28
+ enrollments = new _AnalyticsTrackedEntities.default(new _DataEngine.default());
29
+ request = new _AnalyticsRequest.default().addOrgUnitDimension('ImspTQPwCqd').addDimension('WZbXY0S00lP.de0FEHSIoxh').addDimension('WZbXY0S00lP.sWoqcoByYmD').addPeriodFilter('LAST_MONTH').withTrackedEntity('nEenWmSyUEp').withAsc('ENROLLMENTDATE').withOuMode('DESCENDANTS').withColumns('w75KJ2mc4zz').withPage(1).withPageSize(10);
30
+ fixture = _fixtures.default.get('/api/analytics/enrollments'); // XXX
31
+
32
+ dataEngineMock.query.mockReturnValue(Promise.resolve({
33
+ data: fixture
34
+ }));
35
+ });
36
+ it('should be a function', () => {
37
+ expect(enrollments.getQuery).toBeInstanceOf(Function);
38
+ });
39
+ it('should resolve a promise with data', () => enrollments.getQuery(request).then(data => {
40
+ expect(data.width).toEqual(fixture.width);
41
+ expect(data.height).toEqual(fixture.height);
42
+ }));
43
+ });
44
+ });
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`analytics.trackedEntity should not be allowed to be called without new 1`] = `"Class constructor AnalyticsTrackedEntities cannot be invoked without 'new'"`;
@@ -3,31 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.formatRequestPath = exports.formatDimension = exports.customEncodeURIComponent = void 0;
6
+ exports.customEncodeURIComponent = void 0;
7
7
  // Define our very own special list of characters that we don't want to encode in the URI
8
8
  const whitelistURI = ',&$=/;:';
9
9
  const whitelistURICodes = whitelistURI.split('').map(c => encodeURIComponent(c));
10
10
  const whitelistRegExp = new RegExp(`(?:${whitelistURICodes.join('|')})`, 'g');
11
11
  const customEncodeURIComponent = uri => encodeURIComponent(uri).replace(whitelistRegExp, decodeURIComponent);
12
- exports.customEncodeURIComponent = customEncodeURIComponent;
13
- const formatRequestPath = _ref => {
14
- let {
15
- path,
16
- program,
17
- trackedEntityType
18
- } = _ref;
19
- return [path, program, trackedEntityType].filter(Boolean).join('/');
20
- };
21
- exports.formatRequestPath = formatRequestPath;
22
- const formatDimension = _ref2 => {
23
- let {
24
- outputType,
25
- programId,
26
- programStageId,
27
- dimension
28
- } = _ref2;
29
- return [
30
- // XXX it would be clearer to have this consistent with what is sent in the request as for EVENT/ENROLLMENT
31
- outputType === 'TRACKED_ENTITY' ? programId : undefined, programStageId, dimension].filter(Boolean).join('.');
32
- };
33
- exports.formatDimension = formatDimension;
12
+ exports.customEncodeURIComponent = customEncodeURIComponent;
@@ -68,7 +68,7 @@ const VisualizationOptions = _ref => {
68
68
  }, label);
69
69
  })), _VisualizationOptionsStyle.tabBar.styles), /*#__PURE__*/_react.default.createElement("div", {
70
70
  className: _VisualizationOptionsStyle.tabContent.className
71
- }, tabs[activeTabIndex].content, _VisualizationOptionsStyle.tabContent.styles, _VisualizationOptionsStyle.tabSection.styles, _VisualizationOptionsStyle.tabSectionTitle.styles, _VisualizationOptionsStyle.tabSectionTitleMargin.styles, _VisualizationOptionsStyle.tabSectionOption.styles, _VisualizationOptionsStyle.tabSectionOptionItem.styles, _VisualizationOptionsStyle.tabSectionOptionToggleable.styles, _VisualizationOptionsStyle.tabSectionToggleableSubsection.styles, _VisualizationOptionsStyle.tabSectionOptionComplexInline.styles, _VisualizationOptionsStyle.tabSectionOptionText.styles, _VisualizationOptionsStyle.tabSectionOptionIcon.styles));
71
+ }, tabs[activeTabIndex].content, _VisualizationOptionsStyle.tabContent.styles, _VisualizationOptionsStyle.tabSection.styles, _VisualizationOptionsStyle.tabSectionTitle.styles, _VisualizationOptionsStyle.tabSectionTitleDisabled.styles, _VisualizationOptionsStyle.tabSectionTitleMargin.styles, _VisualizationOptionsStyle.tabSectionOption.styles, _VisualizationOptionsStyle.tabSectionOptionItem.styles, _VisualizationOptionsStyle.tabSectionOptionToggleable.styles, _VisualizationOptionsStyle.tabSectionToggleableSubsection.styles, _VisualizationOptionsStyle.tabSectionOptionComplexInline.styles, _VisualizationOptionsStyle.tabSectionOptionText.styles, _VisualizationOptionsStyle.tabSectionOptionIcon.styles));
72
72
  };
73
73
  return /*#__PURE__*/_react.default.createElement(_ui.Modal, {
74
74
  onClose: onClose,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.tabSectionToggleableSubsection = exports.tabSectionTitleMargin = exports.tabSectionTitle = exports.tabSectionOptionToggleable = exports.tabSectionOptionText = exports.tabSectionOptionItem = exports.tabSectionOptionIcon = exports.tabSectionOptionComplexInline = exports.tabSectionOption = exports.tabSectionContent = exports.tabSection = exports.tabContent = exports.tabBar = exports.modalContent = void 0;
6
+ exports.tabSectionToggleableSubsection = exports.tabSectionTitleMargin = exports.tabSectionTitleDisabled = exports.tabSectionTitle = exports.tabSectionOptionToggleable = exports.tabSectionOptionText = exports.tabSectionOptionItem = exports.tabSectionOptionIcon = exports.tabSectionOptionComplexInline = exports.tabSectionOption = exports.tabSectionContent = exports.tabSection = exports.tabContent = exports.tabBar = exports.modalContent = void 0;
7
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
8
8
  var _ui = require("@dhis2/ui");
9
9
  var _react = _interopRequireDefault(require("react"));
@@ -52,6 +52,13 @@ const tabSectionTitle = {
52
52
  className: "jsx-3115295887"
53
53
  };
54
54
  exports.tabSectionTitle = tabSectionTitle;
55
+ const tabSectionTitleDisabled = {
56
+ styles: /*#__PURE__*/_react.default.createElement(_style.default, {
57
+ id: "3352433486"
58
+ }, [`span.jsx-3352433486{color:${_ui.colors.grey600};}`]),
59
+ className: "jsx-3352433486"
60
+ };
61
+ exports.tabSectionTitleDisabled = tabSectionTitleDisabled;
55
62
  const tabSectionTitleMargin = {
56
63
  styles: /*#__PURE__*/_react.default.createElement(_style.default, {
57
64
  id: "642558349"
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _convertCtrlKey = _interopRequireDefault(require("./convertCtrlKey.js"));
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
+ class Editor extends _react.Component {
17
+ constructor() {
18
+ super(...arguments);
19
+ _defineProperty(this, "onKeyDown", event => {
20
+ (0, _convertCtrlKey.default)(event, this.props.onEdit);
21
+ });
22
+ }
23
+ render() {
24
+ const {
25
+ children
26
+ } = this.props;
27
+ return /*#__PURE__*/_react.default.createElement("div", {
28
+ onKeyDown: this.onKeyDown
29
+ }, children);
30
+ }
31
+ }
32
+ Editor.defaultProps = {
33
+ onEdit: null
34
+ };
35
+ Editor.propTypes = {
36
+ children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]),
37
+ onEdit: _propTypes.default.func
38
+ };
39
+ var _default = Editor;
40
+ exports.default = _default;