@truedat/dd 4.47.6 → 4.47.9
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 +24 -0
- package/package.json +6 -6
- package/src/api/fragments.js +1 -0
- package/src/api/queries.js +10 -0
- package/src/components/LinkStructureTagForm.js +14 -11
- package/src/components/LinkedStructureTag.js +43 -8
- package/src/components/ReferenceDatasetSelectorInputField.js +107 -0
- package/src/components/StructureFieldsDropdown.js +30 -12
- package/src/components/StructureSelectorInputField.js +0 -1
- package/src/components/StructureSelectorInputFieldJoin.js +15 -15
- package/src/components/StructureTagForm.js +23 -1
- package/src/components/StructureTagsCards.js +3 -0
- package/src/components/ValueConditionStructure.js +1 -7
- package/src/components/__tests__/LinkStructureTagForm.spec.js +80 -26
- package/src/components/__tests__/LinkedStructureTag.spec.js +133 -0
- package/src/components/__tests__/StructureTagForm.spec.js +6 -1
- package/src/components/__tests__/StructureTagsCards.spec.js +2 -0
- package/src/components/__tests__/__snapshots__/LinkStructureTagForm.spec.js.snap +267 -17
- package/src/components/__tests__/__snapshots__/LinkedStructureTag.spec.js.snap +16 -0
- package/src/components/__tests__/__snapshots__/StructureSelectorInputFieldJoin.spec.js.snap +30 -5
- package/src/components/__tests__/__snapshots__/StructureTagForm.spec.js.snap +20 -0
- package/src/components/__tests__/__snapshots__/StructureTagsCards.spec.js.snap +10 -0
- package/src/index.js +2 -1
- package/src/messages/en.js +4 -2
- package/src/messages/es.js +4 -2
- package/src/reducers/__tests__/linkedStructureTags.spec.js +1 -1
- package/src/sagas/requestGrantRemoval.js +0 -1
- package/src/selectors/getStructureFieldOptionValue.js +8 -0
- package/src/selectors/getStructuresFields.js +24 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.47.9] 2022-07-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- [TD-4661] Support for ReferenceDatasets on Implementations
|
|
8
|
+
|
|
9
|
+
## [4.47.8] 2022-07-02
|
|
10
|
+
|
|
11
|
+
## Changed
|
|
12
|
+
|
|
13
|
+
- [TD-4176] Add className to LinkStructureTagForm
|
|
14
|
+
|
|
15
|
+
## [4.47.7] 2022-07-02
|
|
16
|
+
|
|
17
|
+
## Added
|
|
18
|
+
|
|
19
|
+
- [TD-4176] Added description in structure tag
|
|
20
|
+
|
|
21
|
+
## Changed
|
|
22
|
+
|
|
23
|
+
- [TD-4176]
|
|
24
|
+
- Changed description by comment in structure tag link
|
|
25
|
+
- Commend now is not mandatory field
|
|
26
|
+
|
|
3
27
|
## [4.47.5] 2022-06-30
|
|
4
28
|
|
|
5
29
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "4.47.
|
|
3
|
+
"version": "4.47.9",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.16.4",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "4.47.
|
|
37
|
+
"@truedat/test": "4.47.9",
|
|
38
38
|
"babel-jest": "^28.1.0",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@apollo/client": "^3.6.4",
|
|
91
|
-
"@truedat/auth": "4.47.
|
|
92
|
-
"@truedat/core": "4.47.
|
|
93
|
-
"@truedat/df": "4.47.
|
|
91
|
+
"@truedat/auth": "4.47.9",
|
|
92
|
+
"@truedat/core": "4.47.9",
|
|
93
|
+
"@truedat/df": "4.47.9",
|
|
94
94
|
"lodash": "^4.17.21",
|
|
95
95
|
"path-to-regexp": "^1.7.0",
|
|
96
96
|
"prop-types": "^15.8.1",
|
|
@@ -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": "21954b7a0ea8240d2a9e8dc5014372eceed3b047"
|
|
116
116
|
}
|
package/src/api/fragments.js
CHANGED
package/src/api/queries.js
CHANGED
|
@@ -31,6 +31,16 @@ export const REFERENCE_DATASETS_QUERY = gql`
|
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
33
33
|
|
|
34
|
+
export const REFERENCE_DATASETS_HEADERS_QUERY = gql`
|
|
35
|
+
query ReferenceDatasetsHeaders {
|
|
36
|
+
referenceDatasets {
|
|
37
|
+
id
|
|
38
|
+
name
|
|
39
|
+
headers
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
34
44
|
export const REFERENCE_DATASET_QUERY = gql`
|
|
35
45
|
query ReferenceDataset($id: ID!) {
|
|
36
46
|
referenceDataset(id: $id) {
|
|
@@ -10,7 +10,7 @@ import { deleteLinkStructureTag, linkStructureTag } from "../routines";
|
|
|
10
10
|
|
|
11
11
|
export const LinkStructureTagForm = ({
|
|
12
12
|
deleteLinkStructureTag,
|
|
13
|
-
|
|
13
|
+
comment,
|
|
14
14
|
linkedStructureTags,
|
|
15
15
|
linkId,
|
|
16
16
|
linkStructureTag,
|
|
@@ -29,7 +29,11 @@ export const LinkStructureTagForm = ({
|
|
|
29
29
|
const options = _.flow(
|
|
30
30
|
_.filter(({ id }) => _.includes(id)(availableTags)),
|
|
31
31
|
_.sortBy(accentInsensitivePathOrder("name")),
|
|
32
|
-
_.map(({ id, name }) => ({
|
|
32
|
+
_.map(({ id, name, description }) => ({
|
|
33
|
+
value: id,
|
|
34
|
+
text: name,
|
|
35
|
+
description: description,
|
|
36
|
+
}))
|
|
33
37
|
)(structureTags);
|
|
34
38
|
const defaultTag = _.negate(_.isNil)(tagId)
|
|
35
39
|
? tagId
|
|
@@ -43,7 +47,7 @@ export const LinkStructureTagForm = ({
|
|
|
43
47
|
const payload = {
|
|
44
48
|
structureId,
|
|
45
49
|
tagId: params.tag,
|
|
46
|
-
tag: {
|
|
50
|
+
tag: { comment: params.comment },
|
|
47
51
|
};
|
|
48
52
|
linkStructureTag(payload);
|
|
49
53
|
};
|
|
@@ -51,13 +55,13 @@ export const LinkStructureTagForm = ({
|
|
|
51
55
|
const { handleSubmit, control, formState } = useForm({
|
|
52
56
|
mode: "all",
|
|
53
57
|
defaultValues: {
|
|
54
|
-
|
|
58
|
+
comment: comment || "",
|
|
55
59
|
tag: defaultTag,
|
|
56
60
|
},
|
|
57
61
|
});
|
|
58
62
|
const { isDirty, isValid } = formState;
|
|
59
63
|
return (
|
|
60
|
-
<Container
|
|
64
|
+
<Container className="link-structure-tag-form">
|
|
61
65
|
<Form onSubmit={handleSubmit(onSubmit)}>
|
|
62
66
|
<Controller
|
|
63
67
|
control={control}
|
|
@@ -87,16 +91,15 @@ export const LinkStructureTagForm = ({
|
|
|
87
91
|
/>
|
|
88
92
|
<Controller
|
|
89
93
|
control={control}
|
|
90
|
-
name="
|
|
91
|
-
rules={{ required: true }}
|
|
94
|
+
name="comment"
|
|
92
95
|
render={({
|
|
93
96
|
field: { onBlur, onChange, value },
|
|
94
97
|
fieldState: { error },
|
|
95
98
|
}) => (
|
|
96
99
|
<Form.TextArea
|
|
97
|
-
data-testid="
|
|
100
|
+
data-testid="comment-id"
|
|
98
101
|
error={!!error}
|
|
99
|
-
name="
|
|
102
|
+
name="comment"
|
|
100
103
|
label={formatMessage({ id: "structure.tag.textArea.label" })}
|
|
101
104
|
placeholder={formatMessage({
|
|
102
105
|
id: "structure.tag.textArea.placeholder",
|
|
@@ -110,7 +113,7 @@ export const LinkStructureTagForm = ({
|
|
|
110
113
|
<div className="actions">
|
|
111
114
|
<Button
|
|
112
115
|
type="submit"
|
|
113
|
-
disabled={!isDirty || !isValid}
|
|
116
|
+
disabled={(!isDirty && options.length > 1) || !isValid}
|
|
114
117
|
primary
|
|
115
118
|
content={formatMessage({ id: submitTitle })}
|
|
116
119
|
/>
|
|
@@ -130,7 +133,7 @@ export const LinkStructureTagForm = ({
|
|
|
130
133
|
|
|
131
134
|
LinkStructureTagForm.propTypes = {
|
|
132
135
|
deleteLinkStructureTag: PropTypes.func,
|
|
133
|
-
|
|
136
|
+
comment: PropTypes.string,
|
|
134
137
|
linkedStructureTags: PropTypes.array,
|
|
135
138
|
linkId: PropTypes.number,
|
|
136
139
|
linkStructureTag: PropTypes.func,
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import {
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { Icon, Label, Popup, Header } from "semantic-ui-react";
|
|
5
6
|
import { connect } from "react-redux";
|
|
6
7
|
import LinkStructureTagForm from "./LinkStructureTagForm";
|
|
7
8
|
|
|
8
|
-
const LinkedStructureTag = ({
|
|
9
|
+
export const LinkedStructureTag = ({
|
|
9
10
|
id,
|
|
10
11
|
_embedded,
|
|
11
12
|
editable,
|
|
12
|
-
|
|
13
|
+
comment,
|
|
13
14
|
loading,
|
|
14
15
|
structureTags,
|
|
15
16
|
}) => {
|
|
17
|
+
const { formatMessage } = useIntl();
|
|
16
18
|
const name = _embedded.data_structure_tag.name;
|
|
19
|
+
const description = _embedded.data_structure_tag.description;
|
|
17
20
|
const tagId = _embedded.data_structure_tag.id;
|
|
18
21
|
const [openDescription, setOpenDescription] = useState(false);
|
|
19
22
|
const [openForm, setOpenForm] = useState(false);
|
|
@@ -24,16 +27,46 @@ const LinkedStructureTag = ({
|
|
|
24
27
|
|
|
25
28
|
const trigger = editable ? <Icon link name="edit" /> : null;
|
|
26
29
|
|
|
30
|
+
const renderTooltip = () => {
|
|
31
|
+
const descriptionTooltip = _.isEmpty(description) ? null : (
|
|
32
|
+
<Header as="h2" subheader={description} />
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const commentTooltip = _.isEmpty(comment) ? null : (
|
|
36
|
+
<>
|
|
37
|
+
<Header
|
|
38
|
+
as="h5"
|
|
39
|
+
content={formatMessage({ id: "structure.tag.tooltip.commentTitle" })}
|
|
40
|
+
/>
|
|
41
|
+
<p>{comment}</p>
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
{descriptionTooltip}
|
|
48
|
+
{commentTooltip}
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
27
53
|
return (
|
|
28
54
|
<Popup
|
|
29
55
|
basic
|
|
30
|
-
content={description}
|
|
31
56
|
open={openDescription}
|
|
32
57
|
onOpen={() => {
|
|
33
|
-
|
|
58
|
+
const commentCondition = !_.isEmpty(comment);
|
|
59
|
+
const descriptionCondition = !_.isEmpty(description);
|
|
60
|
+
const openFormCondition = !openForm;
|
|
61
|
+
|
|
62
|
+
const openTooltipCondition =
|
|
63
|
+
(commentCondition || descriptionCondition) && openFormCondition;
|
|
64
|
+
|
|
65
|
+
if (openTooltipCondition) setOpenDescription(true);
|
|
34
66
|
}}
|
|
35
67
|
onClose={() => setOpenDescription(false)}
|
|
36
68
|
positionFixed
|
|
69
|
+
className="popup-tag"
|
|
37
70
|
trigger={
|
|
38
71
|
<Label tag style={{ marginLeft: "1.5em" }}>
|
|
39
72
|
{_.isEmpty(structureTags) ? null : (
|
|
@@ -49,7 +82,7 @@ const LinkedStructureTag = ({
|
|
|
49
82
|
flowing
|
|
50
83
|
content={
|
|
51
84
|
<LinkStructureTagForm
|
|
52
|
-
|
|
85
|
+
comment={comment}
|
|
53
86
|
linkId={id}
|
|
54
87
|
tagId={tagId}
|
|
55
88
|
/>
|
|
@@ -64,13 +97,15 @@ const LinkedStructureTag = ({
|
|
|
64
97
|
{name}
|
|
65
98
|
</Label>
|
|
66
99
|
}
|
|
67
|
-
|
|
100
|
+
>
|
|
101
|
+
{renderTooltip()}
|
|
102
|
+
</Popup>
|
|
68
103
|
);
|
|
69
104
|
};
|
|
70
105
|
|
|
71
106
|
LinkedStructureTag.propTypes = {
|
|
72
107
|
_embedded: PropTypes.object,
|
|
73
|
-
|
|
108
|
+
comment: PropTypes.string,
|
|
74
109
|
editable: PropTypes.bool,
|
|
75
110
|
id: PropTypes.number,
|
|
76
111
|
loading: PropTypes.bool,
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
|
|
5
|
+
import { matchSorter } from "match-sorter";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { Container, Form, Dropdown, Icon } from "semantic-ui-react";
|
|
8
|
+
|
|
9
|
+
import StructureSelectorInputFieldJoin from "./StructureSelectorInputFieldJoin";
|
|
10
|
+
|
|
11
|
+
export const ReferenceDatasetSelectorInputField = ({
|
|
12
|
+
onChange,
|
|
13
|
+
onChangeField,
|
|
14
|
+
onDelete,
|
|
15
|
+
structures,
|
|
16
|
+
selectedStructure,
|
|
17
|
+
fieldWidth,
|
|
18
|
+
referenceDatasets,
|
|
19
|
+
}) => {
|
|
20
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
21
|
+
const { formatMessage } = useIntl();
|
|
22
|
+
|
|
23
|
+
const matchSorterFp = (items) =>
|
|
24
|
+
matchSorter(items, searchTerm, {
|
|
25
|
+
keys: ["name", "headers"],
|
|
26
|
+
threshold: matchSorter.rankings.CONTAINS,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const datasets = _.flow(
|
|
30
|
+
_.reject(
|
|
31
|
+
({ id }) =>
|
|
32
|
+
_.any({
|
|
33
|
+
structure: {
|
|
34
|
+
type: "reference_dataset",
|
|
35
|
+
id,
|
|
36
|
+
},
|
|
37
|
+
})(structures) && id !== selectedStructure?.structure?.id
|
|
38
|
+
),
|
|
39
|
+
_.cond([
|
|
40
|
+
[() => _.isEmpty(searchTerm), _.identity],
|
|
41
|
+
[_.stubTrue, matchSorterFp],
|
|
42
|
+
])
|
|
43
|
+
)(referenceDatasets);
|
|
44
|
+
|
|
45
|
+
const options = _.map(({ id, name }) => ({ key: id, value: id, text: name }))(
|
|
46
|
+
datasets
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const handleChange = (_e, { value }) =>
|
|
50
|
+
onChange(_.find({ id: value })(datasets));
|
|
51
|
+
const handleSearchChange = (_e, { searchQuery }) =>
|
|
52
|
+
setSearchTerm(searchQuery);
|
|
53
|
+
const handleSelectField = (clauses) => {
|
|
54
|
+
onChangeField({ ...selectedStructure, clauses });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<Form.Field width={fieldWidth ? fieldWidth : 7}>
|
|
60
|
+
<label>
|
|
61
|
+
{formatMessage({ id: `ruleImplementation.props.reference_dataset` })}
|
|
62
|
+
<Icon name="close" className="selectable" onClick={onDelete} />
|
|
63
|
+
</label>
|
|
64
|
+
<Dropdown
|
|
65
|
+
onChange={handleChange}
|
|
66
|
+
onSearchChange={handleSearchChange}
|
|
67
|
+
options={options}
|
|
68
|
+
placeholder={formatMessage({
|
|
69
|
+
id: `ruleImplementation.props.reference_dataset.placeholder`,
|
|
70
|
+
})}
|
|
71
|
+
search
|
|
72
|
+
searchQuery={searchTerm}
|
|
73
|
+
selection
|
|
74
|
+
value={selectedStructure?.structure?.id}
|
|
75
|
+
/>
|
|
76
|
+
</Form.Field>
|
|
77
|
+
{_.prop("structure")(selectedStructure) && (
|
|
78
|
+
<Container style={{ paddingLeft: "8em" }}>
|
|
79
|
+
<Form.Field>
|
|
80
|
+
<label>
|
|
81
|
+
{formatMessage({
|
|
82
|
+
id: "structureSelector.union.criteria",
|
|
83
|
+
})}
|
|
84
|
+
</label>
|
|
85
|
+
<StructureSelectorInputFieldJoin
|
|
86
|
+
structures={structures}
|
|
87
|
+
selectedStructure={selectedStructure}
|
|
88
|
+
handleSelectField={handleSelectField}
|
|
89
|
+
/>
|
|
90
|
+
</Form.Field>
|
|
91
|
+
</Container>
|
|
92
|
+
)}
|
|
93
|
+
</>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
ReferenceDatasetSelectorInputField.propTypes = {
|
|
98
|
+
onChange: PropTypes.func,
|
|
99
|
+
onChangeField: PropTypes.func,
|
|
100
|
+
onDelete: PropTypes.func,
|
|
101
|
+
structures: PropTypes.array,
|
|
102
|
+
selectedStructure: PropTypes.object,
|
|
103
|
+
fieldWidth: PropTypes.number,
|
|
104
|
+
referenceDatasets: PropTypes.array,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default ReferenceDatasetSelectorInputField;
|
|
@@ -19,34 +19,43 @@ export const StructureFieldsDropdown = ({
|
|
|
19
19
|
multiple,
|
|
20
20
|
}) => {
|
|
21
21
|
const { formatMessage } = useIntl();
|
|
22
|
+
|
|
22
23
|
const onClick = ({ value, modifier }) => {
|
|
23
|
-
onSelectField(dropdownItemToField(value), modifier);
|
|
24
|
+
if (!multiple) onSelectField(dropdownItemToField(value), modifier);
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const onChangeStructureFieldsDropdown = (valueOrValues) => {
|
|
27
28
|
return _.flow(
|
|
28
|
-
_.map(
|
|
29
|
-
return dropdownItemToField(value);
|
|
30
|
-
}),
|
|
29
|
+
_.map(dropdownItemToField),
|
|
31
30
|
multiple ? onSelectFields : onSelectField
|
|
32
31
|
)(Array.isArray(valueOrValues) ? valueOrValues : [valueOrValues]);
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
const dropdownItemToField = (value) => {
|
|
36
|
-
const [
|
|
37
|
-
? value.split("/")
|
|
35
|
+
const [fieldIdentifier, parentIndex] = _.isString(value)
|
|
36
|
+
? value.split("/")
|
|
38
37
|
: [value, undefined];
|
|
39
|
-
return _.isNil(
|
|
40
|
-
? _.find({ data_structure_id:
|
|
38
|
+
return _.isNil(parentIndex)
|
|
39
|
+
? _.find({ data_structure_id: Number(fieldIdentifier) })(structureFields)
|
|
40
|
+
: _.any({
|
|
41
|
+
type: "reference_dataset_field",
|
|
42
|
+
parent_index: Number(parentIndex),
|
|
43
|
+
})(structureFields)
|
|
44
|
+
? _.find({
|
|
45
|
+
name: fieldIdentifier,
|
|
46
|
+
parent_index: Number(parentIndex),
|
|
47
|
+
})(structureFields)
|
|
41
48
|
: _.find({
|
|
42
|
-
data_structure_id:
|
|
43
|
-
parent_index:
|
|
49
|
+
data_structure_id: Number(fieldIdentifier),
|
|
50
|
+
parent_index: Number(parentIndex),
|
|
44
51
|
})(structureFields);
|
|
45
52
|
};
|
|
46
53
|
|
|
47
54
|
const formatOption = (field) => {
|
|
48
55
|
const value = _.isNil(field?.parent_index)
|
|
49
56
|
? field.data_structure_id
|
|
57
|
+
: field?.type === "reference_dataset_field"
|
|
58
|
+
? `${field.name}/${field.parent_index}`
|
|
50
59
|
: `${field.data_structure_id}/${field.parent_index}`;
|
|
51
60
|
const modifier = _.find({ sourceType: field.field_type })(
|
|
52
61
|
typeCastModifiers
|
|
@@ -79,7 +88,7 @@ export const StructureFieldsDropdown = ({
|
|
|
79
88
|
const toFieldOption = (field) =>
|
|
80
89
|
_.has("options")(field)
|
|
81
90
|
? {
|
|
82
|
-
icon: "table",
|
|
91
|
+
icon: field?.isReferenceDataset ? "list ol" : "table",
|
|
83
92
|
label: field.label,
|
|
84
93
|
options: _.map(formatOption)(field.options),
|
|
85
94
|
}
|
|
@@ -92,7 +101,16 @@ export const StructureFieldsDropdown = ({
|
|
|
92
101
|
(acc, v, k) =>
|
|
93
102
|
_.isNil(k) || k === "undefined"
|
|
94
103
|
? [...acc, ...v]
|
|
95
|
-
: [
|
|
104
|
+
: [
|
|
105
|
+
...acc,
|
|
106
|
+
{
|
|
107
|
+
label: k,
|
|
108
|
+
options: v,
|
|
109
|
+
isReferenceDataset: _.any({ type: "reference_dataset_field" })(
|
|
110
|
+
v
|
|
111
|
+
),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
96
114
|
[]
|
|
97
115
|
),
|
|
98
116
|
_.map(toFieldOption)
|
|
@@ -3,6 +3,7 @@ import React from "react";
|
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
5
|
import { Grid, Icon, Popup } from "semantic-ui-react";
|
|
6
|
+
import { getStructureFieldOptionValue } from "../selectors/getStructureFieldOptionValue";
|
|
6
7
|
import StructureFieldsDropdown from "./StructureFieldsDropdown";
|
|
7
8
|
|
|
8
9
|
const getClauses = (selectedStructure) => {
|
|
@@ -41,31 +42,29 @@ const JoinClause = ({
|
|
|
41
42
|
}) => {
|
|
42
43
|
const addActionDisabled = _.isEmpty(left) || _.isEmpty(right);
|
|
43
44
|
const { formatMessage } = useIntl();
|
|
45
|
+
|
|
44
46
|
return (
|
|
45
|
-
<Grid>
|
|
47
|
+
<Grid style={{ display: "flex", alignItems: "center" }}>
|
|
46
48
|
<Grid.Column width={4}>
|
|
47
49
|
<StructureFieldsDropdown
|
|
48
50
|
fluid
|
|
49
51
|
parentStructures={structureToFieldDropdown([selectedStructure])}
|
|
50
52
|
onSelectField={handleChange("left", idx)}
|
|
51
|
-
value={
|
|
52
|
-
_.isNil(_.prop("parent_index")(left))
|
|
53
|
-
? _.prop("id")(left)
|
|
54
|
-
: `${_.prop("id")(left)}/${_.prop("parent_index")(left)}`
|
|
55
|
-
}
|
|
53
|
+
value={getStructureFieldOptionValue(left)}
|
|
56
54
|
/>
|
|
57
55
|
</Grid.Column>
|
|
58
|
-
<Grid.Column
|
|
56
|
+
<Grid.Column
|
|
57
|
+
width={1}
|
|
58
|
+
style={{ textAlign: "center", fontSize: "x-large" }}
|
|
59
|
+
>
|
|
60
|
+
{"="}
|
|
61
|
+
</Grid.Column>
|
|
59
62
|
<Grid.Column width={4}>
|
|
60
63
|
<StructureFieldsDropdown
|
|
61
64
|
fluid
|
|
62
65
|
parentStructures={structureToFieldDropdown(parentStructures)}
|
|
63
66
|
onSelectField={handleChange("right", idx)}
|
|
64
|
-
value={
|
|
65
|
-
_.isNil(_.prop("parent_index")(right))
|
|
66
|
-
? _.prop("id")(right)
|
|
67
|
-
: `${_.prop("id")(right)}/${_.prop("parent_index")(right)}`
|
|
68
|
-
}
|
|
67
|
+
value={getStructureFieldOptionValue(right)}
|
|
69
68
|
/>
|
|
70
69
|
</Grid.Column>
|
|
71
70
|
<Grid.Column width={1}>
|
|
@@ -128,15 +127,16 @@ export const StructureSelectorInputFieldJoin = ({
|
|
|
128
127
|
data_structure_id: id,
|
|
129
128
|
parent_index: parent_index,
|
|
130
129
|
name: name,
|
|
130
|
+
type: type,
|
|
131
131
|
} = data;
|
|
132
132
|
const newClause = _.isNil(parent_index)
|
|
133
133
|
? { ...clauses[idx], [prop]: { id, name } }
|
|
134
|
-
: { ...clauses[idx], [prop]: { id, parent_index, name } };
|
|
134
|
+
: { ...clauses[idx], [prop]: { id, parent_index, name, type } };
|
|
135
135
|
const newClauses = _.set(`[${idx}]`, newClause)(clauses);
|
|
136
136
|
handleSelectField(newClauses);
|
|
137
137
|
};
|
|
138
138
|
return (
|
|
139
|
-
|
|
139
|
+
<div style={{ marginBottom: "1em" }}>
|
|
140
140
|
{clauses.map(({ left, right }, idx) => (
|
|
141
141
|
<JoinClause
|
|
142
142
|
key={idx}
|
|
@@ -150,7 +150,7 @@ export const StructureSelectorInputFieldJoin = ({
|
|
|
150
150
|
selectedStructure={selectedStructure}
|
|
151
151
|
/>
|
|
152
152
|
))}
|
|
153
|
-
|
|
153
|
+
</div>
|
|
154
154
|
);
|
|
155
155
|
};
|
|
156
156
|
|
|
@@ -16,7 +16,7 @@ export const StructureTagForm = ({
|
|
|
16
16
|
const { formatMessage } = useIntl();
|
|
17
17
|
const { handleSubmit, control, formState } = useForm({
|
|
18
18
|
mode: "all",
|
|
19
|
-
defaultValues: _.pick(["name", "domainIds"])(structureTag),
|
|
19
|
+
defaultValues: _.pick(["name", "description", "domainIds"])(structureTag),
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const { isDirty, isValid } = formState;
|
|
@@ -46,6 +46,28 @@ export const StructureTagForm = ({
|
|
|
46
46
|
/>
|
|
47
47
|
)}
|
|
48
48
|
/>
|
|
49
|
+
<Controller
|
|
50
|
+
control={control}
|
|
51
|
+
name="description"
|
|
52
|
+
rules={{ required: false }}
|
|
53
|
+
render={({
|
|
54
|
+
field: { onBlur, onChange, value },
|
|
55
|
+
fieldState: { error },
|
|
56
|
+
}) => (
|
|
57
|
+
<Form.Input
|
|
58
|
+
autoComplete="off"
|
|
59
|
+
error={error}
|
|
60
|
+
id="description"
|
|
61
|
+
label={formatMessage({ id: "structureTagForm.props.description" })}
|
|
62
|
+
onBlur={onBlur}
|
|
63
|
+
onChange={(_e, { value }) => onChange(value)}
|
|
64
|
+
placeholder={formatMessage({
|
|
65
|
+
id: "structureTagForm.props.description",
|
|
66
|
+
})}
|
|
67
|
+
value={value}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
/>
|
|
49
71
|
<Controller
|
|
50
72
|
control={control}
|
|
51
73
|
name="domainIds"
|
|
@@ -36,6 +36,9 @@ export const StructureTagsCards = ({ deleteStructureTag, structureTags }) => {
|
|
|
36
36
|
>
|
|
37
37
|
{_.prop("name")(structureTag)}
|
|
38
38
|
</Card.Header>
|
|
39
|
+
<Card.Description>
|
|
40
|
+
{_.prop("description")(structureTag)}
|
|
41
|
+
</Card.Description>
|
|
39
42
|
</Card.Content>
|
|
40
43
|
<Card.Content extra>
|
|
41
44
|
<div className="ui actions">
|
|
@@ -4,7 +4,6 @@ import PropTypes from "prop-types";
|
|
|
4
4
|
import { connect } from "react-redux";
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
6
|
import { getFieldType } from "@truedat/core/services/fieldType";
|
|
7
|
-
import { fetchStructure } from "../routines";
|
|
8
7
|
import StructureFieldsDropdown from "./StructureFieldsDropdown";
|
|
9
8
|
|
|
10
9
|
export const ValueConditionStructure = ({
|
|
@@ -52,15 +51,10 @@ const mapStateToProps = (state) => ({
|
|
|
52
51
|
structuresSiblings: state.structuresSiblings,
|
|
53
52
|
});
|
|
54
53
|
|
|
55
|
-
const mapDispatchToProps = { fetchStructure };
|
|
56
|
-
|
|
57
54
|
ValueConditionStructure.propTypes = {
|
|
58
55
|
onChange: PropTypes.func,
|
|
59
56
|
siblings: PropTypes.array,
|
|
60
57
|
structuresSiblings: PropTypes.object,
|
|
61
58
|
value: PropTypes.number,
|
|
62
59
|
};
|
|
63
|
-
export default connect(
|
|
64
|
-
mapStateToProps,
|
|
65
|
-
mapDispatchToProps
|
|
66
|
-
)(ValueConditionStructure);
|
|
60
|
+
export default connect(mapStateToProps)(ValueConditionStructure);
|