@truedat/df 8.7.0 → 8.7.1
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 +4 -4
- package/src/components/DynamicFormViewer.js +3 -3
- package/src/components/DynamicFormWithTranslations.js +4 -4
- package/src/components/FieldGroupDetail.js +1 -1
- package/src/components/FieldGroupWithTranslations.js +1 -1
- package/src/components/SelectableDynamicForm.js +1 -1
- package/src/components/__tests__/DynamicFieldValue.spec.js +2 -2
- package/src/components/__tests__/DynamicFormViewer.spec.js +7 -7
- package/src/components/__tests__/EditableDynamicFieldValue.spec.js +1 -1
- package/src/components/__tests__/FieldViewerValue.spec.js +12 -12
- package/src/components/__tests__/SelectDynamicFormWithTranslations.spec.js +1 -1
- package/src/components/__tests__/SelectableDynamicForm.spec.js +16 -12
- package/src/components/hierarchies/HierarchyView.js +9 -9
- package/src/components/hierarchies/__tests__/HierarchyRoutes.spec.js +1 -1
- package/src/components/widgets/DropdownDataLoader.js +1 -1
- package/src/components/widgets/DynamicField.js +5 -5
- package/src/components/widgets/DynamicTableField.js +129 -125
- package/src/components/widgets/GroupPreview.js +2 -2
- package/src/components/widgets/HierarchyPreview.js +1 -1
- package/src/components/widgets/ImageField.js +2 -3
- package/src/components/widgets/MarkdownField.js +0 -1
- package/src/components/widgets/StandardDropdown.js +5 -5
- package/src/components/widgets/StringField.js +1 -4
- package/src/components/widgets/TableField.js +1 -1
- package/src/components/widgets/UserGroupPreview.js +1 -1
- package/src/components/widgets/__tests__/CheckboxField.spec.js +2 -2
- package/src/components/widgets/__tests__/DropdownField.spec.js +2 -2
- package/src/components/widgets/__tests__/DynamicField.spec.js +11 -3
- package/src/components/widgets/__tests__/DynamicTableField.spec.js +237 -237
- package/src/components/widgets/__tests__/GroupPreview.spec.js +11 -11
- package/src/components/widgets/__tests__/HierarchyDropdown.spec.js +3 -3
- package/src/components/widgets/__tests__/NumberField.spec.js +1 -1
- package/src/components/widgets/__tests__/PairListField.spec.js +3 -3
- package/src/components/widgets/__tests__/StandardDropdown.spec.js +1 -1
- package/src/components/widgets/__tests__/UserGroupPreview.spec.js +14 -10
- package/src/messages/index.js +1 -1
- package/src/reducers/__tests__/dfMessage.spec.js +5 -5
- package/src/reducers/__tests__/selectedDomain.spec.js +2 -2
- package/src/reducers/__tests__/selectedDomains.spec.js +2 -2
- package/src/reducers/dfMessage.js +4 -4
- package/src/selectors/getOptions.js +2 -2
- package/src/selectors/templates.js +2 -2
- package/src/templates/components/Template.js +2 -2
- package/src/templates/components/TemplateFilters.js +1 -1
- package/src/templates/components/TemplateLoader.js +1 -1
- package/src/templates/components/TemplateRoutes.js +1 -1
- package/src/templates/components/Templates.js +1 -6
- package/src/templates/components/TemplatesContext.js +3 -3
- package/src/templates/components/TemplatesTable.js +1 -1
- package/src/templates/components/__tests__/TemplateLoader.spec.js +2 -2
- package/src/templates/components/__tests__/TemplateRoutes.spec.js +1 -1
- package/src/templates/components/__tests__/TemplatesTable.spec.js +1 -1
- package/src/templates/components/templateForm/ActiveGroupForm.js +3 -3
- package/src/templates/components/templateForm/ConditionalFieldForm.js +3 -3
- package/src/templates/components/templateForm/DependentDomain.js +3 -3
- package/src/templates/components/templateForm/FieldDefinition.js +126 -129
- package/src/templates/components/templateForm/HierarchiesList.js +1 -1
- package/src/templates/components/templateForm/MandatoryConditional.js +2 -2
- package/src/templates/components/templateForm/TemplateForm.js +46 -41
- package/src/templates/components/templateForm/ValuesConfiguration.js +69 -56
- package/src/templates/components/templateForm/ValuesField.js +43 -43
- package/src/templates/components/templateForm/__tests__/DefaultValue.spec.js +35 -35
- package/src/templates/components/templateForm/__tests__/DependentDomain.spec.js +1 -1
- package/src/templates/components/templateForm/__tests__/FieldDefinition.spec.js +227 -201
- package/src/templates/components/templateForm/__tests__/FieldForm.spec.js +12 -10
- package/src/templates/components/templateForm/__tests__/MandatoryConditional.spec.js +3 -3
- package/src/templates/components/templateForm/__tests__/SwitchListForm.spec.js +5 -5
- package/src/templates/components/templateForm/__tests__/SwitchSegment.spec.js +8 -8
- package/src/templates/components/templateForm/__tests__/TableValuesForm.spec.js +207 -189
- package/src/templates/components/templateForm/__tests__/TemplateForm.spec.js +42 -13
- package/src/templates/components/templateForm/__tests__/TemplateFormActions.spec.js +1 -1
- package/src/templates/components/templateForm/__tests__/TemplateRelationsForm.spec.js +3 -1
- package/src/templates/components/templateForm/__tests__/ValuesField.spec.js +6 -6
- package/src/templates/components/templateForm/__tests__/ValuesListForm.spec.js +4 -4
- package/src/templates/components/templateForm/__tests__/ValuesSelector.spec.js +3 -3
- package/src/templates/components/templateForm/widgetDefinitions.js +2 -0
- package/src/templates/reducers/__tests__/allTemplates.spec.js +4 -4
- package/src/templates/reducers/__tests__/selectedTemplate.spec.js +2 -2
- package/src/templates/reducers/__tests__/template.spec.js +4 -4
- package/src/templates/reducers/__tests__/templateDeleting.spec.js +2 -2
- package/src/templates/reducers/__tests__/templateLoading.spec.js +2 -2
- package/src/templates/reducers/__tests__/templates.spec.js +3 -3
- package/src/templates/reducers/__tests__/templatesLoading.spec.js +2 -2
- package/src/templates/sagas/__tests__/createTemplate.spec.js +3 -3
- package/src/templates/sagas/__tests__/fetchTemplates.spec.js +1 -1
- package/src/templates/sagas/index.js +2 -2
- package/src/templates/utils/__tests__/applyDefaults.spec.js +4 -4
- package/src/templates/utils/__tests__/filterDomains.spec.js +15 -15
- package/src/templates/utils/__tests__/filterFields.spec.js +2 -2
- package/src/templates/utils/__tests__/filterSwitches.spec.js +5 -5
- package/src/templates/utils/__tests__/filterValues.spec.js +4 -4
- package/src/templates/utils/__tests__/formatLegacyContent.spec.js +7 -7
- package/src/templates/utils/applyTemplate.js +66 -53
- package/src/templates/utils/filterDepends.js +1 -1
- package/src/templates/utils/filterSwitches.js +3 -3
- package/src/templates/utils/filterValues.js +4 -5
- package/src/templates/utils/flattenFields.js +2 -2
- package/src/templates/utils/formatLegacyContent.js +2 -1
- package/src/templates/utils/parseFieldOptions.js +15 -14
- package/src/templates/utils/parseGroups.js +43 -43
- package/src/templates/utils/validateContent.js +4 -4
|
@@ -2,6 +2,7 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import { useIntl } from "react-intl";
|
|
3
3
|
|
|
4
4
|
export const getCardinalityOptions = (widget) => {
|
|
5
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
5
6
|
const { formatMessage } = useIntl();
|
|
6
7
|
|
|
7
8
|
const cardinalities = _.flow([
|
|
@@ -16,6 +17,7 @@ export const getCardinalityOptions = (widget) => {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
export const getTypeOptions = (widget) => {
|
|
20
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
19
21
|
const { formatMessage } = useIntl();
|
|
20
22
|
|
|
21
23
|
const types = _.flow([_.find({ value: widget }), _.prop("types")])(WIDGETS);
|
|
@@ -12,13 +12,13 @@ describe("reducers: templates", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the fetchTemplates.TRIGGER action", () => {
|
|
14
14
|
expect(allTemplates(fooState, { type: fetchTemplates.TRIGGER })).toEqual(
|
|
15
|
-
initialState
|
|
15
|
+
initialState,
|
|
16
16
|
);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should ignore the clearTemplates.TRIGGER action", () => {
|
|
20
20
|
expect(allTemplates(fooState, { type: clearTemplates.TRIGGER })).toEqual(
|
|
21
|
-
fooState
|
|
21
|
+
fooState,
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ describe("reducers: templates", () => {
|
|
|
27
27
|
allTemplates(fooState, {
|
|
28
28
|
type: fetchTemplates.SUCCESS,
|
|
29
29
|
payload: { scope: "dd", data: [] },
|
|
30
|
-
})
|
|
30
|
+
}),
|
|
31
31
|
).toEqual(fooState);
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ describe("reducers: templates", () => {
|
|
|
37
37
|
allTemplates(fooState, {
|
|
38
38
|
type: fetchTemplates.SUCCESS,
|
|
39
39
|
payload: { data: templates },
|
|
40
|
-
})
|
|
40
|
+
}),
|
|
41
41
|
).toEqual(templates);
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -12,7 +12,7 @@ describe("reducers: selectedTemplate", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the clearTemplate.TRIGGER action", () => {
|
|
14
14
|
expect(selectedTemplate(fooState, { type: clearTemplate.TRIGGER })).toEqual(
|
|
15
|
-
initialState
|
|
15
|
+
initialState,
|
|
16
16
|
);
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ describe("reducers: selectedTemplate", () => {
|
|
|
20
20
|
const id = 1;
|
|
21
21
|
const payload = { id };
|
|
22
22
|
expect(
|
|
23
|
-
selectedTemplate(fooState, { type: selectTemplate.TRIGGER, payload })
|
|
23
|
+
selectedTemplate(fooState, { type: selectTemplate.TRIGGER, payload }),
|
|
24
24
|
).toEqual(payload);
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -13,19 +13,19 @@ describe("reducers: template", () => {
|
|
|
13
13
|
|
|
14
14
|
it("should handle the clearTemplates.TRIGGER action", () => {
|
|
15
15
|
expect(template(fooState, { type: clearTemplates.TRIGGER })).toEqual(
|
|
16
|
-
initialState
|
|
16
|
+
initialState,
|
|
17
17
|
);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it("should handle the clearTemplate.TRIGGER action", () => {
|
|
21
21
|
expect(template(fooState, { type: clearTemplate.TRIGGER })).toEqual(
|
|
22
|
-
initialState
|
|
22
|
+
initialState,
|
|
23
23
|
);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it("should handle the fetchTemplate.TRIGGER action", () => {
|
|
27
27
|
expect(template(fooState, { type: fetchTemplate.TRIGGER })).toEqual(
|
|
28
|
-
initialState
|
|
28
|
+
initialState,
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -35,7 +35,7 @@ describe("reducers: template", () => {
|
|
|
35
35
|
template(fooState, {
|
|
36
36
|
type: fetchTemplate.SUCCESS,
|
|
37
37
|
payload: { data },
|
|
38
|
-
})
|
|
38
|
+
}),
|
|
39
39
|
).toEqual(data);
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -10,13 +10,13 @@ describe("reducers: templateDeleting", () => {
|
|
|
10
10
|
|
|
11
11
|
it("should be true after receiving the deleteTemplate.TRIGGER action", () => {
|
|
12
12
|
expect(templateDeleting(false, { type: deleteTemplate.TRIGGER })).toBe(
|
|
13
|
-
true
|
|
13
|
+
true,
|
|
14
14
|
);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it("should be false after receiving the deleteTemplate.FULFILL action", () => {
|
|
18
18
|
expect(templateDeleting(true, { type: deleteTemplate.FULFILL })).toBe(
|
|
19
|
-
false
|
|
19
|
+
false,
|
|
20
20
|
);
|
|
21
21
|
});
|
|
22
22
|
|
|
@@ -12,13 +12,13 @@ describe("reducers: templateLoading", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the fetchTemplate.TRIGGER action", () => {
|
|
14
14
|
expect(templateLoading(fooState, { type: fetchTemplate.TRIGGER })).toEqual(
|
|
15
|
-
true
|
|
15
|
+
true,
|
|
16
16
|
);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should handle the fetchTemplate.FULFILL action", () => {
|
|
20
20
|
expect(templateLoading(fooState, { type: fetchTemplate.FULFILL })).toEqual(
|
|
21
|
-
false
|
|
21
|
+
false,
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -12,13 +12,13 @@ describe("reducers: templates", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the clearTemplates.TRIGGER action", () => {
|
|
14
14
|
expect(templates(fooState, { type: clearTemplates.TRIGGER })).toEqual(
|
|
15
|
-
initialState
|
|
15
|
+
initialState,
|
|
16
16
|
);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should handle the fetchTemplates.TRIGGER action", () => {
|
|
20
20
|
expect(templates(fooState, { type: fetchTemplates.TRIGGER })).toEqual(
|
|
21
|
-
initialState
|
|
21
|
+
initialState,
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ describe("reducers: templates", () => {
|
|
|
28
28
|
templates(fooState, {
|
|
29
29
|
type: fetchTemplates.SUCCESS,
|
|
30
30
|
payload: { data },
|
|
31
|
-
})
|
|
31
|
+
}),
|
|
32
32
|
).toEqual(data);
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -12,13 +12,13 @@ describe("reducers: templates", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the fetchTemplates.TRIGGER action", () => {
|
|
14
14
|
expect(
|
|
15
|
-
templatesLoading(fooState, { type: fetchTemplates.TRIGGER })
|
|
15
|
+
templatesLoading(fooState, { type: fetchTemplates.TRIGGER }),
|
|
16
16
|
).toEqual(true);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should handle the fetchTemplates.FULFILL action", () => {
|
|
20
20
|
expect(
|
|
21
|
-
templatesLoading(fooState, { type: fetchTemplates.FULFILL })
|
|
21
|
+
templatesLoading(fooState, { type: fetchTemplates.FULFILL }),
|
|
22
22
|
).toEqual(false);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -2,7 +2,7 @@ import { testSaga } from "redux-saga-test-plan";
|
|
|
2
2
|
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
3
3
|
import {
|
|
4
4
|
createTemplateRequestSaga,
|
|
5
|
-
createTemplateSaga
|
|
5
|
+
createTemplateSaga,
|
|
6
6
|
} from "../createTemplate";
|
|
7
7
|
import { createTemplate } from "../../routines";
|
|
8
8
|
import { API_TEMPLATES } from "../../api";
|
|
@@ -35,8 +35,8 @@ describe("sagas: createTemplateSaga", () => {
|
|
|
35
35
|
group: "group1",
|
|
36
36
|
name: "field1",
|
|
37
37
|
label: "Field 1",
|
|
38
|
-
type: "string"
|
|
39
|
-
}
|
|
38
|
+
type: "string",
|
|
39
|
+
},
|
|
40
40
|
];
|
|
41
41
|
const url = API_TEMPLATES;
|
|
42
42
|
const template = { scope, label, content };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { testSaga } from "redux-saga-test-plan";
|
|
2
2
|
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
3
|
+
import { fetchTemplates } from "@truedat/core/routines";
|
|
3
4
|
import {
|
|
4
5
|
fetchTemplatesRequestSaga,
|
|
5
6
|
fetchTemplatesSaga,
|
|
6
7
|
} from "../fetchTemplates";
|
|
7
|
-
import { fetchTemplates } from "@truedat/core/routines";
|
|
8
8
|
import { API_TEMPLATES } from "../../api";
|
|
9
9
|
|
|
10
10
|
describe("sagas: fetchTemplatesRequestSaga", () => {
|
|
@@ -9,7 +9,7 @@ export {
|
|
|
9
9
|
deleteTemplateRequestSaga,
|
|
10
10
|
fetchTemplateRequestSaga,
|
|
11
11
|
fetchTemplatesRequestSaga,
|
|
12
|
-
updateTemplateRequestSaga
|
|
12
|
+
updateTemplateRequestSaga,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export default [
|
|
@@ -17,5 +17,5 @@ export default [
|
|
|
17
17
|
deleteTemplateRequestSaga(),
|
|
18
18
|
fetchTemplateRequestSaga(),
|
|
19
19
|
fetchTemplatesRequestSaga(),
|
|
20
|
-
updateTemplateRequestSaga()
|
|
20
|
+
updateTemplateRequestSaga(),
|
|
21
21
|
];
|
|
@@ -91,7 +91,7 @@ describe("utils: applyDefaults", () => {
|
|
|
91
91
|
foo: { value: "bar", origin: "user" },
|
|
92
92
|
qux: { value: "spqr", origin: "user" },
|
|
93
93
|
xyzzy,
|
|
94
|
-
})
|
|
94
|
+
}),
|
|
95
95
|
).toEqual({
|
|
96
96
|
foo: { value: "bar", origin: "user" },
|
|
97
97
|
qux: { value: "spqr", origin: "user" },
|
|
@@ -105,7 +105,7 @@ describe("utils: applyDefaults", () => {
|
|
|
105
105
|
qux: { value: "spqr", origin: "user" },
|
|
106
106
|
xyzzy,
|
|
107
107
|
bar: { value: "1", origin: "user" },
|
|
108
|
-
})
|
|
108
|
+
}),
|
|
109
109
|
).toEqual({
|
|
110
110
|
foo: { value: "bar", origin: "user" },
|
|
111
111
|
qux: { value: "spqr", origin: "user" },
|
|
@@ -150,8 +150,8 @@ describe("utils: applyDefaults", () => {
|
|
|
150
150
|
expect(
|
|
151
151
|
applyDefaults(templateContent)(
|
|
152
152
|
{ ...defaultContent, xxyy: { value: ["b"], origin: "user" } },
|
|
153
|
-
2
|
|
154
|
-
)
|
|
153
|
+
2,
|
|
154
|
+
),
|
|
155
155
|
).toEqual({
|
|
156
156
|
foo: { value: "bar", origin: "user" },
|
|
157
157
|
qux: { value: "spqr", origin: "user" },
|
|
@@ -19,7 +19,7 @@ describe("filterDomains", () => {
|
|
|
19
19
|
filterDomains(templateContent)({
|
|
20
20
|
foo: { value: "foo", origin: "default" },
|
|
21
21
|
bar: { value: "z", origin: "default" },
|
|
22
|
-
})
|
|
22
|
+
}),
|
|
23
23
|
).toEqual(result);
|
|
24
24
|
expect(
|
|
25
25
|
filterDomains(templateContent)(
|
|
@@ -27,8 +27,8 @@ describe("filterDomains", () => {
|
|
|
27
27
|
foo: { value: "foo", origin: "default" },
|
|
28
28
|
bar: { value: "z", origin: "default" },
|
|
29
29
|
},
|
|
30
|
-
1
|
|
31
|
-
)
|
|
30
|
+
1,
|
|
31
|
+
),
|
|
32
32
|
).toEqual(result);
|
|
33
33
|
|
|
34
34
|
expect(
|
|
@@ -37,8 +37,8 @@ describe("filterDomains", () => {
|
|
|
37
37
|
foo: { value: "foo", origin: "default" },
|
|
38
38
|
bar: { value: "z", origin: "default" },
|
|
39
39
|
},
|
|
40
|
-
2
|
|
41
|
-
)
|
|
40
|
+
2,
|
|
41
|
+
),
|
|
42
42
|
).toEqual(result);
|
|
43
43
|
|
|
44
44
|
expect(
|
|
@@ -47,8 +47,8 @@ describe("filterDomains", () => {
|
|
|
47
47
|
foo: { value: "foo", origin: "default" },
|
|
48
48
|
bar: { value: "a", origin: "default" },
|
|
49
49
|
},
|
|
50
|
-
3
|
|
51
|
-
)
|
|
50
|
+
3,
|
|
51
|
+
),
|
|
52
52
|
).toEqual(result);
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -59,8 +59,8 @@ describe("filterDomains", () => {
|
|
|
59
59
|
foo: { value: "foo", origin: "default" },
|
|
60
60
|
bar: { value: "a", origin: "default" },
|
|
61
61
|
},
|
|
62
|
-
1
|
|
63
|
-
)
|
|
62
|
+
1,
|
|
63
|
+
),
|
|
64
64
|
).toEqual({
|
|
65
65
|
foo: { value: "foo", origin: "default" },
|
|
66
66
|
bar: { value: "a", origin: "default" },
|
|
@@ -72,8 +72,8 @@ describe("filterDomains", () => {
|
|
|
72
72
|
foo: { value: "foo", origin: "default" },
|
|
73
73
|
bar: { value: "e", origin: "default" },
|
|
74
74
|
},
|
|
75
|
-
2
|
|
76
|
-
)
|
|
75
|
+
2,
|
|
76
|
+
),
|
|
77
77
|
).toEqual({
|
|
78
78
|
foo: { value: "foo", origin: "default" },
|
|
79
79
|
bar: { value: "e", origin: "default" },
|
|
@@ -87,8 +87,8 @@ describe("filterDomains", () => {
|
|
|
87
87
|
foo: { value: "foo", origin: "default" },
|
|
88
88
|
bar: { value: ["a"], origin: "default" },
|
|
89
89
|
},
|
|
90
|
-
1
|
|
91
|
-
)
|
|
90
|
+
1,
|
|
91
|
+
),
|
|
92
92
|
).toEqual({
|
|
93
93
|
foo: { value: "foo", origin: "default" },
|
|
94
94
|
bar: { value: ["a"], origin: "default" },
|
|
@@ -100,8 +100,8 @@ describe("filterDomains", () => {
|
|
|
100
100
|
foo: { value: "foo", origin: "default" },
|
|
101
101
|
bar: { value: ["e"], origin: "default" },
|
|
102
102
|
},
|
|
103
|
-
2
|
|
104
|
-
)
|
|
103
|
+
2,
|
|
104
|
+
),
|
|
105
105
|
).toEqual({
|
|
106
106
|
foo: { value: "foo", origin: "default" },
|
|
107
107
|
bar: { value: ["e"], origin: "default" },
|
|
@@ -4,7 +4,7 @@ import { filterFields } from "..";
|
|
|
4
4
|
const templateContent = [
|
|
5
5
|
{ name: "foo" },
|
|
6
6
|
{ name: "bar", values: {} },
|
|
7
|
-
{ name: "baz" }
|
|
7
|
+
{ name: "baz" },
|
|
8
8
|
];
|
|
9
9
|
|
|
10
10
|
describe("utils: filterFields", () => {
|
|
@@ -14,7 +14,7 @@ describe("utils: filterFields", () => {
|
|
|
14
14
|
const o = {
|
|
15
15
|
foo: "any",
|
|
16
16
|
bar: "value",
|
|
17
|
-
baz: { at: "all" }
|
|
17
|
+
baz: { at: "all" },
|
|
18
18
|
};
|
|
19
19
|
const result = filterFields(templateContent)({ ...o, xyzzy });
|
|
20
20
|
expect(result).toMatchObject(o);
|
|
@@ -39,31 +39,31 @@ describe("utils: isSwitchValid", () => {
|
|
|
39
39
|
validator({
|
|
40
40
|
src: { value: "foo", origin: "default" },
|
|
41
41
|
target: { value: "foo1", origin: "default" },
|
|
42
|
-
})
|
|
42
|
+
}),
|
|
43
43
|
).toBe(true);
|
|
44
44
|
expect(
|
|
45
45
|
validator({
|
|
46
46
|
src: { value: "bar", origin: "default" },
|
|
47
47
|
target: { value: "bar2", origin: "default" },
|
|
48
|
-
})
|
|
48
|
+
}),
|
|
49
49
|
).toBe(true);
|
|
50
50
|
expect(
|
|
51
51
|
validator({
|
|
52
52
|
src: { value: "baz", origin: "default" },
|
|
53
53
|
target: { value: "xyzzy", origin: "default" },
|
|
54
|
-
})
|
|
54
|
+
}),
|
|
55
55
|
).toBe(false);
|
|
56
56
|
expect(
|
|
57
57
|
validator({
|
|
58
58
|
src: { value: "foo", origin: "default" },
|
|
59
59
|
target: { value: ["foo1"], origin: "default" },
|
|
60
|
-
})
|
|
60
|
+
}),
|
|
61
61
|
).toBe(true);
|
|
62
62
|
expect(
|
|
63
63
|
validator({
|
|
64
64
|
src: { value: "foo", origin: "default" },
|
|
65
65
|
target: { value: "", origin: "default" },
|
|
66
|
-
})
|
|
66
|
+
}),
|
|
67
67
|
).toBe(true);
|
|
68
68
|
});
|
|
69
69
|
});
|
|
@@ -144,7 +144,7 @@ describe("utils: validValues", () => {
|
|
|
144
144
|
expect(
|
|
145
145
|
filterValues(template)({
|
|
146
146
|
role: { value: "foo bar", origin: "default" },
|
|
147
|
-
})
|
|
147
|
+
}),
|
|
148
148
|
).toEqual({
|
|
149
149
|
role: { value: "foo bar", origin: "default" },
|
|
150
150
|
});
|
|
@@ -152,7 +152,7 @@ describe("utils: validValues", () => {
|
|
|
152
152
|
expect(
|
|
153
153
|
filterValues(template)({
|
|
154
154
|
role: { value: "user:u1", origin: "default" },
|
|
155
|
-
})
|
|
155
|
+
}),
|
|
156
156
|
).toEqual({
|
|
157
157
|
role: { value: null, origin: "default" },
|
|
158
158
|
});
|
|
@@ -160,7 +160,7 @@ describe("utils: validValues", () => {
|
|
|
160
160
|
expect(
|
|
161
161
|
filterValues(template)({
|
|
162
162
|
role: { value: "alias1", origin: "default" },
|
|
163
|
-
})
|
|
163
|
+
}),
|
|
164
164
|
).toEqual({
|
|
165
165
|
role: { value: null, origin: "default" },
|
|
166
166
|
});
|
|
@@ -168,7 +168,7 @@ describe("utils: validValues", () => {
|
|
|
168
168
|
expect(
|
|
169
169
|
filterValues(template)({
|
|
170
170
|
role: { value: "group:foo bar", origin: "default" },
|
|
171
|
-
})
|
|
171
|
+
}),
|
|
172
172
|
).toEqual({
|
|
173
173
|
role: { value: null, origin: "default" },
|
|
174
174
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { formatLegacyContent } from "..";
|
|
2
2
|
|
|
3
3
|
describe("utils: formatLegacyContent", () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
4
|
+
it("should formats legacy contet", () => {
|
|
5
|
+
const content = { single: "foo", multiple: ["bar", "baz"] };
|
|
6
|
+
const result = formatLegacyContent(content);
|
|
7
|
+
expect(result).toEqual({
|
|
8
|
+
single: { value: "foo", origin: "user" },
|
|
9
|
+
multiple: { value: ["bar", "baz"], origin: "user" },
|
|
11
10
|
});
|
|
11
|
+
});
|
|
12
12
|
});
|
|
@@ -14,85 +14,98 @@ const isInformed = _.flow(
|
|
|
14
14
|
[_.isString, _.isEmpty],
|
|
15
15
|
[_.stubTrue, _.isNil],
|
|
16
16
|
]),
|
|
17
|
-
(value) => !value
|
|
17
|
+
(value) => !value,
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const applyTableFields = (templateContent, content, domainId) => {
|
|
21
|
-
const tableFields = _.filter((field) => field.type === "dynamic_table")(
|
|
21
|
+
const tableFields = _.filter((field) => field.type === "dynamic_table")(
|
|
22
|
+
templateContent,
|
|
23
|
+
);
|
|
22
24
|
return _.reduce((content, field) => {
|
|
23
25
|
const fieldName = field.name;
|
|
24
|
-
const contentValues = _.pathOr([], `${fieldName}.value`)(content)
|
|
26
|
+
const contentValues = _.pathOr([], `${fieldName}.value`)(content);
|
|
25
27
|
|
|
26
28
|
if (!_.isEmpty(contentValues)) {
|
|
27
29
|
const tableColumns = field.values.table_columns;
|
|
28
|
-
const updatedContentValues = _.map((contentValue) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
const updatedContentValues = _.map((contentValue) =>
|
|
31
|
+
_.flow(
|
|
32
|
+
filterFields(tableColumns),
|
|
33
|
+
filterValues(tableColumns),
|
|
34
|
+
filterDepends(tableColumns),
|
|
35
|
+
filterSwitches(tableColumns),
|
|
36
|
+
(content) => filterDomains(tableColumns)(content, domainId),
|
|
37
|
+
(content) => applyDefaults(tableColumns)(content, domainId),
|
|
38
|
+
)(contentValue),
|
|
39
|
+
)(contentValues);
|
|
36
40
|
|
|
37
41
|
return _.set(`${fieldName}.value`, updatedContentValues)(content);
|
|
38
42
|
} else {
|
|
39
|
-
return content
|
|
43
|
+
return content;
|
|
40
44
|
}
|
|
41
|
-
}, content)(tableFields)
|
|
42
|
-
}
|
|
45
|
+
}, content)(tableFields);
|
|
46
|
+
};
|
|
43
47
|
|
|
44
|
-
const applyTableFieldsWithoutDefaults = (
|
|
45
|
-
|
|
48
|
+
const applyTableFieldsWithoutDefaults = (
|
|
49
|
+
templateContent,
|
|
50
|
+
content,
|
|
51
|
+
domainId,
|
|
52
|
+
) => {
|
|
53
|
+
const tableFields = _.filter((field) => field.type === "dynamic_table")(
|
|
54
|
+
templateContent,
|
|
55
|
+
);
|
|
46
56
|
return _.reduce((content, field) => {
|
|
47
57
|
const fieldName = field.name;
|
|
48
|
-
const contentValues = _.pathOr([], `${fieldName}.value`)(content)
|
|
58
|
+
const contentValues = _.pathOr([], `${fieldName}.value`)(content);
|
|
49
59
|
|
|
50
60
|
if (!_.isEmpty(contentValues)) {
|
|
51
61
|
const tableColumns = field.values.table_columns;
|
|
52
|
-
const updatedContentValues = _.map((contentValue) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
const updatedContentValues = _.map((contentValue) =>
|
|
63
|
+
_.flow(
|
|
64
|
+
filterFields(tableColumns),
|
|
65
|
+
filterValues(tableColumns),
|
|
66
|
+
filterDepends(tableColumns),
|
|
67
|
+
filterSwitches(tableColumns),
|
|
68
|
+
(content) => filterDomains(tableColumns)(content, domainId),
|
|
69
|
+
(content) => applyDefaults(tableColumns)(content, domainId),
|
|
70
|
+
)(contentValue),
|
|
71
|
+
)(contentValues);
|
|
60
72
|
|
|
61
73
|
return _.set(`${fieldName}.value`, updatedContentValues)(content);
|
|
62
74
|
} else {
|
|
63
|
-
return content
|
|
75
|
+
return content;
|
|
64
76
|
}
|
|
65
|
-
}, content)(tableFields)
|
|
66
|
-
}
|
|
77
|
+
}, content)(tableFields);
|
|
78
|
+
};
|
|
67
79
|
export const applyTemplate =
|
|
68
80
|
(template) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
(content, domainId = null) => {
|
|
82
|
+
const templateContent = flattenFields(template);
|
|
83
|
+
return _.flow(
|
|
84
|
+
filterFields(templateContent),
|
|
85
|
+
filterValues(templateContent),
|
|
86
|
+
filterDepends(templateContent),
|
|
87
|
+
filterSwitches(templateContent),
|
|
88
|
+
(content) => filterDomains(templateContent)(content, domainId),
|
|
89
|
+
(content) => applyDefaults(templateContent)(content, domainId),
|
|
90
|
+
_.pickBy((value) => isInformed(value.value)),
|
|
91
|
+
(content) => applyTableFields(templateContent, content, domainId),
|
|
92
|
+
)(content);
|
|
93
|
+
};
|
|
82
94
|
|
|
83
95
|
export const applyTemplateWithoutDefaults =
|
|
84
96
|
(template) =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
(content, domainId = null) => {
|
|
98
|
+
const templateContent = flattenFields(template);
|
|
99
|
+
return _.flow(
|
|
100
|
+
filterFields(templateContent),
|
|
101
|
+
filterValues(templateContent),
|
|
102
|
+
filterDepends(templateContent),
|
|
103
|
+
filterSwitches(templateContent),
|
|
104
|
+
(content) => filterDomains(templateContent)(content, domainId),
|
|
105
|
+
_.pickBy((value) => isInformed(value.value)),
|
|
106
|
+
(content) =>
|
|
107
|
+
applyTableFieldsWithoutDefaults(templateContent, content, domainId),
|
|
108
|
+
)(content);
|
|
109
|
+
};
|
|
97
110
|
|
|
98
111
|
export default applyTemplate;
|
|
@@ -23,9 +23,9 @@ export const isSwitchValid = (prop, on) =>
|
|
|
23
23
|
: _.isArray(value)
|
|
24
24
|
? _.isEmpty(_.without(validValues)(value))
|
|
25
25
|
: _.includes(value)(validValues),
|
|
26
|
-
})
|
|
26
|
+
}),
|
|
27
27
|
),
|
|
28
|
-
_.overSome
|
|
28
|
+
_.overSome,
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
const filterSwitch = ({
|
|
@@ -42,5 +42,5 @@ const filterSwitch = ({
|
|
|
42
42
|
export const filterSwitches = _.flow(
|
|
43
43
|
_.filter(isSwitch),
|
|
44
44
|
_.map(filterSwitch),
|
|
45
|
-
_.flow
|
|
45
|
+
_.flow,
|
|
46
46
|
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
|
|
3
|
-
const groupCanonicalName = (group) =>
|
|
4
|
-
_.isString(group) ? group : group?.name;
|
|
3
|
+
const groupCanonicalName = (group) => (_.isString(group) ? group : group?.name);
|
|
5
4
|
|
|
6
5
|
const processedGroups = (values = {}) => {
|
|
7
6
|
const details = _.get("processed_groups_details")(values);
|
|
@@ -48,14 +47,14 @@ export const validValues = _.flow(
|
|
|
48
47
|
[
|
|
49
48
|
() =>
|
|
50
49
|
type === "group" &&
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
(_.has("processed_groups", values) ||
|
|
51
|
+
_.has("processed_groups_details", values)),
|
|
53
52
|
() => groupValues(values),
|
|
54
53
|
],
|
|
55
54
|
[
|
|
56
55
|
() =>
|
|
57
56
|
_.has("processed_groups", values) ||
|
|
58
|
-
|
|
57
|
+
_.has("processed_groups_details", values),
|
|
59
58
|
() => userGroupValues(values),
|
|
60
59
|
],
|
|
61
60
|
[_.has("processed_users"), _.pathOr([], "processed_users")],
|