@dhis2/analytics 21.2.5 → 22.0.0-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.
@@ -40,8 +40,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
40
40
  const FileMenu = ({
41
41
  d2,
42
42
  // to be removed as soon as TranslateDialog and FavoritesDialog are rewritten
43
+ defaultFilterVisType,
43
44
  fileType,
44
45
  fileObject,
46
+ filterVisTypes,
45
47
  onNew,
46
48
  onOpen,
47
49
  onSave,
@@ -156,6 +158,8 @@ const FileMenu = ({
156
158
  }, _index.default.t('File'))), /*#__PURE__*/_react.default.createElement(_OpenFileDialog.OpenFileDialog, {
157
159
  open: currentDialog === 'open',
158
160
  type: fileType,
161
+ filterVisTypes: filterVisTypes,
162
+ defaultFilterVisType: defaultFilterVisType,
159
163
  onClose: onDialogClose,
160
164
  onFileSelect: id => {
161
165
  onOpen(id);
@@ -266,8 +270,10 @@ FileMenu.defaultProps = {
266
270
  };
267
271
  FileMenu.propTypes = {
268
272
  d2: _propTypes.default.object,
273
+ defaultFilterVisType: _propTypes.default.string,
269
274
  fileObject: _propTypes.default.object,
270
275
  fileType: _propTypes.default.oneOf(_utils.supportedFileTypes),
276
+ filterVisTypes: _propTypes.default.array,
271
277
  onDelete: _propTypes.default.func,
272
278
  onError: _propTypes.default.func,
273
279
  onNew: _propTypes.default.func,
@@ -7,6 +7,10 @@ exports.default = exports.CustomSelectOption = void 0;
7
7
 
8
8
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
9
 
10
+ var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
11
+
12
+ var _ui = require("@dhis2/ui");
13
+
10
14
  var _classnames = _interopRequireDefault(require("classnames"));
11
15
 
12
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -17,14 +21,15 @@ var _CustomSelectOptionStyle = _interopRequireDefault(require("./styles/CustomSe
17
21
 
18
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
23
 
20
- const CustomSelectOption = ({
24
+ const CustomSelectOptionItem = ({
21
25
  value,
22
26
  label,
23
27
  icon,
28
+ insertDivider,
24
29
  onClick,
25
30
  active,
26
31
  disabled
27
- }) => /*#__PURE__*/_react.default.createElement("div", {
32
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
28
33
  onClick: e => onClick({}, e),
29
34
  "data-value": value,
30
35
  "data-label": label,
@@ -33,10 +38,18 @@ const CustomSelectOption = ({
33
38
  disabled
34
39
  }) || "")
35
40
  }, icon, /*#__PURE__*/_react.default.createElement("span", {
36
- className: "jsx-".concat(_CustomSelectOptionStyle.default.__hash) + " " + "label"
41
+ className: "jsx-".concat(_CustomSelectOptionStyle.default.__hash) + " " + ((0, _classnames.default)({
42
+ label: icon
43
+ }) || "")
37
44
  }, label), /*#__PURE__*/_react.default.createElement(_style.default, {
38
45
  id: _CustomSelectOptionStyle.default.__hash
39
- }, _CustomSelectOptionStyle.default));
46
+ }, _CustomSelectOptionStyle.default)), insertDivider ? /*#__PURE__*/_react.default.createElement(_ui.MenuDivider, {
47
+ dense: true
48
+ }) : null);
49
+
50
+ const CustomSelectOption = props => props.disabled ? /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
51
+ content: _d2I18n.default.t('Not supported by this app yet')
52
+ }, /*#__PURE__*/_react.default.createElement(CustomSelectOptionItem, props)) : /*#__PURE__*/_react.default.createElement(CustomSelectOptionItem, props);
40
53
 
41
54
  exports.CustomSelectOption = CustomSelectOption;
42
55
  CustomSelectOption.propTypes = {
@@ -47,5 +60,6 @@ CustomSelectOption.propTypes = {
47
60
  disabled: _propTypes.default.bool,
48
61
  onClick: _propTypes.default.func
49
62
  };
63
+ CustomSelectOptionItem.propTypes = CustomSelectOption.propTypes;
50
64
  var _default = CustomSelectOption;
51
65
  exports.default = _default;
@@ -18,14 +18,14 @@ var _DateField = require("./DateField.js");
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
20
  const FileList = ({
21
- type,
22
21
  data,
23
- onSelect
22
+ onSelect,
23
+ showVisTypeColumn
24
24
  }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, data.map(visualization => /*#__PURE__*/_react.default.createElement(_ui.DataTableRow, {
25
25
  key: visualization.id
26
26
  }, /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, {
27
27
  onClick: () => onSelect(visualization.id)
28
- }, visualization.displayName), type === 'visualization' && /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, {
28
+ }, visualization.displayName), showVisTypeColumn && /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, {
29
29
  align: "center"
30
30
  }, /*#__PURE__*/_react.default.createElement(_VisTypeIcon.VisTypeIcon, {
31
31
  type: visualization.type,
@@ -46,8 +46,8 @@ FileList.propTypes = {
46
46
  lastUpdated: _propTypes.default.string.isRequired,
47
47
  type: _propTypes.default.string
48
48
  })).isRequired,
49
- type: _propTypes.default.string.isRequired,
50
- onSelect: _propTypes.default.func.isRequired
49
+ onSelect: _propTypes.default.func.isRequired,
50
+ showVisTypeColumn: _propTypes.default.bool
51
51
  };
52
52
  var _default = FileList;
53
53
  exports.default = _default;
@@ -19,6 +19,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
19
19
 
20
20
  var _react = _interopRequireWildcard(require("react"));
21
21
 
22
+ var _visTypes = require("../../modules/visTypes.js");
23
+
22
24
  var _CreatedByFilter = require("./CreatedByFilter.js");
23
25
 
24
26
  var _FileList = require("./FileList.js");
@@ -68,6 +70,8 @@ const getQuery = type => ({
68
70
  const OpenFileDialog = ({
69
71
  type,
70
72
  open,
73
+ filterVisTypes,
74
+ defaultFilterVisType,
71
75
  onClose,
72
76
  onFileSelect,
73
77
  onNew,
@@ -77,7 +81,7 @@ const OpenFileDialog = ({
77
81
  const defaultFilters = {
78
82
  searchTerm: '',
79
83
  createdBy: _CreatedByFilter.CREATED_BY_ALL,
80
- visType: _VisTypeFilter.VIS_TYPE_ALL
84
+ visType: defaultFilterVisType
81
85
  };
82
86
  const [{
83
87
  sortField,
@@ -108,26 +112,23 @@ const OpenFileDialog = ({
108
112
  break;
109
113
  }
110
114
 
111
- switch (filters.visType) {
112
- case _VisTypeFilter.VIS_TYPE_ALL:
113
- break;
115
+ if (filters.visType) {
116
+ switch (filters.visType) {
117
+ case _visTypes.VIS_TYPE_ALL:
118
+ break;
114
119
 
115
- case _VisTypeFilter.VIS_TYPE_CHARTS:
116
- queryFilters.push('type:!eq:PIVOT_TABLE');
117
- break;
120
+ case _visTypes.VIS_TYPE_CHARTS:
121
+ queryFilters.push('type:!eq:PIVOT_TABLE');
122
+ break;
118
123
 
119
- default:
120
- queryFilters.push("type:eq:".concat(filters.visType));
121
- break;
124
+ default:
125
+ queryFilters.push("type:eq:".concat(filters.visType));
126
+ break;
127
+ }
122
128
  }
123
129
 
124
130
  if (filters.searchTerm) {
125
131
  queryFilters.push("name:ilike:".concat(filters.searchTerm));
126
- } // for ER 2.38 only show line list ER types
127
-
128
-
129
- if (type === _utils.AO_TYPE_EVENT_REPORT) {
130
- queryFilters.push('dataType:eq:EVENTS');
131
132
  }
132
133
 
133
134
  return queryFilters;
@@ -180,7 +181,7 @@ const OpenFileDialog = ({
180
181
  width: '110px'
181
182
  }];
182
183
 
183
- if (type === _utils.AO_TYPE_VISUALIZATION) {
184
+ if (filterVisTypes !== null && filterVisTypes !== void 0 && filterVisTypes.length) {
184
185
  headers.splice(1, 0, {
185
186
  field: 'type',
186
187
  label: _d2I18n.default.t('Type'),
@@ -213,9 +214,10 @@ const OpenFileDialog = ({
213
214
  searchTerm: value
214
215
  }), 200));
215
216
  }
216
- })), type === _utils.AO_TYPE_VISUALIZATION && /*#__PURE__*/_react.default.createElement("div", {
217
+ })), (filterVisTypes === null || filterVisTypes === void 0 ? void 0 : filterVisTypes.length) && /*#__PURE__*/_react.default.createElement("div", {
217
218
  className: "jsx-".concat(_OpenFileDialogStyles.styles.__hash) + " " + "type-field-container"
218
219
  }, /*#__PURE__*/_react.default.createElement(_VisTypeFilter.VisTypeFilter, {
220
+ visTypes: filterVisTypes,
219
221
  selected: filters.visType,
220
222
  onChange: value => setFilters({ ...filters,
221
223
  visType: value
@@ -284,9 +286,9 @@ const OpenFileDialog = ({
284
286
  onClose();
285
287
  }
286
288
  }, (0, _utils.getTranslatedString)(type, 'newButtonLabel'))))))))), (data === null || data === void 0 ? void 0 : data.files[_utils.AOTypeMap[type].apiEndpoint].length) > 0 && /*#__PURE__*/_react.default.createElement(_FileList.FileList, {
287
- type: type,
288
289
  data: data.files[_utils.AOTypeMap[type].apiEndpoint],
289
- onSelect: onFileSelect
290
+ onSelect: onFileSelect,
291
+ showVisTypeColumn: Boolean(filterVisTypes === null || filterVisTypes === void 0 ? void 0 : filterVisTypes.length)
290
292
  }))), (data === null || data === void 0 ? void 0 : data.files[_utils.AOTypeMap[type].apiEndpoint].length) > 0 && /*#__PURE__*/_react.default.createElement(_ui.DataTableToolbar, {
291
293
  position: "bottom"
292
294
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -307,7 +309,9 @@ OpenFileDialog.propTypes = {
307
309
  type: _propTypes.default.oneOf(Object.keys(_utils.AOTypeMap)).isRequired,
308
310
  onClose: _propTypes.default.func.isRequired,
309
311
  onFileSelect: _propTypes.default.func.isRequired,
310
- onNew: _propTypes.default.func.isRequired
312
+ onNew: _propTypes.default.func.isRequired,
313
+ defaultFilterVisType: _propTypes.default.string,
314
+ filterVisTypes: _propTypes.default.array
311
315
  };
312
316
  var _default = OpenFileDialog;
313
317
  exports.default = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.VisTypeFilter = exports.VIS_TYPE_CHARTS = exports.VIS_TYPE_ALL = void 0;
6
+ exports.default = exports.VisTypeFilter = void 0;
7
7
 
8
8
  var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
9
9
 
@@ -21,12 +21,8 @@ var _CustomSelectOption = require("./CustomSelectOption.js");
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
 
24
- const VIS_TYPE_ALL = 'all';
25
- exports.VIS_TYPE_ALL = VIS_TYPE_ALL;
26
- const VIS_TYPE_CHARTS = 'charts';
27
- exports.VIS_TYPE_CHARTS = VIS_TYPE_CHARTS;
28
-
29
24
  const VisTypeFilter = ({
25
+ visTypes,
30
26
  selected,
31
27
  onChange
32
28
  }) => /*#__PURE__*/_react.default.createElement(_ui.SingleSelect, {
@@ -37,26 +33,31 @@ const VisTypeFilter = ({
37
33
  prefix: _d2I18n.default.t('Type'),
38
34
  dense: true,
39
35
  maxHeight: "400px"
40
- }, /*#__PURE__*/_react.default.createElement(_ui.SingleSelectOption, {
41
- label: _d2I18n.default.t('All types'),
42
- value: VIS_TYPE_ALL
43
- }), /*#__PURE__*/_react.default.createElement(_ui.SingleSelectOption, {
44
- label: _d2I18n.default.t('All charts'),
45
- value: VIS_TYPE_CHARTS
46
- }), /*#__PURE__*/_react.default.createElement(_ui.Divider, null), Object.entries(_visTypes.visTypeDisplayNames).map(([type, label]) => /*#__PURE__*/_react.default.createElement(_CustomSelectOption.CustomSelectOption, {
36
+ }, visTypes === null || visTypes === void 0 ? void 0 : visTypes.map(({
37
+ type,
38
+ disabled,
39
+ insertDivider
40
+ }) => /*#__PURE__*/_react.default.createElement(_CustomSelectOption.CustomSelectOption, {
47
41
  key: type,
48
- label: label,
42
+ disabled: disabled,
43
+ label: (0, _visTypes.getDisplayNameByVisType)(type),
44
+ insertDivider: insertDivider,
49
45
  value: type,
50
- icon: /*#__PURE__*/_react.default.createElement(_VisTypeIcon.VisTypeIcon, {
46
+ icon: _visTypes.visTypeIcons[type] ? /*#__PURE__*/_react.default.createElement(_VisTypeIcon.VisTypeIcon, {
51
47
  type: type,
52
48
  useSmall: true,
53
49
  color: _ui.colors.grey600
54
- })
50
+ }) : undefined
55
51
  })));
56
52
 
57
53
  exports.VisTypeFilter = VisTypeFilter;
58
54
  VisTypeFilter.propTypes = {
59
55
  selected: _propTypes.default.string,
56
+ visTypes: _propTypes.default.arrayOf(_propTypes.default.shape({
57
+ disabled: _propTypes.default.bool,
58
+ insertDivider: _propTypes.default.bool,
59
+ type: _propTypes.default.string
60
+ })),
60
61
  onChange: _propTypes.default.func
61
62
  };
62
63
  var _default = VisTypeFilter;
@@ -525,6 +525,18 @@ Object.defineProperty(exports, "getLayoutTypeByVisType", {
525
525
  return _visTypeToLayoutType.getLayoutTypeByVisType;
526
526
  }
527
527
  });
528
+ Object.defineProperty(exports, "VIS_TYPE_ALL", {
529
+ enumerable: true,
530
+ get: function () {
531
+ return _visTypes.VIS_TYPE_ALL;
532
+ }
533
+ });
534
+ Object.defineProperty(exports, "VIS_TYPE_CHARTS", {
535
+ enumerable: true,
536
+ get: function () {
537
+ return _visTypes.VIS_TYPE_CHARTS;
538
+ }
539
+ });
528
540
  Object.defineProperty(exports, "VIS_TYPE_COLUMN", {
529
541
  enumerable: true,
530
542
  get: function () {
@@ -621,16 +633,16 @@ Object.defineProperty(exports, "VIS_TYPE_SCATTER", {
621
633
  return _visTypes.VIS_TYPE_SCATTER;
622
634
  }
623
635
  });
624
- Object.defineProperty(exports, "visTypeDisplayNames", {
636
+ Object.defineProperty(exports, "VIS_TYPE_LINE_LIST", {
625
637
  enumerable: true,
626
638
  get: function () {
627
- return _visTypes.visTypeDisplayNames;
639
+ return _visTypes.VIS_TYPE_LINE_LIST;
628
640
  }
629
641
  });
630
- Object.defineProperty(exports, "visTypeDescriptions", {
642
+ Object.defineProperty(exports, "visTypeDisplayNames", {
631
643
  enumerable: true,
632
644
  get: function () {
633
- return _visTypes.visTypeDescriptions;
645
+ return _visTypes.visTypeDisplayNames;
634
646
  }
635
647
  });
636
648
  Object.defineProperty(exports, "visTypeIcons", {
@@ -81,13 +81,13 @@
81
81
  "Anyone": "Anyone",
82
82
  "Only you": "Only you",
83
83
  "Others": "Others",
84
+ "Not supported by this app yet": "Not supported by this app yet",
84
85
  "Filter by name": "Filter by name",
85
86
  "Created": "Created",
86
87
  "Last updated": "Last updated",
87
88
  "Type": "Type",
88
89
  "Clear filters": "Clear filters",
89
90
  "{{firstItemIndex}}-{{lastItemIndex}} of {{totalNumberOfItems}}": "{{firstItemIndex}}-{{lastItemIndex}} of {{totalNumberOfItems}}",
90
- "All charts": "All charts",
91
91
  "Open": "Open",
92
92
  "Couldn't load items": "Couldn't load items",
93
93
  "There was a problem loading items. Try again or contact your system administrator.": "There was a problem loading items. Try again or contact your system administrator.",
@@ -309,19 +309,8 @@
309
309
  "Year over year (column)": "Year over year (column)",
310
310
  "Single value": "Single value",
311
311
  "Scatter": "Scatter",
312
- "View data and indicators in a manipulatable table.": "View data and indicators in a manipulatable table.",
313
- "Compare sizes of related elements vertically. Recommend period as filter.": "Compare sizes of related elements vertically. Recommend period as filter.",
314
- "Compare parts of a whole against related elements vertically. Recommend data or org. unit as series.": "Compare parts of a whole against related elements vertically. Recommend data or org. unit as series.",
315
- "Compare sizes of related elements horizontally. Recommend period as filter.": "Compare sizes of related elements horizontally. Recommend period as filter.",
316
- "Compare parts of a whole against related elements horizontally. Recommend data or org. unit as series.": "Compare parts of a whole against related elements horizontally. Recommend data or org. unit as series.",
317
- "Track or compare changes over time. Recommend period as category.": "Track or compare changes over time. Recommend period as category.",
318
- "Track or compare parts of a whole over time. Recommend data as series and period as category.": "Track or compare parts of a whole over time. Recommend data as series and period as category.",
319
- "Compare parts of a whole at a single point in time. Recommend period as filter.": "Compare parts of a whole at a single point in time. Recommend period as filter.",
320
- "Compare several items against multiple variables.": "Compare several items against multiple variables.",
321
- "Compare a percentage indicator against a 100% scale. Recommend period as filter.": "Compare a percentage indicator against a 100% scale. Recommend period as filter.",
322
- "Compare changes over time between multiple time periods.": "Compare changes over time between multiple time periods.",
323
- "Display a single value. Recommend relative period to show latest data.": "Display a single value. Recommend relative period to show latest data.",
324
- "View the relationship between two data items at a place or time. Recommended for finding outliers.": "View the relationship between two data items at a place or time. Recommended for finding outliers.",
312
+ "Line list": "Line list",
313
+ "All charts": "All charts",
325
314
  "{{seriesName}} (trend)": "{{seriesName}} (trend)",
326
315
  "Trend": "Trend",
327
316
  "No legend for this series": "No legend for this series",
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isColumnBasedType = exports.isLegendSetType = exports.isVerticalType = exports.isTwoCategoryChartType = exports.isSingleValue = exports.isMultiType = exports.isDualAxisType = exports.isYearOverYear = exports.isStacked = exports.defaultVisType = exports.getDisplayNameByVisType = exports.visTypeIcons = exports.visTypeDescriptions = exports.visTypeDisplayNames = exports.VIS_TYPE_SCATTER = exports.VIS_TYPE_PIVOT_TABLE = exports.VIS_TYPE_SINGLE_VALUE = exports.VIS_TYPE_YEAR_OVER_YEAR_COLUMN = exports.VIS_TYPE_YEAR_OVER_YEAR_LINE = exports.VIS_TYPE_BUBBLE = exports.VIS_TYPE_GAUGE = exports.VIS_TYPE_RADAR = exports.VIS_TYPE_PIE = exports.VIS_TYPE_STACKED_AREA = exports.VIS_TYPE_AREA = exports.VIS_TYPE_LINE = exports.VIS_TYPE_STACKED_BAR = exports.VIS_TYPE_BAR = exports.VIS_TYPE_STACKED_COLUMN = exports.VIS_TYPE_COLUMN = void 0;
6
+ exports.isColumnBasedType = exports.isLegendSetType = exports.isVerticalType = exports.isTwoCategoryChartType = exports.isSingleValue = exports.isMultiType = exports.isDualAxisType = exports.isYearOverYear = exports.isStacked = exports.defaultVisType = exports.getDisplayNameByVisType = exports.visTypeIcons = exports.visTypeDisplayNames = exports.VIS_TYPE_CHARTS = exports.VIS_TYPE_ALL = exports.VIS_TYPE_LINE_LIST = exports.VIS_TYPE_SCATTER = exports.VIS_TYPE_PIVOT_TABLE = exports.VIS_TYPE_SINGLE_VALUE = exports.VIS_TYPE_YEAR_OVER_YEAR_COLUMN = exports.VIS_TYPE_YEAR_OVER_YEAR_LINE = exports.VIS_TYPE_BUBBLE = exports.VIS_TYPE_GAUGE = exports.VIS_TYPE_RADAR = exports.VIS_TYPE_PIE = exports.VIS_TYPE_STACKED_AREA = exports.VIS_TYPE_AREA = exports.VIS_TYPE_LINE = exports.VIS_TYPE_STACKED_BAR = exports.VIS_TYPE_BAR = exports.VIS_TYPE_STACKED_COLUMN = exports.VIS_TYPE_COLUMN = void 0;
7
7
 
8
8
  var _ui = require("@dhis2/ui");
9
9
 
@@ -43,6 +43,12 @@ const VIS_TYPE_PIVOT_TABLE = 'PIVOT_TABLE';
43
43
  exports.VIS_TYPE_PIVOT_TABLE = VIS_TYPE_PIVOT_TABLE;
44
44
  const VIS_TYPE_SCATTER = 'SCATTER';
45
45
  exports.VIS_TYPE_SCATTER = VIS_TYPE_SCATTER;
46
+ const VIS_TYPE_LINE_LIST = 'LINE_LIST';
47
+ exports.VIS_TYPE_LINE_LIST = VIS_TYPE_LINE_LIST;
48
+ const VIS_TYPE_ALL = 'ALL';
49
+ exports.VIS_TYPE_ALL = VIS_TYPE_ALL;
50
+ const VIS_TYPE_CHARTS = 'CHARTS';
51
+ exports.VIS_TYPE_CHARTS = VIS_TYPE_CHARTS;
46
52
  const visTypeDisplayNames = {
47
53
  [VIS_TYPE_PIVOT_TABLE]: _index.default.t('Pivot table'),
48
54
  [VIS_TYPE_COLUMN]: _index.default.t('Column'),
@@ -58,27 +64,12 @@ const visTypeDisplayNames = {
58
64
  [VIS_TYPE_YEAR_OVER_YEAR_LINE]: _index.default.t('Year over year (line)'),
59
65
  [VIS_TYPE_YEAR_OVER_YEAR_COLUMN]: _index.default.t('Year over year (column)'),
60
66
  [VIS_TYPE_SINGLE_VALUE]: _index.default.t('Single value'),
61
- [VIS_TYPE_SCATTER]: _index.default.t('Scatter')
67
+ [VIS_TYPE_SCATTER]: _index.default.t('Scatter'),
68
+ [VIS_TYPE_LINE_LIST]: _index.default.t('Line list'),
69
+ [VIS_TYPE_ALL]: _index.default.t('All types'),
70
+ [VIS_TYPE_CHARTS]: _index.default.t('All charts')
62
71
  };
63
72
  exports.visTypeDisplayNames = visTypeDisplayNames;
64
- const visTypeDescriptions = {
65
- [VIS_TYPE_PIVOT_TABLE]: _index.default.t('View data and indicators in a manipulatable table.'),
66
- [VIS_TYPE_COLUMN]: _index.default.t('Compare sizes of related elements vertically. Recommend period as filter.'),
67
- [VIS_TYPE_STACKED_COLUMN]: _index.default.t('Compare parts of a whole against related elements vertically. Recommend data or org. unit as series.'),
68
- [VIS_TYPE_BAR]: _index.default.t('Compare sizes of related elements horizontally. Recommend period as filter.'),
69
- [VIS_TYPE_STACKED_BAR]: _index.default.t('Compare parts of a whole against related elements horizontally. Recommend data or org. unit as series.'),
70
- [VIS_TYPE_LINE]: _index.default.t('Track or compare changes over time. Recommend period as category.'),
71
- [VIS_TYPE_AREA]: _index.default.t('Track or compare changes over time. Recommend period as category.'),
72
- [VIS_TYPE_STACKED_AREA]: _index.default.t('Track or compare parts of a whole over time. Recommend data as series and period as category.'),
73
- [VIS_TYPE_PIE]: _index.default.t('Compare parts of a whole at a single point in time. Recommend period as filter.'),
74
- [VIS_TYPE_RADAR]: _index.default.t('Compare several items against multiple variables.'),
75
- [VIS_TYPE_GAUGE]: _index.default.t('Compare a percentage indicator against a 100% scale. Recommend period as filter.'),
76
- [VIS_TYPE_YEAR_OVER_YEAR_LINE]: _index.default.t('Compare changes over time between multiple time periods.'),
77
- [VIS_TYPE_YEAR_OVER_YEAR_COLUMN]: _index.default.t('Compare changes over time between multiple time periods.'),
78
- [VIS_TYPE_SINGLE_VALUE]: _index.default.t('Display a single value. Recommend relative period to show latest data.'),
79
- [VIS_TYPE_SCATTER]: _index.default.t('View the relationship between two data items at a place or time. Recommended for finding outliers.')
80
- };
81
- exports.visTypeDescriptions = visTypeDescriptions;
82
73
  const visTypeIcons = {
83
74
  [VIS_TYPE_PIVOT_TABLE]: _ui.IconTable24,
84
75
  [VIS_TYPE_BAR]: _ui.IconVisualizationBar24,
@@ -94,7 +85,9 @@ const visTypeIcons = {
94
85
  [VIS_TYPE_YEAR_OVER_YEAR_LINE]: _ui.IconVisualizationLineMulti24,
95
86
  [VIS_TYPE_YEAR_OVER_YEAR_COLUMN]: _ui.IconVisualizationColumnMulti24,
96
87
  [VIS_TYPE_SINGLE_VALUE]: _ui.IconVisualizationSingleValue24,
97
- [VIS_TYPE_SCATTER]: _ui.IconVisualizationScatter24
88
+ [VIS_TYPE_SCATTER]: _ui.IconVisualizationScatter24,
89
+ [VIS_TYPE_LINE_LIST]: _ui.IconTable24 // TODO different icon @joe
90
+
98
91
  };
99
92
  exports.visTypeIcons = visTypeIcons;
100
93
 
@@ -14,8 +14,10 @@ import { supportedFileTypes } from './utils.js';
14
14
  export const FileMenu = ({
15
15
  d2,
16
16
  // to be removed as soon as TranslateDialog and FavoritesDialog are rewritten
17
+ defaultFilterVisType,
17
18
  fileType,
18
19
  fileObject,
20
+ filterVisTypes,
19
21
  onNew,
20
22
  onOpen,
21
23
  onSave,
@@ -130,6 +132,8 @@ export const FileMenu = ({
130
132
  }, i18n.t('File'))), /*#__PURE__*/React.createElement(OpenFileDialog, {
131
133
  open: currentDialog === 'open',
132
134
  type: fileType,
135
+ filterVisTypes: filterVisTypes,
136
+ defaultFilterVisType: defaultFilterVisType,
133
137
  onClose: onDialogClose,
134
138
  onFileSelect: id => {
135
139
  onOpen(id);
@@ -238,8 +242,10 @@ FileMenu.defaultProps = {
238
242
  };
239
243
  FileMenu.propTypes = {
240
244
  d2: PropTypes.object,
245
+ defaultFilterVisType: PropTypes.string,
241
246
  fileObject: PropTypes.object,
242
247
  fileType: PropTypes.oneOf(supportedFileTypes),
248
+ filterVisTypes: PropTypes.array,
243
249
  onDelete: PropTypes.func,
244
250
  onError: PropTypes.func,
245
251
  onNew: PropTypes.func,
@@ -1,16 +1,20 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
+ import i18n from '@dhis2/d2-i18n';
3
+ import { MenuDivider, Tooltip } from '@dhis2/ui';
2
4
  import cx from 'classnames';
3
5
  import PropTypes from 'prop-types';
4
6
  import React from 'react';
5
7
  import styles from './styles/CustomSelectOption.style.js';
6
- export const CustomSelectOption = ({
8
+
9
+ const CustomSelectOptionItem = ({
7
10
  value,
8
11
  label,
9
12
  icon,
13
+ insertDivider,
10
14
  onClick,
11
15
  active,
12
16
  disabled
13
- }) => /*#__PURE__*/React.createElement("div", {
17
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
14
18
  onClick: e => onClick({}, e),
15
19
  "data-value": value,
16
20
  "data-label": label,
@@ -19,10 +23,18 @@ export const CustomSelectOption = ({
19
23
  disabled
20
24
  }) || "")
21
25
  }, icon, /*#__PURE__*/React.createElement("span", {
22
- className: "jsx-".concat(styles.__hash) + " " + "label"
26
+ className: "jsx-".concat(styles.__hash) + " " + (cx({
27
+ label: icon
28
+ }) || "")
23
29
  }, label), /*#__PURE__*/React.createElement(_JSXStyle, {
24
30
  id: styles.__hash
25
- }, styles));
31
+ }, styles)), insertDivider ? /*#__PURE__*/React.createElement(MenuDivider, {
32
+ dense: true
33
+ }) : null);
34
+
35
+ export const CustomSelectOption = props => props.disabled ? /*#__PURE__*/React.createElement(Tooltip, {
36
+ content: i18n.t('Not supported by this app yet')
37
+ }, /*#__PURE__*/React.createElement(CustomSelectOptionItem, props)) : /*#__PURE__*/React.createElement(CustomSelectOptionItem, props);
26
38
  CustomSelectOption.propTypes = {
27
39
  icon: PropTypes.element.isRequired,
28
40
  label: PropTypes.string.isRequired,
@@ -31,4 +43,5 @@ CustomSelectOption.propTypes = {
31
43
  disabled: PropTypes.bool,
32
44
  onClick: PropTypes.func
33
45
  };
46
+ CustomSelectOptionItem.propTypes = CustomSelectOption.propTypes;
34
47
  export default CustomSelectOption;
@@ -4,14 +4,14 @@ import React from 'react';
4
4
  import { VisTypeIcon } from '../VisTypeIcon.js';
5
5
  import { DateField } from './DateField.js';
6
6
  export const FileList = ({
7
- type,
8
7
  data,
9
- onSelect
8
+ onSelect,
9
+ showVisTypeColumn
10
10
  }) => /*#__PURE__*/React.createElement(React.Fragment, null, data.map(visualization => /*#__PURE__*/React.createElement(DataTableRow, {
11
11
  key: visualization.id
12
12
  }, /*#__PURE__*/React.createElement(DataTableCell, {
13
13
  onClick: () => onSelect(visualization.id)
14
- }, visualization.displayName), type === 'visualization' && /*#__PURE__*/React.createElement(DataTableCell, {
14
+ }, visualization.displayName), showVisTypeColumn && /*#__PURE__*/React.createElement(DataTableCell, {
15
15
  align: "center"
16
16
  }, /*#__PURE__*/React.createElement(VisTypeIcon, {
17
17
  type: visualization.type,
@@ -30,7 +30,7 @@ FileList.propTypes = {
30
30
  lastUpdated: PropTypes.string.isRequired,
31
31
  type: PropTypes.string
32
32
  })).isRequired,
33
- type: PropTypes.string.isRequired,
34
- onSelect: PropTypes.func.isRequired
33
+ onSelect: PropTypes.func.isRequired,
34
+ showVisTypeColumn: PropTypes.bool
35
35
  };
36
36
  export default FileList;
@@ -5,13 +5,14 @@ import { Box, Modal, ModalTitle, ModalContent, DataTable, DataTableHead, DataTab
5
5
  import isEqual from 'lodash/isEqual';
6
6
  import PropTypes from 'prop-types';
7
7
  import React, { useEffect, useMemo, useState } from 'react';
8
+ import { VIS_TYPE_ALL, VIS_TYPE_CHARTS } from '../../modules/visTypes.js';
8
9
  import { CreatedByFilter, CREATED_BY_ALL, CREATED_BY_ALL_BUT_CURRENT_USER, CREATED_BY_CURRENT_USER } from './CreatedByFilter.js';
9
10
  import { FileList } from './FileList.js';
10
11
  import { NameFilter } from './NameFilter.js';
11
12
  import { styles } from './OpenFileDialog.styles.js';
12
13
  import { PaginationControls } from './PaginationControls.js';
13
- import { getTranslatedString, AO_TYPE_VISUALIZATION, AO_TYPE_EVENT_REPORT, AOTypeMap } from './utils.js';
14
- import { VisTypeFilter, VIS_TYPE_ALL, VIS_TYPE_CHARTS } from './VisTypeFilter.js';
14
+ import { getTranslatedString, AOTypeMap } from './utils.js';
15
+ import { VisTypeFilter } from './VisTypeFilter.js';
15
16
 
16
17
  const getQuery = type => ({
17
18
  files: {
@@ -42,6 +43,8 @@ const getQuery = type => ({
42
43
  export const OpenFileDialog = ({
43
44
  type,
44
45
  open,
46
+ filterVisTypes,
47
+ defaultFilterVisType,
45
48
  onClose,
46
49
  onFileSelect,
47
50
  onNew,
@@ -51,7 +54,7 @@ export const OpenFileDialog = ({
51
54
  const defaultFilters = {
52
55
  searchTerm: '',
53
56
  createdBy: CREATED_BY_ALL,
54
- visType: VIS_TYPE_ALL
57
+ visType: defaultFilterVisType
55
58
  };
56
59
  const [{
57
60
  sortField,
@@ -82,26 +85,23 @@ export const OpenFileDialog = ({
82
85
  break;
83
86
  }
84
87
 
85
- switch (filters.visType) {
86
- case VIS_TYPE_ALL:
87
- break;
88
+ if (filters.visType) {
89
+ switch (filters.visType) {
90
+ case VIS_TYPE_ALL:
91
+ break;
88
92
 
89
- case VIS_TYPE_CHARTS:
90
- queryFilters.push('type:!eq:PIVOT_TABLE');
91
- break;
93
+ case VIS_TYPE_CHARTS:
94
+ queryFilters.push('type:!eq:PIVOT_TABLE');
95
+ break;
92
96
 
93
- default:
94
- queryFilters.push("type:eq:".concat(filters.visType));
95
- break;
97
+ default:
98
+ queryFilters.push("type:eq:".concat(filters.visType));
99
+ break;
100
+ }
96
101
  }
97
102
 
98
103
  if (filters.searchTerm) {
99
104
  queryFilters.push("name:ilike:".concat(filters.searchTerm));
100
- } // for ER 2.38 only show line list ER types
101
-
102
-
103
- if (type === AO_TYPE_EVENT_REPORT) {
104
- queryFilters.push('dataType:eq:EVENTS');
105
105
  }
106
106
 
107
107
  return queryFilters;
@@ -154,7 +154,7 @@ export const OpenFileDialog = ({
154
154
  width: '110px'
155
155
  }];
156
156
 
157
- if (type === AO_TYPE_VISUALIZATION) {
157
+ if (filterVisTypes !== null && filterVisTypes !== void 0 && filterVisTypes.length) {
158
158
  headers.splice(1, 0, {
159
159
  field: 'type',
160
160
  label: i18n.t('Type'),
@@ -187,9 +187,10 @@ export const OpenFileDialog = ({
187
187
  searchTerm: value
188
188
  }), 200));
189
189
  }
190
- })), type === AO_TYPE_VISUALIZATION && /*#__PURE__*/React.createElement("div", {
190
+ })), (filterVisTypes === null || filterVisTypes === void 0 ? void 0 : filterVisTypes.length) && /*#__PURE__*/React.createElement("div", {
191
191
  className: "jsx-".concat(styles.__hash) + " " + "type-field-container"
192
192
  }, /*#__PURE__*/React.createElement(VisTypeFilter, {
193
+ visTypes: filterVisTypes,
193
194
  selected: filters.visType,
194
195
  onChange: value => setFilters({ ...filters,
195
196
  visType: value
@@ -258,9 +259,9 @@ export const OpenFileDialog = ({
258
259
  onClose();
259
260
  }
260
261
  }, getTranslatedString(type, 'newButtonLabel'))))))))), (data === null || data === void 0 ? void 0 : data.files[AOTypeMap[type].apiEndpoint].length) > 0 && /*#__PURE__*/React.createElement(FileList, {
261
- type: type,
262
262
  data: data.files[AOTypeMap[type].apiEndpoint],
263
- onSelect: onFileSelect
263
+ onSelect: onFileSelect,
264
+ showVisTypeColumn: Boolean(filterVisTypes === null || filterVisTypes === void 0 ? void 0 : filterVisTypes.length)
264
265
  }))), (data === null || data === void 0 ? void 0 : data.files[AOTypeMap[type].apiEndpoint].length) > 0 && /*#__PURE__*/React.createElement(DataTableToolbar, {
265
266
  position: "bottom"
266
267
  }, /*#__PURE__*/React.createElement("div", {
@@ -279,6 +280,8 @@ OpenFileDialog.propTypes = {
279
280
  type: PropTypes.oneOf(Object.keys(AOTypeMap)).isRequired,
280
281
  onClose: PropTypes.func.isRequired,
281
282
  onFileSelect: PropTypes.func.isRequired,
282
- onNew: PropTypes.func.isRequired
283
+ onNew: PropTypes.func.isRequired,
284
+ defaultFilterVisType: PropTypes.string,
285
+ filterVisTypes: PropTypes.array
283
286
  };
284
287
  export default OpenFileDialog;