@tsed/react-formio 1.14.0 → 2.0.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/coverage.json +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1278 -3685
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +957 -2768
- package/dist/index.modern.js.map +1 -1
- package/package.json +4 -5
- package/readme.md +9 -57
- package/src/components/form-edit/useFormEdit.hook.ts +2 -1
- package/src/components/input-tags/inputTags.component.tsx +1 -1
- package/src/components/select/select.component.tsx +1 -1
- package/src/components/table/filters/sliderColumnFilter.component.tsx +2 -2
- package/src/index.ts +3 -2
- package/dist/stores/action/action.actions.d.ts +0 -9
- package/dist/stores/action/action.actions.spec.d.ts +0 -1
- package/dist/stores/action/action.constant.d.ts +0 -1
- package/dist/stores/action/action.reducers.d.ts +0 -7
- package/dist/stores/action/action.reducers.spec.d.ts +0 -1
- package/dist/stores/action/action.selectors.d.ts +0 -2
- package/dist/stores/action/action.selectors.spec.d.ts +0 -1
- package/dist/stores/action/index.d.ts +0 -4
- package/dist/stores/action-info/action-info.actions.d.ts +0 -5
- package/dist/stores/action-info/action-info.actions.spec.d.ts +0 -1
- package/dist/stores/action-info/action-info.constant.d.ts +0 -1
- package/dist/stores/action-info/action-info.reducers.d.ts +0 -7
- package/dist/stores/action-info/action-info.reducers.spec.d.ts +0 -1
- package/dist/stores/action-info/action-info.selectors.d.ts +0 -2
- package/dist/stores/action-info/action-info.selectors.spec.d.ts +0 -1
- package/dist/stores/action-info/index.d.ts +0 -4
- package/dist/stores/actions/actions.actions.d.ts +0 -5
- package/dist/stores/actions/actions.actions.spec.d.ts +0 -1
- package/dist/stores/actions/actions.constant.d.ts +0 -1
- package/dist/stores/actions/actions.reducers.d.ts +0 -8
- package/dist/stores/actions/actions.reducers.spec.d.ts +0 -1
- package/dist/stores/actions/actions.selectors.d.ts +0 -2
- package/dist/stores/actions/actions.selectors.spec.d.ts +0 -1
- package/dist/stores/actions/index.d.ts +0 -4
- package/dist/stores/auth/auth.actions.d.ts +0 -9
- package/dist/stores/auth/auth.constant.d.ts +0 -1
- package/dist/stores/auth/auth.reducers.d.ts +0 -16
- package/dist/stores/auth/auth.reducers.spec.d.ts +0 -1
- package/dist/stores/auth/auth.selectors.d.ts +0 -6
- package/dist/stores/auth/auth.selectors.spec.d.ts +0 -1
- package/dist/stores/auth/auth.utils.d.ts +0 -6
- package/dist/stores/auth/auth.utils.spec.d.ts +0 -1
- package/dist/stores/auth/getAccess.action.d.ts +0 -1
- package/dist/stores/auth/getAccess.action.spec.d.ts +0 -1
- package/dist/stores/auth/getProjectAccess.action.d.ts +0 -1
- package/dist/stores/auth/index.d.ts +0 -10
- package/dist/stores/auth/initAuth.action.d.ts +0 -1
- package/dist/stores/auth/initAuth.action.spec.d.ts +0 -1
- package/dist/stores/auth/logout.action.d.ts +0 -1
- package/dist/stores/auth/logout.action.spec.d.ts +0 -1
- package/dist/stores/auth/setUser.action.d.ts +0 -1
- package/dist/stores/auth/setUser.action.spec.d.ts +0 -1
- package/dist/stores/form/form.actions.d.ts +0 -10
- package/dist/stores/form/form.actions.spec.d.ts +0 -1
- package/dist/stores/form/form.reducers.d.ts +0 -9
- package/dist/stores/form/form.reducers.spec.d.ts +0 -1
- package/dist/stores/form/form.selectors.d.ts +0 -2
- package/dist/stores/form/form.selectors.spec.d.ts +0 -1
- package/dist/stores/form/index.d.ts +0 -3
- package/dist/stores/forms/forms.actions.d.ts +0 -9
- package/dist/stores/forms/forms.actions.spec.d.ts +0 -1
- package/dist/stores/forms/forms.reducers.d.ts +0 -16
- package/dist/stores/forms/forms.reducers.spec.d.ts +0 -1
- package/dist/stores/forms/forms.selectors.d.ts +0 -10
- package/dist/stores/forms/forms.selectors.spec.d.ts +0 -1
- package/dist/stores/forms/index.d.ts +0 -3
- package/dist/stores/index.d.ts +0 -10
- package/dist/stores/index.spec.d.ts +0 -1
- package/dist/stores/root/index.d.ts +0 -1
- package/dist/stores/root/root.selectors.d.ts +0 -5
- package/dist/stores/root/root.selectors.spec.d.ts +0 -1
- package/dist/stores/submission/index.d.ts +0 -3
- package/dist/stores/submission/submission.actions.d.ts +0 -10
- package/dist/stores/submission/submission.actions.spec.d.ts +0 -1
- package/dist/stores/submission/submission.reducers.d.ts +0 -11
- package/dist/stores/submission/submission.reducers.spec.d.ts +0 -1
- package/dist/stores/submission/submission.selectors.d.ts +0 -2
- package/dist/stores/submission/submission.selectors.spec.d.ts +0 -1
- package/dist/stores/submissions/index.d.ts +0 -3
- package/dist/stores/submissions/submissions.actions.d.ts +0 -6
- package/dist/stores/submissions/submissions.actions.spec.d.ts +0 -1
- package/dist/stores/submissions/submissions.reducers.d.ts +0 -17
- package/dist/stores/submissions/submissions.reducers.spec.d.ts +0 -1
- package/dist/stores/submissions/submissions.selectors.d.ts +0 -9
- package/dist/stores/submissions/submissions.selectors.spec.d.ts +0 -1
- package/dist/utils/clean.d.ts +0 -1
- package/dist/utils/clean.test.d.ts +0 -1
- package/dist/utils/mapRequestParams.d.ts +0 -9
- package/dist/utils/mapRequestParams.test.d.ts +0 -1
- package/dist/utils/url.d.ts +0 -3
- package/dist/utils/url.test.d.ts +0 -1
- package/src/stores/action/action.actions.spec.ts +0 -114
- package/src/stores/action/action.actions.ts +0 -82
- package/src/stores/action/action.constant.ts +0 -1
- package/src/stores/action/action.reducers.spec.ts +0 -91
- package/src/stores/action/action.reducers.ts +0 -54
- package/src/stores/action/action.selectors.spec.ts +0 -19
- package/src/stores/action/action.selectors.ts +0 -6
- package/src/stores/action/index.ts +0 -4
- package/src/stores/action-info/action-info.actions.spec.ts +0 -46
- package/src/stores/action-info/action-info.actions.ts +0 -32
- package/src/stores/action-info/action-info.constant.ts +0 -1
- package/src/stores/action-info/action-info.reducers.spec.ts +0 -60
- package/src/stores/action-info/action-info.reducers.ts +0 -44
- package/src/stores/action-info/action-info.selectors.spec.ts +0 -19
- package/src/stores/action-info/action-info.selectors.ts +0 -7
- package/src/stores/action-info/index.ts +0 -4
- package/src/stores/actions/actions.actions.spec.ts +0 -62
- package/src/stores/actions/actions.actions.ts +0 -34
- package/src/stores/actions/actions.constant.ts +0 -1
- package/src/stores/actions/actions.reducers.spec.ts +0 -62
- package/src/stores/actions/actions.reducers.ts +0 -48
- package/src/stores/actions/actions.selectors.spec.ts +0 -34
- package/src/stores/actions/actions.selectors.ts +0 -7
- package/src/stores/actions/index.ts +0 -4
- package/src/stores/auth/auth.actions.ts +0 -13
- package/src/stores/auth/auth.constant.ts +0 -1
- package/src/stores/auth/auth.reducers.spec.ts +0 -376
- package/src/stores/auth/auth.reducers.ts +0 -151
- package/src/stores/auth/auth.selectors.spec.ts +0 -47
- package/src/stores/auth/auth.selectors.ts +0 -14
- package/src/stores/auth/auth.utils.spec.ts +0 -29
- package/src/stores/auth/auth.utils.tsx +0 -37
- package/src/stores/auth/getAccess.action.spec.ts +0 -257
- package/src/stores/auth/getAccess.action.ts +0 -57
- package/src/stores/auth/getProjectAccess.action.ts +0 -25
- package/src/stores/auth/index.ts +0 -10
- package/src/stores/auth/initAuth.action.spec.ts +0 -56
- package/src/stores/auth/initAuth.action.ts +0 -29
- package/src/stores/auth/logout.action.spec.ts +0 -25
- package/src/stores/auth/logout.action.ts +0 -9
- package/src/stores/auth/setUser.action.spec.ts +0 -25
- package/src/stores/auth/setUser.action.ts +0 -9
- package/src/stores/form/form.actions.spec.ts +0 -203
- package/src/stores/form/form.actions.ts +0 -84
- package/src/stores/form/form.reducers.spec.ts +0 -78
- package/src/stores/form/form.reducers.ts +0 -59
- package/src/stores/form/form.selectors.spec.ts +0 -19
- package/src/stores/form/form.selectors.ts +0 -5
- package/src/stores/form/index.ts +0 -3
- package/src/stores/forms/forms.actions.spec.ts +0 -91
- package/src/stores/forms/forms.actions.ts +0 -44
- package/src/stores/forms/forms.reducers.spec.ts +0 -97
- package/src/stores/forms/forms.reducers.ts +0 -77
- package/src/stores/forms/forms.selectors.spec.ts +0 -39
- package/src/stores/forms/forms.selectors.ts +0 -6
- package/src/stores/forms/index.ts +0 -3
- package/src/stores/index.spec.ts +0 -125
- package/src/stores/index.ts +0 -33
- package/src/stores/root/index.ts +0 -1
- package/src/stores/root/root.selectors.spec.ts +0 -94
- package/src/stores/root/root.selectors.ts +0 -23
- package/src/stores/submission/index.ts +0 -3
- package/src/stores/submission/submission.actions.spec.ts +0 -214
- package/src/stores/submission/submission.actions.ts +0 -81
- package/src/stores/submission/submission.reducers.spec.ts +0 -96
- package/src/stores/submission/submission.reducers.ts +0 -70
- package/src/stores/submission/submission.selectors.spec.ts +0 -19
- package/src/stores/submission/submission.selectors.ts +0 -5
- package/src/stores/submissions/index.ts +0 -3
- package/src/stores/submissions/submissions.actions.spec.ts +0 -99
- package/src/stores/submissions/submissions.actions.ts +0 -38
- package/src/stores/submissions/submissions.reducers.spec.ts +0 -98
- package/src/stores/submissions/submissions.reducers.ts +0 -78
- package/src/stores/submissions/submissions.selectors.spec.ts +0 -39
- package/src/stores/submissions/submissions.selectors.ts +0 -6
- package/src/utils/clean.test.ts +0 -7
- package/src/utils/clean.ts +0 -12
- package/src/utils/mapRequestParams.test.ts +0 -81
- package/src/utils/mapRequestParams.ts +0 -36
- package/src/utils/url.test.ts +0 -31
- package/src/utils/url.ts +0 -23
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { failForms, receiveForms, requestForms, resetForms } from "./forms.actions";
|
|
2
|
-
import { formsReducer } from "./forms.reducers";
|
|
3
|
-
|
|
4
|
-
describe("Forms reducer", () => {
|
|
5
|
-
it("should return state (resetForms)", () => {
|
|
6
|
-
const reducer = formsReducer("name");
|
|
7
|
-
const state: any = {};
|
|
8
|
-
const payload = {};
|
|
9
|
-
|
|
10
|
-
expect(reducer.$emit(resetForms.toString(), state, payload)).toEqual({
|
|
11
|
-
name: "name",
|
|
12
|
-
error: null,
|
|
13
|
-
data: [],
|
|
14
|
-
isActive: false,
|
|
15
|
-
parameters: {
|
|
16
|
-
filters: [],
|
|
17
|
-
pageCount: 0,
|
|
18
|
-
pageIndex: 0,
|
|
19
|
-
pageSize: 10,
|
|
20
|
-
query: {},
|
|
21
|
-
select: "",
|
|
22
|
-
sortBy: []
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
it("should return state (requestForms)", () => {
|
|
27
|
-
const reducer = formsReducer("name");
|
|
28
|
-
const state: any = {};
|
|
29
|
-
const payload: any = {
|
|
30
|
-
parameters: {
|
|
31
|
-
pageSize: 10,
|
|
32
|
-
pageIndex: 1,
|
|
33
|
-
sortBy: [],
|
|
34
|
-
filters: [],
|
|
35
|
-
filterId: "id",
|
|
36
|
-
select: "select"
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
expect(reducer.$emit(requestForms.toString(), state, payload)).toEqual({
|
|
41
|
-
name: "name",
|
|
42
|
-
error: null,
|
|
43
|
-
parameters: {
|
|
44
|
-
filterId: "id",
|
|
45
|
-
filters: [],
|
|
46
|
-
pageIndex: 1,
|
|
47
|
-
pageSize: 10,
|
|
48
|
-
select: "select",
|
|
49
|
-
sortBy: []
|
|
50
|
-
},
|
|
51
|
-
data: [],
|
|
52
|
-
isActive: true
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
it("should return state (receiveForms)", () => {
|
|
56
|
-
const reducer = formsReducer("name");
|
|
57
|
-
const state: any = {
|
|
58
|
-
parameters: {
|
|
59
|
-
pageSize: 10
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const payload: any = {
|
|
63
|
-
forms: [{ _id: "id" }],
|
|
64
|
-
url: "url",
|
|
65
|
-
success: "success"
|
|
66
|
-
};
|
|
67
|
-
payload.forms.serverCount = 100;
|
|
68
|
-
|
|
69
|
-
expect(reducer.$emit(receiveForms.toString(), state, payload)).toEqual({
|
|
70
|
-
name: "name",
|
|
71
|
-
data: [
|
|
72
|
-
{
|
|
73
|
-
_id: "id"
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
isActive: false,
|
|
77
|
-
parameters: {
|
|
78
|
-
pageCount: 10,
|
|
79
|
-
pageSize: 10,
|
|
80
|
-
totalLength: 100
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
it("should return state (failForms)", () => {
|
|
85
|
-
const reducer = formsReducer("name");
|
|
86
|
-
const state: any = {};
|
|
87
|
-
const payload = {
|
|
88
|
-
error: new Error("message")
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
expect(reducer.$emit(failForms.toString(), state, payload)).toEqual({
|
|
92
|
-
name: "name",
|
|
93
|
-
error: payload.error,
|
|
94
|
-
isActive: false
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createReducer } from "@tsed/redux-utils";
|
|
2
|
-
|
|
3
|
-
import { FormSchema } from "../../interfaces";
|
|
4
|
-
import { failForms, receiveForms, requestForms, resetForms } from "./forms.actions";
|
|
5
|
-
|
|
6
|
-
export interface FormsState {
|
|
7
|
-
error: null | Error;
|
|
8
|
-
isActive: boolean;
|
|
9
|
-
parameters: {
|
|
10
|
-
pageSize: number;
|
|
11
|
-
pageIndex: number;
|
|
12
|
-
pageCount: number;
|
|
13
|
-
query: any;
|
|
14
|
-
select: any;
|
|
15
|
-
sortBy: any[];
|
|
16
|
-
filters: any[];
|
|
17
|
-
};
|
|
18
|
-
data: FormSchema[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const createInitialState = ({ pageIndex = 0, pageSize = 10, query = {}, select = "", sortBy = [] }: any = {}): FormsState => {
|
|
22
|
-
return {
|
|
23
|
-
error: null,
|
|
24
|
-
isActive: false,
|
|
25
|
-
parameters: {
|
|
26
|
-
pageSize,
|
|
27
|
-
pageIndex,
|
|
28
|
-
pageCount: 0,
|
|
29
|
-
query,
|
|
30
|
-
select,
|
|
31
|
-
sortBy,
|
|
32
|
-
filters: []
|
|
33
|
-
},
|
|
34
|
-
data: []
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const formsReducer = createReducer<FormsState>({}, createInitialState)
|
|
39
|
-
.on(resetForms, (_: any, _2: any, reset: any) => {
|
|
40
|
-
return reset();
|
|
41
|
-
})
|
|
42
|
-
.on(requestForms, (state: FormsState, { parameters }: any) => {
|
|
43
|
-
return {
|
|
44
|
-
...state,
|
|
45
|
-
parameters: {
|
|
46
|
-
...state.parameters,
|
|
47
|
-
...parameters
|
|
48
|
-
},
|
|
49
|
-
error: null,
|
|
50
|
-
data: [],
|
|
51
|
-
isActive: true
|
|
52
|
-
};
|
|
53
|
-
})
|
|
54
|
-
.on(receiveForms, (state: FormsState, { forms }: any) => {
|
|
55
|
-
const total = forms.serverCount;
|
|
56
|
-
const pageCount = Math.ceil(total / (state.parameters.pageSize || 10));
|
|
57
|
-
|
|
58
|
-
delete forms.serverCount;
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
...state,
|
|
62
|
-
data: forms,
|
|
63
|
-
isActive: false,
|
|
64
|
-
parameters: {
|
|
65
|
-
...state.parameters,
|
|
66
|
-
pageCount,
|
|
67
|
-
totalLength: total
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
})
|
|
71
|
-
.on(failForms, (state: any, { error }: any) => {
|
|
72
|
-
return {
|
|
73
|
-
...state,
|
|
74
|
-
error,
|
|
75
|
-
isActive: false
|
|
76
|
-
};
|
|
77
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { selectForms, selectFormsParameters } from "./forms.selectors";
|
|
2
|
-
|
|
3
|
-
describe("form Selectors", () => {
|
|
4
|
-
describe("selectForm()", () => {
|
|
5
|
-
it("should return data", () => {
|
|
6
|
-
expect(
|
|
7
|
-
selectForms("forms", {
|
|
8
|
-
forms: {
|
|
9
|
-
data: [
|
|
10
|
-
{
|
|
11
|
-
id: "id"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
).toEqual([
|
|
17
|
-
{
|
|
18
|
-
id: "id"
|
|
19
|
-
}
|
|
20
|
-
]);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe("selectFormsParameters()", () => {
|
|
24
|
-
it("should return data", () => {
|
|
25
|
-
expect(
|
|
26
|
-
selectFormsParameters("forms", {
|
|
27
|
-
forms: {
|
|
28
|
-
parameters: {},
|
|
29
|
-
data: [
|
|
30
|
-
{
|
|
31
|
-
id: "id"
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
).toEqual({});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { selectRoot } from "../root";
|
|
2
|
-
import { FormsState } from "./forms.reducers";
|
|
3
|
-
|
|
4
|
-
export const selectForms = (name: string, state: any) => selectRoot<FormsState>(name, state).data;
|
|
5
|
-
|
|
6
|
-
export const selectFormsParameters = (name: string, state: any) => selectRoot<FormsState>(name, state).parameters;
|
package/src/stores/index.spec.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { defaultFormioReducer } from "./index";
|
|
2
|
-
|
|
3
|
-
describe("defaultFormioReducer", () => {
|
|
4
|
-
it("should return initial state", () => {
|
|
5
|
-
const state = Object.entries(defaultFormioReducer).reduce((state, [key, reduce]) => {
|
|
6
|
-
return {
|
|
7
|
-
...state,
|
|
8
|
-
[key]: reduce(undefined, {} as any)
|
|
9
|
-
};
|
|
10
|
-
}, {});
|
|
11
|
-
|
|
12
|
-
expect(state).toEqual({
|
|
13
|
-
action: {
|
|
14
|
-
data: {},
|
|
15
|
-
error: null,
|
|
16
|
-
isActive: false,
|
|
17
|
-
name: "action"
|
|
18
|
-
},
|
|
19
|
-
actionInfo: {
|
|
20
|
-
data: {},
|
|
21
|
-
error: null,
|
|
22
|
-
isActive: false,
|
|
23
|
-
name: "actionInfo"
|
|
24
|
-
},
|
|
25
|
-
actions: {
|
|
26
|
-
availableActions: [],
|
|
27
|
-
data: [],
|
|
28
|
-
error: null,
|
|
29
|
-
isActive: false,
|
|
30
|
-
name: "actions"
|
|
31
|
-
},
|
|
32
|
-
auth: {
|
|
33
|
-
authenticated: false,
|
|
34
|
-
error: null,
|
|
35
|
-
formAccess: {},
|
|
36
|
-
forms: {},
|
|
37
|
-
init: false,
|
|
38
|
-
is: {},
|
|
39
|
-
isActive: false,
|
|
40
|
-
name: "auth",
|
|
41
|
-
projectAccess: {},
|
|
42
|
-
roles: {},
|
|
43
|
-
submissionAccess: {},
|
|
44
|
-
user: null
|
|
45
|
-
},
|
|
46
|
-
form: {
|
|
47
|
-
data: {},
|
|
48
|
-
error: null,
|
|
49
|
-
id: "",
|
|
50
|
-
isActive: false,
|
|
51
|
-
lastUpdated: 0,
|
|
52
|
-
name: "form",
|
|
53
|
-
url: ""
|
|
54
|
-
},
|
|
55
|
-
forms: {
|
|
56
|
-
data: [],
|
|
57
|
-
error: null,
|
|
58
|
-
isActive: false,
|
|
59
|
-
name: "forms",
|
|
60
|
-
parameters: {
|
|
61
|
-
filters: [],
|
|
62
|
-
pageCount: 0,
|
|
63
|
-
pageIndex: 0,
|
|
64
|
-
pageSize: 10,
|
|
65
|
-
query: {
|
|
66
|
-
type: "form"
|
|
67
|
-
},
|
|
68
|
-
select: "",
|
|
69
|
-
sortBy: []
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
resource: {
|
|
73
|
-
data: {},
|
|
74
|
-
error: null,
|
|
75
|
-
id: "",
|
|
76
|
-
isActive: false,
|
|
77
|
-
lastUpdated: 0,
|
|
78
|
-
name: "resource",
|
|
79
|
-
url: ""
|
|
80
|
-
},
|
|
81
|
-
resources: {
|
|
82
|
-
data: [],
|
|
83
|
-
error: null,
|
|
84
|
-
isActive: false,
|
|
85
|
-
name: "resources",
|
|
86
|
-
parameters: {
|
|
87
|
-
filters: [],
|
|
88
|
-
pageCount: 0,
|
|
89
|
-
pageIndex: 0,
|
|
90
|
-
pageSize: 10,
|
|
91
|
-
query: {
|
|
92
|
-
type: "resource"
|
|
93
|
-
},
|
|
94
|
-
select: "",
|
|
95
|
-
sortBy: []
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
submission: {
|
|
99
|
-
data: {},
|
|
100
|
-
error: null,
|
|
101
|
-
formId: "",
|
|
102
|
-
id: "",
|
|
103
|
-
isActive: false,
|
|
104
|
-
lastUpdated: 0,
|
|
105
|
-
name: "submission",
|
|
106
|
-
url: ""
|
|
107
|
-
},
|
|
108
|
-
submissions: {
|
|
109
|
-
data: [],
|
|
110
|
-
error: null,
|
|
111
|
-
formId: "",
|
|
112
|
-
isActive: false,
|
|
113
|
-
name: "submissions",
|
|
114
|
-
parameters: {
|
|
115
|
-
pageCount: 0,
|
|
116
|
-
pageIndex: 0,
|
|
117
|
-
pageSize: 10,
|
|
118
|
-
query: {},
|
|
119
|
-
select: "",
|
|
120
|
-
sortBy: []
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
package/src/stores/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { combine } from "@tsed/redux-utils";
|
|
2
|
-
|
|
3
|
-
import { actionReducer } from "./action";
|
|
4
|
-
import { actionInfoReducer } from "./action-info";
|
|
5
|
-
import { actionsReducer } from "./actions";
|
|
6
|
-
import { authReducer } from "./auth";
|
|
7
|
-
import { formReducer } from "./form";
|
|
8
|
-
import { formsReducer } from "./forms";
|
|
9
|
-
import { submissionReducer } from "./submission";
|
|
10
|
-
import { submissionsReducer } from "./submissions";
|
|
11
|
-
|
|
12
|
-
export * from "./action";
|
|
13
|
-
export * from "./action-info";
|
|
14
|
-
export * from "./actions";
|
|
15
|
-
export * from "./auth";
|
|
16
|
-
export * from "./form";
|
|
17
|
-
export * from "./forms";
|
|
18
|
-
export * from "./root";
|
|
19
|
-
export * from "./submission";
|
|
20
|
-
export * from "./submissions";
|
|
21
|
-
|
|
22
|
-
export const defaultFormioReducer = combine(
|
|
23
|
-
authReducer,
|
|
24
|
-
actionsReducer,
|
|
25
|
-
actionReducer,
|
|
26
|
-
actionInfoReducer,
|
|
27
|
-
formReducer("form"),
|
|
28
|
-
formsReducer("forms", { query: { type: "form" } }),
|
|
29
|
-
formReducer("resource"),
|
|
30
|
-
formsReducer("resources", { query: { type: "resource" } }),
|
|
31
|
-
submissionReducer("submission"),
|
|
32
|
-
submissionsReducer("submissions")
|
|
33
|
-
);
|
package/src/stores/root/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./root.selectors";
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { oneOfIsActive, selectError, selectIsActive, selectRoot } from "./root.selectors";
|
|
2
|
-
|
|
3
|
-
describe("root Selectors", () => {
|
|
4
|
-
describe("selectRoot()", () => {
|
|
5
|
-
it("should return submission", () => {
|
|
6
|
-
expect(
|
|
7
|
-
// eslint-disable-next-line no-undef
|
|
8
|
-
selectRoot("submission", {
|
|
9
|
-
submission: {
|
|
10
|
-
data: {
|
|
11
|
-
_id: "id"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
).toEqual({
|
|
16
|
-
data: {
|
|
17
|
-
_id: "id"
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe("selectError()", () => {
|
|
23
|
-
it("should return error", () => {
|
|
24
|
-
expect(
|
|
25
|
-
selectError("submission", {
|
|
26
|
-
submission: {
|
|
27
|
-
error: null,
|
|
28
|
-
data: {
|
|
29
|
-
_id: "id"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
).toEqual(null);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe("selectIsActive()", () => {
|
|
37
|
-
it("should return error", () => {
|
|
38
|
-
expect(
|
|
39
|
-
selectIsActive("submission", {
|
|
40
|
-
submission: {
|
|
41
|
-
error: null,
|
|
42
|
-
isActive: true,
|
|
43
|
-
data: {
|
|
44
|
-
_id: "id"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
).toEqual(true);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe("oneOfIsActive", () => {
|
|
52
|
-
it("should is active state", () => {
|
|
53
|
-
expect(
|
|
54
|
-
oneOfIsActive(
|
|
55
|
-
"loader",
|
|
56
|
-
"other"
|
|
57
|
-
)({
|
|
58
|
-
loader: {
|
|
59
|
-
isActive: false
|
|
60
|
-
},
|
|
61
|
-
other: {
|
|
62
|
-
isActive: true
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
).toEqual(true);
|
|
66
|
-
expect(
|
|
67
|
-
oneOfIsActive(
|
|
68
|
-
"loader",
|
|
69
|
-
"other"
|
|
70
|
-
)({
|
|
71
|
-
loader: {
|
|
72
|
-
isActive: true
|
|
73
|
-
},
|
|
74
|
-
other: {
|
|
75
|
-
isActive: false
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
).toEqual(true);
|
|
79
|
-
expect(
|
|
80
|
-
oneOfIsActive(
|
|
81
|
-
"loader",
|
|
82
|
-
"other"
|
|
83
|
-
)({
|
|
84
|
-
loader: {
|
|
85
|
-
isActive: false
|
|
86
|
-
},
|
|
87
|
-
other: {
|
|
88
|
-
isActive: false
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
).toEqual(false);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import get from "lodash/get";
|
|
2
|
-
|
|
3
|
-
export function selectRoot<State = Record<string, any>>(name: string): (state: Record<string, any>) => State;
|
|
4
|
-
export function selectRoot<State = Record<string, any>>(name: string, state: Record<string, any>): State;
|
|
5
|
-
export function selectRoot<State = Record<string, any>>(name: string, state?: Record<string, any>): State & any {
|
|
6
|
-
if (state) {
|
|
7
|
-
return state[name];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return (state: Record<string, any>) => selectRoot(name, state);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const selectError = (name: string, state: Record<string, any>): null | Error => get(selectRoot(name, state)!, "error");
|
|
14
|
-
|
|
15
|
-
export const selectIsActive = (name: string, state: Record<string, any>): boolean => get(selectRoot(name, state)!, "isActive");
|
|
16
|
-
|
|
17
|
-
export function oneOfIsActive(...names: string[]) {
|
|
18
|
-
return (state: any) => {
|
|
19
|
-
return !!names.find((name) => {
|
|
20
|
-
return get(state, `${name}.isActive`, get(state, `${name}.current.isActive`));
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
}
|