@truedat/core 4.49.10 → 4.50.4
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/CHANGELOG.md +7 -0
- package/package.json +2 -2
- package/src/api/queries.js +1 -0
- package/src/components/Date.js +15 -0
- package/src/components/FilterItem.js +5 -3
- package/src/components/SelectedFilters.js +1 -1
- package/src/components/TemplateSelector.js +21 -11
- package/src/components/TreeSelector.js +8 -2
- package/src/components/__tests__/DomainSelector.spec.js +28 -4
- package/src/components/index.js +2 -0
- package/src/services/__tests__/filters.spec.js +9 -1
- package/src/services/filters.js +5 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.50.4",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"react-dom": ">= 16.8.6 < 17",
|
|
113
113
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "d9f12f551a3780a8785197e02c6842b89ab24ec3"
|
|
116
116
|
}
|
package/src/api/queries.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import Moment from "react-moment";
|
|
4
|
+
|
|
5
|
+
export const Date = ({ value, className }) =>
|
|
6
|
+
value ? (
|
|
7
|
+
<Moment className={className} date={value} format="YYYY-MM-DD" />
|
|
8
|
+
) : null;
|
|
9
|
+
|
|
10
|
+
Date.propTypes = {
|
|
11
|
+
value: PropTypes.string,
|
|
12
|
+
className: PropTypes.string,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default Date;
|
|
@@ -26,10 +26,12 @@ export const FilterItem = ({
|
|
|
26
26
|
active,
|
|
27
27
|
filter,
|
|
28
28
|
toggleFilterValue,
|
|
29
|
-
option: { text, value }
|
|
29
|
+
option: { text, value },
|
|
30
30
|
}) => (
|
|
31
31
|
<Dropdown.Item
|
|
32
|
-
onClick={
|
|
32
|
+
onClick={(e) =>
|
|
33
|
+
preventDefault(e, () => toggleFilterValue({ filter, value }))
|
|
34
|
+
}
|
|
33
35
|
active={active}
|
|
34
36
|
>
|
|
35
37
|
<Icon name={active ? "check square outline" : "square outline"} />
|
|
@@ -41,7 +43,7 @@ FilterItem.propTypes = {
|
|
|
41
43
|
active: PropTypes.bool,
|
|
42
44
|
filter: PropTypes.string,
|
|
43
45
|
toggleFilterValue: PropTypes.func,
|
|
44
|
-
option: PropTypes.object
|
|
46
|
+
option: PropTypes.object,
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
export default FilterItem;
|
|
@@ -25,6 +25,8 @@ export const TemplateSelector = ({
|
|
|
25
25
|
required,
|
|
26
26
|
selectedValue,
|
|
27
27
|
templates,
|
|
28
|
+
placeholder,
|
|
29
|
+
hideLabel = false,
|
|
28
30
|
}) => {
|
|
29
31
|
const { formatMessage } = useIntl();
|
|
30
32
|
const options = makeOptions(formatMessage)(templates);
|
|
@@ -37,23 +39,29 @@ export const TemplateSelector = ({
|
|
|
37
39
|
|
|
38
40
|
return hidden ? null : (
|
|
39
41
|
<Form.Field required={required}>
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
{hideLabel ? null : (
|
|
43
|
+
<label>
|
|
44
|
+
<FormattedMessage id="template.selector.label" />
|
|
45
|
+
{!selectedValue && required ? (
|
|
46
|
+
<Label pointing="left">
|
|
47
|
+
<FormattedMessage id="template.form.validation.empty_required" />
|
|
48
|
+
</Label>
|
|
49
|
+
) : null}
|
|
50
|
+
</label>
|
|
51
|
+
)}
|
|
48
52
|
<Form.Dropdown
|
|
49
53
|
clearable={clearable}
|
|
50
54
|
loading={loading}
|
|
51
55
|
name={name}
|
|
52
56
|
onChange={handleChange}
|
|
53
57
|
options={options}
|
|
54
|
-
placeholder={
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
placeholder={
|
|
59
|
+
placeholder
|
|
60
|
+
? placeholder
|
|
61
|
+
: formatMessage({
|
|
62
|
+
id: loading ? "loading" : "template.selector.placeholder",
|
|
63
|
+
})
|
|
64
|
+
}
|
|
57
65
|
search
|
|
58
66
|
selection
|
|
59
67
|
value={_.toString(selectedValue)}
|
|
@@ -70,6 +78,8 @@ TemplateSelector.propTypes = {
|
|
|
70
78
|
required: PropTypes.bool,
|
|
71
79
|
selectedValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
72
80
|
templates: PropTypes.array,
|
|
81
|
+
placeholder: PropTypes.string,
|
|
82
|
+
hideLabel: PropTypes.bool,
|
|
73
83
|
};
|
|
74
84
|
|
|
75
85
|
const emptyTemplates = [];
|
|
@@ -49,8 +49,10 @@ const labelValues = _.cond([
|
|
|
49
49
|
]);
|
|
50
50
|
|
|
51
51
|
export const TreeSelector = ({
|
|
52
|
+
check = false,
|
|
52
53
|
error,
|
|
53
54
|
label,
|
|
55
|
+
labels = false,
|
|
54
56
|
multiple = false,
|
|
55
57
|
name,
|
|
56
58
|
onBlur,
|
|
@@ -113,13 +115,15 @@ export const TreeSelector = ({
|
|
|
113
115
|
({ id, level }) => level === 0 || _.includes(id)(displayed)
|
|
114
116
|
);
|
|
115
117
|
|
|
116
|
-
const trigger = (
|
|
118
|
+
const trigger = labels ? (
|
|
117
119
|
<SelectedLabels
|
|
118
120
|
placeholder={placeholder}
|
|
119
121
|
options={options}
|
|
120
122
|
onClick={handleClick}
|
|
121
123
|
value={labelValues(value)}
|
|
122
124
|
/>
|
|
125
|
+
) : (
|
|
126
|
+
<label>{placeholder}</label>
|
|
123
127
|
);
|
|
124
128
|
|
|
125
129
|
const items = _.flow(
|
|
@@ -128,7 +132,7 @@ export const TreeSelector = ({
|
|
|
128
132
|
_.map((option) => (
|
|
129
133
|
<DropdownMenuItem
|
|
130
134
|
key={option?.id}
|
|
131
|
-
check={
|
|
135
|
+
check={check}
|
|
132
136
|
onOpen={handleOpen}
|
|
133
137
|
onClick={handleClick}
|
|
134
138
|
open={_.contains(option.id)(open)}
|
|
@@ -175,8 +179,10 @@ export const TreeSelector = ({
|
|
|
175
179
|
};
|
|
176
180
|
|
|
177
181
|
TreeSelector.propTypes = {
|
|
182
|
+
check: PropTypes.bool,
|
|
178
183
|
error: PropTypes.bool,
|
|
179
184
|
label: PropTypes.string,
|
|
185
|
+
labels: PropTypes.bool,
|
|
180
186
|
multiple: PropTypes.bool,
|
|
181
187
|
name: PropTypes.string,
|
|
182
188
|
onBlur: PropTypes.func,
|
|
@@ -12,10 +12,34 @@ const domainsMock = {
|
|
|
12
12
|
result: {
|
|
13
13
|
data: {
|
|
14
14
|
domains: [
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
{
|
|
16
|
+
__typename: "Domain",
|
|
17
|
+
id: "1",
|
|
18
|
+
name: "foo",
|
|
19
|
+
externalId: "A",
|
|
20
|
+
parentId: null,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
__typename: "Domain",
|
|
24
|
+
id: "2",
|
|
25
|
+
name: "bar",
|
|
26
|
+
externalId: "B",
|
|
27
|
+
parentId: "1",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
__typename: "Domain",
|
|
31
|
+
id: "3",
|
|
32
|
+
name: "baz",
|
|
33
|
+
externalId: "C",
|
|
34
|
+
parentId: "2",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
__typename: "Domain",
|
|
38
|
+
id: "4",
|
|
39
|
+
name: "xyzzy",
|
|
40
|
+
externalId: "D",
|
|
41
|
+
parentId: "99",
|
|
42
|
+
},
|
|
19
43
|
],
|
|
20
44
|
},
|
|
21
45
|
},
|
package/src/components/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import Comments from "./Comments";
|
|
|
10
10
|
import CommentsLoader from "./CommentsLoader";
|
|
11
11
|
import ConfirmModal from "./ConfirmModal";
|
|
12
12
|
import DashboardMenu from "./DashboardMenu";
|
|
13
|
+
import Date from "./Date";
|
|
13
14
|
import DateFilter from "./DateFilter";
|
|
14
15
|
import DateRangeFilter from "./DateRangeFilter";
|
|
15
16
|
import DateTime from "./DateTime";
|
|
@@ -58,6 +59,7 @@ export {
|
|
|
58
59
|
CommentsLoader,
|
|
59
60
|
ConfirmModal,
|
|
60
61
|
DashboardMenu,
|
|
62
|
+
Date,
|
|
61
63
|
DateFilter,
|
|
62
64
|
DateRangeFilter,
|
|
63
65
|
DateTime,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import { mergeFilters, getSearchPayload } from "../filters";
|
|
2
|
+
import { isEmbedded, mergeFilters, getSearchPayload } from "../filters";
|
|
3
3
|
|
|
4
4
|
describe("services: filters", () => {
|
|
5
5
|
describe("mergeFilters", () => {
|
|
@@ -72,4 +72,12 @@ describe("services: filters", () => {
|
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
describe("isEmbedded", () => {
|
|
77
|
+
test("returns true iff item has name and id prop", () => {
|
|
78
|
+
expect(isEmbedded({ id: 123, name: "foo" })).toBe(true);
|
|
79
|
+
expect(isEmbedded(123)).toBe(false);
|
|
80
|
+
expect(isEmbedded("123")).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
75
83
|
});
|
package/src/services/filters.js
CHANGED
|
@@ -28,10 +28,14 @@ export const getSearchPayload = (searchQuery, props) => {
|
|
|
28
28
|
]);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
export const isEmbedded = _.overEvery(_.has("id"), _.has("name"));
|
|
32
|
+
|
|
31
33
|
export const formatFilterValues = (selectedFilter) => (values) =>
|
|
32
34
|
selectedFilter === "taxonomy"
|
|
33
35
|
? getDomainSelectorOptions({ domains: values })
|
|
36
|
+
: _.any(isEmbedded)(values)
|
|
37
|
+
? _.map(({ id, name }) => ({ value: id, text: name }))(values)
|
|
34
38
|
: values;
|
|
35
39
|
|
|
36
40
|
export const toFilterValues = (filterValues) =>
|
|
37
|
-
_.map((v) => (_.isObject(v) ? v.id : v))(filterValues);
|
|
41
|
+
_.map((v) => (_.isObject(v) ? v.id || v.value : v))(filterValues);
|