@truedat/df 5.18.2 → 5.19.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/df",
3
- "version": "5.18.2",
3
+ "version": "5.19.0",
4
4
  "description": "Truedat Web Data Quality Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -87,8 +87,8 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "@apollo/client": "^3.7.1",
90
- "@truedat/auth": "5.18.2",
91
- "@truedat/core": "5.18.2",
90
+ "@truedat/auth": "5.19.0",
91
+ "@truedat/core": "5.19.0",
92
92
  "decode-uri-component": "^0.2.2",
93
93
  "path-to-regexp": "^1.7.0",
94
94
  "prop-types": "^15.8.1",
@@ -109,5 +109,5 @@
109
109
  "react-dom": ">= 16.8.6 < 17",
110
110
  "semantic-ui-react": ">= 2.0.3 < 2.2"
111
111
  },
112
- "gitHead": "d69ace0ddcf34baa4f4b60a6862a053327c1d299"
112
+ "gitHead": "df3fcd6655456c3468259d79762800c3c417147d"
113
113
  }
@@ -15,7 +15,6 @@ import {
15
15
  import { getValues } from "./valueDefinitions";
16
16
 
17
17
  const boostingEnabledScopes = ["bg", "dq", "ie", "ri"];
18
- const searchableEnabledScopes = ["bg", "dq", "ie", "ri", "dd"];
19
18
 
20
19
  const typeFromKey = (keys) =>
21
20
  _.includes("role_groups")(keys)
@@ -50,9 +49,7 @@ export const FieldForm = ({
50
49
  widget,
51
50
  disabledName,
52
51
  errors,
53
- editable = true,
54
52
  boost = "",
55
- searchable = true,
56
53
  } = field;
57
54
  const fieldNamePrefix = `${groupNamePrefix}.fields[${fieldIndex}]`;
58
55
  const valueName = `${fieldNamePrefix}.values`;
@@ -122,12 +119,6 @@ export const FieldForm = ({
122
119
  changeValue(valueName, value);
123
120
  };
124
121
 
125
- const checkboxEnabledText = (value) => {
126
- const msgPath = "template.field.checkbox.";
127
- const msg = value ? msgPath + "enabled" : msgPath + "disabled";
128
- return formatMessage({ id: msg });
129
- };
130
-
131
122
  //On widget change, verify if type and cardinality are still valid
132
123
  useEffect(() => {
133
124
  const widgetOptions = _.find({ value: widget })(WIDGETS);
@@ -263,34 +254,6 @@ export const FieldForm = ({
263
254
  />
264
255
  </Form.Field>
265
256
  ) : null}
266
- {_.includes(scope)(searchableEnabledScopes) ? (
267
- <Form.Field>
268
- <label>
269
- <FormattedMessage id="template.field.searchable" />
270
- </label>
271
- <Form.Checkbox
272
- name={`${fieldNamePrefix}.searchable`}
273
- label={checkboxEnabledText(searchable)}
274
- checked={searchable}
275
- onChange={(e, { name, checked: value }) =>
276
- onChange(null, { name, value })
277
- }
278
- />
279
- </Form.Field>
280
- ) : null}
281
- <Form.Field>
282
- <label>
283
- <FormattedMessage id="template.field.editable" />
284
- </label>
285
- <Form.Checkbox
286
- name={`${fieldNamePrefix}.editable`}
287
- label={checkboxEnabledText(editable)}
288
- checked={editable}
289
- onChange={(e, { name, checked: value }) =>
290
- onChange(null, { name, value })
291
- }
292
- />
293
- </Form.Field>
294
257
  </Form.Group>
295
258
  <ValuesField
296
259
  defaultField={defaultField}
@@ -301,6 +264,8 @@ export const FieldForm = ({
301
264
  onChange={onChange}
302
265
  onSelectionChange={onValueSelectionChange}
303
266
  subscribableField={subscribableField}
267
+ fieldNamePrefix={fieldNamePrefix}
268
+ scope={scope}
304
269
  values={values}
305
270
  />
306
271
  <ConditionalFieldForm
@@ -80,6 +80,7 @@ export const TemplateForm = ({ loading, template, onSubmit }) => {
80
80
  "editable",
81
81
  "boost",
82
82
  "searchable",
83
+ "ai_suggestion",
83
84
  ];
84
85
 
85
86
  const dependsProperty = _.isEmpty(_.path("depends.on")(field))
@@ -1,5 +1,5 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
2
+ import React, { useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { Form, Segment } from "semantic-ui-react";
5
5
  import { useIntl } from "react-intl";
@@ -7,6 +7,8 @@ import DefaultValue from "./DefaultValue";
7
7
  import ValuesSelector from "./ValuesSelector";
8
8
  import { valueSegment } from "./valueDefinitions";
9
9
 
10
+ const searchableEnabledScopes = ["bg", "dq", "ie", "ri", "dd"];
11
+
10
12
  export const ValuesField = ({
11
13
  defaultField,
12
14
  field,
@@ -17,8 +19,22 @@ export const ValuesField = ({
17
19
  onSelectionChange,
18
20
  subscribableField,
19
21
  values,
22
+ fieldNamePrefix,
23
+ scope,
20
24
  }) => {
21
25
  const { formatMessage } = useIntl();
26
+ const { ai_suggestion, editable = true, searchable = true } = field;
27
+
28
+ const hasAiSuggestion =
29
+ fieldType === "string" &&
30
+ _.includes(keyType)(["fixed", "fixed_tuple", undefined]);
31
+ useEffect(() => {
32
+ if (!hasAiSuggestion)
33
+ onChange(null, {
34
+ name: `${fieldNamePrefix}.ai_suggestion`,
35
+ value: false,
36
+ });
37
+ }, [hasAiSuggestion]);
22
38
 
23
39
  const valueTypes = (options) =>
24
40
  _.map(({ id, value }) => ({
@@ -54,16 +70,63 @@ export const ValuesField = ({
54
70
  values={_.path(`values.${keyType}`)(field)}
55
71
  />
56
72
  ) : null}
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
- ) : null}
73
+ <Form.Group size="small" widths="equal">
74
+ <Form.Field>
75
+ <Form.Checkbox
76
+ name={`${fieldNamePrefix}.editable`}
77
+ label={formatMessage({
78
+ id: "template.field.editable",
79
+ defaultMessage: "Editable",
80
+ })}
81
+ checked={editable}
82
+ onChange={(e, { name, checked: value }) =>
83
+ onChange(null, { name, value })
84
+ }
85
+ />
86
+ </Form.Field>
87
+
88
+ {hasAiSuggestion ? (
89
+ <Form.Field>
90
+ <Form.Checkbox
91
+ name={`${fieldNamePrefix}.ai_suggestion`}
92
+ label={formatMessage({
93
+ id: "template.field.ai_suggestion",
94
+ defaultMessage: "AI Suggestions",
95
+ })}
96
+ checked={ai_suggestion}
97
+ onChange={(_e, { name, checked: value }) =>
98
+ onChange(null, { name, value })
99
+ }
100
+ />
101
+ </Form.Field>
102
+ ) : null}
103
+
104
+ {_.includes(scope)(searchableEnabledScopes) ? (
105
+ <Form.Field>
106
+ <Form.Checkbox
107
+ name={`${fieldNamePrefix}.searchable`}
108
+ label={formatMessage({
109
+ id: "template.field.searchable",
110
+ defaultMessage: "Sercheable",
111
+ })}
112
+ checked={searchable}
113
+ onChange={(_e, { name, checked: value }) =>
114
+ onChange(null, { name, value })
115
+ }
116
+ />
117
+ </Form.Field>
118
+ ) : null}
119
+ {_.includes(keyType)(["fixed", "fixed_tuple"]) ? (
120
+ <Form.Checkbox
121
+ name={subscribableField}
122
+ label={formatMessage({ id: "template.field.subscribable" })}
123
+ checked={_.prop("subscribable")(field) || false}
124
+ onChange={(_e, { name, checked: value }) =>
125
+ onChange(null, { name, value })
126
+ }
127
+ />
128
+ ) : null}
129
+ </Form.Group>
67
130
  <DefaultValue
68
131
  defaultField={defaultField}
69
132
  field={field}
@@ -86,6 +149,8 @@ ValuesField.propTypes = {
86
149
  onSelectionChange: PropTypes.func,
87
150
  subscribableField: PropTypes.string,
88
151
  values: PropTypes.array,
152
+ fieldNamePrefix: PropTypes.string,
153
+ scope: PropTypes.string,
89
154
  };
90
155
 
91
156
  export default ValuesField;
@@ -208,21 +208,6 @@ exports[`<FieldForm /> manages handleCardinalityChange 1`] = `
208
208
  selection={true}
209
209
  value="?"
210
210
  />
211
- <FormField>
212
- <label>
213
- <MemoizedFormattedMessage
214
- id="template.field.editable"
215
- />
216
- </label>
217
- <FormCheckbox
218
- as={[Function]}
219
- checked={true}
220
- control={[Function]}
221
- label="template.field.checkbox.enabled"
222
- name="Group.fields[0].editable"
223
- onChange={[Function]}
224
- />
225
- </FormField>
226
211
  </FormGroup>
227
212
  <ValuesField
228
213
  defaultField="Group.fields[0].default"
@@ -239,6 +224,7 @@ exports[`<FieldForm /> manages handleCardinalityChange 1`] = `
239
224
  "name": "name",
240
225
  }
241
226
  }
227
+ fieldNamePrefix="Group.fields[0]"
242
228
  name="Group.fields[0].values"
243
229
  onChange={[MockFunction]}
244
230
  onSelectionChange={[Function]}
@@ -602,21 +588,6 @@ exports[`<FieldForm /> matches the latest snapshot 1`] = `
602
588
  required={true}
603
589
  selection={true}
604
590
  />
605
- <FormField>
606
- <label>
607
- <MemoizedFormattedMessage
608
- id="template.field.editable"
609
- />
610
- </label>
611
- <FormCheckbox
612
- as={[Function]}
613
- checked={true}
614
- control={[Function]}
615
- label="template.field.checkbox.enabled"
616
- name="undefined.fields[0].editable"
617
- onChange={[Function]}
618
- />
619
- </FormField>
620
591
  </FormGroup>
621
592
  <ValuesField
622
593
  defaultField="undefined.fields[0].default"
@@ -637,6 +608,7 @@ exports[`<FieldForm /> matches the latest snapshot 1`] = `
637
608
  "widget": "string",
638
609
  }
639
610
  }
611
+ fieldNamePrefix="undefined.fields[0]"
640
612
  fieldType="list"
641
613
  keyType="0"
642
614
  name="undefined.fields[0].values"
@@ -877,21 +849,6 @@ exports[`<FieldForm /> renders MandatoryConditional 1`] = `
877
849
  selection={true}
878
850
  value="?"
879
851
  />
880
- <FormField>
881
- <label>
882
- <MemoizedFormattedMessage
883
- id="template.field.editable"
884
- />
885
- </label>
886
- <FormCheckbox
887
- as={[Function]}
888
- checked={true}
889
- control={[Function]}
890
- label="template.field.checkbox.enabled"
891
- name="Group.fields[0].editable"
892
- onChange={[Function]}
893
- />
894
- </FormField>
895
852
  </FormGroup>
896
853
  <ValuesField
897
854
  defaultField="Group.fields[0].default"
@@ -908,6 +865,7 @@ exports[`<FieldForm /> renders MandatoryConditional 1`] = `
908
865
  "name": "name",
909
866
  }
910
867
  }
868
+ fieldNamePrefix="Group.fields[0]"
911
869
  name="Group.fields[0].values"
912
870
  onChange={[MockFunction]}
913
871
  onSelectionChange={[Function]}
@@ -1296,21 +1254,6 @@ exports[`<FieldForm /> renders ValuesField and manages onChange 1`] = `
1296
1254
  required={true}
1297
1255
  selection={true}
1298
1256
  />
1299
- <FormField>
1300
- <label>
1301
- <MemoizedFormattedMessage
1302
- id="template.field.editable"
1303
- />
1304
- </label>
1305
- <FormCheckbox
1306
- as={[Function]}
1307
- checked={true}
1308
- control={[Function]}
1309
- label="template.field.checkbox.enabled"
1310
- name="Group.fields[0].editable"
1311
- onChange={[Function]}
1312
- />
1313
- </FormField>
1314
1257
  </FormGroup>
1315
1258
  <ValuesField
1316
1259
  defaultField="Group.fields[0].default"
@@ -1330,6 +1273,7 @@ exports[`<FieldForm /> renders ValuesField and manages onChange 1`] = `
1330
1273
  "widget": "dropdown",
1331
1274
  }
1332
1275
  }
1276
+ fieldNamePrefix="Group.fields[0]"
1333
1277
  fieldType="string"
1334
1278
  keyType="fixed"
1335
1279
  name="Group.fields[0].values"
@@ -2,6 +2,21 @@
2
2
 
3
3
  exports[`<ValuesField /> fixed matches the latest snapshot for null values 1`] = `
4
4
  <Segment>
5
+ <FormGroup
6
+ size="small"
7
+ widths="equal"
8
+ >
9
+ <FormField>
10
+ <FormCheckbox
11
+ as={[Function]}
12
+ checked={true}
13
+ control={[Function]}
14
+ label="template.field.editable"
15
+ name="undefined.editable"
16
+ onChange={[Function]}
17
+ />
18
+ </FormField>
19
+ </FormGroup>
5
20
  <DefaultValue
6
21
  field={
7
22
  {
@@ -35,13 +50,28 @@ exports[`<ValuesField /> fixed_tuple matches the latest snapshot for null values
35
50
  ]
36
51
  }
37
52
  />
38
- <FormCheckbox
39
- as={[Function]}
40
- checked={false}
41
- control={[Function]}
42
- label="template.field.subscribable"
43
- onChange={[Function]}
44
- />
53
+ <FormGroup
54
+ size="small"
55
+ widths="equal"
56
+ >
57
+ <FormField>
58
+ <FormCheckbox
59
+ as={[Function]}
60
+ checked={true}
61
+ control={[Function]}
62
+ label="template.field.editable"
63
+ name="undefined.editable"
64
+ onChange={[Function]}
65
+ />
66
+ </FormField>
67
+ <FormCheckbox
68
+ as={[Function]}
69
+ checked={false}
70
+ control={[Function]}
71
+ label="template.field.subscribable"
72
+ onChange={[Function]}
73
+ />
74
+ </FormGroup>
45
75
  <DefaultValue
46
76
  field={
47
77
  {
@@ -64,6 +94,21 @@ exports[`<ValuesField /> fixed_tuple matches the latest snapshot for null values
64
94
 
65
95
  exports[`<ValuesField /> noPrefix matches the latest snapshot for null values 1`] = `
66
96
  <Segment>
97
+ <FormGroup
98
+ size="small"
99
+ widths="equal"
100
+ >
101
+ <FormField>
102
+ <FormCheckbox
103
+ as={[Function]}
104
+ checked={true}
105
+ control={[Function]}
106
+ label="template.field.editable"
107
+ name="undefined.editable"
108
+ onChange={[Function]}
109
+ />
110
+ </FormField>
111
+ </FormGroup>
67
112
  <DefaultValue
68
113
  field={
69
114
  {
@@ -78,6 +123,21 @@ exports[`<ValuesField /> noPrefix matches the latest snapshot for null values 1`
78
123
 
79
124
  exports[`<ValuesField /> role_users matches the latest snapshot for not null values 1`] = `
80
125
  <Segment>
126
+ <FormGroup
127
+ size="small"
128
+ widths="equal"
129
+ >
130
+ <FormField>
131
+ <FormCheckbox
132
+ as={[Function]}
133
+ checked={true}
134
+ control={[Function]}
135
+ label="template.field.editable"
136
+ name="undefined.editable"
137
+ onChange={[Function]}
138
+ />
139
+ </FormField>
140
+ </FormGroup>
81
141
  <DefaultValue
82
142
  field={
83
143
  {
@@ -114,6 +174,21 @@ exports[`<ValuesField /> switch matches the latest snapshot for null values 1`]
114
174
  }
115
175
  }
116
176
  />
177
+ <FormGroup
178
+ size="small"
179
+ widths="equal"
180
+ >
181
+ <FormField>
182
+ <FormCheckbox
183
+ as={[Function]}
184
+ checked={true}
185
+ control={[Function]}
186
+ label="template.field.editable"
187
+ name="undefined.editable"
188
+ onChange={[Function]}
189
+ />
190
+ </FormField>
191
+ </FormGroup>
117
192
  <DefaultValue
118
193
  field={
119
194
  {
@@ -142,6 +217,21 @@ exports[`<ValuesField /> switch matches the latest snapshot for null values 1`]
142
217
 
143
218
  exports[`<ValuesField /> table_columns matches the latest snapshot 1`] = `
144
219
  <Segment>
220
+ <FormGroup
221
+ size="small"
222
+ widths="equal"
223
+ >
224
+ <FormField>
225
+ <FormCheckbox
226
+ as={[Function]}
227
+ checked={true}
228
+ control={[Function]}
229
+ label="template.field.editable"
230
+ name="undefined.editable"
231
+ onChange={[Function]}
232
+ />
233
+ </FormField>
234
+ </FormGroup>
145
235
  <DefaultValue
146
236
  field={
147
237
  {