@truedat/bg 4.51.2 → 4.51.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.
@@ -1,111 +1,144 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<ConceptsBulkUpdate /> matches the latest snapshot 1`] = `
4
- <Container
5
- as={[Function]}
6
- text={true}
7
- >
8
- <Header
9
- as="h2"
4
+ <div>
5
+ <div
6
+ class="ui segment ui text container"
7
+ style=""
10
8
  >
11
- <Icon
12
- as="i"
13
- name="book"
14
- />
15
- <HeaderContent>
16
- <MemoizedFormattedMessage
17
- id="concepts.header.edit.bulk"
9
+ <h2
10
+ class="ui header"
11
+ >
12
+ <i
13
+ aria-hidden="true"
14
+ class="book icon"
18
15
  />
19
- </HeaderContent>
20
- </Header>
21
- <Header
22
- as="h3"
23
- >
24
- <HeaderContent>
25
- <MemoizedFormattedMessage
26
- id="concepts.header.edit.bulk.concepts_count"
27
- values={
28
- Object {
29
- "concepts_count": undefined,
30
- }
31
- }
32
- />
33
- </HeaderContent>
34
- </Header>
35
- <lazy />
36
- <Header
37
- as="h4"
38
- >
39
- <HeaderContent>
40
- <MemoizedFormattedMessage
41
- id="concepts.header.edit.bulk.info_message"
42
- />
43
- </HeaderContent>
44
- </Header>
45
- <Form
46
- as="form"
47
- loading={false}
48
- >
49
- <Connect(DomainDropdownSelector)
50
- invalid={true}
51
- onChange={[Function]}
52
- />
53
- <ConfirmModal
54
- actions={
55
- Array [
56
- Object {
57
- "content": <Memo(MemoizedFormattedMessage)
58
- id="confirmation.no"
59
- />,
60
- "key": "no",
61
- "secondary": true,
62
- },
63
- Object {
64
- "content": <Memo(MemoizedFormattedMessage)
65
- id="confirmation.yes"
66
- />,
67
- "key": "yes",
68
- "onClick": [Function],
69
- "primary": true,
70
- },
71
- ]
72
- }
73
- content={
74
- <Memo(MemoizedFormattedMessage)
75
- id="concepts.edit.bulk.confirmation.content"
76
- values={
77
- Object {
78
- "concepts_count": undefined,
79
- }
80
- }
81
- />
82
- }
83
- header={
84
- <Memo(MemoizedFormattedMessage)
85
- id="concepts.edit.bulk.confirmation.header"
86
- />
87
- }
88
- onConfirm={[Function]}
89
- trigger={
90
- <Button
91
- as="button"
92
- content={
93
- <Memo(MemoizedFormattedMessage)
94
- id="actions.save"
95
- />
96
- }
97
- disabled={true}
98
- primary={true}
99
- />
100
- }
101
- />
102
- <HistoryBackButton
103
- content={
104
- <Memo(MemoizedFormattedMessage)
105
- id="actions.cancel"
106
- />
107
- }
108
- />
109
- </Form>
110
- </Container>
16
+ <div
17
+ class="content"
18
+ >
19
+ Edit Business Concepts
20
+ </div>
21
+ </h2>
22
+ <h3
23
+ class="ui header"
24
+ >
25
+ <div
26
+ class="content"
27
+ >
28
+ Selected concepts: "1"
29
+ </div>
30
+ </h3>
31
+ <h4
32
+ class="ui header"
33
+ >
34
+ <div
35
+ class="content"
36
+ >
37
+ Only modify fields to be updated
38
+ </div>
39
+ </h4>
40
+ <form
41
+ class="ui form"
42
+ >
43
+ <div
44
+ class="required field"
45
+ >
46
+ <div
47
+ aria-expanded="false"
48
+ aria-multiselectable="false"
49
+ class="ui floating dropdown"
50
+ required=""
51
+ role="listbox"
52
+ tabindex="0"
53
+ >
54
+ <label>
55
+ Select a domain...
56
+ </label>
57
+ <i
58
+ aria-hidden="true"
59
+ class="dropdown icon"
60
+ />
61
+ <div
62
+ class="menu transition"
63
+ >
64
+ <div
65
+ class="ui left icon input search"
66
+ >
67
+ <input
68
+ type="text"
69
+ />
70
+ <i
71
+ aria-hidden="true"
72
+ class="search icon"
73
+ />
74
+ </div>
75
+ <div
76
+ class="scrolling menu transition"
77
+ >
78
+ <div
79
+ aria-selected="false"
80
+ class="item"
81
+ role="option"
82
+ >
83
+ <div
84
+ style="margin-left: 0px;"
85
+ >
86
+ <i
87
+ aria-hidden="true"
88
+ class="plus icon"
89
+ />
90
+ barDomain
91
+ </div>
92
+ </div>
93
+ <div
94
+ aria-selected="false"
95
+ class="item"
96
+ role="option"
97
+ >
98
+ <div
99
+ style="margin-left: 0px;"
100
+ >
101
+ <i
102
+ aria-hidden="true"
103
+ class="icon"
104
+ />
105
+ bazDomain
106
+ </div>
107
+ </div>
108
+ <div
109
+ aria-selected="false"
110
+ class="item"
111
+ role="option"
112
+ >
113
+ <div
114
+ style="margin-left: 0px;"
115
+ >
116
+ <i
117
+ aria-hidden="true"
118
+ class="icon"
119
+ />
120
+ fooDomain
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ <button
128
+ class="ui primary disabled button"
129
+ disabled=""
130
+ tabindex="-1"
131
+ >
132
+ Save
133
+ </button>
134
+ <a
135
+ class="ui secondary button"
136
+ href="/"
137
+ role="button"
138
+ >
139
+ Cancel
140
+ </a>
141
+ </form>
142
+ </div>
143
+ </div>
111
144
  `;
@@ -15,24 +15,19 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
15
15
  class="ui form"
16
16
  >
17
17
  <div
18
- class="required field"
18
+ class="field"
19
19
  >
20
- <label>
21
- Domain
22
- </label>
23
20
  <div
24
21
  aria-expanded="false"
25
22
  aria-multiselectable="true"
26
23
  class="ui floating multiple dropdown"
27
- name="sharedTo"
28
- required=""
29
24
  role="listbox"
30
25
  tabindex="0"
31
26
  >
32
27
  <div
33
28
  class="ui label"
34
29
  >
35
- bar
30
+ barDomain
36
31
  <i
37
32
  aria-hidden="true"
38
33
  class="delete icon"
@@ -60,8 +55,8 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
60
55
  class="scrolling menu transition"
61
56
  >
62
57
  <div
63
- aria-selected="false"
64
- class="item"
58
+ aria-selected="true"
59
+ class="selected item"
65
60
  role="option"
66
61
  >
67
62
  <div
@@ -69,14 +64,14 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
69
64
  >
70
65
  <i
71
66
  aria-hidden="true"
72
- class="icon"
67
+ class="plus icon"
73
68
  />
74
- foo
69
+ barDomain
75
70
  </div>
76
71
  </div>
77
72
  <div
78
- aria-selected="true"
79
- class="selected item"
73
+ aria-selected="false"
74
+ class="item"
80
75
  role="option"
81
76
  >
82
77
  <div
@@ -86,7 +81,7 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
86
81
  aria-hidden="true"
87
82
  class="icon"
88
83
  />
89
- bar
84
+ bazDomain
90
85
  </div>
91
86
  </div>
92
87
  <div
@@ -101,7 +96,7 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
101
96
  aria-hidden="true"
102
97
  class="icon"
103
98
  />
104
- baz
99
+ fooDomain
105
100
  </div>
106
101
  </div>
107
102
  </div>
@@ -1,13 +1,5 @@
1
- import DomainDropdownSelector from "./DomainDropdownSelector";
2
- import DomainMenuSelector from "./DomainMenuSelector";
3
1
  import DomainRoutes from "./DomainRoutes";
4
2
  import DomainsLoader from "./DomainsLoader";
5
3
  import DomainStructures from "./DomainStructures";
6
4
 
7
- export {
8
- DomainDropdownSelector,
9
- DomainMenuSelector,
10
- DomainRoutes,
11
- DomainsLoader,
12
- DomainStructures,
13
- };
5
+ export { DomainRoutes, DomainsLoader, DomainStructures };
@@ -1,200 +0,0 @@
1
- import _ from "lodash/fp";
2
- import React, { useEffect, useState } from "react";
3
- import { connect } from "react-redux";
4
- import { Form, Icon, Label } from "semantic-ui-react";
5
- import PropTypes from "prop-types";
6
- import { lowerDeburr } from "@truedat/core/services/sort";
7
- import { useIntl } from "react-intl";
8
- import { getDomainSelectorOptions } from "../selectors";
9
-
10
- const toDomainOption = ({ id, canOpen, handleOpen, open, name, level }) => {
11
- const doHandleOpen = (e) => {
12
- e && e.preventDefault();
13
- e && e.stopPropagation();
14
- handleOpen(id);
15
- };
16
-
17
- return {
18
- key: id,
19
- text: name,
20
- value: id,
21
- content: (
22
- <div style={{ marginLeft: `${8 * level}px` }}>
23
- {canOpen ? (
24
- <Icon name={open ? "minus" : "plus"} onClick={doHandleOpen} />
25
- ) : (
26
- <Icon />
27
- )}
28
- {name}
29
- </div>
30
- ),
31
- };
32
- };
33
-
34
- export const DomainDropdownSelector = ({
35
- clearable: preClearable = true,
36
- disabled,
37
- domainOptions: options,
38
- hideLabel,
39
- invalid,
40
- multiple = false,
41
- onChange,
42
- value: defaultValue,
43
- }) => {
44
- const [query, setQuery] = useState();
45
- const [open, setOpen] = useState([]);
46
- const [displayed, setDisplayed] = useState([]);
47
- const [clearable, setClearable] = useState(preClearable);
48
- const [value, setValue] = useState(defaultValue);
49
- const { formatMessage } = useIntl();
50
-
51
- useEffect(() => {
52
- if (_.size(options) === 1) {
53
- const firstValue = _.first(options).id;
54
- if (value !== firstValue) {
55
- setClearable(false);
56
- handleChange({ preventDefault: () => {} }, { value: firstValue });
57
- }
58
- }
59
- }, [options]);
60
-
61
- useEffect(() => {
62
- const option = _.find({ id: value })(options);
63
- if (!_.isNil(option)) {
64
- const ancestors = _.map("id")(option.ancestors);
65
- const ids = [...ancestors, option.id];
66
- setOpen(ancestors);
67
- setDisplayed(ids);
68
- }
69
- }, [value, options]);
70
-
71
- useEffect(() => {
72
- if (!_.isNil(defaultValue) && value !== defaultValue) {
73
- setValue(defaultValue);
74
- }
75
- }, [value, defaultValue]);
76
-
77
- const displayAll = () => {
78
- const ids = _.map("id")(options);
79
- setOpen(ids);
80
- setDisplayed(ids);
81
- };
82
-
83
- const handleOpen = (domainId) => {
84
- const domain = _.find({ id: domainId })(options);
85
- const isOpen = _.contains(domainId)(open);
86
- const children = _.map("id")(domain.children);
87
- const descendents = _.map("id")(domain.descendents);
88
- if (isOpen) {
89
- setOpen(_.without([domainId, ...descendents])(open));
90
- setDisplayed(_.without(descendents)(displayed));
91
- } else {
92
- setOpen(_.union([domainId])(open));
93
- setDisplayed(_.union(children)(displayed));
94
- }
95
- };
96
-
97
- const handleBlur = () => {
98
- setQuery();
99
- const lastesSelection = _.isNumber(value) ? value : _.last(value);
100
- if (!_.isNil(lastesSelection)) {
101
- const domain = _.find({ id: lastesSelection })(options);
102
- const ancestors = _.map("id")(domain.ancestors);
103
- const ids = [...ancestors, domain.id];
104
- setOpen(ancestors);
105
- setDisplayed(ids);
106
- }
107
- };
108
-
109
- const handleChange = (e, { value }) => {
110
- e.preventDefault();
111
- setQuery();
112
- setValue(value);
113
- onChange && onChange(e, { value });
114
- };
115
-
116
- const handleSearch = (e, { searchQuery }) => {
117
- e.preventDefault();
118
- setQuery(lowerDeburr(searchQuery));
119
- if (!_.isEmpty(searchQuery)) {
120
- displayAll();
121
- }
122
- };
123
- const match = (name, query) => _.contains(query)(lowerDeburr(name));
124
- const filterSearch = (all) => {
125
- if (query) {
126
- return _.filter(
127
- (domain) =>
128
- match(domain.name, query) ||
129
- _.some((descendent) => match(descendent.name, query))(
130
- domain.descendents
131
- )
132
- )(all);
133
- }
134
- return all;
135
- };
136
-
137
- const filterDisplayed = (all) =>
138
- _.filter((domain) => domain.level == 0 || _.contains(domain.id)(displayed))(
139
- all
140
- );
141
-
142
- const filteredOptions = _.flow(filterSearch, filterDisplayed)(options);
143
-
144
- return (
145
- <Form.Field required={!hideLabel}>
146
- {!hideLabel && (
147
- <label>
148
- {formatMessage({ id: "domain.selector.label" })}
149
- {invalid ? (
150
- <Label pointing="left">
151
- {formatMessage({ id: "template.form.validation.empty_required" })}
152
- </Label>
153
- ) : null}
154
- </label>
155
- )}
156
- <Form.Dropdown
157
- clearable={clearable}
158
- disabled={disabled}
159
- fluid
160
- name="domain"
161
- onChange={handleChange}
162
- onBlur={handleBlur}
163
- onSearchChange={handleSearch}
164
- options={_.map((option) =>
165
- toDomainOption({
166
- ...option,
167
- open: _.contains(option.id)(open),
168
- canOpen: _.negate(_.isEmpty)(option.children),
169
- handleOpen,
170
- })
171
- )(filteredOptions)}
172
- placeholder={formatMessage({ id: "domain.selector.placeholder" })}
173
- search={_.identity}
174
- multiple={multiple}
175
- selection
176
- value={value}
177
- />
178
- </Form.Field>
179
- );
180
- };
181
-
182
- DomainDropdownSelector.propTypes = {
183
- clearable: PropTypes.bool,
184
- disabled: PropTypes.bool,
185
- domainOptions: PropTypes.array,
186
- hideLabel: PropTypes.bool,
187
- invalid: PropTypes.bool,
188
- multiple: PropTypes.bool,
189
- onChange: PropTypes.func,
190
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.array]),
191
- };
192
-
193
- const mapStateToProps = (state, props) => ({
194
- domainOptions: _.flow(
195
- _.prop("domainOptions"),
196
- _.defaultTo(getDomainSelectorOptions(state))
197
- )(props),
198
- });
199
-
200
- export default connect(mapStateToProps)(DomainDropdownSelector);