@dhis2/analytics 999.9.9-TE-alpha.3 → 999.9.9-interpretations-for-dashboard.alpha.2
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/api/analytics/Analytics.js +0 -7
- package/build/cjs/api/analytics/AnalyticsBase.js +6 -24
- package/build/cjs/api/analytics/AnalyticsRequest.js +10 -33
- package/build/cjs/api/analytics/AnalyticsRequestBase.js +1 -3
- package/build/cjs/api/analytics/AnalyticsRequestPropertiesMixin.js +0 -19
- package/build/cjs/api/analytics/__tests__/AnalyticsTrackedEntities.spec.js +44 -0
- package/build/cjs/api/analytics/__tests__/__snapshots__/AnalyticsTrackedEntities.spec.js.snap +3 -0
- package/build/cjs/api/analytics/utils.js +2 -23
- package/build/cjs/components/Interpretations/InterpretationModal/InterpretationThread.js +13 -9
- package/build/cjs/components/Interpretations/InterpretationModal/index.js +8 -1
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationList.js +5 -2
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +5 -2
- package/build/cjs/components/Interpretations/common/Interpretation/Interpretation.js +16 -1
- package/build/cjs/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js +2 -2
- package/build/cjs/components/RichText/Editor.bk/Editor.js +40 -0
- package/build/cjs/components/RichText/Editor.bk/__tests__/Editor.spec.js +29 -0
- package/build/cjs/components/RichText/Editor.bk/__tests__/convertCtrlKey.spec.js +205 -0
- package/build/cjs/components/RichText/Editor.bk/convertCtrlKey.js +87 -0
- package/build/cjs/components/RichText/Parser.bk/MdParser.js +107 -0
- package/build/cjs/components/RichText/Parser.bk/Parser.js +34 -0
- package/build/cjs/components/RichText/Parser.bk/__tests__/MdParser.spec.js +34 -0
- package/build/cjs/components/RichText/Parser.bk/__tests__/Parser.spec.js +41 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuDropdown.js +3 -1
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuDropdown.spec.js +8 -0
- package/build/cjs/index.js +61 -54
- package/build/cjs/locales/cs/translations.json +2 -1
- package/build/cjs/locales/en/translations.json +2 -1
- package/build/cjs/locales/es/translations.json +10 -9
- package/build/cjs/locales/es_419/translations.json +12 -6
- package/build/cjs/locales/fr/translations.json +10 -9
- package/build/cjs/locales/id/translations.json +5 -4
- package/build/cjs/locales/nl/translations.json +3 -2
- package/build/cjs/locales/pt/translations.json +10 -9
- package/build/cjs/locales/pt_BR/translations.json +19 -13
- package/build/cjs/locales/sv/translations.json +8 -2
- package/build/cjs/locales/vi/translations.json +2 -1
- package/build/cjs/locales/zh/translations.json +7 -7
- package/build/cjs/modules/layout/axisGetDimensionIds.js +1 -1
- package/build/cjs/modules/layout/dimension.js +2 -9
- package/build/cjs/modules/layout/dimensionCreate.js +0 -3
- package/build/cjs/modules/layout/dimensionGetId.js +3 -9
- package/build/cjs/modules/layout/layoutFilterDimensions.js +1 -1
- package/build/cjs/modules/layout/layoutGetAxisIdDimensionIdsObject.js +1 -1
- package/build/cjs/modules/layout/layoutGetDimensionIdItemIdsObject.js +1 -1
- package/build/cjs/modules/layout/layoutHasDynamicDimension.js +1 -1
- package/build/es/api/analytics/Analytics.js +0 -7
- package/build/es/api/analytics/AnalyticsBase.js +6 -24
- package/build/es/api/analytics/AnalyticsRequest.js +10 -33
- package/build/es/api/analytics/AnalyticsRequestBase.js +1 -3
- package/build/es/api/analytics/AnalyticsRequestPropertiesMixin.js +0 -19
- package/build/es/api/analytics/__tests__/AnalyticsTrackedEntities.spec.js +41 -0
- package/build/es/api/analytics/__tests__/__snapshots__/AnalyticsTrackedEntities.spec.js.snap +3 -0
- package/build/es/api/analytics/utils.js +1 -20
- package/build/es/components/Interpretations/InterpretationModal/InterpretationThread.js +13 -9
- package/build/es/components/Interpretations/InterpretationModal/index.js +2 -1
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationList.js +5 -2
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +5 -2
- package/build/es/components/Interpretations/common/Interpretation/Interpretation.js +17 -2
- package/build/es/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js +2 -2
- package/build/es/components/RichText/Editor.bk/Editor.js +30 -0
- package/build/es/components/RichText/Editor.bk/__tests__/Editor.spec.js +26 -0
- package/build/es/components/RichText/Editor.bk/__tests__/convertCtrlKey.spec.js +202 -0
- package/build/es/components/RichText/Editor.bk/convertCtrlKey.js +80 -0
- package/build/es/components/RichText/Parser.bk/MdParser.js +99 -0
- package/build/es/components/RichText/Parser.bk/Parser.js +24 -0
- package/build/es/components/RichText/Parser.bk/__tests__/MdParser.spec.js +31 -0
- package/build/es/components/RichText/Parser.bk/__tests__/Parser.spec.js +38 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuDropdown.js +3 -1
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuDropdown.spec.js +8 -0
- package/build/es/index.js +2 -2
- package/build/es/locales/cs/translations.json +2 -1
- package/build/es/locales/en/translations.json +2 -1
- package/build/es/locales/es/translations.json +10 -9
- package/build/es/locales/es_419/translations.json +12 -6
- package/build/es/locales/fr/translations.json +10 -9
- package/build/es/locales/id/translations.json +5 -4
- package/build/es/locales/nl/translations.json +3 -2
- package/build/es/locales/pt/translations.json +10 -9
- package/build/es/locales/pt_BR/translations.json +19 -13
- package/build/es/locales/sv/translations.json +8 -2
- package/build/es/locales/vi/translations.json +2 -1
- package/build/es/locales/zh/translations.json +7 -7
- package/build/es/modules/layout/axisGetDimensionIds.js +1 -1
- package/build/es/modules/layout/dimension.js +1 -7
- package/build/es/modules/layout/dimensionCreate.js +1 -4
- package/build/es/modules/layout/dimensionGetId.js +4 -10
- package/build/es/modules/layout/layoutFilterDimensions.js +1 -1
- package/build/es/modules/layout/layoutGetAxisIdDimensionIdsObject.js +1 -1
- package/build/es/modules/layout/layoutGetDimensionIdItemIdsObject.js +1 -1
- package/build/es/modules/layout/layoutHasDynamicDimension.js +1 -1
- package/package.json +1 -1
- package/build/cjs/api/analytics/AnalyticsTrackedEntities.js +0 -31
- package/build/es/api/analytics/AnalyticsTrackedEntities.js +0 -24
|
@@ -9,7 +9,6 @@ var _AnalyticsEnrollments = _interopRequireDefault(require("./AnalyticsEnrollmen
|
|
|
9
9
|
var _AnalyticsEvents = _interopRequireDefault(require("./AnalyticsEvents.js"));
|
|
10
10
|
var _AnalyticsRequest = _interopRequireDefault(require("./AnalyticsRequest.js"));
|
|
11
11
|
var _AnalyticsResponse = _interopRequireDefault(require("./AnalyticsResponse.js"));
|
|
12
|
-
var _AnalyticsTrackedEntities = _interopRequireDefault(require("./AnalyticsTrackedEntities.js"));
|
|
13
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
13
|
/**
|
|
15
14
|
* @module analytics
|
|
@@ -20,8 +19,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
19
|
* Analytics class used to request analytics data from Web API.
|
|
21
20
|
*
|
|
22
21
|
* @requires analytics.AnalyticsAggregate
|
|
23
|
-
* @requires analytics.AnalyticsTrackedEntities
|
|
24
|
-
* @requires analytics.AnalyticsEnrollments
|
|
25
22
|
* @requires analytics.AnalyticsEvents
|
|
26
23
|
* @requires analytics.AnalyticsRequest
|
|
27
24
|
* @requires analytics.AnalyticsResponse
|
|
@@ -41,7 +38,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
41
38
|
class Analytics {
|
|
42
39
|
/**
|
|
43
40
|
* @param {!module:analytics.AnalyticsAggregate} analyticsAggregate The AnalyticsAggregate instance
|
|
44
|
-
* @param {!module:analytics.AnalyticsTrackedEntities} analyticsTrackedEntities The AnalyticsTrackedEntities instance
|
|
45
41
|
* @param {!module:analytics.AnalyticsEnrollments} analyticsEnrollments The AnalyticsEnrollments instance
|
|
46
42
|
* @param {!module:analytics.AnalyticsEvents} analyticsEvents The AnalyticsEvents instance
|
|
47
43
|
* @param {!module:analytics.AnalyticsRequest} analyticsRequest The AnalyticsRequest class
|
|
@@ -50,14 +46,12 @@ class Analytics {
|
|
|
50
46
|
constructor(_ref) {
|
|
51
47
|
let {
|
|
52
48
|
aggregate,
|
|
53
|
-
trackedEntities,
|
|
54
49
|
enrollments,
|
|
55
50
|
events,
|
|
56
51
|
request,
|
|
57
52
|
response
|
|
58
53
|
} = _ref;
|
|
59
54
|
this.aggregate = aggregate;
|
|
60
|
-
this.trackedEntities = trackedEntities;
|
|
61
55
|
this.enrollments = enrollments;
|
|
62
56
|
this.events = events;
|
|
63
57
|
this.request = request;
|
|
@@ -80,7 +74,6 @@ class Analytics {
|
|
|
80
74
|
if (!Analytics.getAnalytics.analytics) {
|
|
81
75
|
Analytics.getAnalytics.analytics = new Analytics({
|
|
82
76
|
aggregate: new _AnalyticsAggregate.default(dataEngine),
|
|
83
|
-
trackedEntities: new _AnalyticsTrackedEntities.default(dataEngine),
|
|
84
77
|
enrollments: new _AnalyticsEnrollments.default(dataEngine),
|
|
85
78
|
events: new _AnalyticsEvents.default(dataEngine),
|
|
86
79
|
request: _AnalyticsRequest.default,
|
|
@@ -6,21 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
|
|
8
8
|
var _AnalyticsRequest = _interopRequireDefault(require("./AnalyticsRequest.js"));
|
|
9
|
-
var _utils = require("./utils.js");
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
10
|
const analyticsQuery = {
|
|
12
11
|
resource: 'analytics',
|
|
13
12
|
id: _ref => {
|
|
14
13
|
let {
|
|
15
14
|
path,
|
|
16
|
-
program
|
|
17
|
-
trackedEntityType
|
|
15
|
+
program
|
|
18
16
|
} = _ref;
|
|
19
|
-
return
|
|
20
|
-
path,
|
|
21
|
-
program,
|
|
22
|
-
trackedEntityType
|
|
23
|
-
});
|
|
17
|
+
return [path, program].filter(Boolean).join('/');
|
|
24
18
|
},
|
|
25
19
|
params: _ref2 => {
|
|
26
20
|
let {
|
|
@@ -40,14 +34,9 @@ const analyticsDataQuery = {
|
|
|
40
34
|
id: _ref3 => {
|
|
41
35
|
let {
|
|
42
36
|
path,
|
|
43
|
-
program
|
|
44
|
-
trackedEntityType
|
|
37
|
+
program
|
|
45
38
|
} = _ref3;
|
|
46
|
-
return
|
|
47
|
-
path,
|
|
48
|
-
program,
|
|
49
|
-
trackedEntityType
|
|
50
|
-
});
|
|
39
|
+
return [path, program].filter(Boolean).join('/');
|
|
51
40
|
},
|
|
52
41
|
params: _ref4 => {
|
|
53
42
|
let {
|
|
@@ -69,14 +58,9 @@ const analyticsMetaDataQuery = {
|
|
|
69
58
|
id: _ref5 => {
|
|
70
59
|
let {
|
|
71
60
|
path,
|
|
72
|
-
program
|
|
73
|
-
trackedEntityType
|
|
61
|
+
program
|
|
74
62
|
} = _ref5;
|
|
75
|
-
return
|
|
76
|
-
path,
|
|
77
|
-
program,
|
|
78
|
-
trackedEntityType
|
|
79
|
-
});
|
|
63
|
+
return [path, program].filter(Boolean).join('/');
|
|
80
64
|
},
|
|
81
65
|
params: _ref6 => {
|
|
82
66
|
let {
|
|
@@ -168,7 +152,6 @@ class AnalyticsBase {
|
|
|
168
152
|
variables: {
|
|
169
153
|
path: req.path,
|
|
170
154
|
program: req.program,
|
|
171
|
-
trackedEntityType: req.trackedEntityType,
|
|
172
155
|
dimensions: generateDimensionStrings(req.dimensions),
|
|
173
156
|
filters: generateDimensionStrings(req.filters),
|
|
174
157
|
parameters: req.parameters,
|
|
@@ -211,7 +194,6 @@ class AnalyticsBase {
|
|
|
211
194
|
variables: {
|
|
212
195
|
path: req.path,
|
|
213
196
|
program: req.program,
|
|
214
|
-
trackedEntityType: req.trackedEntityType,
|
|
215
197
|
dimensions: generateDimensionStrings(req.dimensions, options),
|
|
216
198
|
filters: generateDimensionStrings(req.filters, options),
|
|
217
199
|
parameters: req.parameters
|
|
@@ -10,7 +10,6 @@ var _AnalyticsRequestBase = _interopRequireDefault(require("./AnalyticsRequestBa
|
|
|
10
10
|
var _AnalyticsRequestDimensionsMixin = _interopRequireDefault(require("./AnalyticsRequestDimensionsMixin.js"));
|
|
11
11
|
var _AnalyticsRequestFiltersMixin = _interopRequireDefault(require("./AnalyticsRequestFiltersMixin.js"));
|
|
12
12
|
var _AnalyticsRequestPropertiesMixin = _interopRequireDefault(require("./AnalyticsRequestPropertiesMixin.js"));
|
|
13
|
-
var _utils = require("./utils.js");
|
|
14
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
14
|
/**
|
|
16
15
|
* @description
|
|
@@ -48,7 +47,6 @@ class AnalyticsRequest extends (0, _AnalyticsRequestDimensionsMixin.default)((0,
|
|
|
48
47
|
fromVisualization(visualization) {
|
|
49
48
|
let passFilterAsDimension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
50
49
|
let request = this;
|
|
51
|
-
const outputType = visualization.outputType;
|
|
52
50
|
|
|
53
51
|
// extract dimensions from visualization
|
|
54
52
|
const columns = visualization.columns || [];
|
|
@@ -59,28 +57,19 @@ class AnalyticsRequest extends (0, _AnalyticsRequestDimensionsMixin.default)((0,
|
|
|
59
57
|
if ((_d$legendSet = d.legendSet) !== null && _d$legendSet !== void 0 && _d$legendSet.id) {
|
|
60
58
|
dimension += `-${d.legendSet.id}`;
|
|
61
59
|
}
|
|
60
|
+
if ((_d$programStage = d.programStage) !== null && _d$programStage !== void 0 && _d$programStage.id) {
|
|
61
|
+
dimension = `${d.programStage.id}.${dimension}`;
|
|
62
|
+
}
|
|
62
63
|
if (d.filter) {
|
|
63
64
|
dimension += `:${d.filter}`;
|
|
64
65
|
}
|
|
65
|
-
const programStageId = (_d$programStage = d.programStage) === null || _d$programStage === void 0 ? void 0 : _d$programStage.id;
|
|
66
66
|
if ((_d$repetition = d.repetition) !== null && _d$repetition !== void 0 && (_d$repetition$indexes = _d$repetition.indexes) !== null && _d$repetition$indexes !== void 0 && _d$repetition$indexes.length) {
|
|
67
67
|
d.repetition.indexes.forEach(index => {
|
|
68
|
-
|
|
69
|
-
request = request.addDimension((0, _utils.formatDimension)({
|
|
70
|
-
programId: (_d$program = d.program) === null || _d$program === void 0 ? void 0 : _d$program.id,
|
|
71
|
-
programStageId: `${programStageId}[${index}]`,
|
|
72
|
-
dimension,
|
|
73
|
-
outputType
|
|
74
|
-
}));
|
|
68
|
+
request = request.addDimension(dimension.replace(/\./, `[${index}].`));
|
|
75
69
|
});
|
|
76
70
|
} else {
|
|
77
|
-
var _d$
|
|
78
|
-
request = request.addDimension((0
|
|
79
|
-
programId: (_d$program2 = d.program) === null || _d$program2 === void 0 ? void 0 : _d$program2.id,
|
|
80
|
-
programStageId,
|
|
81
|
-
dimension,
|
|
82
|
-
outputType
|
|
83
|
-
}), (_d$items = d.items) === null || _d$items === void 0 ? void 0 : _d$items.map(item => item.id));
|
|
71
|
+
var _d$items;
|
|
72
|
+
request = request.addDimension(dimension, (_d$items = d.items) === null || _d$items === void 0 ? void 0 : _d$items.map(item => item.id));
|
|
84
73
|
}
|
|
85
74
|
});
|
|
86
75
|
|
|
@@ -95,29 +84,17 @@ class AnalyticsRequest extends (0, _AnalyticsRequestDimensionsMixin.default)((0,
|
|
|
95
84
|
request = request.addDimension(f.dimension, (_f$items = f.items) === null || _f$items === void 0 ? void 0 : _f$items.map(item => item.id));
|
|
96
85
|
} else {
|
|
97
86
|
var _f$programStage, _f$repetition, _f$repetition$indexes;
|
|
98
|
-
let filterString = f.dimension;
|
|
87
|
+
let filterString = (_f$programStage = f.programStage) !== null && _f$programStage !== void 0 && _f$programStage.id ? `${f.programStage.id}.${f.dimension}` : f.dimension;
|
|
99
88
|
if (f.filter) {
|
|
100
89
|
filterString += `:${f.filter}`;
|
|
101
90
|
}
|
|
102
|
-
const programStageId = (_f$programStage = f.programStage) === null || _f$programStage === void 0 ? void 0 : _f$programStage.id;
|
|
103
91
|
if ((_f$repetition = f.repetition) !== null && _f$repetition !== void 0 && (_f$repetition$indexes = _f$repetition.indexes) !== null && _f$repetition$indexes !== void 0 && _f$repetition$indexes.length) {
|
|
104
92
|
f.repetition.indexes.forEach(index => {
|
|
105
|
-
|
|
106
|
-
request = request.addFilter((0, _utils.formatDimension)({
|
|
107
|
-
programId: (_f$program = f.program) === null || _f$program === void 0 ? void 0 : _f$program.id,
|
|
108
|
-
programStageId: `${programStageId}[${index}]`,
|
|
109
|
-
dimension: filterString,
|
|
110
|
-
outputType
|
|
111
|
-
}));
|
|
93
|
+
request = request.addFilter(filterString.replace(/\./, `[${index}].`));
|
|
112
94
|
});
|
|
113
95
|
} else {
|
|
114
|
-
var _f$
|
|
115
|
-
request = request.addFilter((0
|
|
116
|
-
programId: (_f$program2 = f.program) === null || _f$program2 === void 0 ? void 0 : _f$program2.id,
|
|
117
|
-
programStageId,
|
|
118
|
-
dimension: filterString,
|
|
119
|
-
outputType
|
|
120
|
-
}), (_f$items2 = f.items) === null || _f$items2 === void 0 ? void 0 : _f$items2.map(item => item.id));
|
|
96
|
+
var _f$items2;
|
|
97
|
+
request = request.addFilter(filterString, (_f$items2 = f.items) === null || _f$items2 === void 0 ? void 0 : _f$items2.map(item => item.id));
|
|
121
98
|
}
|
|
122
99
|
}
|
|
123
100
|
});
|
|
@@ -24,7 +24,6 @@ class AnalyticsRequestBase {
|
|
|
24
24
|
format = 'json',
|
|
25
25
|
path,
|
|
26
26
|
program,
|
|
27
|
-
trackedEntityType,
|
|
28
27
|
dimensions = [],
|
|
29
28
|
filters = [],
|
|
30
29
|
parameters = {}
|
|
@@ -33,7 +32,6 @@ class AnalyticsRequestBase {
|
|
|
33
32
|
this.format = format.toLowerCase();
|
|
34
33
|
this.path = path;
|
|
35
34
|
this.program = program;
|
|
36
|
-
this.trackedEntityType = trackedEntityType;
|
|
37
35
|
this.dimensions = dimensions;
|
|
38
36
|
this.filters = filters;
|
|
39
37
|
this.parameters = {
|
|
@@ -72,7 +70,7 @@ class AnalyticsRequestBase {
|
|
|
72
70
|
}
|
|
73
71
|
return dimension;
|
|
74
72
|
});
|
|
75
|
-
const endPoint = [this.endPoint, this.path, this.program
|
|
73
|
+
const endPoint = [this.endPoint, this.path, this.program].filter(e => !!e).join('/');
|
|
76
74
|
return `${endPoint}.${this.format}?dimension=${encodedDimensions.join('&dimension=')}`;
|
|
77
75
|
}
|
|
78
76
|
|
|
@@ -497,25 +497,6 @@ class extends base {
|
|
|
497
497
|
return new _AnalyticsRequest.default(this);
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
/**
|
|
501
|
-
* Sets the tracked entity type for the request.
|
|
502
|
-
* It appends the tracked entity type id to the request's path.
|
|
503
|
-
*
|
|
504
|
-
* @param {!String} trackedEntityType The tracked entity type id
|
|
505
|
-
*
|
|
506
|
-
* @returns {AnalyticsRequest} A new instance of the class for chaining purposes
|
|
507
|
-
*
|
|
508
|
-
* @example
|
|
509
|
-
* const req = new analytics.request()
|
|
510
|
-
* .withTrackedEntityType('nEenWmSyUEp');
|
|
511
|
-
*/
|
|
512
|
-
withTrackedEntityType(trackedEntityType) {
|
|
513
|
-
if (trackedEntityType) {
|
|
514
|
-
this.trackedEntityType = trackedEntityType;
|
|
515
|
-
}
|
|
516
|
-
return new _AnalyticsRequest.default(this);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
500
|
/**
|
|
520
501
|
* Sets the program for the request.
|
|
521
502
|
* It appends the program id to the request's path.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _fixtures = _interopRequireDefault(require("../../../__fixtures__/fixtures.js"));
|
|
4
|
+
var _DataEngine = _interopRequireDefault(require("../__mocks__/DataEngine.js"));
|
|
5
|
+
var _AnalyticsRequest = _interopRequireDefault(require("../AnalyticsRequest.js"));
|
|
6
|
+
var _AnalyticsTrackedEntities = _interopRequireDefault(require("../AnalyticsTrackedEntities.js"));
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
describe.skip('analytics.trackedEntity', () => {
|
|
9
|
+
let enrollments;
|
|
10
|
+
let request;
|
|
11
|
+
let dataEngineMock;
|
|
12
|
+
let fixture;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
dataEngineMock = new _DataEngine.default();
|
|
15
|
+
_DataEngine.default.mockClear();
|
|
16
|
+
enrollments = new _AnalyticsTrackedEntities.default();
|
|
17
|
+
});
|
|
18
|
+
it('should not be allowed to be called without new', () => {
|
|
19
|
+
expect(() => (0, _AnalyticsTrackedEntities.default)()).toThrowErrorMatchingSnapshot();
|
|
20
|
+
});
|
|
21
|
+
it('should use the dataEngine object when it is passed', () => {
|
|
22
|
+
const dataEngineMockObject = {};
|
|
23
|
+
enrollments = new _AnalyticsTrackedEntities.default(dataEngineMockObject);
|
|
24
|
+
expect(enrollments.dataEngine).toBe(dataEngineMockObject);
|
|
25
|
+
});
|
|
26
|
+
describe('.getQuery()', () => {
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
enrollments = new _AnalyticsTrackedEntities.default(new _DataEngine.default());
|
|
29
|
+
request = new _AnalyticsRequest.default().addOrgUnitDimension('ImspTQPwCqd').addDimension('WZbXY0S00lP.de0FEHSIoxh').addDimension('WZbXY0S00lP.sWoqcoByYmD').addPeriodFilter('LAST_MONTH').withTrackedEntity('nEenWmSyUEp').withAsc('ENROLLMENTDATE').withOuMode('DESCENDANTS').withColumns('w75KJ2mc4zz').withPage(1).withPageSize(10);
|
|
30
|
+
fixture = _fixtures.default.get('/api/analytics/enrollments'); // XXX
|
|
31
|
+
|
|
32
|
+
dataEngineMock.query.mockReturnValue(Promise.resolve({
|
|
33
|
+
data: fixture
|
|
34
|
+
}));
|
|
35
|
+
});
|
|
36
|
+
it('should be a function', () => {
|
|
37
|
+
expect(enrollments.getQuery).toBeInstanceOf(Function);
|
|
38
|
+
});
|
|
39
|
+
it('should resolve a promise with data', () => enrollments.getQuery(request).then(data => {
|
|
40
|
+
expect(data.width).toEqual(fixture.width);
|
|
41
|
+
expect(data.height).toEqual(fixture.height);
|
|
42
|
+
}));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -3,31 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.customEncodeURIComponent = void 0;
|
|
7
7
|
// Define our very own special list of characters that we don't want to encode in the URI
|
|
8
8
|
const whitelistURI = ',&$=/;:';
|
|
9
9
|
const whitelistURICodes = whitelistURI.split('').map(c => encodeURIComponent(c));
|
|
10
10
|
const whitelistRegExp = new RegExp(`(?:${whitelistURICodes.join('|')})`, 'g');
|
|
11
11
|
const customEncodeURIComponent = uri => encodeURIComponent(uri).replace(whitelistRegExp, decodeURIComponent);
|
|
12
|
-
exports.customEncodeURIComponent = customEncodeURIComponent;
|
|
13
|
-
const formatRequestPath = _ref => {
|
|
14
|
-
let {
|
|
15
|
-
path,
|
|
16
|
-
program,
|
|
17
|
-
trackedEntityType
|
|
18
|
-
} = _ref;
|
|
19
|
-
return [path, program, trackedEntityType].filter(Boolean).join('/');
|
|
20
|
-
};
|
|
21
|
-
exports.formatRequestPath = formatRequestPath;
|
|
22
|
-
const formatDimension = _ref2 => {
|
|
23
|
-
let {
|
|
24
|
-
outputType,
|
|
25
|
-
programId,
|
|
26
|
-
programStageId,
|
|
27
|
-
dimension
|
|
28
|
-
} = _ref2;
|
|
29
|
-
return [
|
|
30
|
-
// XXX it would be clearer to have this consistent with what is sent in the request as for EVENT/ENROLLMENT
|
|
31
|
-
outputType === 'TRACKED_ENTITY_INSTANCE' ? programId : undefined, programStageId, dimension].filter(Boolean).join('.');
|
|
32
|
-
};
|
|
33
|
-
exports.formatDimension = formatDimension;
|
|
12
|
+
exports.customEncodeURIComponent = customEncodeURIComponent;
|
|
@@ -25,7 +25,8 @@ const InterpretationThread = _ref => {
|
|
|
25
25
|
onInterpretationDeleted,
|
|
26
26
|
initialFocus,
|
|
27
27
|
onThreadUpdated,
|
|
28
|
-
downloadMenuComponent: DownloadMenu
|
|
28
|
+
downloadMenuComponent: DownloadMenu,
|
|
29
|
+
dashboardRedirectUrl
|
|
29
30
|
} = _ref;
|
|
30
31
|
const {
|
|
31
32
|
fromServerDate
|
|
@@ -40,18 +41,19 @@ const InterpretationThread = _ref => {
|
|
|
40
41
|
}, [initialFocus]);
|
|
41
42
|
const interpretationAccess = (0, _index.getInterpretationAccess)(interpretation, currentUser);
|
|
42
43
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
-
className: "jsx-
|
|
44
|
-
fetching
|
|
44
|
+
className: "jsx-3292109121" + " " + ((0, _classnames.default)('container', {
|
|
45
|
+
fetching,
|
|
46
|
+
dashboard: !!dashboardRedirectUrl
|
|
45
47
|
}) || "")
|
|
46
48
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
47
|
-
className: "jsx-
|
|
49
|
+
className: "jsx-3292109121" + " " + 'title'
|
|
48
50
|
}, /*#__PURE__*/_react.default.createElement(_ui.IconClock16, {
|
|
49
51
|
color: _ui.colors.grey700
|
|
50
52
|
}), (0, _moment.default)(fromServerDate(interpretation.created)).format('LLL')), DownloadMenu && /*#__PURE__*/_react.default.createElement(DownloadMenu, {
|
|
51
53
|
relativePeriodDate: interpretation.created,
|
|
52
|
-
className: "jsx-
|
|
54
|
+
className: "jsx-3292109121"
|
|
53
55
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
54
|
-
className: "jsx-
|
|
56
|
+
className: "jsx-3292109121" + " " + 'thread'
|
|
55
57
|
}, /*#__PURE__*/_react.default.createElement(_index.Interpretation, {
|
|
56
58
|
currentUser: currentUser,
|
|
57
59
|
interpretation: interpretation,
|
|
@@ -61,9 +63,10 @@ const InterpretationThread = _ref => {
|
|
|
61
63
|
} : null,
|
|
62
64
|
onUpdated: () => onThreadUpdated(true),
|
|
63
65
|
onDeleted: onInterpretationDeleted,
|
|
66
|
+
dashboardRedirectUrl: dashboardRedirectUrl,
|
|
64
67
|
isInThread: true
|
|
65
68
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
-
className: "jsx-
|
|
69
|
+
className: "jsx-3292109121" + " " + 'comments'
|
|
67
70
|
}, interpretation.comments.map(comment => /*#__PURE__*/_react.default.createElement(_Comment.Comment, {
|
|
68
71
|
key: comment.id,
|
|
69
72
|
comment: comment,
|
|
@@ -77,8 +80,8 @@ const InterpretationThread = _ref => {
|
|
|
77
80
|
onSave: () => onThreadUpdated(true),
|
|
78
81
|
focusRef: focusRef
|
|
79
82
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
80
|
-
id: "
|
|
81
|
-
}, [".thread.jsx-
|
|
83
|
+
id: "3292109121"
|
|
84
|
+
}, [".thread.jsx-3292109121{margin-top:var(--spacers-dp16);overflow-y:auto;-webkit-scroll-behavior:smooth;-moz-scroll-behavior:smooth;-ms-scroll-behavior:smooth;scroll-behavior:smooth;}", ".dashboard.jsx-3292109121 .thread.jsx-3292109121{overflow-y:hidden;}", ".container.jsx-3292109121{position:relative;overflow:auto;max-height:calc(100vh - 285px);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".container.dashboard.jsx-3292109121{max-height:none;}", ".container.fetching.jsx-3292109121::before{content:'';position:absolute;inset:0px;background-color:rgba(255,255,255,0.8);}", ".container.fetching.jsx-3292109121::after{content:'';position:absolute;top:calc(50% - 12px);left:calc(50% - 12px);width:24px;height:24px;border-width:4px;border-style:solid;border-color:rgba(110,122,138,0.15) rgba(110,122,138,0.15) rgb(20,124,215);border-image:initial;border-radius:50%;-webkit-animation:1s linear 0s infinite normal none running rotation-jsx-3292109121;animation:1s linear 0s infinite normal none running rotation-jsx-3292109121;}", ".title.jsx-3292109121{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:var(--spacers-dp8);color:var(--colors-grey900);font-size:14px;line-height:18px;}", ".comments.jsx-3292109121{padding-left:16px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;padding-top:var(--spacers-dp4);gap:var(--spacers-dp4);}", "@-webkit-keyframes rotation-jsx-3292109121{0%{-webkit-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0);}100%{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}", "@keyframes rotation-jsx-3292109121{0%{-webkit-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0);}100%{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}"]));
|
|
82
85
|
};
|
|
83
86
|
exports.InterpretationThread = InterpretationThread;
|
|
84
87
|
InterpretationThread.propTypes = {
|
|
@@ -86,6 +89,7 @@ InterpretationThread.propTypes = {
|
|
|
86
89
|
fetching: _propTypes.default.bool.isRequired,
|
|
87
90
|
interpretation: _propTypes.default.object.isRequired,
|
|
88
91
|
onInterpretationDeleted: _propTypes.default.func.isRequired,
|
|
92
|
+
dashboardRedirectUrl: _propTypes.default.string,
|
|
89
93
|
downloadMenuComponent: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.func]),
|
|
90
94
|
initialFocus: _propTypes.default.bool,
|
|
91
95
|
onThreadUpdated: _propTypes.default.func
|
|
@@ -9,4 +9,11 @@ Object.defineProperty(exports, "InterpretationModal", {
|
|
|
9
9
|
return _InterpretationModal.InterpretationModal;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
Object.defineProperty(exports, "InterpretationThread", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _InterpretationThread.InterpretationThread;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _InterpretationModal = require("./InterpretationModal.js");
|
|
19
|
+
var _InterpretationThread = require("./InterpretationThread.js");
|
|
@@ -30,7 +30,8 @@ const InterpretationList = _ref => {
|
|
|
30
30
|
onInterpretationClick,
|
|
31
31
|
onReplyIconClick,
|
|
32
32
|
refresh,
|
|
33
|
-
disabled
|
|
33
|
+
disabled,
|
|
34
|
+
dashboardRedirectUrl
|
|
34
35
|
} = _ref;
|
|
35
36
|
const {
|
|
36
37
|
fromServerDate
|
|
@@ -67,7 +68,8 @@ const InterpretationList = _ref => {
|
|
|
67
68
|
onReplyIconClick: onReplyIconClick,
|
|
68
69
|
onDeleted: refresh,
|
|
69
70
|
onUpdated: refresh,
|
|
70
|
-
disabled: disabled
|
|
71
|
+
disabled: disabled,
|
|
72
|
+
dashboardRedirectUrl: dashboardRedirectUrl
|
|
71
73
|
}))))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
72
74
|
id: "4058400613",
|
|
73
75
|
dynamic: [_ui.spacers.dp8, _ui.spacers.dp8, _ui.spacers.dp16, _ui.colors.grey800, _ui.spacers.dp12, _ui.spacers.dp12, _ui.spacers.dp32, _ui.spacers.dp4]
|
|
@@ -80,5 +82,6 @@ InterpretationList.propTypes = {
|
|
|
80
82
|
refresh: _propTypes.default.func.isRequired,
|
|
81
83
|
onInterpretationClick: _propTypes.default.func.isRequired,
|
|
82
84
|
onReplyIconClick: _propTypes.default.func.isRequired,
|
|
85
|
+
dashboardRedirectUrl: _propTypes.default.string,
|
|
83
86
|
disabled: _propTypes.default.bool
|
|
84
87
|
};
|
|
@@ -40,7 +40,8 @@ const InterpretationsUnit = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
40
40
|
onInterpretationClick,
|
|
41
41
|
onReplyIconClick,
|
|
42
42
|
disabled,
|
|
43
|
-
renderId
|
|
43
|
+
renderId,
|
|
44
|
+
dashboardRedirectUrl
|
|
44
45
|
} = _ref2;
|
|
45
46
|
const [isExpanded, setIsExpanded] = (0, _react.useState)(true);
|
|
46
47
|
const showNoTimeDimensionHelpText = type === 'eventVisualization' && !visualizationHasTimeDimension;
|
|
@@ -103,7 +104,8 @@ const InterpretationsUnit = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
103
104
|
onInterpretationClick: onInterpretationClick,
|
|
104
105
|
onReplyIconClick: onReplyIconClick,
|
|
105
106
|
refresh: onCompleteAction,
|
|
106
|
-
disabled: disabled
|
|
107
|
+
disabled: disabled,
|
|
108
|
+
dashboardRedirectUrl: dashboardRedirectUrl
|
|
107
109
|
}))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
108
110
|
id: "4120713286",
|
|
109
111
|
dynamic: [_ui.spacers.dp16, _ui.colors.grey400, _ui.colors.white, _ui.spacers.dp32, _ui.colors.grey900]
|
|
@@ -119,6 +121,7 @@ InterpretationsUnit.propTypes = {
|
|
|
119
121
|
currentUser: _propTypes.default.object.isRequired,
|
|
120
122
|
id: _propTypes.default.string.isRequired,
|
|
121
123
|
type: _propTypes.default.string.isRequired,
|
|
124
|
+
dashboardRedirectUrl: _propTypes.default.string,
|
|
122
125
|
disabled: _propTypes.default.bool,
|
|
123
126
|
renderId: _propTypes.default.number,
|
|
124
127
|
visualizationHasTimeDimension: _propTypes.default.bool,
|
|
@@ -24,6 +24,7 @@ const Interpretation = _ref => {
|
|
|
24
24
|
onDeleted,
|
|
25
25
|
disabled,
|
|
26
26
|
onReplyIconClick,
|
|
27
|
+
dashboardRedirectUrl,
|
|
27
28
|
isInThread
|
|
28
29
|
} = _ref;
|
|
29
30
|
const [isUpdateMode, setIsUpdateMode] = (0, _react.useState)(false);
|
|
@@ -37,7 +38,7 @@ const Interpretation = _ref => {
|
|
|
37
38
|
currentUser,
|
|
38
39
|
onComplete: onUpdated
|
|
39
40
|
});
|
|
40
|
-
const shouldShowButton = !!onClick && !disabled;
|
|
41
|
+
const shouldShowButton = Boolean(!!onClick && !disabled & !dashboardRedirectUrl);
|
|
41
42
|
const interpretationAccess = (0, _index.getInterpretationAccess)(interpretation, currentUser);
|
|
42
43
|
let tooltip = _d2I18n.default.t('Reply');
|
|
43
44
|
if (!interpretationAccess.comment) {
|
|
@@ -51,6 +52,9 @@ const Interpretation = _ref => {
|
|
|
51
52
|
tooltip = _d2I18n.default.t('View replies');
|
|
52
53
|
}
|
|
53
54
|
}
|
|
55
|
+
|
|
56
|
+
// Maps still uses old url style /?id= instead of hash
|
|
57
|
+
const getAppInterpretationUrl = () => dashboardRedirectUrl.includes('?') ? `${dashboardRedirectUrl}&interpretationId=${interpretation.id}` : `${dashboardRedirectUrl}?interpretationId=${interpretation.id}`;
|
|
54
58
|
return isUpdateMode ? /*#__PURE__*/_react.default.createElement(_InterpretationUpdateForm.InterpretationUpdateForm, {
|
|
55
59
|
close: () => setIsUpdateMode(false),
|
|
56
60
|
id: interpretation.id,
|
|
@@ -77,6 +81,16 @@ const Interpretation = _ref => {
|
|
|
77
81
|
count: interpretation.comments.length,
|
|
78
82
|
dataTest: "interpretation-reply-button",
|
|
79
83
|
viewOnly: isInThread && !interpretationAccess.comment
|
|
84
|
+
}), dashboardRedirectUrl && !isInThread && /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
85
|
+
tooltipContent: _d2I18n.default.t('See interpretation'),
|
|
86
|
+
iconComponent: _ui.IconView16,
|
|
87
|
+
onClick: () => onClick(interpretation.id),
|
|
88
|
+
dataTest: "interpretation-view-button"
|
|
89
|
+
}), dashboardRedirectUrl && /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
90
|
+
tooltipContent: _d2I18n.default.t('Open in app'),
|
|
91
|
+
iconComponent: _ui.IconLaunch16,
|
|
92
|
+
onClick: () => window.open(getAppInterpretationUrl(), '_blank'),
|
|
93
|
+
dataTest: "interpretation-launch-in-app-button"
|
|
80
94
|
}), interpretationAccess.share && /*#__PURE__*/_react.default.createElement(_index.MessageIconButton, {
|
|
81
95
|
iconComponent: _ui.IconShare16,
|
|
82
96
|
tooltipContent: _d2I18n.default.t('Share'),
|
|
@@ -111,6 +125,7 @@ Interpretation.propTypes = {
|
|
|
111
125
|
onDeleted: _propTypes.default.func.isRequired,
|
|
112
126
|
onReplyIconClick: _propTypes.default.func.isRequired,
|
|
113
127
|
onUpdated: _propTypes.default.func.isRequired,
|
|
128
|
+
dashboardRedirectUrl: _propTypes.default.string,
|
|
114
129
|
disabled: _propTypes.default.bool,
|
|
115
130
|
isInThread: _propTypes.default.bool,
|
|
116
131
|
onClick: _propTypes.default.func
|
package/build/cjs/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js
CHANGED
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.tooltipAnchorClasses = exports.toolbarClasses = exports.mainClasses = exports.emojisPopoverClasses = void 0;
|
|
7
7
|
var _ui = require("@dhis2/ui");
|
|
8
|
-
const mainClasses = [".container.jsx-
|
|
8
|
+
const mainClasses = [".container.jsx-1273817287{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;width:100%;}", `.preview.jsx-1273817287{font-size:14px;line-height:19px;color:${_ui.colors.grey900};}`, `.textarea.jsx-1273817287{width:100%;box-sizing:border-box;padding:${_ui.spacers.dp8} ${_ui.spacers.dp12};color:${_ui.colors.grey900};background-color:${_ui.colors.white};border:1px solid ${_ui.colors.grey500};border-radius:3px;box-shadow:inset 0 0 0 1px rgba(102,113,123,0.15), inset 0 1px 2px 0 rgba(102,113,123,0.1);outline:0;font-size:14px;line-height:${_ui.spacers.dp16};-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}`, `.textarea.jsx-1273817287:focus{outline:none;box-shadow:0 0 0 3px ${_ui.theme.focus};width:calc(100% - 3px);}`, `.textarea.jsx-1273817287:disabled{background-color:${_ui.colors.grey100};border-color:${_ui.colors.grey500};color:${_ui.theme.disabled};cursor:not-allowed;}`];
|
|
9
9
|
exports.mainClasses = mainClasses;
|
|
10
|
-
mainClasses.__hash = "
|
|
10
|
+
mainClasses.__hash = "1273817287";
|
|
11
11
|
const toolbarClasses = [`.toolbar.jsx-2267496677{background:${_ui.colors.grey050};border-radius:3px;border:1px solid ${_ui.colors.grey300};margin-bottom:${_ui.spacers.dp4};}`, `.actionsWrapper.jsx-2267496677{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:${_ui.spacers.dp4};-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;padding:${_ui.spacers.dp4};}`, `.mainActions.jsx-2267496677{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${_ui.spacers.dp4};margin-top:${_ui.spacers.dp2};}`, ".sideActions.jsx-2267496677{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", `.previewWrapper.jsx-2267496677{margin:${_ui.spacers.dp4};text-align:right;}`];
|
|
12
12
|
exports.toolbarClasses = toolbarClasses;
|
|
13
13
|
toolbarClasses.__hash = "2267496677";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _convertCtrlKey = _interopRequireDefault(require("./convertCtrlKey.js"));
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
+
class Editor extends _react.Component {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
_defineProperty(this, "onKeyDown", event => {
|
|
20
|
+
(0, _convertCtrlKey.default)(event, this.props.onEdit);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
const {
|
|
25
|
+
children
|
|
26
|
+
} = this.props;
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
+
onKeyDown: this.onKeyDown
|
|
29
|
+
}, children);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
Editor.defaultProps = {
|
|
33
|
+
onEdit: null
|
|
34
|
+
};
|
|
35
|
+
Editor.propTypes = {
|
|
36
|
+
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]),
|
|
37
|
+
onEdit: _propTypes.default.func
|
|
38
|
+
};
|
|
39
|
+
var _default = Editor;
|
|
40
|
+
exports.default = _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _enzyme = require("enzyme");
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _convertCtrlKey = _interopRequireDefault(require("../convertCtrlKey.js"));
|
|
6
|
+
var _Editor = _interopRequireDefault(require("../Editor.js"));
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
jest.mock('../convertCtrlKey');
|
|
9
|
+
describe('RichText: Editor component', () => {
|
|
10
|
+
let richTextEditor;
|
|
11
|
+
const componentProps = {
|
|
12
|
+
onEdit: jest.fn()
|
|
13
|
+
};
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
_convertCtrlKey.default.mockClear();
|
|
16
|
+
});
|
|
17
|
+
const renderComponent = props => {
|
|
18
|
+
return (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_Editor.default, props, /*#__PURE__*/_react.default.createElement("input", null)));
|
|
19
|
+
};
|
|
20
|
+
it('renders a result', () => {
|
|
21
|
+
richTextEditor = renderComponent(componentProps);
|
|
22
|
+
expect(richTextEditor).toHaveLength(1);
|
|
23
|
+
});
|
|
24
|
+
it('calls convertCtrlKey on keydown', () => {
|
|
25
|
+
richTextEditor = renderComponent(componentProps);
|
|
26
|
+
richTextEditor.simulate('keyDown');
|
|
27
|
+
expect(_convertCtrlKey.default).toHaveBeenCalled();
|
|
28
|
+
});
|
|
29
|
+
});
|