@truedat/core 5.17.2 → 5.18.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/package.json +2 -2
- package/src/api/queries.js +7 -1
- package/src/components/FieldLabel.js +52 -0
- package/src/components/QxMenu.js +3 -2
- package/src/components/index.js +2 -0
- package/src/hooks/useActionDomains.js +19 -0
- package/src/hooks/useAuthorizedAction.js +19 -0
- package/src/routes.js +12 -2
- package/src/services/columnDecorators.js +19 -0
- package/src/services/formRules.js +35 -0
- package/src/services/index.js +2 -0
- package/src/services/statusColor.js +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"react-dom": ">= 16.8.6 < 17",
|
|
118
118
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "2cd5914eafeae16400d4ccccfabc00cd2c84c80f"
|
|
121
121
|
}
|
package/src/api/queries.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gql } from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
export const DOMAINS_QUERY = gql`
|
|
4
|
-
query DomainsQuery($action: String!, $domainActions: [String
|
|
4
|
+
query DomainsQuery($action: String!, $domainActions: [String], $ids: [ID]) {
|
|
5
5
|
domains(action: $action, ids: $ids) {
|
|
6
6
|
id
|
|
7
7
|
externalId
|
|
@@ -12,6 +12,12 @@ export const DOMAINS_QUERY = gql`
|
|
|
12
12
|
}
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
|
+
export const HAS_ANY_DOMAIN_QUERY = gql`
|
|
16
|
+
query HasAnyDomainQuery($action: String!) {
|
|
17
|
+
has_any_domain(action: $action)
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
15
21
|
export const DOMAIN_QUERY = gql`
|
|
16
22
|
query DomainQuery($id: ID!, $actions: [String!]) {
|
|
17
23
|
domain(id: $id) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { Form, Icon, Popup, Label } from "semantic-ui-react";
|
|
4
|
+
|
|
5
|
+
export default function FieldLabel({
|
|
6
|
+
children,
|
|
7
|
+
label,
|
|
8
|
+
required,
|
|
9
|
+
tooltip,
|
|
10
|
+
error,
|
|
11
|
+
}) {
|
|
12
|
+
return (
|
|
13
|
+
<Form.Field>
|
|
14
|
+
<label className="field-label">
|
|
15
|
+
{label}
|
|
16
|
+
{required && <span>*</span>}
|
|
17
|
+
{tooltip && (
|
|
18
|
+
<Popup
|
|
19
|
+
trigger={
|
|
20
|
+
<Icon
|
|
21
|
+
className="field-label-popup"
|
|
22
|
+
name="question circle outline"
|
|
23
|
+
/>
|
|
24
|
+
}
|
|
25
|
+
content={tooltip}
|
|
26
|
+
on="click"
|
|
27
|
+
hideOnScroll
|
|
28
|
+
/>
|
|
29
|
+
)}
|
|
30
|
+
{error && (
|
|
31
|
+
<Label
|
|
32
|
+
size="small"
|
|
33
|
+
className="field-label-error"
|
|
34
|
+
basic
|
|
35
|
+
pointing="left"
|
|
36
|
+
>
|
|
37
|
+
{error}
|
|
38
|
+
</Label>
|
|
39
|
+
)}
|
|
40
|
+
</label>
|
|
41
|
+
{children}
|
|
42
|
+
</Form.Field>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
FieldLabel.propTypes = {
|
|
47
|
+
children: PropTypes.node,
|
|
48
|
+
label: PropTypes.string,
|
|
49
|
+
required: PropTypes.bool,
|
|
50
|
+
tooltip: PropTypes.string,
|
|
51
|
+
error: PropTypes.string,
|
|
52
|
+
};
|
package/src/components/QxMenu.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { useAuthorized } from "../hooks";
|
|
3
|
-
import { DATA_VIEWS, FUNCTIONS } from "../routes";
|
|
3
|
+
import { DATA_VIEWS, FUNCTIONS, QUALITY_CONTROLS } from "../routes";
|
|
4
4
|
import Submenu from "./Submenu";
|
|
5
5
|
|
|
6
6
|
export const ITEMS = [
|
|
7
7
|
{ name: "dataViews", routes: [DATA_VIEWS] },
|
|
8
8
|
{ name: "functions", routes: [FUNCTIONS] },
|
|
9
|
+
{ name: "quality_controls", routes: [QUALITY_CONTROLS] },
|
|
9
10
|
];
|
|
10
11
|
|
|
11
12
|
export default function QxMenu() {
|
|
12
|
-
const authorized = useAuthorized();
|
|
13
|
+
const authorized = useAuthorized("quality_control");
|
|
13
14
|
|
|
14
15
|
return authorized ? (
|
|
15
16
|
<Submenu items={ITEMS} icon="weight" name="quality_experience" />
|
package/src/components/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import DescriptionInput from "./DescriptionInput";
|
|
|
19
19
|
import DomainSelector from "./DomainSelector";
|
|
20
20
|
import DropdownMenuItem from "./DropdownMenuItem";
|
|
21
21
|
import ErrorBoundary from "./ErrorBoundary";
|
|
22
|
+
import FieldLabel from "./FieldLabel";
|
|
22
23
|
import FiltersLoader from "./FiltersLoader";
|
|
23
24
|
import GlossaryMenu from "./GlossaryMenu";
|
|
24
25
|
import GrantMenu from "./GrantMenu";
|
|
@@ -72,6 +73,7 @@ export {
|
|
|
72
73
|
DomainSelector,
|
|
73
74
|
DropdownMenuItem,
|
|
74
75
|
ErrorBoundary,
|
|
76
|
+
FieldLabel,
|
|
75
77
|
FiltersLoader,
|
|
76
78
|
GlossaryMenu,
|
|
77
79
|
GrantMenu,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { useQuery } from "@apollo/client";
|
|
4
|
+
import { DOMAINS_QUERY } from "../api/queries";
|
|
5
|
+
|
|
6
|
+
export default function useActionDomains(props) {
|
|
7
|
+
const action = _.propOr("viewDomain", "action")(props);
|
|
8
|
+
const onCompleted = _.prop("onLoad")(props);
|
|
9
|
+
return useQuery(DOMAINS_QUERY, {
|
|
10
|
+
fetchPolicy: "cache-and-network",
|
|
11
|
+
variables: { action },
|
|
12
|
+
onCompleted,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
useActionDomains.propTypes = {
|
|
17
|
+
action: PropTypes.string,
|
|
18
|
+
onLoad: PropTypes.func,
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { useQuery } from "@apollo/client";
|
|
4
|
+
import { HAS_ANY_DOMAIN_QUERY } from "../api/queries";
|
|
5
|
+
|
|
6
|
+
export default function useAuthorizedAction(props) {
|
|
7
|
+
const action = _.propOr("viewDomain", "action")(props);
|
|
8
|
+
const onCompleted = _.prop("onLoad")(props);
|
|
9
|
+
return useQuery(HAS_ANY_DOMAIN_QUERY, {
|
|
10
|
+
fetchPolicy: "cache-and-network",
|
|
11
|
+
variables: { action },
|
|
12
|
+
onCompleted,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
useAuthorizedAction.propTypes = {
|
|
17
|
+
action: PropTypes.string,
|
|
18
|
+
onLoad: PropTypes.func,
|
|
19
|
+
};
|
package/src/routes.js
CHANGED
|
@@ -145,6 +145,12 @@ export const PENDING_STRUCTURE_NOTES = "/structureNotes";
|
|
|
145
145
|
export const PROFILE_EXECUTION =
|
|
146
146
|
"/profileGroups/:group_id/profileExecutions/:id";
|
|
147
147
|
export const PROFILE_GROUP = "/profileGroups/:id";
|
|
148
|
+
export const QUALITY_CONTROLS = "/qualityControls";
|
|
149
|
+
export const QUALITY_CONTROL_NEW = "/qualityControls/new";
|
|
150
|
+
export const QUALITY_CONTROL_EDIT = "/qualityControls/:id/edit";
|
|
151
|
+
export const QUALITY_CONTROL_NEW_DRAFT = "/qualityControls/:id/new_draft";
|
|
152
|
+
export const QUALITY_CONTROL = "/qualityControls/:id";
|
|
153
|
+
export const QUALITY_CONTROL_HISTORY = "/qualityControls/:id/history";
|
|
148
154
|
export const QUALITY_DASHBOARD = "/quality_dashboard";
|
|
149
155
|
export const REFERENCE_DATASET = "/referenceDatasets/:id";
|
|
150
156
|
export const REFERENCE_DATASETS = "/referenceDatasets";
|
|
@@ -225,7 +231,6 @@ export const TEMPLATE = "/templates/:templateId";
|
|
|
225
231
|
export const TEMPLATES = "/templates";
|
|
226
232
|
export const TEMPLATES_NEW = "/templates/new";
|
|
227
233
|
export const TEMPLATE_EDIT = "/templates/:id/edit";
|
|
228
|
-
export const TEMPLATE_SCOPE = "/templates\\?scope=:scope";
|
|
229
234
|
export const UNAUTHORIZED = "/unauthorized";
|
|
230
235
|
export const USER = "/users/:id";
|
|
231
236
|
export const USERS = "/users";
|
|
@@ -346,6 +351,12 @@ const routes = {
|
|
|
346
351
|
PENDING_STRUCTURE_NOTES,
|
|
347
352
|
PROFILE_EXECUTION,
|
|
348
353
|
PROFILE_GROUP,
|
|
354
|
+
QUALITY_CONTROLS,
|
|
355
|
+
QUALITY_CONTROL_NEW,
|
|
356
|
+
QUALITY_CONTROL_EDIT,
|
|
357
|
+
QUALITY_CONTROL_NEW_DRAFT,
|
|
358
|
+
QUALITY_CONTROL,
|
|
359
|
+
QUALITY_CONTROL_HISTORY,
|
|
349
360
|
QUALITY_DASHBOARD,
|
|
350
361
|
REFERENCE_DATASET,
|
|
351
362
|
REFERENCE_DATASETS,
|
|
@@ -423,7 +434,6 @@ const routes = {
|
|
|
423
434
|
TEMPLATES,
|
|
424
435
|
TEMPLATES_NEW,
|
|
425
436
|
TEMPLATE_EDIT,
|
|
426
|
-
TEMPLATE_SCOPE,
|
|
427
437
|
UNAUTHORIZED,
|
|
428
438
|
USER,
|
|
429
439
|
USERS,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import Moment from "react-moment";
|
|
6
|
+
|
|
7
|
+
export const TranslateDecorator = ({ id }) =>
|
|
8
|
+
id ? <FormattedMessage id={id} defaultMessage={id} /> : null;
|
|
9
|
+
|
|
10
|
+
TranslateDecorator.propTypes = {
|
|
11
|
+
id: PropTypes.string,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const DateDecorator = ({ date }) =>
|
|
15
|
+
date ? <Moment date={date} format="YYYY-MM-DD HH:mm" /> : null;
|
|
16
|
+
|
|
17
|
+
DateDecorator.propTypes = {
|
|
18
|
+
date: PropTypes.string,
|
|
19
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const numberRules = ({
|
|
2
|
+
formatMessage,
|
|
3
|
+
required,
|
|
4
|
+
minValue,
|
|
5
|
+
maxValue,
|
|
6
|
+
}) => ({
|
|
7
|
+
required: required
|
|
8
|
+
? formatMessage({ id: "form.validation.empty_required" })
|
|
9
|
+
: null,
|
|
10
|
+
min:
|
|
11
|
+
minValue || minValue === 0
|
|
12
|
+
? {
|
|
13
|
+
value: minValue,
|
|
14
|
+
message: formatMessage(
|
|
15
|
+
{ id: "form.validation.must_be_greater_than_or_equal" },
|
|
16
|
+
{ value: minValue }
|
|
17
|
+
),
|
|
18
|
+
}
|
|
19
|
+
: null,
|
|
20
|
+
max:
|
|
21
|
+
maxValue || maxValue === 0
|
|
22
|
+
? {
|
|
23
|
+
value: maxValue,
|
|
24
|
+
message: formatMessage(
|
|
25
|
+
{ id: "form.validation.must_be_less_than_or_equal" },
|
|
26
|
+
{ value: maxValue }
|
|
27
|
+
),
|
|
28
|
+
}
|
|
29
|
+
: null,
|
|
30
|
+
pattern: {
|
|
31
|
+
value: /^(-)?\d+(\.\d+)?$/,
|
|
32
|
+
message: formatMessage({ id: "form.validation.must_be_a_number" }),
|
|
33
|
+
},
|
|
34
|
+
valueAsNumber: true,
|
|
35
|
+
});
|
package/src/services/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import * as filters from "./filters";
|
|
|
5
5
|
import * as message from "./message";
|
|
6
6
|
import * as sort from "./sort";
|
|
7
7
|
import * as format from "./format";
|
|
8
|
+
import * as formRules from "./formRules";
|
|
8
9
|
import columnDecorator from "./columnDecorator";
|
|
9
10
|
import columnDecoratorComponent from "./columnDecoratorComponent";
|
|
10
11
|
import columnPredicate from "./columnPredicate";
|
|
@@ -18,6 +19,7 @@ export {
|
|
|
18
19
|
fieldType,
|
|
19
20
|
filters,
|
|
20
21
|
format,
|
|
22
|
+
formRules,
|
|
21
23
|
message,
|
|
22
24
|
sort,
|
|
23
25
|
};
|