@truedat/core 4.50.2 → 4.50.3

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.50.3] 2022-08-29
4
+
5
+ ### Changed
6
+
7
+ - [TD-5091] Dynamic `domain` fields are now integer ids instead of embedded
8
+ documents
9
+
3
10
  ## [4.49.4] 2022-07-29
4
11
 
5
12
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "4.50.2",
3
+ "version": "4.50.3",
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": "5785ca8828b3c25947e8d2587c909f729fbee317"
115
+ "gitHead": "ecf9302d2b22a74d3339a85398788a68e086c428"
116
116
  }
@@ -4,6 +4,7 @@ export const DOMAINS_QUERY = gql`
4
4
  query DomainsQuery($action: String!, $domainActions: [String!]) {
5
5
  domains(action: $action) {
6
6
  id
7
+ externalId
7
8
  name
8
9
  parentId
9
10
  actions(actions: $domainActions)
@@ -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={e => preventDefault(e, () => toggleFilterValue({ filter, value }))}
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;
@@ -1,5 +1,5 @@
1
1
  import _ from "lodash/fp";
2
- import React, { useEffect } from "react";
2
+ import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { FormattedMessage } from "react-intl";
5
5
  import FilterDropdown from "./FilterDropdown";
@@ -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={false}
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
- { __typename: "Domain", id: "1", name: "foo", parentId: null },
16
- { __typename: "Domain", id: "2", name: "bar", parentId: "1" },
17
- { __typename: "Domain", id: "3", name: "baz", parentId: "2" },
18
- { __typename: "Domain", id: "4", name: "xyzzy", parentId: "99" },
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
  },
@@ -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
  });
@@ -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);