@truedat/dq 4.28.8 → 4.29.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 +5 -5
- package/src/components/ImplementationSummary.js +49 -47
- package/src/components/NewRuleImplementation.js +67 -62
- package/src/components/ruleImplementationForm/FieldModifier.js +26 -16
- package/src/components/ruleImplementationForm/FiltersField.js +25 -23
- package/src/components/ruleImplementationForm/FiltersFormGroup.js +41 -25
- package/src/components/ruleImplementationForm/FiltersGrid.js +17 -19
- package/src/components/ruleImplementationForm/FiltersGroup.js +6 -5
- package/src/components/ruleImplementationForm/PopulationForm.js +3 -3
- package/src/components/ruleImplementationForm/RuleImplementationForm.js +38 -31
- package/src/components/ruleImplementationForm/ValueConditions.js +6 -6
- package/src/components/ruleImplementationForm/operators.js +19 -22
- package/src/selectors/getRuleImplementationOperators.js +1 -1
|
@@ -10,7 +10,7 @@ import FixedListField from "./FixedListField";
|
|
|
10
10
|
import NumberField from "./NumberField";
|
|
11
11
|
import StringField from "./StringField";
|
|
12
12
|
import StringListField from "./StringListField";
|
|
13
|
-
import FieldModifier from
|
|
13
|
+
import FieldModifier from "./FieldModifier";
|
|
14
14
|
|
|
15
15
|
const StructureFieldsDropdown = React.lazy(() =>
|
|
16
16
|
import("@truedat/dd/components/StructureFieldsDropdown")
|
|
@@ -50,7 +50,7 @@ export const FiltersField = ({
|
|
|
50
50
|
const [active, setActive] = useState(false);
|
|
51
51
|
const { value_type, value_type_filter, fixed_values } = operator;
|
|
52
52
|
|
|
53
|
-
const modifierDef = _.find({name: modifier?.name})(typeCastModifiers)
|
|
53
|
+
const modifierDef = _.find({ name: modifier?.name })(typeCastModifiers);
|
|
54
54
|
|
|
55
55
|
switch (value_type) {
|
|
56
56
|
case "string":
|
|
@@ -115,27 +115,29 @@ export const FiltersField = ({
|
|
|
115
115
|
/>
|
|
116
116
|
) : (
|
|
117
117
|
<>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
118
|
+
<StructureFieldsDropdown
|
|
119
|
+
label={label}
|
|
120
|
+
inline={false}
|
|
121
|
+
parentStructures={parentStructures}
|
|
122
|
+
structureFields={structureFields}
|
|
123
|
+
typeCastModifiers={typeCastModifiers}
|
|
124
|
+
filters={{ field_type: [fieldType] }}
|
|
125
|
+
onSelectField={(value, modifier) =>
|
|
126
|
+
onChange(
|
|
127
|
+
null,
|
|
128
|
+
_.pick(["data_structure_id", "name"])(value),
|
|
129
|
+
modifier ? { name: modifier.name } : null
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
value={_.prop("id")(value)}
|
|
133
|
+
/>
|
|
134
|
+
{modifier && (
|
|
135
|
+
<FieldModifier
|
|
136
|
+
modifier={modifierDef}
|
|
137
|
+
value={modifier}
|
|
138
|
+
onChange={(modifier) => onChange(null, value, modifier)}
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
139
141
|
</>
|
|
140
142
|
);
|
|
141
143
|
case "string_list":
|
|
@@ -5,8 +5,8 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
6
|
import { getStructureFields } from "../../selectors/getStructureFields";
|
|
7
7
|
import FiltersField from "./FiltersField";
|
|
8
|
-
import FieldModifier from
|
|
9
|
-
import operatorFunctions from
|
|
8
|
+
import FieldModifier from "./FieldModifier";
|
|
9
|
+
import operatorFunctions from "./operators";
|
|
10
10
|
|
|
11
11
|
const OptionGroup = React.lazy(() =>
|
|
12
12
|
import("@truedat/core/components/OptionGroup")
|
|
@@ -36,14 +36,20 @@ export const FiltersFormGroup = ({
|
|
|
36
36
|
const structureFieldType = clause?.structure?.field_type;
|
|
37
37
|
const modifiers = _.path(`${structureFieldType}.modifiers`)(operators);
|
|
38
38
|
const modifierValue = clause?.modifier;
|
|
39
|
-
const modifier = _.find({name: modifierValue?.name})(modifiers);
|
|
39
|
+
const modifier = _.find({ name: modifierValue?.name })(modifiers);
|
|
40
40
|
|
|
41
41
|
const fieldType = modifier?.cast_as || structureFieldType;
|
|
42
42
|
const nestedCondition = !_.isEmpty(siblings);
|
|
43
43
|
const structureFields = getStructureFields(parentStructures);
|
|
44
44
|
|
|
45
|
-
const {operatorsOptions, getOperatorValue, typeCastModifiers} =
|
|
46
|
-
operatorFunctions(
|
|
45
|
+
const { operatorsOptions, getOperatorValue, typeCastModifiers } =
|
|
46
|
+
operatorFunctions(
|
|
47
|
+
operators,
|
|
48
|
+
fieldType,
|
|
49
|
+
nestedCondition,
|
|
50
|
+
scope,
|
|
51
|
+
formatMessage
|
|
52
|
+
);
|
|
47
53
|
|
|
48
54
|
return (
|
|
49
55
|
<Form.Group className={"force-margin-bottom"}>
|
|
@@ -54,7 +60,7 @@ export const FiltersFormGroup = ({
|
|
|
54
60
|
<ValueConditionStructure
|
|
55
61
|
siblings={siblings}
|
|
56
62
|
value={clause?.structure?.id}
|
|
57
|
-
onChange={value => onStructureChange(index, value)}
|
|
63
|
+
onChange={(value) => onStructureChange(index, value)}
|
|
58
64
|
/>
|
|
59
65
|
) : (
|
|
60
66
|
<StructureFieldsDropdown
|
|
@@ -62,7 +68,7 @@ export const FiltersFormGroup = ({
|
|
|
62
68
|
inline={false}
|
|
63
69
|
parentStructures={parentStructures}
|
|
64
70
|
structureFields={structureFields}
|
|
65
|
-
onSelectField={value => onStructureChange(index, value)}
|
|
71
|
+
onSelectField={(value) => onStructureChange(index, value)}
|
|
66
72
|
value={clause?.structure?.id}
|
|
67
73
|
/>
|
|
68
74
|
)}
|
|
@@ -74,45 +80,53 @@ export const FiltersFormGroup = ({
|
|
|
74
80
|
icon="ellipsis vertical"
|
|
75
81
|
>
|
|
76
82
|
<Dropdown.Menu>
|
|
77
|
-
{modifiers.map((modifier, key) =>
|
|
83
|
+
{modifiers.map((modifier, key) => (
|
|
78
84
|
<Dropdown.Item
|
|
79
85
|
key={key}
|
|
80
|
-
icon={
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
icon={
|
|
87
|
+
modifier.cast_as
|
|
88
|
+
? formatMessage({
|
|
89
|
+
id: `field_type.icon.${modifier.cast_as}`,
|
|
90
|
+
defaultMessage: "hashtag",
|
|
91
|
+
})
|
|
92
|
+
: null
|
|
93
|
+
}
|
|
94
|
+
text={formatMessage({
|
|
95
|
+
id: `filtersGrid.field.modifier.${modifier.name}`,
|
|
96
|
+
})}
|
|
85
97
|
onClick={() =>
|
|
86
|
-
onModifierChange(index, {name: modifier.name})
|
|
98
|
+
onModifierChange(index, { name: modifier.name })
|
|
87
99
|
}
|
|
88
100
|
/>
|
|
89
|
-
)}
|
|
101
|
+
))}
|
|
90
102
|
</Dropdown.Menu>
|
|
91
103
|
</Dropdown>
|
|
92
104
|
)}
|
|
93
105
|
</div>
|
|
94
|
-
{modifier &&
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
{modifier && (
|
|
107
|
+
<FieldModifier
|
|
108
|
+
modifier={modifier}
|
|
109
|
+
value={modifierValue}
|
|
110
|
+
onChange={(value) => onModifierChange(index, value)}
|
|
111
|
+
removable
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
100
114
|
</div>
|
|
101
115
|
<Form.Field>
|
|
102
116
|
<OptionGroup
|
|
103
117
|
label={formatMessage({
|
|
104
|
-
id: "filtersGrid.field.operator"
|
|
118
|
+
id: "filtersGrid.field.operator",
|
|
105
119
|
})}
|
|
106
120
|
options={operatorsOptions}
|
|
107
121
|
value={getOperatorValue(clause)}
|
|
108
122
|
onClick={({ id }) => onOperatorChange(index, id)}
|
|
109
123
|
placeholder={formatMessage({
|
|
110
|
-
id: "operator.dropdown.placeholder"
|
|
124
|
+
id: "operator.dropdown.placeholder",
|
|
111
125
|
})}
|
|
112
126
|
/>
|
|
113
127
|
</Form.Field>
|
|
114
128
|
{!_.isEmpty(clause?.operator) &&
|
|
115
|
-
_.range(0, clause?.operator?.arity || 1).map(nth_value => (
|
|
129
|
+
_.range(0, clause?.operator?.arity || 1).map((nth_value) => (
|
|
116
130
|
<Form.Field
|
|
117
131
|
width={clause?.operator?.arity === 2 ? 4 : 9}
|
|
118
132
|
key={`value_${nth_value}`}
|
|
@@ -125,7 +139,9 @@ export const FiltersFormGroup = ({
|
|
|
125
139
|
value={_.nth(nth_value)(clause?.value)}
|
|
126
140
|
modifier={_.nth(nth_value)(clause?.value_modifier)}
|
|
127
141
|
label={formatMessage({ id: "filtersGrid.field.value" })}
|
|
128
|
-
onChange={(_e, value, modifier) =>
|
|
142
|
+
onChange={(_e, value, modifier) =>
|
|
143
|
+
onValueChange(index, value, modifier, nth_value)
|
|
144
|
+
}
|
|
129
145
|
/>
|
|
130
146
|
</Form.Field>
|
|
131
147
|
))}
|
|
@@ -22,7 +22,7 @@ export const FiltersGrid = ({
|
|
|
22
22
|
const onStructureChange = (index, value) => {
|
|
23
23
|
const structure = {
|
|
24
24
|
..._.pick(["field_type", "name"])(value),
|
|
25
|
-
id: value.data_structure_id
|
|
25
|
+
id: value.data_structure_id,
|
|
26
26
|
};
|
|
27
27
|
setRowValue({
|
|
28
28
|
index,
|
|
@@ -31,8 +31,8 @@ export const FiltersGrid = ({
|
|
|
31
31
|
modifier: null,
|
|
32
32
|
operator: {},
|
|
33
33
|
value: null,
|
|
34
|
-
value_modifier: null
|
|
35
|
-
}
|
|
34
|
+
value_modifier: null,
|
|
35
|
+
},
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -47,24 +47,24 @@ export const FiltersGrid = ({
|
|
|
47
47
|
operator: {},
|
|
48
48
|
value: null,
|
|
49
49
|
value_modifier: null,
|
|
50
|
-
population: null
|
|
51
|
-
}
|
|
50
|
+
population: null,
|
|
51
|
+
},
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const composeValue = (value_type, value) => {
|
|
56
56
|
if (value_type == "field") {
|
|
57
57
|
return {
|
|
58
|
-
id: value.data_structure_id ||
|
|
58
|
+
id: value.data_structure_id || value.id,
|
|
59
59
|
name: value.name,
|
|
60
|
-
path: value.path
|
|
60
|
+
path: value.path,
|
|
61
61
|
};
|
|
62
62
|
} else {
|
|
63
63
|
return { raw: value };
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const onValueChange = (rowIndex, value, modifier=null, valueIndex) => {
|
|
67
|
+
const onValueChange = (rowIndex, value, modifier = null, valueIndex) => {
|
|
68
68
|
const rowValue = _.nth(rowIndex)(rows);
|
|
69
69
|
const value_type = _.path("operator.value_type")(rowValue);
|
|
70
70
|
|
|
@@ -80,11 +80,9 @@ export const FiltersGrid = ({
|
|
|
80
80
|
valueIndex == 0
|
|
81
81
|
? [composeValue(value_type, value), secondValue]
|
|
82
82
|
: [firstValue, composeValue(value_type, value)];
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
const updatedValueModifier =
|
|
85
|
-
valueIndex == 0
|
|
86
|
-
? [modifier, secondModifier]
|
|
87
|
-
: [firstModifier, modifier];
|
|
85
|
+
valueIndex == 0 ? [modifier, secondModifier] : [firstModifier, modifier];
|
|
88
86
|
|
|
89
87
|
setRowValue({
|
|
90
88
|
index: rowIndex,
|
|
@@ -92,8 +90,8 @@ export const FiltersGrid = ({
|
|
|
92
90
|
...rowValue,
|
|
93
91
|
value: _.take(arity)(updatedValue),
|
|
94
92
|
value_modifier: _.take(arity)(updatedValueModifier),
|
|
95
|
-
population: null
|
|
96
|
-
}
|
|
93
|
+
population: null,
|
|
94
|
+
},
|
|
97
95
|
});
|
|
98
96
|
};
|
|
99
97
|
|
|
@@ -107,8 +105,8 @@ export const FiltersGrid = ({
|
|
|
107
105
|
...rowValue,
|
|
108
106
|
operator: { ..._.omit(["group"])(operatorEntry) },
|
|
109
107
|
value: null,
|
|
110
|
-
population: null
|
|
111
|
-
}
|
|
108
|
+
population: null,
|
|
109
|
+
},
|
|
112
110
|
});
|
|
113
111
|
};
|
|
114
112
|
|
|
@@ -118,8 +116,8 @@ export const FiltersGrid = ({
|
|
|
118
116
|
index,
|
|
119
117
|
value: {
|
|
120
118
|
...rowValue,
|
|
121
|
-
population
|
|
122
|
-
}
|
|
119
|
+
population,
|
|
120
|
+
},
|
|
123
121
|
});
|
|
124
122
|
};
|
|
125
123
|
|
|
@@ -158,7 +156,7 @@ FiltersGrid.propTypes = {
|
|
|
158
156
|
setRowValue: PropTypes.func,
|
|
159
157
|
scope: PropTypes.string,
|
|
160
158
|
structures: PropTypes.array,
|
|
161
|
-
typeOperators: PropTypes.array
|
|
159
|
+
typeOperators: PropTypes.array,
|
|
162
160
|
};
|
|
163
161
|
|
|
164
162
|
export default FiltersGrid;
|
|
@@ -27,26 +27,27 @@ const Filter = ({
|
|
|
27
27
|
const [activePopulation, setActivePopulation] = useState(
|
|
28
28
|
!_.isEmpty(clause?.population)
|
|
29
29
|
);
|
|
30
|
-
const conditionApplies = row =>
|
|
30
|
+
const conditionApplies = (row) =>
|
|
31
31
|
row?.operator?.value_type_filter === "any" &&
|
|
32
32
|
row?.operator?.value_type === "field" &&
|
|
33
33
|
row?.operator?.population &&
|
|
34
34
|
row?.value;
|
|
35
|
-
const onPopupClick = index => {
|
|
35
|
+
const onPopupClick = (index) => {
|
|
36
36
|
const display = !activePopulation;
|
|
37
37
|
!display && onConditionChange(index, null);
|
|
38
38
|
!display && setActiveConditionIndex(-1);
|
|
39
39
|
display && setActiveConditionIndex(index);
|
|
40
40
|
setActivePopulation(display);
|
|
41
41
|
};
|
|
42
|
-
const onValueConditionChange = value => {
|
|
42
|
+
const onValueConditionChange = (value) => {
|
|
43
43
|
onConditionChange(index, value);
|
|
44
44
|
if (_.isNil(value)) {
|
|
45
45
|
setActiveConditionIndex(-1);
|
|
46
46
|
setActivePopulation(false);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
const findSiblings = row =>
|
|
49
|
+
const findSiblings = (row) =>
|
|
50
|
+
_.filter((v) => !_.isNil(v?.id))(row?.value || []);
|
|
50
51
|
return (
|
|
51
52
|
<>
|
|
52
53
|
<Grid.Row>
|
|
@@ -76,7 +77,7 @@ const Filter = ({
|
|
|
76
77
|
content={formatMessage({
|
|
77
78
|
id: _.isEmpty(clause?.population)
|
|
78
79
|
? "filtersGrid.field.filters.popup"
|
|
79
|
-
: "filtersGrid.field.filters.deletion.popup"
|
|
80
|
+
: "filtersGrid.field.filters.deletion.popup",
|
|
80
81
|
})}
|
|
81
82
|
hideOnScroll
|
|
82
83
|
/>
|
|
@@ -27,14 +27,14 @@ const PopulationTypeForm = ({ createFilter }) => (
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
PopulationTypeForm.propTypes = {
|
|
30
|
-
createFilter: PropTypes.func
|
|
30
|
+
createFilter: PropTypes.func,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export default function PopulationForm({
|
|
34
34
|
typeOperators,
|
|
35
35
|
population,
|
|
36
36
|
structures,
|
|
37
|
-
setPopulation
|
|
37
|
+
setPopulation,
|
|
38
38
|
}) {
|
|
39
39
|
const setPopulationField = ({ index, value }) => {
|
|
40
40
|
if (_.isNil(index)) {
|
|
@@ -61,5 +61,5 @@ PopulationForm.propTypes = {
|
|
|
61
61
|
typeOperators: PropTypes.array,
|
|
62
62
|
population: PropTypes.array,
|
|
63
63
|
structures: PropTypes.array,
|
|
64
|
-
setPopulation: PropTypes.func
|
|
64
|
+
setPopulation: PropTypes.func,
|
|
65
65
|
};
|
|
@@ -24,7 +24,7 @@ const RuleImplementationStep = ({ activeStep, name, icon }) => (
|
|
|
24
24
|
RuleImplementationStep.propTypes = {
|
|
25
25
|
activeStep: PropTypes.string,
|
|
26
26
|
name: PropTypes.string,
|
|
27
|
-
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
|
|
27
|
+
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export const RuleImplementationForm = ({
|
|
@@ -37,7 +37,7 @@ export const RuleImplementationForm = ({
|
|
|
37
37
|
handleSubmit,
|
|
38
38
|
operators,
|
|
39
39
|
onChange,
|
|
40
|
-
applyTemplate
|
|
40
|
+
applyTemplate,
|
|
41
41
|
}) => {
|
|
42
42
|
const { formatMessage } = useIntl();
|
|
43
43
|
const history = useHistory();
|
|
@@ -45,14 +45,17 @@ export const RuleImplementationForm = ({
|
|
|
45
45
|
{ name: "information", icon: "info", isValid: () => true },
|
|
46
46
|
{ name: "dataset", icon: "database", isValid: () => validDataSet() },
|
|
47
47
|
{ name: "population", icon: "user", isValid: () => validPopulation() },
|
|
48
|
-
{ name: "validations", icon: "setting", isValid: () => validValidations() }
|
|
48
|
+
{ name: "validations", icon: "setting", isValid: () => validValidations() },
|
|
49
49
|
];
|
|
50
50
|
|
|
51
51
|
const [activeStep, setActiveStep] = useState("information");
|
|
52
52
|
const [selector, setSelector] = useState();
|
|
53
53
|
|
|
54
|
-
const {
|
|
55
|
-
|
|
54
|
+
const {
|
|
55
|
+
dataset: structures,
|
|
56
|
+
population,
|
|
57
|
+
validations,
|
|
58
|
+
} = ruleImplementation || {};
|
|
56
59
|
|
|
57
60
|
const validPopulation = () =>
|
|
58
61
|
_.every(_.isEmpty)(population) || populationComplete();
|
|
@@ -65,29 +68,29 @@ export const RuleImplementationForm = ({
|
|
|
65
68
|
const areStructuresComplete = () =>
|
|
66
69
|
!_.isEmpty(structures) &&
|
|
67
70
|
_.every(
|
|
68
|
-
i =>
|
|
71
|
+
(i) =>
|
|
69
72
|
itemComplete(_.nth(i)(structures), [
|
|
70
73
|
"structure.id",
|
|
71
|
-
"structure.name"
|
|
74
|
+
"structure.name",
|
|
72
75
|
]) &&
|
|
73
76
|
(i == 0 ||
|
|
74
77
|
_.flow(_.nth(i), _.prop("clauses"), areClausesComplete)(structures))
|
|
75
78
|
)(_.range(0, _.size(structures)));
|
|
76
79
|
|
|
77
|
-
const areClausesComplete = clauses =>
|
|
80
|
+
const areClausesComplete = (clauses) =>
|
|
78
81
|
_.size(clauses) > 0 &&
|
|
79
|
-
_.every(c => itemComplete(c, ["left", "right"]))(clauses);
|
|
82
|
+
_.every((c) => itemComplete(c, ["left", "right"]))(clauses);
|
|
80
83
|
|
|
81
84
|
const populationComplete = () =>
|
|
82
85
|
_.flow(
|
|
83
86
|
_.filter(_.negate(_.isEmpty)),
|
|
84
|
-
_.every(p => itemComplete(p, attrsFromProfile(p)))
|
|
87
|
+
_.every((p) => itemComplete(p, attrsFromProfile(p)))
|
|
85
88
|
)(population);
|
|
86
89
|
|
|
87
90
|
const validationsComplete = () =>
|
|
88
|
-
_.every(v => itemComplete(v, attrsFromProfile(v)))(validations);
|
|
91
|
+
_.every((v) => itemComplete(v, attrsFromProfile(v)))(validations);
|
|
89
92
|
|
|
90
|
-
const attrsFromProfile = p => {
|
|
93
|
+
const attrsFromProfile = (p) => {
|
|
91
94
|
const valueType = p?.operator?.value_type;
|
|
92
95
|
return _.isNil(valueType)
|
|
93
96
|
? ["operator"]
|
|
@@ -96,7 +99,7 @@ export const RuleImplementationForm = ({
|
|
|
96
99
|
|
|
97
100
|
const itemComplete = (item, attrs) =>
|
|
98
101
|
_.every(
|
|
99
|
-
attr =>
|
|
102
|
+
(attr) =>
|
|
100
103
|
mandatoryAttr(attr, item) &&
|
|
101
104
|
!emptyAttr(attr, item) &&
|
|
102
105
|
validArity(attr, item) &&
|
|
@@ -114,7 +117,7 @@ export const RuleImplementationForm = ({
|
|
|
114
117
|
const values = _.path(attr)(item);
|
|
115
118
|
return (
|
|
116
119
|
_.size(values) == _.path("operator.arity")(item) &&
|
|
117
|
-
_.every(v => !_.isNil(v))(values)
|
|
120
|
+
_.every((v) => !_.isNil(v))(values)
|
|
118
121
|
);
|
|
119
122
|
}
|
|
120
123
|
return true;
|
|
@@ -123,18 +126,20 @@ export const RuleImplementationForm = ({
|
|
|
123
126
|
const nestedValid = (attr, item) => {
|
|
124
127
|
if (attr === "population" && !_.isNil(item?.population)) {
|
|
125
128
|
const population = item?.population;
|
|
126
|
-
return _.every(p => itemComplete(p, attrsFromProfile(p)))(population);
|
|
129
|
+
return _.every((p) => itemComplete(p, attrsFromProfile(p)))(population);
|
|
127
130
|
}
|
|
128
131
|
return true;
|
|
129
132
|
};
|
|
130
133
|
|
|
131
|
-
const setNextStep = stepName => {
|
|
134
|
+
const setNextStep = (stepName) => {
|
|
132
135
|
const nextStep = getNextStep(stepName);
|
|
133
136
|
if (nextStep) setActiveStep(nextStep);
|
|
134
137
|
};
|
|
135
138
|
|
|
136
|
-
const getNextStep = stepName => {
|
|
137
|
-
const currentStepIndex = _.findIndex(step => step.name == stepName)(
|
|
139
|
+
const getNextStep = (stepName) => {
|
|
140
|
+
const currentStepIndex = _.findIndex((step) => step.name == stepName)(
|
|
141
|
+
steps
|
|
142
|
+
);
|
|
138
143
|
if (currentStepIndex + 1 >= steps.length) {
|
|
139
144
|
return null;
|
|
140
145
|
} else {
|
|
@@ -142,13 +147,15 @@ export const RuleImplementationForm = ({
|
|
|
142
147
|
}
|
|
143
148
|
};
|
|
144
149
|
|
|
145
|
-
const setPreviousStep = stepName => {
|
|
150
|
+
const setPreviousStep = (stepName) => {
|
|
146
151
|
const previousStep = getPreviousStep(stepName);
|
|
147
152
|
if (previousStep) setActiveStep(previousStep);
|
|
148
153
|
};
|
|
149
154
|
|
|
150
|
-
const getPreviousStep = stepName => {
|
|
151
|
-
const currentStepIndex = _.findIndex(step => step.name == stepName)(
|
|
155
|
+
const getPreviousStep = (stepName) => {
|
|
156
|
+
const currentStepIndex = _.findIndex((step) => step.name == stepName)(
|
|
157
|
+
steps
|
|
158
|
+
);
|
|
152
159
|
if (currentStepIndex - 1 < 0) {
|
|
153
160
|
return null;
|
|
154
161
|
} else {
|
|
@@ -156,18 +163,18 @@ export const RuleImplementationForm = ({
|
|
|
156
163
|
}
|
|
157
164
|
};
|
|
158
165
|
|
|
159
|
-
const isButtonDisabled = currentStep => !validStep(currentStep);
|
|
166
|
+
const isButtonDisabled = (currentStep) => !validStep(currentStep);
|
|
160
167
|
|
|
161
|
-
const validStep = stepName =>
|
|
162
|
-
_.prop("isValid")(_.find(step => step.name == stepName)(steps))();
|
|
168
|
+
const validStep = (stepName) =>
|
|
169
|
+
_.prop("isValid")(_.find((step) => step.name == stepName)(steps))();
|
|
163
170
|
|
|
164
171
|
const completeStep = (index, activeStep) => {
|
|
165
|
-
if (index >= _.findIndex(s => s.name == activeStep)(steps)) return false;
|
|
172
|
+
if (index >= _.findIndex((s) => s.name == activeStep)(steps)) return false;
|
|
166
173
|
return _.prop("isValid")(_.nth(index)(steps))();
|
|
167
174
|
};
|
|
168
175
|
|
|
169
176
|
const doSubmit = () => {
|
|
170
|
-
if (_.every(s => _.prop("isValid")(s)())(steps)) {
|
|
177
|
+
if (_.every((s) => _.prop("isValid")(s)())(steps)) {
|
|
171
178
|
handleSubmit();
|
|
172
179
|
}
|
|
173
180
|
};
|
|
@@ -201,7 +208,7 @@ export const RuleImplementationForm = ({
|
|
|
201
208
|
setImplementationKey,
|
|
202
209
|
ruleImplementation,
|
|
203
210
|
onChange,
|
|
204
|
-
applyTemplate
|
|
211
|
+
applyTemplate,
|
|
205
212
|
}}
|
|
206
213
|
/>
|
|
207
214
|
)}
|
|
@@ -212,7 +219,7 @@ export const RuleImplementationForm = ({
|
|
|
212
219
|
structures,
|
|
213
220
|
selector,
|
|
214
221
|
setStructures,
|
|
215
|
-
setSelector
|
|
222
|
+
setSelector,
|
|
216
223
|
}}
|
|
217
224
|
/>
|
|
218
225
|
)}
|
|
@@ -280,11 +287,11 @@ RuleImplementationForm.propTypes = {
|
|
|
280
287
|
setValidations: PropTypes.func,
|
|
281
288
|
operators: PropTypes.object,
|
|
282
289
|
onChange: PropTypes.func,
|
|
283
|
-
applyTemplate: PropTypes.func
|
|
290
|
+
applyTemplate: PropTypes.func,
|
|
284
291
|
};
|
|
285
292
|
|
|
286
|
-
const mapStateToProps = state => ({
|
|
287
|
-
isSubmitting: state.ruleImplementationCreating
|
|
293
|
+
const mapStateToProps = (state) => ({
|
|
294
|
+
isSubmitting: state.ruleImplementationCreating,
|
|
288
295
|
});
|
|
289
296
|
|
|
290
297
|
export default connect(mapStateToProps)(RuleImplementationForm);
|
|
@@ -13,13 +13,13 @@ export const ValueConditions = ({
|
|
|
13
13
|
population = [],
|
|
14
14
|
parentStructures,
|
|
15
15
|
scope,
|
|
16
|
-
siblings
|
|
16
|
+
siblings,
|
|
17
17
|
}) => {
|
|
18
18
|
const onStructureChange = (index, value, opts) => {
|
|
19
19
|
const structure = {
|
|
20
20
|
..._.pick(["field_type", "name", "data_structure_id"])(value),
|
|
21
21
|
id: value?.data_structure_id,
|
|
22
|
-
opts
|
|
22
|
+
opts,
|
|
23
23
|
};
|
|
24
24
|
const updatedCondition = { structure };
|
|
25
25
|
const modifiedPopulation = replaceAt(index, updatedCondition)(population);
|
|
@@ -32,7 +32,7 @@ export const ValueConditions = ({
|
|
|
32
32
|
const updatedCondition = {
|
|
33
33
|
...clause,
|
|
34
34
|
operator: _.omit(["group"])(operatorEntry),
|
|
35
|
-
value: null
|
|
35
|
+
value: null,
|
|
36
36
|
};
|
|
37
37
|
const modifiedPopulation = replaceAt(index, updatedCondition)(population);
|
|
38
38
|
onChange && onChange(modifiedPopulation);
|
|
@@ -48,13 +48,13 @@ export const ValueConditions = ({
|
|
|
48
48
|
|
|
49
49
|
const updatedCondition = {
|
|
50
50
|
...clause,
|
|
51
|
-
value: _.take(arity)(modifiedValues)
|
|
51
|
+
value: _.take(arity)(modifiedValues),
|
|
52
52
|
};
|
|
53
53
|
const modifiedPopulation = replaceAt(index, updatedCondition)(population);
|
|
54
54
|
onChange && onChange(modifiedPopulation);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
const onRowDelete = index => {
|
|
57
|
+
const onRowDelete = (index) => {
|
|
58
58
|
if (index === 0 && _.size(population) === 1) {
|
|
59
59
|
onChange(null);
|
|
60
60
|
} else {
|
|
@@ -105,7 +105,7 @@ ValueConditions.propTypes = {
|
|
|
105
105
|
onChange: PropTypes.func,
|
|
106
106
|
parentStructures: PropTypes.array,
|
|
107
107
|
scope: PropTypes.string,
|
|
108
|
-
siblings: PropTypes.array
|
|
108
|
+
siblings: PropTypes.array,
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
export default ValueConditions;
|