@truedat/df 4.35.3 → 4.35.7

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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.35.6] 2022-01-04
4
+
5
+ ### Added
6
+
7
+ - [TD-4312] Autogenerated template identifier widget
8
+
3
9
  ## [4.34.0] 2021-12-02
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/df",
3
- "version": "4.35.3",
3
+ "version": "4.35.7",
4
4
  "description": "Truedat Web Data Quality Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -80,8 +80,8 @@
80
80
  ]
81
81
  },
82
82
  "dependencies": {
83
- "@truedat/auth": "4.35.3",
84
- "@truedat/core": "4.35.3",
83
+ "@truedat/auth": "4.35.7",
84
+ "@truedat/core": "4.35.7",
85
85
  "axios": "^0.19.2",
86
86
  "path-to-regexp": "^1.7.0",
87
87
  "prop-types": "^15.7.2",
@@ -100,5 +100,5 @@
100
100
  "react-dom": ">= 16.8.6 < 17",
101
101
  "semantic-ui-react": ">= 0.88.2 < 2.1"
102
102
  },
103
- "gitHead": "10cfa24ea2c47fe56e640e16cecaa51f302aaad3"
103
+ "gitHead": "99812619b928d7802bb2f33df3f3321c9c36995e"
104
104
  }
@@ -14,12 +14,13 @@ import DomainPreview from "./widgets/DomainPreview";
14
14
  import FieldGroupCopy from "./FieldGroupCopy";
15
15
  import ImagePreview from "./widgets/ImagePreview";
16
16
  import SystemPreview from "./widgets/SystemPreview";
17
+ import "../styles/fieldGroupDetail.less";
17
18
 
18
19
  const RichTextEditor = React.lazy(() =>
19
20
  import("@truedat/core/components/RichTextEditor")
20
21
  );
21
22
 
