@dhis2/analytics 28.1.3 → 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/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/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
|
@@ -8,40 +8,31 @@ var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
|
8
8
|
var _ui = require("@dhis2/ui");
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _hooks = require("../../InterpretationsProvider/hooks.js");
|
|
11
12
|
var _index = require("../index.js");
|
|
12
13
|
var _InterpretationDeleteButton = require("./InterpretationDeleteButton.js");
|
|
13
14
|
var _InterpretationUpdateForm = require("./InterpretationUpdateForm.js");
|
|
14
|
-
var _useLike = require("./useLike.js");
|
|
15
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); }
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
const Interpretation = ({
|
|
18
|
-
|
|
19
|
-
currentUser,
|
|
20
|
-
onClick,
|
|
21
|
-
onUpdated,
|
|
22
|
-
onDeleted,
|
|
23
|
-
disabled,
|
|
18
|
+
id,
|
|
24
19
|
onReplyIconClick,
|
|
25
20
|
dashboardRedirectUrl,
|
|
21
|
+
disabled,
|
|
26
22
|
isInThread,
|
|
27
|
-
|
|
23
|
+
onClick,
|
|
24
|
+
onDeleted
|
|
28
25
|
}) => {
|
|
26
|
+
const interpretation = (0, _hooks.useInterpretation)(id);
|
|
27
|
+
const interpretationAccess = (0, _hooks.useInterpretationAccess)(interpretation);
|
|
29
28
|
const [isUpdateMode, setIsUpdateMode] = (0, _react.useState)(false);
|
|
30
29
|
const [showSharingDialog, setShowSharingDialog] = (0, _react.useState)(false);
|
|
31
30
|
const {
|
|
32
31
|
toggleLike,
|
|
33
32
|
isLikedByCurrentUser,
|
|
34
33
|
toggleLikeInProgress
|
|
35
|
-
} = (0,
|
|
36
|
-
interpretation,
|
|
37
|
-
currentUser,
|
|
38
|
-
onComplete: likedBy => onLikeToggled({
|
|
39
|
-
id: interpretation.id,
|
|
40
|
-
likedBy
|
|
41
|
-
})
|
|
42
|
-
});
|
|
34
|
+
} = (0, _hooks.useLike)(id);
|
|
43
35
|
const shouldShowButton = Boolean(!!onClick && !disabled & !dashboardRedirectUrl);
|
|
44
|
-
const interpretationAccess = (0, _index.getInterpretationAccess)(interpretation, currentUser);
|
|
45
36
|
let tooltip = _d2I18n.default.t('Reply');
|
|
46
37
|
if (!interpretationAccess.comment) {
|
|
47
38
|
if (isInThread) {
|
|
@@ -56,14 +47,12 @@ const Interpretation = ({
|
|
|
56
47
|
}
|
|
57
48
|
|
|
58
49
|
// Maps still uses old url style /?id= instead of hash
|
|
59
|
-
const getAppInterpretationUrl = () => dashboardRedirectUrl.includes('?') ? `${dashboardRedirectUrl}&interpretationId=${
|
|
50
|
+
const getAppInterpretationUrl = () => dashboardRedirectUrl.includes('?') ? `${dashboardRedirectUrl}&interpretationId=${id}` : `${dashboardRedirectUrl}?interpretationId=${id}`;
|
|
60
51
|
return isUpdateMode ? /*#__PURE__*/_react.default.createElement(_InterpretationUpdateForm.InterpretationUpdateForm, {
|
|
61
|
-
|
|
62
|
-
id:
|
|
52
|
+
onComplete: () => setIsUpdateMode(false),
|
|
53
|
+
id: id,
|
|
63
54
|
showSharingLink: interpretationAccess.share,
|
|
64
|
-
|
|
65
|
-
text: interpretation.text,
|
|
66
|
-
currentUser: currentUser
|
|
55
|
+
text: interpretation.text
|
|
67
56
|
}) : /*#__PURE__*/_react.default.createElement(_index.Message, {
|
|
68
57
|
text: interpretation.text,
|
|
69
58
|
created: interpretation.created,
|
|
@@ -79,14 +68,14 @@ const Interpretation = ({
|
|
|
79
68
|
}), /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
80
69
|
tooltipContent: tooltip,
|
|
81
70
|
iconComponent: _ui.IconReply16,
|
|
82
|
-
onClick: () => onReplyIconClick
|
|
71
|
+
onClick: () => onReplyIconClick === null || onReplyIconClick === void 0 ? void 0 : onReplyIconClick(id),
|
|
83
72
|
count: interpretation.comments.length,
|
|
84
73
|
dataTest: "interpretation-reply-button",
|
|
85
74
|
viewOnly: isInThread && !interpretationAccess.comment
|
|
86
75
|
}), dashboardRedirectUrl && !isInThread && /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
87
76
|
tooltipContent: _d2I18n.default.t('See interpretation'),
|
|
88
77
|
iconComponent: _ui.IconView16,
|
|
89
|
-
onClick: () => onClick(
|
|
78
|
+
onClick: () => onClick(id),
|
|
90
79
|
dataTest: "interpretation-view-button"
|
|
91
80
|
}), dashboardRedirectUrl && /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
92
81
|
tooltipContent: _d2I18n.default.t('Open in app'),
|
|
@@ -101,7 +90,7 @@ const Interpretation = ({
|
|
|
101
90
|
}), showSharingDialog && /*#__PURE__*/_react.default.createElement(_ui.SharingDialog, {
|
|
102
91
|
open: true,
|
|
103
92
|
type: 'interpretation',
|
|
104
|
-
id:
|
|
93
|
+
id: id,
|
|
105
94
|
onClose: () => setShowSharingDialog(false)
|
|
106
95
|
}), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, interpretationAccess.edit && /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
107
96
|
iconComponent: _ui.IconEdit16,
|
|
@@ -109,27 +98,24 @@ const Interpretation = ({
|
|
|
109
98
|
onClick: () => setIsUpdateMode(true),
|
|
110
99
|
dataTest: "interpretation-edit-button"
|
|
111
100
|
}), interpretationAccess.delete && /*#__PURE__*/_react.default.createElement(_InterpretationDeleteButton.InterpretationDeleteButton, {
|
|
112
|
-
id:
|
|
101
|
+
id: id,
|
|
113
102
|
onComplete: onDeleted
|
|
114
103
|
}))), shouldShowButton && /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
115
104
|
secondary: true,
|
|
116
105
|
small: true,
|
|
117
106
|
onClick: (_, event) => {
|
|
118
107
|
event.stopPropagation();
|
|
119
|
-
onClick(
|
|
108
|
+
onClick(id);
|
|
120
109
|
}
|
|
121
110
|
}, _d2I18n.default.t('See interpretation')));
|
|
122
111
|
};
|
|
123
112
|
exports.Interpretation = Interpretation;
|
|
124
113
|
Interpretation.propTypes = {
|
|
125
|
-
|
|
126
|
-
interpretation: _propTypes.default.object.isRequired,
|
|
127
|
-
onDeleted: _propTypes.default.func.isRequired,
|
|
128
|
-
onLikeToggled: _propTypes.default.func.isRequired,
|
|
114
|
+
id: _propTypes.default.string.isRequired,
|
|
129
115
|
onReplyIconClick: _propTypes.default.func.isRequired,
|
|
130
|
-
onUpdated: _propTypes.default.func.isRequired,
|
|
131
116
|
dashboardRedirectUrl: _propTypes.default.string,
|
|
132
117
|
disabled: _propTypes.default.bool,
|
|
133
118
|
isInThread: _propTypes.default.bool,
|
|
134
|
-
onClick: _propTypes.default.func
|
|
119
|
+
onClick: _propTypes.default.func,
|
|
120
|
+
onDeleted: _propTypes.default.func
|
|
135
121
|
};
|
package/build/cjs/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js
CHANGED
|
@@ -9,26 +9,24 @@ var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
|
9
9
|
var _ui = require("@dhis2/ui");
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _hooks = require("../../InterpretationsProvider/hooks.js");
|
|
12
13
|
var _index = require("../index.js");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
const mutation = {
|
|
15
|
-
resource: 'interpretations',
|
|
16
|
-
id: ({
|
|
17
|
-
id
|
|
18
|
-
}) => id,
|
|
19
|
-
type: 'delete'
|
|
20
|
-
};
|
|
21
15
|
const InterpretationDeleteButton = ({
|
|
22
16
|
id,
|
|
23
17
|
onComplete
|
|
24
18
|
}) => {
|
|
19
|
+
const {
|
|
20
|
+
show: showErrorAlert
|
|
21
|
+
} = (0, _appRuntime.useAlert)(_d2I18n.default.t('Could not delete interpretation'), {
|
|
22
|
+
critical: true
|
|
23
|
+
});
|
|
25
24
|
const [remove, {
|
|
26
25
|
loading
|
|
27
|
-
}] = (0,
|
|
26
|
+
}] = (0, _hooks.useDeleteInterpretation)({
|
|
27
|
+
id,
|
|
28
28
|
onComplete,
|
|
29
|
-
|
|
30
|
-
id
|
|
31
|
-
}
|
|
29
|
+
showErrorAlert
|
|
32
30
|
});
|
|
33
31
|
return /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
34
32
|
tooltipContent: _d2I18n.default.t('Delete'),
|
|
@@ -41,5 +39,5 @@ const InterpretationDeleteButton = ({
|
|
|
41
39
|
exports.InterpretationDeleteButton = InterpretationDeleteButton;
|
|
42
40
|
InterpretationDeleteButton.propTypes = {
|
|
43
41
|
id: _propTypes.default.string.isRequired,
|
|
44
|
-
onComplete: _propTypes.default.func
|
|
42
|
+
onComplete: _propTypes.default.func
|
|
45
43
|
};
|
package/build/cjs/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js
CHANGED
|
@@ -11,46 +11,37 @@ var _ui = require("@dhis2/ui");
|
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _index = require("../../../RichText/index.js");
|
|
14
|
+
var _hooks = require("../../InterpretationsProvider/hooks.js");
|
|
14
15
|
var _index2 = require("../index.js");
|
|
15
16
|
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); }
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
const mutation = {
|
|
18
|
-
resource: 'interpretations',
|
|
19
|
-
type: 'update',
|
|
20
|
-
partial: false,
|
|
21
|
-
id: ({
|
|
22
|
-
id
|
|
23
|
-
}) => id,
|
|
24
|
-
data: ({
|
|
25
|
-
interpretationText
|
|
26
|
-
}) => interpretationText
|
|
27
|
-
};
|
|
28
18
|
const InterpretationUpdateForm = ({
|
|
29
|
-
close,
|
|
30
|
-
currentUser,
|
|
31
19
|
id,
|
|
32
20
|
onComplete,
|
|
33
21
|
showSharingLink,
|
|
34
22
|
text
|
|
35
23
|
}) => {
|
|
24
|
+
const currentUser = (0, _hooks.useInterpretationsCurrentUser)();
|
|
36
25
|
const [interpretationText, setInterpretationText] = (0, _react.useState)(text || '');
|
|
26
|
+
const {
|
|
27
|
+
show: showErrorAlert
|
|
28
|
+
} = (0, _appRuntime.useAlert)(_d2I18n.default.t('Could not update interpretation text'), {
|
|
29
|
+
critical: true
|
|
30
|
+
});
|
|
37
31
|
const [update, {
|
|
38
32
|
loading,
|
|
39
33
|
error
|
|
40
|
-
}] = (0,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
variables: {
|
|
46
|
-
id
|
|
47
|
-
}
|
|
34
|
+
}] = (0, _hooks.useUpdateInterpretationText)({
|
|
35
|
+
id,
|
|
36
|
+
text: interpretationText,
|
|
37
|
+
onComplete,
|
|
38
|
+
onError: showErrorAlert
|
|
48
39
|
});
|
|
49
40
|
const errorText = error ? error.message || _d2I18n.default.t('Could not update interpretation') : '';
|
|
50
41
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
51
42
|
className: _style.default.dynamic([["2690082310", [_ui.spacers.dp8, _ui.spacers.dp8, _ui.colors.grey100]]]) + " " + "message"
|
|
52
43
|
}, /*#__PURE__*/_react.default.createElement(_index2.MessageEditorContainer, {
|
|
53
|
-
|
|
44
|
+
currentUserName: currentUser.name
|
|
54
45
|
}, /*#__PURE__*/_react.default.createElement(_index.RichTextEditor, {
|
|
55
46
|
inputPlaceholder: _d2I18n.default.t('Enter interpretation text'),
|
|
56
47
|
onChange: setInterpretationText,
|
|
@@ -79,8 +70,6 @@ const InterpretationUpdateForm = ({
|
|
|
79
70
|
};
|
|
80
71
|
exports.InterpretationUpdateForm = InterpretationUpdateForm;
|
|
81
72
|
InterpretationUpdateForm.propTypes = {
|
|
82
|
-
close: _propTypes.default.func.isRequired,
|
|
83
|
-
currentUser: _propTypes.default.object.isRequired,
|
|
84
73
|
id: _propTypes.default.string.isRequired,
|
|
85
74
|
onComplete: _propTypes.default.func.isRequired,
|
|
86
75
|
showSharingLink: _propTypes.default.bool,
|
|
@@ -11,7 +11,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
const MessageEditorContainer = ({
|
|
13
13
|
children,
|
|
14
|
-
|
|
14
|
+
currentUserName,
|
|
15
15
|
dataTest
|
|
16
16
|
}) => /*#__PURE__*/_react.default.createElement("div", {
|
|
17
17
|
"data-test": dataTest,
|
|
@@ -19,7 +19,7 @@ const MessageEditorContainer = ({
|
|
|
19
19
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
20
20
|
className: _style.default.dynamic([["969803715", [_ui.spacers.dp8, _ui.spacers.dp12]]]) + " " + "avatar"
|
|
21
21
|
}, /*#__PURE__*/_react.default.createElement(_ui.UserAvatar, {
|
|
22
|
-
name:
|
|
22
|
+
name: currentUserName,
|
|
23
23
|
medium: true
|
|
24
24
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
25
25
|
className: _style.default.dynamic([["969803715", [_ui.spacers.dp8, _ui.spacers.dp12]]]) + " " + "editor"
|
|
@@ -29,7 +29,7 @@ const MessageEditorContainer = ({
|
|
|
29
29
|
}, [`.container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${_ui.spacers.dp8};margin-top:${_ui.spacers.dp12};}`, ".avatar.__jsx-style-dynamic-selector{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;}", ".editor.__jsx-style-dynamic-selector{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;height:100%;}"]));
|
|
30
30
|
exports.MessageEditorContainer = MessageEditorContainer;
|
|
31
31
|
MessageEditorContainer.propTypes = {
|
|
32
|
-
|
|
32
|
+
currentUserName: _propTypes.default.string.isRequired,
|
|
33
33
|
children: _propTypes.default.node,
|
|
34
34
|
dataTest: _propTypes.default.string
|
|
35
35
|
};
|