@truedat/core 4.39.0 → 4.40.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.40.0] 2022-03-27
4
+
5
+ ### Changed
6
+
7
+ - [TD-4491] Simplified `SelectedFilters` component and `formatFilterValues`
8
+ function
9
+
3
10
  ## [4.37.4] 2022-02-04
4
11
 
5
12
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "4.39.0",
3
+ "version": "4.40.0",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -106,5 +106,5 @@
106
106
  "react-dom": ">= 16.8.6 < 17",
107
107
  "semantic-ui-react": ">= 0.88.2 < 2.1"
108
108
  },
109
- "gitHead": "f3d2fe3fcdec546afc22d0a79c4f4f3dfb91ea48"
109
+ "gitHead": "0bd677584da73a5021a5c96f2e5525fde9a1958a"
110
110
  }
@@ -3,11 +3,13 @@ import PropTypes from "prop-types";
3
3
  import Moment from "react-moment";
4
4
 
5
5
  export const DateTime = ({ value, className }) =>
6
- value ? <Moment className={className} date={value} format="YYYY-MM-DD HH:mm" /> : null;
6
+ value ? (
7
+ <Moment className={className} date={value} format="YYYY-MM-DD HH:mm" />
8
+ ) : null;
7
9
 
8
10
  DateTime.propTypes = {
9
11
  value: PropTypes.string,
10
- className: PropTypes.className,
12
+ className: PropTypes.string,
11
13
  };
12
14
 
13
15
  export default DateTime;
@@ -19,7 +19,7 @@ export const SelectedFilters = ({
19
19
  saveFilters,
20
20
  selectedFilter,
21
21
  selectedFilters,
22
- selectedFilterActiveValues,
22
+ selectedFilterActiveValues: activeValues,
23
23
  selectedFilterValues,
24
24
  selectedUserFilter,
25
25
  toggleFilterValue,
@@ -40,36 +40,33 @@ export const SelectedFilters = ({
40
40
  />
41
41
  )}
42
42
  <div className="selectedFilters">
43
- {!_.isEmpty(selectedFilters) && (
44
- <div className="appliedFilters">
45
- <FormattedMessage id="search.applied_filters" />
46
- </div>
47
- )}
48
- {!_.isEmpty(selectedFilters) &&
49
- selectedFilters.map((filter) => {
50
- const filterOptions = _.isEqual(filter, selectedFilter)
51
- ? selectedFilterValues
52
- : null;
53
- const props = {
54
- key: filter,
55
- activeValues: selectedFilterActiveValues,
56
- closeFilter: closeFilter,
57
- filter,
58
- loading,
59
- openFilter,
60
- options: filterOptions,
61
- removeFilter,
62
- toggleFilterValue,
63
- filterItemMapping,
64
- };
65
- return selectedFilter === "taxonomy" ? (
66
- <FilterMultilevelDropdown {...props} />
67
- ) : (
68
- <FilterDropdown {...props} />
69
- );
70
- })}
71
- {!_.isEmpty(selectedFilters) && (
43
+ {_.isEmpty(selectedFilters) ? null : (
72
44
  <>
45
+ <div className="appliedFilters">
46
+ <FormattedMessage id="search.applied_filters" />
47
+ </div>
48
+ {selectedFilters.map((filter) => {
49
+ const options = _.isEqual(filter, selectedFilter)
50
+ ? selectedFilterValues
51
+ : null;
52
+ const props = {
53
+ key: filter,
54
+ activeValues,
55
+ closeFilter,
56
+ filter,
57
+ loading,
58
+ openFilter,
59
+ options,
60
+ removeFilter,
61
+ toggleFilterValue,
62
+ filterItemMapping,
63
+ };
64
+ return selectedFilter === "taxonomy" ? (
65
+ <FilterMultilevelDropdown {...props} />
66
+ ) : (
67
+ <FilterDropdown {...props} />
68
+ );
69
+ })}
73
70
  <a className="resetFilters" onClick={() => resetFilters()}>
74
71
  <FormattedMessage id="search.clear_filters" />
75
72
  </a>
@@ -28,17 +28,10 @@ export const getSearchPayload = (searchQuery, props) => {
28
28
  ]);
29
29
  };
30
30
 
31
- export const formatFilterValues = (selectedFilter) => (values) => {
32
- if (selectedFilter === "taxonomy") {
33
- const domains = _.flow(
34
- _.map((domain) => ({ ...domain, parent_id: _.head(domain.parent_ids) })),
35
- _.map(_.omit(["parent_ids"]))
36
- )(values);
37
- return getDomainSelectorOptions({ domains });
38
- }
39
-
40
- return values;
41
- };
31
+ export const formatFilterValues = (selectedFilter) => (values) =>
32
+ selectedFilter === "taxonomy"
33
+ ? getDomainSelectorOptions({ domains: values })
34
+ : values;
42
35
 
43
36
  export const toFilterValues = (filterValues) =>
44
37
  _.map((v) => (_.isObject(v) ? v.id : v))(filterValues);