@dhis2/analytics 28.1.2 → 29.0.0
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/build/cjs/__demo__/InterpretationsUnit.stories.js +9 -6
- package/build/cjs/__fixtures__/interpretationsMockData.js +204 -0
- package/build/cjs/components/Interpretations/DashboardItemInterpretations/DashboardInterpretationThread.js +56 -0
- package/build/cjs/components/Interpretations/DashboardItemInterpretations/DashboardItemInterpretations.js +54 -0
- package/build/cjs/components/Interpretations/DashboardItemInterpretations/index.js +12 -0
- package/build/cjs/components/Interpretations/InterpretationModal/Comment.js +12 -17
- package/build/cjs/components/Interpretations/InterpretationModal/CommentAddForm.js +20 -34
- package/build/cjs/components/Interpretations/InterpretationModal/CommentDeleteButton.js +11 -36
- package/build/cjs/components/Interpretations/InterpretationModal/CommentUpdateForm.js +11 -27
- package/build/cjs/components/Interpretations/InterpretationModal/InterpretationModal.js +11 -68
- package/build/cjs/components/Interpretations/InterpretationModal/InterpretationThread.js +11 -24
- package/build/cjs/components/Interpretations/InterpretationsProvider/InterpretationsManager.js +275 -0
- package/build/cjs/components/Interpretations/InterpretationsProvider/InterpretationsProvider.js +28 -0
- package/build/cjs/components/Interpretations/InterpretationsProvider/__tests__/groupInterpretationIdsByDate.spec.js +37 -0
- package/build/cjs/components/Interpretations/InterpretationsProvider/__tests__/hooks.spec.js +565 -0
- package/build/cjs/components/Interpretations/InterpretationsProvider/groupInterpretationIdsByDate.js +16 -0
- package/build/cjs/components/Interpretations/InterpretationsProvider/hooks.js +278 -0
- package/build/cjs/components/Interpretations/InterpretationsProvider/index.js +12 -0
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationForm.js +25 -30
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationList.js +8 -38
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +22 -73
- package/build/cjs/components/Interpretations/common/Interpretation/Interpretation.js +20 -34
- package/build/cjs/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js +10 -12
- package/build/cjs/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +13 -24
- package/build/cjs/components/Interpretations/common/Message/MessageEditorContainer.js +3 -3
- package/build/cjs/index.js +72 -63
- package/build/cjs/locales/en/translations.json +10 -1
- package/build/cjs/modules/pivotTable/getHeaderForDisplay.js +1 -1
- package/build/es/__demo__/InterpretationsUnit.stories.js +9 -6
- package/build/es/__fixtures__/interpretationsMockData.js +198 -0
- package/build/es/components/Interpretations/DashboardItemInterpretations/DashboardInterpretationThread.js +48 -0
- package/build/es/components/Interpretations/DashboardItemInterpretations/DashboardItemInterpretations.js +45 -0
- package/build/es/components/Interpretations/DashboardItemInterpretations/index.js +1 -0
- package/build/es/components/Interpretations/InterpretationModal/Comment.js +14 -19
- package/build/es/components/Interpretations/InterpretationModal/CommentAddForm.js +21 -35
- package/build/es/components/Interpretations/InterpretationModal/CommentDeleteButton.js +11 -35
- package/build/es/components/Interpretations/InterpretationModal/CommentUpdateForm.js +12 -28
- package/build/es/components/Interpretations/InterpretationModal/InterpretationModal.js +12 -69
- package/build/es/components/Interpretations/InterpretationModal/InterpretationThread.js +11 -24
- package/build/es/components/Interpretations/InterpretationsProvider/InterpretationsManager.js +268 -0
- package/build/es/components/Interpretations/InterpretationsProvider/InterpretationsProvider.js +19 -0
- package/build/es/components/Interpretations/InterpretationsProvider/__tests__/groupInterpretationIdsByDate.spec.js +35 -0
- package/build/es/components/Interpretations/InterpretationsProvider/__tests__/hooks.spec.js +561 -0
- package/build/es/components/Interpretations/InterpretationsProvider/groupInterpretationIdsByDate.js +9 -0
- package/build/es/components/Interpretations/InterpretationsProvider/hooks.js +258 -0
- package/build/es/components/Interpretations/InterpretationsProvider/index.js +1 -0
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationForm.js +26 -31
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationList.js +8 -38
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +23 -75
- package/build/es/components/Interpretations/common/Interpretation/Interpretation.js +21 -35
- package/build/es/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js +11 -13
- package/build/es/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +14 -25
- package/build/es/components/Interpretations/common/Message/MessageEditorContainer.js +3 -3
- package/build/es/index.js +3 -1
- package/build/es/locales/en/translations.json +10 -1
- package/build/es/modules/pivotTable/getHeaderForDisplay.js +1 -1
- package/package.json +1 -1
- package/build/cjs/components/Interpretations/common/Interpretation/useLike.js +0 -56
- package/build/es/components/Interpretations/common/Interpretation/useLike.js +0 -50
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.WithNoTimeDimensionsWarning = exports.Default = void 0;
|
|
7
7
|
var _appRuntime = require("@dhis2/app-runtime");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _InterpretationsProvider = require("../components/Interpretations/InterpretationsProvider/InterpretationsProvider.js");
|
|
9
10
|
var _index = require("../components/Interpretations/InterpretationsUnit/index.js");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
var _default = exports.default = {
|
|
@@ -18,15 +19,16 @@ const Default = () => {
|
|
|
18
19
|
interpretations: []
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
22
|
+
}, /*#__PURE__*/_react.default.createElement(_InterpretationsProvider.InterpretationsProvider, {
|
|
22
23
|
currentUser: {
|
|
23
24
|
name: 'Tom Wakiki'
|
|
24
|
-
}
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/_react.default.createElement(_index.InterpretationsUnit, {
|
|
25
27
|
id: "abcd",
|
|
26
28
|
onReplyIconClick: Function.prototype,
|
|
27
29
|
type: "eventVisualization",
|
|
28
30
|
visualizationHasTimeDimension: true
|
|
29
|
-
}));
|
|
31
|
+
})));
|
|
30
32
|
};
|
|
31
33
|
exports.Default = Default;
|
|
32
34
|
const WithNoTimeDimensionsWarning = () => {
|
|
@@ -36,15 +38,16 @@ const WithNoTimeDimensionsWarning = () => {
|
|
|
36
38
|
interpretations: []
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_InterpretationsProvider.InterpretationsProvider, {
|
|
40
42
|
currentUser: {
|
|
41
43
|
name: 'Tom Wakiki'
|
|
42
|
-
}
|
|
44
|
+
}
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(_index.InterpretationsUnit, {
|
|
43
46
|
id: "abcd",
|
|
44
47
|
onReplyIconClick: Function.prototype,
|
|
45
48
|
type: "eventVisualization",
|
|
46
49
|
visualizationHasTimeDimension: false
|
|
47
|
-
}));
|
|
50
|
+
})));
|
|
48
51
|
};
|
|
49
52
|
exports.WithNoTimeDimensionsWarning = WithNoTimeDimensionsWarning;
|
|
50
53
|
WithNoTimeDimensionsWarning.story = {
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.visualization = exports.newInterpretation = exports.newComment = exports.interpretations = exports.interpretationDetails = exports.currentUser = void 0;
|
|
7
|
+
const currentUser = exports.currentUser = {
|
|
8
|
+
id: 'currentuserid',
|
|
9
|
+
name: 'John Traore',
|
|
10
|
+
email: 'dummy@dhis2.org',
|
|
11
|
+
settings: {
|
|
12
|
+
keyDbLocale: 'en',
|
|
13
|
+
keyMessageSmsNotification: false,
|
|
14
|
+
keyTrackerDashboardLayout: '',
|
|
15
|
+
keyCurrentStyle: 'light_blue/light_blue.css',
|
|
16
|
+
keyStyle: 'light_blue/light_blue.css',
|
|
17
|
+
keyUiLocale: 'en',
|
|
18
|
+
keyAnalysisDisplayProperty: 'name',
|
|
19
|
+
keyMessageEmailNotification: false
|
|
20
|
+
},
|
|
21
|
+
authorities: ['F_VIEW_UNAPPROVED_DATA']
|
|
22
|
+
};
|
|
23
|
+
const interpretations = exports.interpretations = [{
|
|
24
|
+
id: 'interpretation1',
|
|
25
|
+
text: 'This is the first interpretation',
|
|
26
|
+
created: '2025-09-04T07:47:12.477',
|
|
27
|
+
createdBy: {
|
|
28
|
+
id: 'currentuserid',
|
|
29
|
+
code: null,
|
|
30
|
+
name: 'John Traore',
|
|
31
|
+
displayName: 'John Traore',
|
|
32
|
+
username: 'admin'
|
|
33
|
+
},
|
|
34
|
+
comments: [{
|
|
35
|
+
id: 'commentid1'
|
|
36
|
+
}, {
|
|
37
|
+
id: 'commentid2'
|
|
38
|
+
}],
|
|
39
|
+
likes: 1,
|
|
40
|
+
access: {
|
|
41
|
+
manage: true,
|
|
42
|
+
write: true
|
|
43
|
+
},
|
|
44
|
+
likedBy: [{
|
|
45
|
+
id: 'currentuserid',
|
|
46
|
+
code: null,
|
|
47
|
+
name: 'John Traore',
|
|
48
|
+
displayName: 'John Traore',
|
|
49
|
+
username: 'admin'
|
|
50
|
+
}]
|
|
51
|
+
}, {
|
|
52
|
+
id: 'interpretation2',
|
|
53
|
+
text: 'Analysis shows interesting trends in the data distribution across different regions',
|
|
54
|
+
created: '2025-09-03T14:22:35.891',
|
|
55
|
+
createdBy: {
|
|
56
|
+
id: 'otheruserid1',
|
|
57
|
+
code: null,
|
|
58
|
+
name: 'Sarah Johnson',
|
|
59
|
+
displayName: 'Sarah Johnson',
|
|
60
|
+
username: 'sjohnson'
|
|
61
|
+
},
|
|
62
|
+
comments: [{
|
|
63
|
+
id: 'commentid3'
|
|
64
|
+
}],
|
|
65
|
+
likes: 3,
|
|
66
|
+
access: {
|
|
67
|
+
manage: false,
|
|
68
|
+
write: false
|
|
69
|
+
},
|
|
70
|
+
likedBy: [{
|
|
71
|
+
id: 'currentuserid',
|
|
72
|
+
code: null,
|
|
73
|
+
name: 'John Traore',
|
|
74
|
+
displayName: 'John Traore',
|
|
75
|
+
username: 'admin'
|
|
76
|
+
}, {
|
|
77
|
+
id: 'otheruserid1',
|
|
78
|
+
code: null,
|
|
79
|
+
name: 'Sarah Johnson',
|
|
80
|
+
displayName: 'Sarah Johnson',
|
|
81
|
+
username: 'sjohnson'
|
|
82
|
+
}, {
|
|
83
|
+
id: 'otheruserid2',
|
|
84
|
+
code: null,
|
|
85
|
+
name: 'Mike Chen',
|
|
86
|
+
displayName: 'Mike Chen',
|
|
87
|
+
username: 'mchen'
|
|
88
|
+
}]
|
|
89
|
+
}, {
|
|
90
|
+
id: 'interpretation3',
|
|
91
|
+
text: 'The quarterly report reveals significant improvements in performance metrics',
|
|
92
|
+
created: '2025-09-02T10:15:48.123',
|
|
93
|
+
createdBy: {
|
|
94
|
+
id: 'currentuserid',
|
|
95
|
+
code: null,
|
|
96
|
+
name: 'John Traore',
|
|
97
|
+
displayName: 'John Traore',
|
|
98
|
+
username: 'admin'
|
|
99
|
+
},
|
|
100
|
+
comments: [],
|
|
101
|
+
likes: 0,
|
|
102
|
+
access: {
|
|
103
|
+
manage: true,
|
|
104
|
+
write: true
|
|
105
|
+
},
|
|
106
|
+
likedBy: []
|
|
107
|
+
}, {
|
|
108
|
+
id: 'interpretation4',
|
|
109
|
+
text: 'We need to investigate the outliers in this dataset more thoroughly',
|
|
110
|
+
created: '2025-09-01T16:33:21.654',
|
|
111
|
+
createdBy: {
|
|
112
|
+
id: 'otheruserid2',
|
|
113
|
+
code: null,
|
|
114
|
+
name: 'Mike Chen',
|
|
115
|
+
displayName: 'Mike Chen',
|
|
116
|
+
username: 'mchen'
|
|
117
|
+
},
|
|
118
|
+
comments: [{
|
|
119
|
+
id: 'commentid4'
|
|
120
|
+
}, {
|
|
121
|
+
id: 'commentid5'
|
|
122
|
+
}, {
|
|
123
|
+
id: 'commentid6'
|
|
124
|
+
}],
|
|
125
|
+
likes: 2,
|
|
126
|
+
access: {
|
|
127
|
+
manage: false,
|
|
128
|
+
write: true
|
|
129
|
+
},
|
|
130
|
+
likedBy: [{
|
|
131
|
+
id: 'otheruserid1',
|
|
132
|
+
code: null,
|
|
133
|
+
name: 'Sarah Johnson',
|
|
134
|
+
displayName: 'Sarah Johnson',
|
|
135
|
+
username: 'sjohnson'
|
|
136
|
+
}, {
|
|
137
|
+
id: 'otheruserid2',
|
|
138
|
+
code: null,
|
|
139
|
+
name: 'Mike Chen',
|
|
140
|
+
displayName: 'Mike Chen',
|
|
141
|
+
username: 'mchen'
|
|
142
|
+
}]
|
|
143
|
+
}];
|
|
144
|
+
const interpretationDetails = exports.interpretationDetails = {
|
|
145
|
+
...interpretations[0],
|
|
146
|
+
comments: [{
|
|
147
|
+
created: '2025-09-04T07:47:39.167',
|
|
148
|
+
createdBy: {
|
|
149
|
+
id: 'currentuserid',
|
|
150
|
+
code: null,
|
|
151
|
+
name: 'John Traore',
|
|
152
|
+
displayName: 'John Traore',
|
|
153
|
+
username: 'admin'
|
|
154
|
+
},
|
|
155
|
+
text: 'This is the first comment',
|
|
156
|
+
id: 'commentid1'
|
|
157
|
+
}, {
|
|
158
|
+
created: '2025-09-04T07:47:42.011',
|
|
159
|
+
createdBy: {
|
|
160
|
+
id: 'currentuserid',
|
|
161
|
+
code: null,
|
|
162
|
+
name: 'John Traore',
|
|
163
|
+
displayName: 'John Traore',
|
|
164
|
+
username: 'admin'
|
|
165
|
+
},
|
|
166
|
+
text: 'This is the second comment',
|
|
167
|
+
id: 'commentid2'
|
|
168
|
+
}]
|
|
169
|
+
};
|
|
170
|
+
const newInterpretation = exports.newInterpretation = {
|
|
171
|
+
id: 'interpretation5',
|
|
172
|
+
text: 'This is a new interpretation for testing',
|
|
173
|
+
created: '2025-09-04T08:30:15.123',
|
|
174
|
+
createdBy: {
|
|
175
|
+
id: 'currentuserid',
|
|
176
|
+
code: null,
|
|
177
|
+
name: 'John Traore',
|
|
178
|
+
displayName: 'John Traore',
|
|
179
|
+
username: 'admin'
|
|
180
|
+
},
|
|
181
|
+
comments: [],
|
|
182
|
+
likes: 0,
|
|
183
|
+
access: {
|
|
184
|
+
manage: true,
|
|
185
|
+
write: true
|
|
186
|
+
},
|
|
187
|
+
likedBy: []
|
|
188
|
+
};
|
|
189
|
+
const newComment = exports.newComment = {
|
|
190
|
+
created: '2025-09-04T08:45:22.456',
|
|
191
|
+
createdBy: {
|
|
192
|
+
id: 'currentuserid',
|
|
193
|
+
code: null,
|
|
194
|
+
name: 'John Traore',
|
|
195
|
+
displayName: 'John Traore',
|
|
196
|
+
username: 'admin'
|
|
197
|
+
},
|
|
198
|
+
text: 'This is a new comment for testing',
|
|
199
|
+
id: 'commentid7'
|
|
200
|
+
};
|
|
201
|
+
const visualization = exports.visualization = {
|
|
202
|
+
id: 'viz123',
|
|
203
|
+
type: 'CHART'
|
|
204
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DashboardInterpretationThread = void 0;
|
|
7
|
+
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
9
|
+
var _ui = require("@dhis2/ui");
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _InterpretationThread = require("../InterpretationModal/InterpretationThread.js");
|
|
13
|
+
var _hooks = require("../InterpretationsProvider/hooks.js");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const DashboardInterpretationThread = ({
|
|
16
|
+
interpretationId,
|
|
17
|
+
onClose,
|
|
18
|
+
dashboardRedirectUrl,
|
|
19
|
+
initialFocus
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
data: interpretation,
|
|
23
|
+
loading,
|
|
24
|
+
error
|
|
25
|
+
} = (0, _hooks.useActiveInterpretation)(interpretationId);
|
|
26
|
+
if (loading) {
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Layer, null, /*#__PURE__*/_react.default.createElement(_ui.CenteredContent, null, /*#__PURE__*/_react.default.createElement(_ui.CircularLoader, null)));
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
+
className: "jsx-95761030" + " " + "container"
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
32
|
+
className: "jsx-95761030" + " " + "button-container"
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
34
|
+
small: true,
|
|
35
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconChevronLeft16, null),
|
|
36
|
+
onClick: onClose
|
|
37
|
+
}, _d2I18n.default.t('Back to all interpretations'))), error && /*#__PURE__*/_react.default.createElement(_ui.NoticeBox, {
|
|
38
|
+
error: true,
|
|
39
|
+
title: _d2I18n.default.t('Could not load interpretation details')
|
|
40
|
+
}, _d2I18n.default.t('The request to fetch interpretation comments failed')), interpretation && !error && /*#__PURE__*/_react.default.createElement(_InterpretationThread.InterpretationThread, {
|
|
41
|
+
loading: loading,
|
|
42
|
+
interpretation: interpretation,
|
|
43
|
+
onInterpretationDeleted: onClose,
|
|
44
|
+
initialFocus: initialFocus,
|
|
45
|
+
dashboardRedirectUrl: dashboardRedirectUrl
|
|
46
|
+
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
47
|
+
id: "95761030"
|
|
48
|
+
}, [".container.jsx-95761030{padding:var(--spacers-dp16) var(--spacers-dp16) var(--spacers-dp32) var(--spacers-dp16);}", ".button-container.jsx-95761030{margin-bottom:var(--spacers-dp8);}"]));
|
|
49
|
+
};
|
|
50
|
+
exports.DashboardInterpretationThread = DashboardInterpretationThread;
|
|
51
|
+
DashboardInterpretationThread.propTypes = {
|
|
52
|
+
interpretationId: _propTypes.default.string.isRequired,
|
|
53
|
+
onClose: _propTypes.default.func.isRequired,
|
|
54
|
+
dashboardRedirectUrl: _propTypes.default.string,
|
|
55
|
+
initialFocus: _propTypes.default.bool
|
|
56
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DashboardItemInterpretations = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _InterpretationsProvider = require("../InterpretationsProvider/InterpretationsProvider.js");
|
|
10
|
+
var _InterpretationsUnit = require("../InterpretationsUnit/InterpretationsUnit.js");
|
|
11
|
+
var _DashboardInterpretationThread = require("./DashboardInterpretationThread.js");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const DashboardItemInterpretations = ({
|
|
15
|
+
currentUser,
|
|
16
|
+
dashboardRedirectUrl,
|
|
17
|
+
id,
|
|
18
|
+
type
|
|
19
|
+
}) => {
|
|
20
|
+
const [activeInterpretationId, setActiveInterpretationId] = (0, _react.useState)(null);
|
|
21
|
+
const [initialFocus, setInitialFocus] = (0, _react.useState)(false);
|
|
22
|
+
const onInterpretationClick = (0, _react.useCallback)(interpretationId => {
|
|
23
|
+
setActiveInterpretationId(interpretationId);
|
|
24
|
+
}, []);
|
|
25
|
+
const onReplyIconClick = (0, _react.useCallback)(interpretationId => {
|
|
26
|
+
setActiveInterpretationId(interpretationId);
|
|
27
|
+
setInitialFocus(true);
|
|
28
|
+
}, []);
|
|
29
|
+
const onClose = (0, _react.useCallback)(() => {
|
|
30
|
+
setActiveInterpretationId(null);
|
|
31
|
+
setInitialFocus(false);
|
|
32
|
+
}, []);
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_InterpretationsProvider.InterpretationsProvider, {
|
|
34
|
+
currentUser: currentUser
|
|
35
|
+
}, activeInterpretationId ? /*#__PURE__*/_react.default.createElement(_DashboardInterpretationThread.DashboardInterpretationThread, {
|
|
36
|
+
interpretationId: activeInterpretationId,
|
|
37
|
+
onClose: onClose,
|
|
38
|
+
dashboardRedirectUrl: dashboardRedirectUrl,
|
|
39
|
+
initialFocus: initialFocus
|
|
40
|
+
}) : /*#__PURE__*/_react.default.createElement(_InterpretationsUnit.InterpretationsUnit, {
|
|
41
|
+
id: id,
|
|
42
|
+
type: type,
|
|
43
|
+
dashboardRedirectUrl: dashboardRedirectUrl,
|
|
44
|
+
onInterpretationClick: onInterpretationClick,
|
|
45
|
+
onReplyIconClick: onReplyIconClick
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
exports.DashboardItemInterpretations = DashboardItemInterpretations;
|
|
49
|
+
DashboardItemInterpretations.propTypes = {
|
|
50
|
+
currentUser: _propTypes.default.object.isRequired,
|
|
51
|
+
dashboardRedirectUrl: _propTypes.default.string.isRequired,
|
|
52
|
+
id: _propTypes.default.string.isRequired,
|
|
53
|
+
type: _propTypes.default.string.isRequired
|
|
54
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DashboardItemInterpretations", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _DashboardItemInterpretations.DashboardItemInterpretations;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _DashboardItemInterpretations = require("./DashboardItemInterpretations.js");
|
|
@@ -9,28 +9,28 @@ var _ui = require("@dhis2/ui");
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _index = require("../common/index.js");
|
|
12
|
+
var _hooks = require("../InterpretationsProvider/hooks.js");
|
|
12
13
|
var _CommentDeleteButton = require("./CommentDeleteButton.js");
|
|
13
14
|
var _CommentUpdateForm = require("./CommentUpdateForm.js");
|
|
14
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
const Comment = ({
|
|
17
18
|
comment,
|
|
18
|
-
currentUser,
|
|
19
|
-
interpretationId,
|
|
20
|
-
onThreadUpdated,
|
|
21
19
|
canComment
|
|
22
20
|
}) => {
|
|
23
21
|
const [isUpdateMode, setIsUpdateMode] = (0, _react.useState)(false);
|
|
24
|
-
const
|
|
22
|
+
const [commentText, setCommentText] = (0, _react.useState)(comment.text);
|
|
23
|
+
const onUpdateComplete = (0, _react.useCallback)(newText => {
|
|
24
|
+
setCommentText(newText);
|
|
25
|
+
setIsUpdateMode(false);
|
|
26
|
+
}, []);
|
|
27
|
+
const commentAccess = (0, _hooks.useCommentAccess)(comment, canComment);
|
|
25
28
|
return isUpdateMode ? /*#__PURE__*/_react.default.createElement(_CommentUpdateForm.CommentUpdateForm, {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onComplete: () => onThreadUpdated(false),
|
|
30
|
-
text: comment.text,
|
|
31
|
-
currentUser: currentUser
|
|
29
|
+
onComplete: onUpdateComplete,
|
|
30
|
+
id: comment.id,
|
|
31
|
+
text: comment.text
|
|
32
32
|
}) : /*#__PURE__*/_react.default.createElement(_index.Message, {
|
|
33
|
-
text:
|
|
33
|
+
text: commentText,
|
|
34
34
|
created: comment.created,
|
|
35
35
|
username: comment.createdBy.displayName
|
|
36
36
|
}, commentAccess.edit && /*#__PURE__*/_react.default.createElement(_index.MessageStatsBar, null, /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
@@ -38,16 +38,11 @@ const Comment = ({
|
|
|
38
38
|
tooltipContent: _d2I18n.default.t('Edit'),
|
|
39
39
|
onClick: () => setIsUpdateMode(true)
|
|
40
40
|
}), commentAccess.delete && /*#__PURE__*/_react.default.createElement(_CommentDeleteButton.CommentDeleteButton, {
|
|
41
|
-
|
|
42
|
-
interpretationId: interpretationId,
|
|
43
|
-
onComplete: () => onThreadUpdated(true)
|
|
41
|
+
id: comment.id
|
|
44
42
|
})));
|
|
45
43
|
};
|
|
46
44
|
exports.Comment = Comment;
|
|
47
45
|
Comment.propTypes = {
|
|
48
46
|
comment: _propTypes.default.object.isRequired,
|
|
49
|
-
currentUser: _propTypes.default.object.isRequired,
|
|
50
|
-
interpretationId: _propTypes.default.string.isRequired,
|
|
51
|
-
onThreadUpdated: _propTypes.default.func.isRequired,
|
|
52
47
|
canComment: _propTypes.default.bool
|
|
53
48
|
};
|
|
@@ -4,63 +4,52 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CommentAddForm = void 0;
|
|
7
|
-
var _appRuntime = require("@dhis2/app-runtime");
|
|
8
7
|
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
9
8
|
var _ui = require("@dhis2/ui");
|
|
10
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
11
|
var _index = require("../../RichText/index.js");
|
|
13
12
|
var _index2 = require("../common/index.js");
|
|
13
|
+
var _hooks = require("../InterpretationsProvider/hooks.js");
|
|
14
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
const CommentAddForm = ({
|
|
17
|
-
interpretationId,
|
|
18
|
-
currentUser,
|
|
19
|
-
onSave,
|
|
20
17
|
focusRef
|
|
21
18
|
}) => {
|
|
19
|
+
const currentUser = (0, _hooks.useInterpretationsCurrentUser)();
|
|
22
20
|
const [showRichTextEditor, setShowRichTextEditor] = (0, _react.useState)(false);
|
|
23
|
-
const [
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
commentText
|
|
29
|
-
}) => commentText
|
|
30
|
-
});
|
|
21
|
+
const [text, setText] = (0, _react.useState)('');
|
|
22
|
+
const closeForm = (0, _react.useCallback)(() => {
|
|
23
|
+
setShowRichTextEditor(false);
|
|
24
|
+
setText('');
|
|
25
|
+
}, []);
|
|
31
26
|
const [save, {
|
|
32
|
-
loading
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
onSave();
|
|
38
|
-
}
|
|
27
|
+
loading,
|
|
28
|
+
error
|
|
29
|
+
}] = (0, _hooks.useAddCommentToActiveInterpretation)({
|
|
30
|
+
text,
|
|
31
|
+
onComplete: closeForm
|
|
39
32
|
});
|
|
40
33
|
const inputPlaceholder = _d2I18n.default.t('Write a reply');
|
|
41
34
|
return /*#__PURE__*/_react.default.createElement(_index2.MessageEditorContainer, {
|
|
42
|
-
|
|
35
|
+
currentUserName: currentUser.name
|
|
43
36
|
}, showRichTextEditor ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.RichTextEditor, {
|
|
44
37
|
inputPlaceholder: inputPlaceholder,
|
|
45
|
-
onChange:
|
|
46
|
-
value:
|
|
38
|
+
onChange: setText,
|
|
39
|
+
value: text,
|
|
47
40
|
ref: focusRef,
|
|
48
|
-
disabled: loading
|
|
41
|
+
disabled: loading,
|
|
42
|
+
errorText: error ? _d2I18n.default.t('Could not post reply') : ''
|
|
49
43
|
}), /*#__PURE__*/_react.default.createElement(_index2.MessageButtonStrip, null, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
50
44
|
primary: true,
|
|
51
45
|
small: true,
|
|
52
|
-
onClick:
|
|
53
|
-
commentText
|
|
54
|
-
}),
|
|
46
|
+
onClick: save,
|
|
55
47
|
loading: loading
|
|
56
48
|
}, _d2I18n.default.t('Post reply')), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
57
49
|
secondary: true,
|
|
58
50
|
small: true,
|
|
59
51
|
disabled: loading,
|
|
60
|
-
onClick:
|
|
61
|
-
setCommentText('');
|
|
62
|
-
setShowRichTextEditor(false);
|
|
63
|
-
}
|
|
52
|
+
onClick: closeForm
|
|
64
53
|
}, _d2I18n.default.t('Cancel')))) : /*#__PURE__*/_react.default.createElement(_index2.MessageInput, {
|
|
65
54
|
onFocus: () => setShowRichTextEditor(true),
|
|
66
55
|
placeholder: inputPlaceholder,
|
|
@@ -69,8 +58,5 @@ const CommentAddForm = ({
|
|
|
69
58
|
};
|
|
70
59
|
exports.CommentAddForm = CommentAddForm;
|
|
71
60
|
CommentAddForm.propTypes = {
|
|
72
|
-
|
|
73
|
-
focusRef: _propTypes.default.object.isRequired,
|
|
74
|
-
interpretationId: _propTypes.default.string.isRequired,
|
|
75
|
-
onSave: _propTypes.default.func
|
|
61
|
+
focusRef: _propTypes.default.object.isRequired
|
|
76
62
|
};
|
|
@@ -5,62 +5,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.CommentDeleteButton = void 0;
|
|
7
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
|
-
var _appRuntime = require("@dhis2/app-runtime");
|
|
9
8
|
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
10
9
|
var _ui = require("@dhis2/ui");
|
|
11
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _react =
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
12
|
var _index = require("../common/index.js");
|
|
14
|
-
|
|
13
|
+
var _hooks = require("../InterpretationsProvider/hooks.js");
|
|
15
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
const mutation = {
|
|
17
|
-
resource: 'interpretations',
|
|
18
|
-
id: ({
|
|
19
|
-
interpretationId,
|
|
20
|
-
commentId
|
|
21
|
-
}) => `${interpretationId}/comments/${commentId}`,
|
|
22
|
-
type: 'delete'
|
|
23
|
-
};
|
|
24
15
|
const CommentDeleteButton = ({
|
|
25
|
-
|
|
26
|
-
interpretationId,
|
|
27
|
-
onComplete
|
|
16
|
+
id
|
|
28
17
|
}) => {
|
|
29
|
-
const [deleteError, setDeleteError] = (0, _react.useState)(null);
|
|
30
18
|
const [remove, {
|
|
31
|
-
loading
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onComplete();
|
|
36
|
-
},
|
|
37
|
-
onError: () => setDeleteError(_d2I18n.default.t('Delete failed')),
|
|
38
|
-
variables: {
|
|
39
|
-
commentId,
|
|
40
|
-
interpretationId
|
|
41
|
-
}
|
|
19
|
+
loading,
|
|
20
|
+
error
|
|
21
|
+
}] = (0, _hooks.useDeleteCommentFromActiveInterpretation)({
|
|
22
|
+
id
|
|
42
23
|
});
|
|
43
|
-
const onDelete = () => {
|
|
44
|
-
setDeleteError(null);
|
|
45
|
-
remove();
|
|
46
|
-
};
|
|
47
24
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
48
25
|
className: _style.default.dynamic([["945681082", [_ui.colors.red500]]]) + " " + "delete-button-container"
|
|
49
26
|
}, /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
50
27
|
tooltipContent: _d2I18n.default.t('Delete'),
|
|
51
28
|
iconComponent: _ui.IconDelete16,
|
|
52
|
-
onClick:
|
|
29
|
+
onClick: remove,
|
|
53
30
|
disabled: loading
|
|
54
|
-
}),
|
|
31
|
+
}), error && /*#__PURE__*/_react.default.createElement("span", {
|
|
55
32
|
className: _style.default.dynamic([["945681082", [_ui.colors.red500]]]) + " " + "delete-error"
|
|
56
|
-
},
|
|
33
|
+
}, _d2I18n.default.t('Could not delete comment')), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
57
34
|
id: "945681082",
|
|
58
35
|
dynamic: [_ui.colors.red500]
|
|
59
36
|
}, [".delete-button-container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:4px;}", `.delete-error.__jsx-style-dynamic-selector{color:${_ui.colors.red500};font-size:12px;line-height:12px;}`]));
|
|
60
37
|
};
|
|
61
38
|
exports.CommentDeleteButton = CommentDeleteButton;
|
|
62
39
|
CommentDeleteButton.propTypes = {
|
|
63
|
-
|
|
64
|
-
interpretationId: _propTypes.default.string.isRequired,
|
|
65
|
-
onComplete: _propTypes.default.func.isRequired
|
|
40
|
+
id: _propTypes.default.string.isRequired
|
|
66
41
|
};
|