@truedat/dd 4.43.6 → 4.44.2
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 +6 -0
- package/package.json +6 -6
- package/src/api/fragments.js +10 -0
- package/src/api/mutations.js +28 -0
- package/src/api/queries.js +20 -0
- package/src/api.js +0 -4
- package/src/components/DictionaryRoutes.js +2 -10
- package/src/components/LinkStructureTagForm.js +2 -2
- package/src/components/LinkedStructureTag.js +16 -7
- package/src/components/StructureLinkTagButton.js +8 -11
- package/src/components/StructureSummary.js +1 -1
- package/src/components/StructureTag.js +59 -20
- package/src/components/StructureTagForm.js +30 -35
- package/src/components/StructureTags.js +7 -6
- package/src/components/StructureTagsCards.js +56 -59
- package/src/components/StructureTagsCrumbs.js +4 -4
- package/src/components/StructureTagsRoutes.js +33 -57
- package/src/components/StructuresRoutes.js +0 -3
- package/src/components/TagsHeader.js +14 -21
- package/src/components/__tests__/PendingStructureNoteRow.spec.js +5 -1
- package/src/components/__tests__/PendingStructureNotes.spec.js +2 -2
- package/src/components/__tests__/StructureTag.spec.js +4 -1
- package/src/components/__tests__/StructureTagForm.spec.js +40 -82
- package/src/components/__tests__/StructureTags.spec.js +7 -7
- package/src/components/__tests__/StructureTagsCards.spec.js +38 -36
- package/src/components/__tests__/StructuresUploadEventsTable.spec.js +36 -42
- package/src/components/__tests__/__snapshots__/DictionaryRoutes.spec.js.snap +3 -3
- package/src/components/__tests__/__snapshots__/PendingStructureNoteRow.spec.js.snap +33 -29
- package/src/components/__tests__/__snapshots__/StructureTag.spec.js.snap +13 -2
- package/src/components/__tests__/__snapshots__/StructureTagForm.spec.js.snap +7 -56
- package/src/components/__tests__/__snapshots__/StructureTags.spec.js.snap +32 -44
- package/src/components/__tests__/__snapshots__/StructureTagsCards.spec.js.snap +53 -118
- package/src/components/__tests__/__snapshots__/StructureTagsCrumbs.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/StructureTypes.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/StructureTypesCrumbs.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/StructureTypesTable.spec.js.snap +2 -2
- package/src/messages/en.js +1 -0
- package/src/messages/es.js +1 -0
- package/src/reducers/__tests__/editableStructureTags.spec.js +39 -0
- package/src/reducers/__tests__/structureTagsSaving.spec.js +40 -0
- package/src/reducers/__tests__/structuresUploadEventsLoading.spec.js +18 -4
- package/src/reducers/editableStructureTags.js +19 -0
- package/src/reducers/index.js +4 -9
- package/src/reducers/structureTagSaving.js +18 -0
- package/src/routines.js +3 -5
- package/src/sagas/__tests__/createStructureTag.spec.js +28 -13
- package/src/sagas/__tests__/deleteStructureTag.spec.js +27 -15
- package/src/sagas/__tests__/updateStructureTag.spec.js +26 -13
- package/src/sagas/createStructureTag.js +15 -13
- package/src/sagas/deleteStructureTag.js +13 -8
- package/src/sagas/index.js +0 -6
- package/src/sagas/updateStructureTag.js +8 -15
- package/src/selectors/__tests__/getStructuresUploadEventColumns.spec.js +1 -1
- package/src/components/StructureTagLoader.js +0 -28
- package/src/components/StructureTagsLoader.js +0 -26
- package/src/components/__tests__/StructureTagLoader.spec.js +0 -29
- package/src/components/__tests__/StructureTagsLoader.spec.js +0 -24
- package/src/components/__tests__/__snapshots__/StructureTagLoader.spec.js.snap +0 -3
- package/src/components/__tests__/__snapshots__/StructureTagsLoader.spec.js.snap +0 -3
- package/src/reducers/__tests__/structureTag.spec.js +0 -80
- package/src/reducers/__tests__/structureTagLoading.spec.js +0 -40
- package/src/reducers/__tests__/structureTags.spec.js +0 -32
- package/src/reducers/__tests__/structureTagsLoading.spec.js +0 -40
- package/src/reducers/structureTag.js +0 -38
- package/src/reducers/structureTagLoading.js +0 -16
- package/src/reducers/structureTags.js +0 -19
- package/src/reducers/structureTagsLoading.js +0 -16
- package/src/sagas/__tests__/deleteStructureType.spec.js +0 -70
- package/src/sagas/__tests__/fetchStructureTag.spec.js +0 -74
- package/src/sagas/__tests__/fetchStructureTags.spec.js +0 -72
- package/src/sagas/fetchStructureTag.js +0 -29
- package/src/sagas/fetchStructureTags.js +0 -25
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.44.2",
|
|
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.14.1",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "4.
|
|
37
|
+
"@truedat/test": "4.44.2",
|
|
38
38
|
"babel-jest": "^27.0.6",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@truedat/auth": "4.
|
|
88
|
-
"@truedat/core": "4.
|
|
89
|
-
"@truedat/df": "4.
|
|
87
|
+
"@truedat/auth": "4.44.2",
|
|
88
|
+
"@truedat/core": "4.44.2",
|
|
89
|
+
"@truedat/df": "4.44.2",
|
|
90
90
|
"lodash": "^4.17.21",
|
|
91
91
|
"path-to-regexp": "^1.7.0",
|
|
92
92
|
"prop-types": "^15.7.2",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"react-dom": ">= 16.8.6 < 17",
|
|
108
108
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "ca0c5fffcba96736f7a2054f3c37789da8c30a9e"
|
|
111
111
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
|
+
import { STRUCTURE_TAG_DETAIL } from "./fragments";
|
|
3
|
+
|
|
4
|
+
export const CREATE_STRUCTURE_TAG = gql`
|
|
5
|
+
mutation CreateStructureTag($structureTag: StructureTagInput!) {
|
|
6
|
+
createStructureTag(structureTag: $structureTag) {
|
|
7
|
+
...StructureTagDetail
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
${STRUCTURE_TAG_DETAIL}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const UPDATE_STRUCTURE_TAG = gql`
|
|
14
|
+
mutation UpdateStructureTag($structureTag: StructureTagInput!) {
|
|
15
|
+
updateStructureTag(structureTag: $structureTag) {
|
|
16
|
+
...StructureTagDetail
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
${STRUCTURE_TAG_DETAIL}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export const DELETE_STRUCTURE_TAG = gql`
|
|
23
|
+
mutation DeleteStructureTag($id: ID!) {
|
|
24
|
+
deleteStructureTag(id: $id) {
|
|
25
|
+
id
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
|
+
import { STRUCTURE_TAG_DETAIL } from "./fragments";
|
|
3
|
+
|
|
4
|
+
export const STRUCTURE_TAG_QUERY = gql`
|
|
5
|
+
query StructureTag($id: ID!) {
|
|
6
|
+
structureTag(id: $id) {
|
|
7
|
+
...StructureTagDetail
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
${STRUCTURE_TAG_DETAIL}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const STRUCTURE_TAGS_QUERY = gql`
|
|
14
|
+
query StructureTags {
|
|
15
|
+
structureTags {
|
|
16
|
+
...StructureTagDetail
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
${STRUCTURE_TAG_DETAIL}
|
|
20
|
+
`;
|
package/src/api.js
CHANGED
|
@@ -27,8 +27,6 @@ const API_PROFILE_GROUPS = "/api/profile_execution_groups";
|
|
|
27
27
|
const API_SYSTEM = "/api/systems/:id";
|
|
28
28
|
const API_SYSTEMS = "/api/systems";
|
|
29
29
|
const API_SYSTEM_STRUCTURES = "/api/systems/:id/structures";
|
|
30
|
-
const API_STRUCTURE_TAG = "/api/data_structure_tags/:id";
|
|
31
|
-
const API_STRUCTURE_TAGS = "/api/data_structure_tags";
|
|
32
30
|
const API_STRUCTURE_TYPE = "/api/data_structure_types/:id";
|
|
33
31
|
const API_STRUCTURE_TYPES = "/api/data_structure_types";
|
|
34
32
|
const API_STRUCTURES_DOMAINS_UPLOAD =
|
|
@@ -76,8 +74,6 @@ export {
|
|
|
76
74
|
API_SYSTEM,
|
|
77
75
|
API_SYSTEMS,
|
|
78
76
|
API_SYSTEM_STRUCTURES,
|
|
79
|
-
API_STRUCTURE_TAG,
|
|
80
|
-
API_STRUCTURE_TAGS,
|
|
81
77
|
API_STRUCTURE_TYPE,
|
|
82
78
|
API_STRUCTURE_TYPES,
|
|
83
79
|
API_USER_SEARCH_FILTERS,
|
|
@@ -72,15 +72,7 @@ export const DictionaryRoutes = () => {
|
|
|
72
72
|
</>
|
|
73
73
|
)}
|
|
74
74
|
/>
|
|
75
|
-
<Route
|
|
76
|
-
path={STRUCTURE_TAGS}
|
|
77
|
-
render={() => (
|
|
78
|
-
<>
|
|
79
|
-
<StructureTypesLoader />
|
|
80
|
-
<StructureTagsRoutes />
|
|
81
|
-
</>
|
|
82
|
-
)}
|
|
83
|
-
/>
|
|
75
|
+
<Route path={STRUCTURE_TAGS} render={() => <StructureTagsRoutes />} />
|
|
84
76
|
<Route
|
|
85
77
|
path={STRUCTURE_TYPES}
|
|
86
78
|
render={() => (
|
|
@@ -113,7 +105,7 @@ export const DictionaryRoutes = () => {
|
|
|
113
105
|
render={() => (
|
|
114
106
|
<>
|
|
115
107
|
<StructureTypesLoader />
|
|
116
|
-
<
|
|
108
|
+
<ProfileGroupLoader />
|
|
117
109
|
<Switch>
|
|
118
110
|
<Route
|
|
119
111
|
exact
|
|
@@ -142,11 +142,11 @@ LinkStructureTagForm.propTypes = {
|
|
|
142
142
|
const mapStateToProps = ({
|
|
143
143
|
linkedStructureTags,
|
|
144
144
|
structure,
|
|
145
|
-
|
|
145
|
+
editableStructureTags,
|
|
146
146
|
}) => ({
|
|
147
147
|
linkedStructureTags,
|
|
148
148
|
structureId: _.prop("id")(structure),
|
|
149
|
-
structureTags,
|
|
149
|
+
structureTags: editableStructureTags,
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
const mapDispatchToProps = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
1
2
|
import React, { useEffect, useState } from "react";
|
|
2
3
|
import PropTypes from "prop-types";
|
|
3
4
|
import { Icon, Label, Popup } from "semantic-ui-react";
|
|
@@ -7,9 +8,10 @@ import LinkStructureTagForm from "./LinkStructureTagForm";
|
|
|
7
8
|
const LinkedStructureTag = ({
|
|
8
9
|
id,
|
|
9
10
|
_embedded,
|
|
11
|
+
editable,
|
|
10
12
|
description,
|
|
11
13
|
loading,
|
|
12
|
-
|
|
14
|
+
structureTags,
|
|
13
15
|
}) => {
|
|
14
16
|
const name = _embedded.data_structure_tag.name;
|
|
15
17
|
const tagId = _embedded.data_structure_tag.id;
|
|
@@ -20,6 +22,8 @@ const LinkedStructureTag = ({
|
|
|
20
22
|
if (loading) setOpenForm(false);
|
|
21
23
|
}, [loading, setOpenForm]);
|
|
22
24
|
|
|
25
|
+
const trigger = editable ? <Icon link name="edit" /> : null;
|
|
26
|
+
|
|
23
27
|
return (
|
|
24
28
|
<Popup
|
|
25
29
|
basic
|
|
@@ -32,7 +36,7 @@ const LinkedStructureTag = ({
|
|
|
32
36
|
positionFixed
|
|
33
37
|
trigger={
|
|
34
38
|
<Label tag style={{ marginLeft: "1.5em" }}>
|
|
35
|
-
{
|
|
39
|
+
{_.isEmpty(structureTags) ? null : (
|
|
36
40
|
<Popup
|
|
37
41
|
on="click"
|
|
38
42
|
basic
|
|
@@ -53,7 +57,7 @@ const LinkedStructureTag = ({
|
|
|
53
57
|
position="bottom center"
|
|
54
58
|
size="large"
|
|
55
59
|
positionFixed
|
|
56
|
-
trigger={
|
|
60
|
+
trigger={trigger}
|
|
57
61
|
/>
|
|
58
62
|
)}
|
|
59
63
|
|
|
@@ -67,14 +71,19 @@ const LinkedStructureTag = ({
|
|
|
67
71
|
LinkedStructureTag.propTypes = {
|
|
68
72
|
_embedded: PropTypes.object,
|
|
69
73
|
description: PropTypes.string,
|
|
74
|
+
editable: PropTypes.bool,
|
|
70
75
|
id: PropTypes.number,
|
|
71
76
|
loading: PropTypes.bool,
|
|
72
|
-
|
|
77
|
+
structureTags: PropTypes.array,
|
|
73
78
|
};
|
|
74
79
|
|
|
75
|
-
const mapStateToProps =
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
const mapStateToProps = ({
|
|
81
|
+
editableStructureTags,
|
|
82
|
+
linkingStructureTags,
|
|
83
|
+
deletingStructureTags,
|
|
84
|
+
}) => ({
|
|
85
|
+
loading: linkingStructureTags || deletingStructureTags,
|
|
86
|
+
structureTags: editableStructureTags,
|
|
78
87
|
});
|
|
79
88
|
|
|
80
89
|
export default connect(mapStateToProps)(LinkedStructureTag);
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useState } from "react";
|
|
2
3
|
import { Button, Popup } from "semantic-ui-react";
|
|
3
4
|
import { useIntl } from "react-intl";
|
|
4
5
|
import { connect } from "react-redux";
|
|
5
6
|
import PropTypes from "prop-types";
|
|
6
7
|
import LinkStructureTagForm from "./LinkStructureTagForm";
|
|
7
8
|
|
|
8
|
-
export const StructureLinkTagButton = ({
|
|
9
|
+
export const StructureLinkTagButton = ({ structureTags }) => {
|
|
9
10
|
const { formatMessage } = useIntl();
|
|
10
11
|
const [open, setOpen] = useState(false);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
if (loading) setOpen(false);
|
|
14
|
-
}, [loading, setOpen]);
|
|
15
|
-
|
|
16
|
-
return (
|
|
13
|
+
return _.isEmpty(structureTags) ? null : (
|
|
17
14
|
<Popup
|
|
18
15
|
on="click"
|
|
19
16
|
basic
|
|
@@ -21,7 +18,7 @@ export const StructureLinkTagButton = ({ loading }) => {
|
|
|
21
18
|
onOpen={() => setOpen(true)}
|
|
22
19
|
onClose={() => setOpen(false)}
|
|
23
20
|
open={open}
|
|
24
|
-
content={<LinkStructureTagForm />}
|
|
21
|
+
content={<LinkStructureTagForm structureTags={structureTags} />}
|
|
25
22
|
position="bottom center"
|
|
26
23
|
size="large"
|
|
27
24
|
positionFixed
|
|
@@ -40,11 +37,11 @@ export const StructureLinkTagButton = ({ loading }) => {
|
|
|
40
37
|
};
|
|
41
38
|
|
|
42
39
|
StructureLinkTagButton.propTypes = {
|
|
43
|
-
|
|
40
|
+
structureTags: PropTypes.array,
|
|
44
41
|
};
|
|
45
42
|
|
|
46
|
-
const mapStateToProps = ({
|
|
47
|
-
|
|
43
|
+
const mapStateToProps = ({ editableStructureTags }) => ({
|
|
44
|
+
structureTags: editableStructureTags,
|
|
48
45
|
});
|
|
49
46
|
|
|
50
47
|
export default connect(mapStateToProps)(StructureLinkTagButton);
|
|
@@ -153,7 +153,7 @@ const mapStateToProps = (state) => ({
|
|
|
153
153
|
userPermissions: state.userPermissions,
|
|
154
154
|
linkedStructureTagsLoading: state.linkedStructureTagsLoading,
|
|
155
155
|
updatedAt: getStructureUpdatedAt(state),
|
|
156
|
-
structureTags: state.
|
|
156
|
+
structureTags: state.editableStructureTags,
|
|
157
157
|
structureGrant: state.structureGrant,
|
|
158
158
|
...state.structure,
|
|
159
159
|
isAdmin: state.authentication.role === "admin",
|
|
@@ -2,30 +2,69 @@ import React from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { Header, Icon, Container, Segment } from "semantic-ui-react";
|
|
4
4
|
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import { connect } from "react-redux";
|
|
6
|
+
import { Loading } from "@truedat/core/components";
|
|
7
|
+
import { createStructureTag, updateStructureTag } from "../routines";
|
|
8
|
+
import StructureTagsCrumbs from "./StructureTagsCrumbs";
|
|
5
9
|
import StructureTagForm from "./StructureTagForm";
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const DEFAULT_VALUES = {
|
|
12
|
+
name: "",
|
|
13
|
+
domainIds: [],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const StructureTag = ({
|
|
17
|
+
structureTag = DEFAULT_VALUES,
|
|
18
|
+
updateStructureTag,
|
|
19
|
+
createStructureTag,
|
|
20
|
+
loading,
|
|
21
|
+
saving,
|
|
22
|
+
id,
|
|
23
|
+
}) => {
|
|
24
|
+
const action = id
|
|
25
|
+
? "structureTags.actions.edit"
|
|
26
|
+
: "structureTags.actions.create";
|
|
27
|
+
const onSubmit = id
|
|
28
|
+
? (data) => updateStructureTag({ ...data, id })
|
|
29
|
+
: createStructureTag;
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<StructureTagsCrumbs action={action} />
|
|
33
|
+
<Container text as={Segment}>
|
|
34
|
+
<Header as="h2">
|
|
35
|
+
<Icon name="tag" />
|
|
36
|
+
<Header.Content>
|
|
37
|
+
<FormattedMessage id={action} />
|
|
38
|
+
</Header.Content>
|
|
39
|
+
</Header>
|
|
40
|
+
{loading ? (
|
|
41
|
+
<Loading />
|
|
42
|
+
) : (
|
|
43
|
+
<StructureTagForm
|
|
44
|
+
structureTag={structureTag}
|
|
45
|
+
onSubmit={onSubmit}
|
|
46
|
+
saving={saving}
|
|
19
47
|
/>
|
|
20
|
-
|
|
21
|
-
</
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
48
|
+
)}
|
|
49
|
+
</Container>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
26
53
|
|
|
27
54
|
StructureTag.propTypes = {
|
|
28
|
-
|
|
55
|
+
structureTag: PropTypes.object,
|
|
56
|
+
updateStructureTag: PropTypes.func,
|
|
57
|
+
createStructureTag: PropTypes.func,
|
|
58
|
+
loading: PropTypes.bool,
|
|
59
|
+
saving: PropTypes.bool,
|
|
60
|
+
id: PropTypes.string,
|
|
29
61
|
};
|
|
30
62
|
|
|
31
|
-
|
|
63
|
+
const mapStateToProps = ({ structureTagSaving }) => ({
|
|
64
|
+
saving: structureTagSaving,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export default connect(mapStateToProps, {
|
|
68
|
+
createStructureTag,
|
|
69
|
+
updateStructureTag,
|
|
70
|
+
})(StructureTag);
|
|
@@ -1,38 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useState } from "react";
|
|
2
3
|
import PropTypes from "prop-types";
|
|
3
4
|
import { Button, Form } from "semantic-ui-react";
|
|
4
5
|
import { useForm, Controller } from "react-hook-form";
|
|
5
6
|
import { useIntl } from "react-intl";
|
|
6
|
-
import {
|
|
7
|
-
import { HistoryBackButton } from "@truedat/core/components";
|
|
8
|
-
import { createStructureTag, updateStructureTag } from "../routines";
|
|
7
|
+
import { HistoryBackButton, DomainSelector } from "@truedat/core/components";
|
|
9
8
|
|
|
10
9
|
export const StructureTagForm = ({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
loading,
|
|
11
|
+
onSubmit,
|
|
12
|
+
saving,
|
|
14
13
|
structureTag,
|
|
15
14
|
}) => {
|
|
15
|
+
const [domainsLoading, setDomainsLoading] = useState(true);
|
|
16
16
|
const { formatMessage } = useIntl();
|
|
17
17
|
const { handleSubmit, control, formState } = useForm({
|
|
18
18
|
mode: "all",
|
|
19
|
-
defaultValues:
|
|
20
|
-
name: "",
|
|
21
|
-
...structureTag,
|
|
22
|
-
},
|
|
19
|
+
defaultValues: _.pick(["name", "domainIds"])(structureTag),
|
|
23
20
|
});
|
|
24
21
|
|
|
25
|
-
const onSubmit = (params) =>
|
|
26
|
-
"id" in structureTag
|
|
27
|
-
? updateStructureTag({
|
|
28
|
-
id: structureTag.id,
|
|
29
|
-
...params,
|
|
30
|
-
})
|
|
31
|
-
: createStructureTag(params);
|
|
32
22
|
const { isDirty, isValid } = formState;
|
|
33
23
|
|
|
34
24
|
return (
|
|
35
|
-
<Form onSubmit={handleSubmit(onSubmit)}>
|
|
25
|
+
<Form onSubmit={handleSubmit(onSubmit)} loading={loading || domainsLoading}>
|
|
36
26
|
<Controller
|
|
37
27
|
control={control}
|
|
38
28
|
name="name"
|
|
@@ -56,19 +46,32 @@ export const StructureTagForm = ({
|
|
|
56
46
|
/>
|
|
57
47
|
)}
|
|
58
48
|
/>
|
|
49
|
+
<Controller
|
|
50
|
+
control={control}
|
|
51
|
+
name="domainIds"
|
|
52
|
+
render={({ field: { onChange, value } }) => (
|
|
53
|
+
<DomainSelector
|
|
54
|
+
action="manageTags"
|
|
55
|
+
value={value}
|
|
56
|
+
onLoad={() => setDomainsLoading(false)}
|
|
57
|
+
onChange={(_e, { value }) => onChange(value)}
|
|
58
|
+
label={formatMessage({ id: "structureTagForm.props.domains" })}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
61
|
+
/>
|
|
59
62
|
<div className="actions">
|
|
60
63
|
<Button
|
|
61
64
|
floated="right"
|
|
62
65
|
type="submit"
|
|
63
66
|
primary
|
|
64
|
-
loading={
|
|
65
|
-
disabled={
|
|
67
|
+
loading={saving}
|
|
68
|
+
disabled={saving || !isDirty || !isValid}
|
|
66
69
|
>
|
|
67
|
-
{formatMessage({ id: "actions.
|
|
70
|
+
{formatMessage({ id: "actions.save" })}
|
|
68
71
|
</Button>
|
|
69
72
|
<HistoryBackButton
|
|
70
73
|
content={formatMessage({ id: "actions.cancel" })}
|
|
71
|
-
disabled={
|
|
74
|
+
disabled={saving}
|
|
72
75
|
/>
|
|
73
76
|
</div>
|
|
74
77
|
</Form>
|
|
@@ -76,18 +79,10 @@ export const StructureTagForm = ({
|
|
|
76
79
|
};
|
|
77
80
|
|
|
78
81
|
StructureTagForm.propTypes = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
onSubmit: PropTypes.func.isRequired,
|
|
83
|
+
loading: PropTypes.bool,
|
|
84
|
+
saving: PropTypes.bool,
|
|
82
85
|
structureTag: PropTypes.object,
|
|
83
86
|
};
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
isSubmitting: structureTagCreating,
|
|
87
|
-
structureTag,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
export default connect(mapStateToProps, {
|
|
91
|
-
createStructureTag,
|
|
92
|
-
updateStructureTag,
|
|
93
|
-
})(StructureTagForm);
|
|
88
|
+
export default StructureTagForm;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Link } from "react-router-dom";
|
|
3
3
|
import { Button, Header, Icon, Segment } from "semantic-ui-react";
|
|
4
|
-
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
5
5
|
import { STRUCTURE_TAGS_NEW } from "@truedat/core/routes";
|
|
6
|
-
import { useAuthorized } from "@truedat/core/hooks";
|
|
7
6
|
import StructureTagsCards from "./StructureTagsCards";
|
|
8
7
|
|
|
9
|
-
export const StructureTags = () =>
|
|
10
|
-
|
|
8
|
+
export const StructureTags = () => {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
return (
|
|
11
11
|
<Segment>
|
|
12
12
|
<Header as="h2">
|
|
13
13
|
<Button
|
|
@@ -15,7 +15,7 @@ export const StructureTags = () =>
|
|
|
15
15
|
primary
|
|
16
16
|
as={Link}
|
|
17
17
|
to={STRUCTURE_TAGS_NEW}
|
|
18
|
-
content={
|
|
18
|
+
content={formatMessage({ id: "structureTags.actions.create" })}
|
|
19
19
|
/>
|
|
20
20
|
<Icon name="tags" circular />
|
|
21
21
|
<Header.Content>
|
|
@@ -27,6 +27,7 @@ export const StructureTags = () =>
|
|
|
27
27
|
</Header>
|
|
28
28
|
<StructureTagsCards />
|
|
29
29
|
</Segment>
|
|
30
|
-
)
|
|
30
|
+
);
|
|
31
|
+
};
|
|
31
32
|
|
|
32
33
|
export default StructureTags;
|
|
@@ -5,9 +5,11 @@ import { connect } from "react-redux";
|
|
|
5
5
|
import { Link } from "react-router-dom";
|
|
6
6
|
import { Button, Card, Message, Icon } from "semantic-ui-react";
|
|
7
7
|
import { FormattedMessage } from "react-intl";
|
|
8
|
-
import {
|
|
8
|
+
import { useQuery } from "@apollo/client";
|
|
9
|
+
import { ConfirmModal, Loading } from "@truedat/core/components";
|
|
9
10
|
import { linkTo } from "@truedat/core/routes";
|
|
10
11
|
import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
|
|
12
|
+
import { STRUCTURE_TAGS_QUERY } from "../api/queries";
|
|
11
13
|
import { deleteStructureTag } from "../routines";
|
|
12
14
|
|
|
13
15
|
const EmptyMessage = () => (
|
|
@@ -21,72 +23,67 @@ const EmptyMessage = () => (
|
|
|
21
23
|
</Message>
|
|
22
24
|
);
|
|
23
25
|
|
|
24
|
-
export const StructureTagsCards = ({
|
|
25
|
-
deleteStructureTag,
|
|
26
|
-
structureTags,
|
|
27
|
-
structureTagsLoading,
|
|
28
|
-
}) => {
|
|
29
|
-
if (structureTagsLoading) return null;
|
|
26
|
+
export const StructureTagsCards = ({ deleteStructureTag, structureTags }) => {
|
|
30
27
|
if (_.isEmpty(structureTags)) return <EmptyMessage />;
|
|
31
28
|
return (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
<Card
|
|
36
|
-
<Card.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
header
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</Card.Group>
|
|
75
|
-
</>
|
|
29
|
+
<Card.Group>
|
|
30
|
+
{structureTags.map((structureTag) => (
|
|
31
|
+
<Card key={structureTag?.id}>
|
|
32
|
+
<Card.Content>
|
|
33
|
+
<Card.Header
|
|
34
|
+
as={Link}
|
|
35
|
+
to={linkTo.STRUCTURE_TAGS_EDIT({ id: structureTag.id })}
|
|
36
|
+
>
|
|
37
|
+
{_.prop("name")(structureTag)}
|
|
38
|
+
</Card.Header>
|
|
39
|
+
</Card.Content>
|
|
40
|
+
<Card.Content extra>
|
|
41
|
+
<div className="ui actions">
|
|
42
|
+
<ConfirmModal
|
|
43
|
+
icon="trash"
|
|
44
|
+
trigger={<Button icon="trash" basic color="red" />}
|
|
45
|
+
header={
|
|
46
|
+
<FormattedMessage id="structureTags.actions.delete.confirmation.header" />
|
|
47
|
+
}
|
|
48
|
+
content={
|
|
49
|
+
structureTag.structureCount > 0 ? (
|
|
50
|
+
<FormattedMessage
|
|
51
|
+
id="structureTags.actions.delete.confirmation.content"
|
|
52
|
+
values={{
|
|
53
|
+
name: <i>{`'${structureTag.name}'`}</i>,
|
|
54
|
+
count: structureTag.structureCount,
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
) : (
|
|
58
|
+
<FormattedMessage
|
|
59
|
+
id="structureTags.actions.delete.noStructures.confirmation.content"
|
|
60
|
+
values={{ name: <i>{`'${structureTag.name}'`}</i> }}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
onConfirm={() => deleteStructureTag({ id: structureTag.id })}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</Card.Content>
|
|
68
|
+
</Card>
|
|
69
|
+
))}
|
|
70
|
+
</Card.Group>
|
|
76
71
|
);
|
|
77
72
|
};
|
|
78
73
|
|
|
79
74
|
StructureTagsCards.propTypes = {
|
|
80
75
|
structureTags: PropTypes.array,
|
|
81
|
-
structureTagsLoading: PropTypes.bool,
|
|
82
76
|
deleteStructureTag: PropTypes.func,
|
|
83
77
|
};
|
|
84
78
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
export const StructureTagsCardsLoader = (props) => {
|
|
80
|
+
const { loading, error, data } = useQuery(STRUCTURE_TAGS_QUERY);
|
|
81
|
+
if (error) return null;
|
|
82
|
+
if (loading) return <Loading />;
|
|
83
|
+
const structureTags = _.sortBy(accentInsensitivePathOrder("name"))(
|
|
84
|
+
data?.structureTags || []
|
|
85
|
+
);
|
|
86
|
+
return <StructureTagsCards structureTags={structureTags} {...props} />;
|
|
87
|
+
};
|
|
89
88
|
|
|
90
|
-
export default connect(
|
|
91
|
-
StructureTagsCards
|
|
92
|
-
);
|
|
89
|
+
export default connect(null, { deleteStructureTag })(StructureTagsCardsLoader);
|