22
- const ValueRenderByType = ({ value, type, multiple, values }) => {
23
+ const ValueRenderByType = ({ value, type, multiple, values, widget }) => {
23
24
  switch (type) {
24
25
  case "url":
25
26
  return (
@@ -69,7 +70,18 @@ const ValueRenderByType = ({ value, type, multiple, values }) => {
69
70
  if (multiple) {
70
71
  return <Label>{value}</Label>;
71
72
  }
72
- return <div style={{ whiteSpace: "pre-wrap" }}>{value}</div>;
73
+ return (
74
+ <div
75
+ className={[
76
+ "default-value",
77
+ widget === "identifier" ? "identifier-value" : "",
78
+ ]
79
+ .join(" ")
80
+ .trim()}
81
+ >
82
+ {value}
83
+ </div>
84
+ );
73
85
  }
74
86
  };
75
87
 
@@ -78,6 +90,7 @@ ValueRenderByType.propTypes = {
78
90
  type: PropTypes.string,
79
91
  values: PropTypes.any,
80
92
  multiple: PropTypes.bool,
93
+ widget: PropTypes.string,
81
94
  };
82
95
 
83
96
  const parseField = (field) => {
@@ -104,7 +117,7 @@ const parseField = (field) => {
104
117
  const DynamicFieldValue = ({ label, value, type, values, widget }) => {
105
118
  return (
106
119
  <List.Item>
107
- <List.Header>{label}</List.Header>
120
+ <List.Header className="dynamic-field-header">{label}</List.Header>
108
121
  <List.Description>
109
122
  {_.isNil(value) || (!_.isNumber(value) && _.isEmpty(value)) ? (
110
123
  <Icon name="minus" color="grey" />
@@ -127,7 +140,12 @@ const DynamicFieldValue = ({ label, value, type, values, widget }) => {
127
140
  ) : widget === "password" ? (
128
141
  "*****"
129
142
  ) : (
130
- <ValueRenderByType value={value} type={type} values={values} />
143
+ <ValueRenderByType
144
+ value={value}
145
+ type={type}
146
+ values={values}
147
+ widget={widget}
148
+ />
131
149
  )}
132
150
  </List.Description>
133
151
  </List.Item>
@@ -8,6 +8,7 @@ import CheckboxField from "./CheckboxField";
8
8
  import ColorPickerField from "./ColorPickerField";
9
9
  import DropdownField from "./DropdownField";
10
10
  import EnrichedTextField from "./EnrichedTextField";
11
+ import IdentifierField from "./IdentifierField";
11
12
  import ImageField from "./ImageField";
12
13
  import PairListField from "./PairListField";
13
14
  import PasswordField from "./PasswordField";
@@ -24,6 +25,8 @@ const isNullOrEmpty = (value) =>
24
25
 
25
26
  const FieldByWidget = ({ scope, widget, onChange, field }) => {
26
27
  switch (widget) {
28
+ case "identifier":
29
+ return <IdentifierField field={field} />;
27
30
  case "dropdown":
28
31
  return <DropdownField field={field} scope={scope} onChange={onChange} />;
29
32
  case "radio":
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { useIntl } from "react-intl";
4
+
5
+ import "../../styles/identifierField.less";
6
+
7
+ export const IdentifierField = ({ field: { value } }) => {
8
+ const { formatMessage } = useIntl();
9
+ return (
10
+ <p className="identifier">
11
+ {value || formatMessage({ id: "template.field.autogenerated" })}
12
+ </p>
13
+ );
14
+ };
15
+
16
+ IdentifierField.propTypes = {
17
+ field: PropTypes.object,
18
+ };
19
+
20
+ export default IdentifierField;
@@ -8,7 +8,9 @@ export default {
8
8
  "template.actions.delete.confirmation.content":
9
9
  "Template {name} will be deleted. Are you sure?",
10
10
  "template.actions.delete.confirmation.header": "Delete Template",
11
+ "template.field.autogenerated": "Generated automatically",
11
12
  "template.field.cardinality": "Cardinality",
13
+ "template.field.cardinality.0": "None (autogenerated)",
12
14
  "template.field.cardinality.*": "None or more",
13
15
  "template.field.cardinality.+": "One or more",
14
16
  "template.field.cardinality.1": "One",
@@ -8,7 +8,9 @@ export default {
8
8
  "template.actions.delete.confirmation.content":
9
9
  "Se va a eliminar la plantilla {name}. ¿Estás seguro?",
10
10
  "template.actions.delete.confirmation.header": "Eliminar plantilla",
11
+ "template.field.autogenerated": "Generado automáticamente",
11
12
  "template.field.cardinality": "Cardinalidad",
13
+ "template.field.cardinality.0": "Ninguno (autogenerado)",
12
14
  "template.field.cardinality.*": "Ningúno o más",
13
15
  "template.field.cardinality.+": "Uno o más",
14
16
  "template.field.cardinality.1": "Uno",
@@ -0,0 +1,11 @@
1
+ .list > .item > .header.dynamic-field-header {
2
+ margin-bottom: 10px;
3
+ }
4
+
5
+ .identifier-value {
6
+ font-family: 'Courier New', Courier, monospace;
7
+ font-size: medium;
8
+ }
9
+ .default-value {
10
+ whiteSpace: "pre-wrap"
11
+ }
@@ -0,0 +1,8 @@
1
+ .identifier {
2
+ font-family: 'Courier New', Courier, monospace;
3
+ color: #bbb;
4
+ margin: 20px 0;
5
+ padding: 10px;
6
+ border: 1px solid #ccc;
7
+
8
+ }
@@ -62,6 +62,7 @@ export const DefaultValue = ({
62
62
  />
63
63
  )}
64
64
  {!type &&
65
+ field.cardinality != "0" &&
65
66
  !_.includes(fieldType)([
66
67
  "url",
67
68
  "date",
@@ -27,53 +27,53 @@ export const ValuesField = ({
27
27
  text: formatMessage({ id }),
28
28
  }))(options);
29
29
 
30
- return (
31
- valueSegment(values, keyType, fieldType) && (
32
- <Segment>
33
- {_.size(values) > 1 && (
34
- <Form.Dropdown
35
- fluid
36
- selection
37
- label={formatMessage({ id: "template.field.values" })}
38
- onChange={onSelectionChange}
39
- value={keyType || "null"}
40
- required
41
- options={valueTypes(values)}
42
- />
43
- )}
44
- {keyType && (
45
- <ValuesSelector
46
- cardinality={field?.cardinality}
30
+ return field.cardinality == "0"
31
+ ? null
32
+ : valueSegment(values, keyType, fieldType) && (
33
+ <Segment>
34
+ {_.size(values) > 1 && (
35
+ <Form.Dropdown
36
+ fluid
37
+ selection
38
+ label={formatMessage({ id: "template.field.values" })}
39
+ onChange={onSelectionChange}
40
+ value={keyType || "null"}
41
+ required
42
+ options={valueTypes(values)}
43
+ />
44
+ )}
45
+ {keyType && (
46
+ <ValuesSelector
47
+ cardinality={field?.cardinality}
48
+ defaultField={defaultField}
49
+ defaultValue={field?.default}
50
+ name={name}
51
+ formatMessage={formatMessage}
52
+ onChange={onChange}
53
+ type={keyType}
54
+ values={_.path(`values.${keyType}`)(field)}
55
+ />
56
+ )}
57
+ {_.includes(keyType)(["fixed", "fixed_tuple"]) && (
58
+ <Form.Checkbox
59
+ name={subscribableField}
60
+ label={formatMessage({ id: "template.field.subscribable" })}
61
+ checked={_.prop("subscribable")(field) || false}
62
+ onChange={(e, { name, checked: value }) =>
63
+ onChange(null, { name, value })
64
+ }
65
+ />
66
+ )}
67
+ <DefaultValue
47
68
  defaultField={defaultField}
48
- defaultValue={field?.default}
49
- name={name}
69
+ field={field}
70
+ fieldType={fieldType}
50
71
  formatMessage={formatMessage}
51
72
  onChange={onChange}
52
73
  type={keyType}
53
- values={_.path(`values.${keyType}`)(field)}
54
- />
55
- )}
56
- {_.includes(keyType)(["fixed", "fixed_tuple"]) && (
57
- <Form.Checkbox
58
- name={subscribableField}
59
- label={formatMessage({ id: "template.field.subscribable" })}
60
- checked={_.prop("subscribable")(field) || false}
61
- onChange={(e, { name, checked: value }) =>
62
- onChange(null, { name, value })
63
- }
64
74
  />
65
- )}
66
- <DefaultValue
67
- defaultField={defaultField}
68
- field={field}
69
- fieldType={fieldType}
70
- formatMessage={formatMessage}
71
- onChange={onChange}
72
- type={keyType}
73
- />
74
- </Segment>
75
- )
76
- );
75
+ </Segment>
76
+ );
77
77
  };
78
78
 
79
79
  ValuesField.propTypes = {
@@ -84,6 +84,12 @@ exports[`<FieldForm /> manages handleCardinalityChange 1`] = `
84
84
  onChange={[Function]}
85
85
  options={
86
86
  Array [
87
+ Object {
88
+ "icon": "hashtag",
89
+ "key": undefined,
90
+ "text": "Identifier",
91
+ "value": "identifier",
92
+ },
87
93
  Object {
88
94
  "icon": "minus",
89
95
  "key": undefined,
@@ -425,6 +431,12 @@ exports[`<FieldForm /> matches the latest snapshot 1`] = `
425
431
  onChange={[Function]}
426
432
  options={
427
433
  Array [
434
+ Object {
435
+ "icon": "hashtag",
436
+ "key": undefined,
437
+ "text": "Identifier",
438
+ "value": "identifier",
439
+ },
428
440
  Object {
429
441
  "icon": "minus",
430
442
  "key": undefined,
@@ -711,6 +723,12 @@ exports[`<FieldForm /> renders MandatoryConditional 1`] = `
711
723
  onChange={[Function]}
712
724
  options={
713
725
  Array [
726
+ Object {
727
+ "icon": "hashtag",
728
+ "key": undefined,
729
+ "text": "Identifier",
730
+ "value": "identifier",
731
+ },
714
732
  Object {
715
733
  "icon": "minus",
716
734
  "key": undefined,
@@ -1052,6 +1070,12 @@ exports[`<FieldForm /> renders ValuesField and manages onChange 1`] = `
1052
1070
  onChange={[Function]}
1053
1071
  options={
1054
1072
  Array [
1073
+ Object {
1074
+ "icon": "hashtag",
1075
+ "key": undefined,
1076
+ "text": "Identifier",
1077
+ "value": "identifier",
1078
+ },
1055
1079
  Object {
1056
1080
  "icon": "minus",
1057
1081
  "key": undefined,
@@ -31,6 +31,14 @@ export const getWidgetOptions = () => {
31
31
  };
32
32
 
33
33
  export const WIDGETS = [
34
+ {
35
+ key: "identifier",
36
+ value: "identifier",
37
+ text: "Identifier",
38
+ icon: "hashtag",
39
+ cardinalities: ["0"],
40
+ types: ["string"]
41
+ },
34
42
  {
35
43
  key: "string",
36
44
  value: "string",