@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
|
@@ -2,38 +2,29 @@ import i18n from '@dhis2/d2-i18n';
|
|
|
2
2
|
import { Button, SharingDialog, IconReply16, IconShare16, IconThumbUp16, IconEdit16, IconLaunch16, IconView16 } from '@dhis2/ui';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useInterpretation, useInterpretationAccess, useLike } from '../../InterpretationsProvider/hooks.js';
|
|
6
|
+
import { Message, MessageStatsBar, MessageIconButton } from '../index.js';
|
|
6
7
|
import { InterpretationDeleteButton } from './InterpretationDeleteButton.js';
|
|
7
8
|
import { InterpretationUpdateForm } from './InterpretationUpdateForm.js';
|
|
8
|
-
import { useLike } from './useLike.js';
|
|
9
9
|
export const Interpretation = ({
|
|
10
|
-
|
|
11
|
-
currentUser,
|
|
12
|
-
onClick,
|
|
13
|
-
onUpdated,
|
|
14
|
-
onDeleted,
|
|
15
|
-
disabled,
|
|
10
|
+
id,
|
|
16
11
|
onReplyIconClick,
|
|
17
12
|
dashboardRedirectUrl,
|
|
13
|
+
disabled,
|
|
18
14
|
isInThread,
|
|
19
|
-
|
|
15
|
+
onClick,
|
|
16
|
+
onDeleted
|
|
20
17
|
}) => {
|
|
18
|
+
const interpretation = useInterpretation(id);
|
|
19
|
+
const interpretationAccess = useInterpretationAccess(interpretation);
|
|
21
20
|
const [isUpdateMode, setIsUpdateMode] = useState(false);
|
|
22
21
|
const [showSharingDialog, setShowSharingDialog] = useState(false);
|
|
23
22
|
const {
|
|
24
23
|
toggleLike,
|
|
25
24
|
isLikedByCurrentUser,
|
|
26
25
|
toggleLikeInProgress
|
|
27
|
-
} = useLike(
|
|
28
|
-
interpretation,
|
|
29
|
-
currentUser,
|
|
30
|
-
onComplete: likedBy => onLikeToggled({
|
|
31
|
-
id: interpretation.id,
|
|
32
|
-
likedBy
|
|
33
|
-
})
|
|
34
|
-
});
|
|
26
|
+
} = useLike(id);
|
|
35
27
|
const shouldShowButton = Boolean(!!onClick && !disabled & !dashboardRedirectUrl);
|
|
36
|
-
const interpretationAccess = getInterpretationAccess(interpretation, currentUser);
|
|
37
28
|
let tooltip = i18n.t('Reply');
|
|
38
29
|
if (!interpretationAccess.comment) {
|
|
39
30
|
if (isInThread) {
|
|
@@ -48,14 +39,12 @@ export const Interpretation = ({
|
|
|
48
39
|
}
|
|
49
40
|
|
|
50
41
|
// Maps still uses old url style /?id= instead of hash
|
|
51
|
-
const getAppInterpretationUrl = () => dashboardRedirectUrl.includes('?') ? `${dashboardRedirectUrl}&interpretationId=${
|
|
42
|
+
const getAppInterpretationUrl = () => dashboardRedirectUrl.includes('?') ? `${dashboardRedirectUrl}&interpretationId=${id}` : `${dashboardRedirectUrl}?interpretationId=${id}`;
|
|
52
43
|
return isUpdateMode ? /*#__PURE__*/React.createElement(InterpretationUpdateForm, {
|
|
53
|
-
|
|
54
|
-
id:
|
|
44
|
+
onComplete: () => setIsUpdateMode(false),
|
|
45
|
+
id: id,
|
|
55
46
|
showSharingLink: interpretationAccess.share,
|
|
56
|
-
|
|
57
|
-
text: interpretation.text,
|
|
58
|
-
currentUser: currentUser
|
|
47
|
+
text: interpretation.text
|
|
59
48
|
}) : /*#__PURE__*/React.createElement(Message, {
|
|
60
49
|
text: interpretation.text,
|
|
61
50
|
created: interpretation.created,
|
|
@@ -71,14 +60,14 @@ export const Interpretation = ({
|
|
|
71
60
|
}), /*#__PURE__*/React.createElement(MessageIconButton, {
|
|
72
61
|
tooltipContent: tooltip,
|
|
73
62
|
iconComponent: IconReply16,
|
|
74
|
-
onClick: () => onReplyIconClick
|
|
63
|
+
onClick: () => onReplyIconClick === null || onReplyIconClick === void 0 ? void 0 : onReplyIconClick(id),
|
|
75
64
|
count: interpretation.comments.length,
|
|
76
65
|
dataTest: "interpretation-reply-button",
|
|
77
66
|
viewOnly: isInThread && !interpretationAccess.comment
|
|
78
67
|
}), dashboardRedirectUrl && !isInThread && /*#__PURE__*/React.createElement(MessageIconButton, {
|
|
79
68
|
tooltipContent: i18n.t('See interpretation'),
|
|
80
69
|
iconComponent: IconView16,
|
|
81
|
-
onClick: () => onClick(
|
|
70
|
+
onClick: () => onClick(id),
|
|
82
71
|
dataTest: "interpretation-view-button"
|
|
83
72
|
}), dashboardRedirectUrl && /*#__PURE__*/React.createElement(MessageIconButton, {
|
|
84
73
|
tooltipContent: i18n.t('Open in app'),
|
|
@@ -93,7 +82,7 @@ export const Interpretation = ({
|
|
|
93
82
|
}), showSharingDialog && /*#__PURE__*/React.createElement(SharingDialog, {
|
|
94
83
|
open: true,
|
|
95
84
|
type: 'interpretation',
|
|
96
|
-
id:
|
|
85
|
+
id: id,
|
|
97
86
|
onClose: () => setShowSharingDialog(false)
|
|
98
87
|
}), /*#__PURE__*/React.createElement(React.Fragment, null, interpretationAccess.edit && /*#__PURE__*/React.createElement(MessageIconButton, {
|
|
99
88
|
iconComponent: IconEdit16,
|
|
@@ -101,26 +90,23 @@ export const Interpretation = ({
|
|
|
101
90
|
onClick: () => setIsUpdateMode(true),
|
|
102
91
|
dataTest: "interpretation-edit-button"
|
|
103
92
|
}), interpretationAccess.delete && /*#__PURE__*/React.createElement(InterpretationDeleteButton, {
|
|
104
|
-
id:
|
|
93
|
+
id: id,
|
|
105
94
|
onComplete: onDeleted
|
|
106
95
|
}))), shouldShowButton && /*#__PURE__*/React.createElement(Button, {
|
|
107
96
|
secondary: true,
|
|
108
97
|
small: true,
|
|
109
98
|
onClick: (_, event) => {
|
|
110
99
|
event.stopPropagation();
|
|
111
|
-
onClick(
|
|
100
|
+
onClick(id);
|
|
112
101
|
}
|
|
113
102
|
}, i18n.t('See interpretation')));
|
|
114
103
|
};
|
|
115
104
|
Interpretation.propTypes = {
|
|
116
|
-
|
|
117
|
-
interpretation: PropTypes.object.isRequired,
|
|
118
|
-
onDeleted: PropTypes.func.isRequired,
|
|
119
|
-
onLikeToggled: PropTypes.func.isRequired,
|
|
105
|
+
id: PropTypes.string.isRequired,
|
|
120
106
|
onReplyIconClick: PropTypes.func.isRequired,
|
|
121
|
-
onUpdated: PropTypes.func.isRequired,
|
|
122
107
|
dashboardRedirectUrl: PropTypes.string,
|
|
123
108
|
disabled: PropTypes.bool,
|
|
124
109
|
isInThread: PropTypes.bool,
|
|
125
|
-
onClick: PropTypes.func
|
|
110
|
+
onClick: PropTypes.func,
|
|
111
|
+
onDeleted: PropTypes.func
|
|
126
112
|
};
|
package/build/es/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useAlert } from '@dhis2/app-runtime';
|
|
2
2
|
import i18n from '@dhis2/d2-i18n';
|
|
3
3
|
import { IconDelete16 } from '@dhis2/ui';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { useDeleteInterpretation } from '../../InterpretationsProvider/hooks.js';
|
|
6
7
|
import { MessageIconButton } from '../index.js';
|
|
7
|
-
const mutation = {
|
|
8
|
-
resource: 'interpretations',
|
|
9
|
-
id: ({
|
|
10
|
-
id
|
|
11
|
-
}) => id,
|
|
12
|
-
type: 'delete'
|
|
13
|
-
};
|
|
14
8
|
const InterpretationDeleteButton = ({
|
|
15
9
|
id,
|
|
16
10
|
onComplete
|
|
17
11
|
}) => {
|
|
12
|
+
const {
|
|
13
|
+
show: showErrorAlert
|
|
14
|
+
} = useAlert(i18n.t('Could not delete interpretation'), {
|
|
15
|
+
critical: true
|
|
16
|
+
});
|
|
18
17
|
const [remove, {
|
|
19
18
|
loading
|
|
20
|
-
}] =
|
|
19
|
+
}] = useDeleteInterpretation({
|
|
20
|
+
id,
|
|
21
21
|
onComplete,
|
|
22
|
-
|
|
23
|
-
id
|
|
24
|
-
}
|
|
22
|
+
showErrorAlert
|
|
25
23
|
});
|
|
26
24
|
return /*#__PURE__*/React.createElement(MessageIconButton, {
|
|
27
25
|
tooltipContent: i18n.t('Delete'),
|
|
@@ -33,6 +31,6 @@ const InterpretationDeleteButton = ({
|
|
|
33
31
|
};
|
|
34
32
|
InterpretationDeleteButton.propTypes = {
|
|
35
33
|
id: PropTypes.string.isRequired,
|
|
36
|
-
onComplete: PropTypes.func
|
|
34
|
+
onComplete: PropTypes.func
|
|
37
35
|
};
|
|
38
36
|
export { InterpretationDeleteButton };
|
package/build/es/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js
CHANGED
|
@@ -1,48 +1,39 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
import {
|
|
2
|
+
import { useAlert } from '@dhis2/app-runtime';
|
|
3
3
|
import i18n from '@dhis2/d2-i18n';
|
|
4
4
|
import { Button, spacers, colors } from '@dhis2/ui';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
import { RichTextEditor } from '../../../RichText/index.js';
|
|
8
|
+
import { useUpdateInterpretationText, useInterpretationsCurrentUser } from '../../InterpretationsProvider/hooks.js';
|
|
8
9
|
import { MessageEditorContainer, MessageButtonStrip, InterpretationSharingLink } from '../index.js';
|
|
9
|
-
const mutation = {
|
|
10
|
-
resource: 'interpretations',
|
|
11
|
-
type: 'update',
|
|
12
|
-
partial: false,
|
|
13
|
-
id: ({
|
|
14
|
-
id
|
|
15
|
-
}) => id,
|
|
16
|
-
data: ({
|
|
17
|
-
interpretationText
|
|
18
|
-
}) => interpretationText
|
|
19
|
-
};
|
|
20
10
|
export const InterpretationUpdateForm = ({
|
|
21
|
-
close,
|
|
22
|
-
currentUser,
|
|
23
11
|
id,
|
|
24
12
|
onComplete,
|
|
25
13
|
showSharingLink,
|
|
26
14
|
text
|
|
27
15
|
}) => {
|
|
16
|
+
const currentUser = useInterpretationsCurrentUser();
|
|
28
17
|
const [interpretationText, setInterpretationText] = useState(text || '');
|
|
18
|
+
const {
|
|
19
|
+
show: showErrorAlert
|
|
20
|
+
} = useAlert(i18n.t('Could not update interpretation text'), {
|
|
21
|
+
critical: true
|
|
22
|
+
});
|
|
29
23
|
const [update, {
|
|
30
24
|
loading,
|
|
31
25
|
error
|
|
32
|
-
}] =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
variables: {
|
|
38
|
-
id
|
|
39
|
-
}
|
|
26
|
+
}] = useUpdateInterpretationText({
|
|
27
|
+
id,
|
|
28
|
+
text: interpretationText,
|
|
29
|
+
onComplete,
|
|
30
|
+
onError: showErrorAlert
|
|
40
31
|
});
|
|
41
32
|
const errorText = error ? error.message || i18n.t('Could not update interpretation') : '';
|
|
42
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
43
34
|
className: _JSXStyle.dynamic([["2690082310", [spacers.dp8, spacers.dp8, colors.grey100]]]) + " " + "message"
|
|
44
35
|
}, /*#__PURE__*/React.createElement(MessageEditorContainer, {
|
|
45
|
-
|
|
36
|
+
currentUserName: currentUser.name
|
|
46
37
|
}, /*#__PURE__*/React.createElement(RichTextEditor, {
|
|
47
38
|
inputPlaceholder: i18n.t('Enter interpretation text'),
|
|
48
39
|
onChange: setInterpretationText,
|
|
@@ -70,8 +61,6 @@ export const InterpretationUpdateForm = ({
|
|
|
70
61
|
}, [`.message.__jsx-style-dynamic-selector{padding:0 ${spacers.dp8} ${spacers.dp8};background-color:${colors.grey100};border-radius:5px;}`]));
|
|
71
62
|
};
|
|
72
63
|
InterpretationUpdateForm.propTypes = {
|
|
73
|
-
close: PropTypes.func.isRequired,
|
|
74
|
-
currentUser: PropTypes.object.isRequired,
|
|
75
64
|
id: PropTypes.string.isRequired,
|
|
76
65
|
onComplete: PropTypes.func.isRequired,
|
|
77
66
|
showSharingLink: PropTypes.bool,
|
|
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
const MessageEditorContainer = ({
|
|
6
6
|
children,
|
|
7
|
-
|
|
7
|
+
currentUserName,
|
|
8
8
|
dataTest
|
|
9
9
|
}) => /*#__PURE__*/React.createElement("div", {
|
|
10
10
|
"data-test": dataTest,
|
|
@@ -12,7 +12,7 @@ const MessageEditorContainer = ({
|
|
|
12
12
|
}, /*#__PURE__*/React.createElement("div", {
|
|
13
13
|
className: _JSXStyle.dynamic([["969803715", [spacers.dp8, spacers.dp12]]]) + " " + "avatar"
|
|
14
14
|
}, /*#__PURE__*/React.createElement(UserAvatar, {
|
|
15
|
-
name:
|
|
15
|
+
name: currentUserName,
|
|
16
16
|
medium: true
|
|
17
17
|
})), /*#__PURE__*/React.createElement("div", {
|
|
18
18
|
className: _JSXStyle.dynamic([["969803715", [spacers.dp8, spacers.dp12]]]) + " " + "editor"
|
|
@@ -21,7 +21,7 @@ const MessageEditorContainer = ({
|
|
|
21
21
|
dynamic: [spacers.dp8, spacers.dp12]
|
|
22
22
|
}, [`.container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${spacers.dp8};margin-top:${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%;}"]));
|
|
23
23
|
MessageEditorContainer.propTypes = {
|
|
24
|
-
|
|
24
|
+
currentUserName: PropTypes.string.isRequired,
|
|
25
25
|
children: PropTypes.node,
|
|
26
26
|
dataTest: PropTypes.string
|
|
27
27
|
};
|
package/build/es/index.js
CHANGED
|
@@ -16,8 +16,10 @@ export { preparePayloadForSaveAs, preparePayloadForSave } from './components/Fil
|
|
|
16
16
|
export { default as VisTypeIcon } from './components/VisTypeIcon.js';
|
|
17
17
|
export { default as LegendKey } from './components/LegendKey/LegendKey.js';
|
|
18
18
|
export { default as AboutAOUnit } from './components/AboutAOUnit/AboutAOUnit.js';
|
|
19
|
+
export { DashboardItemInterpretations } from './components/Interpretations/DashboardItemInterpretations/index.js';
|
|
19
20
|
export { InterpretationsUnit } from './components/Interpretations/InterpretationsUnit/index.js';
|
|
20
|
-
export {
|
|
21
|
+
export { InterpretationsProvider } from './components/Interpretations/InterpretationsProvider/index.js';
|
|
22
|
+
export { InterpretationModal } from './components/Interpretations/InterpretationModal/index.js';
|
|
21
23
|
export * from './components/Toolbar/index.js';
|
|
22
24
|
export { TranslationDialog } from './components/TranslationDialog/index.js';
|
|
23
25
|
export { OfflineTooltip } from './components/OfflineTooltip.js';
|
|
@@ -164,10 +164,14 @@
|
|
|
164
164
|
"map": "map",
|
|
165
165
|
"visualization": "visualization",
|
|
166
166
|
"Untitled {{visualizationType}}, {{date}}": "Untitled {{visualizationType}}, {{date}}",
|
|
167
|
+
"Back to all interpretations": "Back to all interpretations",
|
|
168
|
+
"Could not load interpretation details": "Could not load interpretation details",
|
|
169
|
+
"The request to fetch interpretation comments failed": "The request to fetch interpretation comments failed",
|
|
167
170
|
"Edit": "Edit",
|
|
168
171
|
"Write a reply": "Write a reply",
|
|
172
|
+
"Could not post reply": "Could not post reply",
|
|
169
173
|
"Post reply": "Post reply",
|
|
170
|
-
"
|
|
174
|
+
"Could not delete comment": "Could not delete comment",
|
|
171
175
|
"Could not update comment": "Could not update comment",
|
|
172
176
|
"Enter comment text": "Enter comment text",
|
|
173
177
|
"Update": "Update",
|
|
@@ -176,9 +180,12 @@
|
|
|
176
180
|
"The interpretation couldn’t be displayed. Try again or contact your system administrator.": "The interpretation couldn’t be displayed. Try again or contact your system administrator.",
|
|
177
181
|
"Hide interpretation": "Hide interpretation",
|
|
178
182
|
"Write an interpretation": "Write an interpretation",
|
|
183
|
+
"Could not post interpretation": "Could not post interpretation",
|
|
179
184
|
"Other people viewing this interpretation in the future may see more data.": "Other people viewing this interpretation in the future may see more data.",
|
|
180
185
|
"Post interpretation": "Post interpretation",
|
|
181
186
|
"Interpretations": "Interpretations",
|
|
187
|
+
"Error loading interpretations": "Error loading interpretations",
|
|
188
|
+
"Could not load interpretations": "Could not load interpretations",
|
|
182
189
|
"Reply": "Reply",
|
|
183
190
|
"{{count}} replies": "{{count}} reply",
|
|
184
191
|
"{{count}} replies_plural": "{{count}} replies",
|
|
@@ -188,7 +195,9 @@
|
|
|
188
195
|
"See interpretation": "See interpretation",
|
|
189
196
|
"Open in app": "Open in app",
|
|
190
197
|
"Share": "Share",
|
|
198
|
+
"Could not delete interpretation": "Could not delete interpretation",
|
|
191
199
|
"Manage sharing": "Manage sharing",
|
|
200
|
+
"Could not update interpretation text": "Could not update interpretation text",
|
|
192
201
|
"Could not update interpretation": "Could not update interpretation",
|
|
193
202
|
"Enter interpretation text": "Enter interpretation text",
|
|
194
203
|
"Not available offline": "Not available offline",
|
package/package.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useLike = void 0;
|
|
7
|
-
var _appRuntime = require("@dhis2/app-runtime");
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
const useLike = ({
|
|
10
|
-
interpretation,
|
|
11
|
-
currentUser,
|
|
12
|
-
onComplete
|
|
13
|
-
}) => {
|
|
14
|
-
const resource = `interpretations/${interpretation.id}/like`;
|
|
15
|
-
const likeMutationRef = (0, _react.useRef)({
|
|
16
|
-
resource,
|
|
17
|
-
type: 'create'
|
|
18
|
-
});
|
|
19
|
-
const unlikeMutationRef = (0, _react.useRef)({
|
|
20
|
-
resource,
|
|
21
|
-
type: 'delete'
|
|
22
|
-
});
|
|
23
|
-
const [like, {
|
|
24
|
-
loading: likeLoading
|
|
25
|
-
}] = (0, _appRuntime.useDataMutation)(likeMutationRef.current, {
|
|
26
|
-
onComplete: () => {
|
|
27
|
-
const newLikedBy = interpretation.likedBy.concat({
|
|
28
|
-
id: currentUser.id
|
|
29
|
-
});
|
|
30
|
-
setIsLikedByCurrentUser(true);
|
|
31
|
-
onComplete(newLikedBy);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const [unlike, {
|
|
35
|
-
loading: unlikeLoading
|
|
36
|
-
}] = (0, _appRuntime.useDataMutation)(unlikeMutationRef.current, {
|
|
37
|
-
onComplete: () => {
|
|
38
|
-
const newLikedBy = interpretation.likedBy.filter(lb => lb.id !== currentUser.id);
|
|
39
|
-
setIsLikedByCurrentUser(false);
|
|
40
|
-
onComplete(newLikedBy);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
const [isLikedByCurrentUser, setIsLikedByCurrentUser] = (0, _react.useState)(false);
|
|
44
|
-
const toggleLike = () => {
|
|
45
|
-
isLikedByCurrentUser ? unlike() : like();
|
|
46
|
-
};
|
|
47
|
-
(0, _react.useEffect)(() => {
|
|
48
|
-
setIsLikedByCurrentUser(interpretation.likedBy.some(likedBy => likedBy.id === currentUser.id));
|
|
49
|
-
}, [currentUser, interpretation]);
|
|
50
|
-
return {
|
|
51
|
-
isLikedByCurrentUser,
|
|
52
|
-
toggleLike,
|
|
53
|
-
toggleLikeInProgress: likeLoading || unlikeLoading
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.useLike = useLike;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { useDataMutation } from '@dhis2/app-runtime';
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
const useLike = ({
|
|
4
|
-
interpretation,
|
|
5
|
-
currentUser,
|
|
6
|
-
onComplete
|
|
7
|
-
}) => {
|
|
8
|
-
const resource = `interpretations/${interpretation.id}/like`;
|
|
9
|
-
const likeMutationRef = useRef({
|
|
10
|
-
resource,
|
|
11
|
-
type: 'create'
|
|
12
|
-
});
|
|
13
|
-
const unlikeMutationRef = useRef({
|
|
14
|
-
resource,
|
|
15
|
-
type: 'delete'
|
|
16
|
-
});
|
|
17
|
-
const [like, {
|
|
18
|
-
loading: likeLoading
|
|
19
|
-
}] = useDataMutation(likeMutationRef.current, {
|
|
20
|
-
onComplete: () => {
|
|
21
|
-
const newLikedBy = interpretation.likedBy.concat({
|
|
22
|
-
id: currentUser.id
|
|
23
|
-
});
|
|
24
|
-
setIsLikedByCurrentUser(true);
|
|
25
|
-
onComplete(newLikedBy);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const [unlike, {
|
|
29
|
-
loading: unlikeLoading
|
|
30
|
-
}] = useDataMutation(unlikeMutationRef.current, {
|
|
31
|
-
onComplete: () => {
|
|
32
|
-
const newLikedBy = interpretation.likedBy.filter(lb => lb.id !== currentUser.id);
|
|
33
|
-
setIsLikedByCurrentUser(false);
|
|
34
|
-
onComplete(newLikedBy);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const [isLikedByCurrentUser, setIsLikedByCurrentUser] = useState(false);
|
|
38
|
-
const toggleLike = () => {
|
|
39
|
-
isLikedByCurrentUser ? unlike() : like();
|
|
40
|
-
};
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
setIsLikedByCurrentUser(interpretation.likedBy.some(likedBy => likedBy.id === currentUser.id));
|
|
43
|
-
}, [currentUser, interpretation]);
|
|
44
|
-
return {
|
|
45
|
-
isLikedByCurrentUser,
|
|
46
|
-
toggleLike,
|
|
47
|
-
toggleLikeInProgress: likeLoading || unlikeLoading
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export { useLike };
|