@tsed/react-formio 1.13.0 → 1.13.3
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/.eslintignore +13 -0
- package/.eslintrc.js +7 -0
- package/coverage.json +6 -0
- package/dist/components/actions-table/actionsTable.component.d.ts +0 -1
- package/dist/components/actions-table/actionsTable.stories.d.ts +0 -1
- package/dist/components/alert/alert.component.d.ts +1 -2
- package/dist/components/alert/alert.stories.d.ts +0 -1
- package/dist/components/card/card.stories.d.ts +0 -1
- package/dist/components/form/form.component.d.ts +1 -2
- package/dist/components/form/form.component.spec.d.ts +1 -0
- package/dist/components/form/form.stories.d.ts +3745 -172
- package/dist/components/form/useForm.hook.d.ts +1 -2
- package/dist/components/form-access/formAccess.stories.d.ts +1 -2
- package/dist/components/form-action/formAction.stories.d.ts +0 -1
- package/dist/components/form-builder/formBuilder.stories.d.ts +518 -153
- package/dist/components/form-control/formControl.component.d.ts +2 -2
- package/dist/components/form-control/formControl.component.spec.d.ts +1 -0
- package/dist/components/form-control/formControl.stories.d.ts +57 -0
- package/dist/components/form-edit/formEdit.component.d.ts +0 -1
- package/dist/components/form-edit/formEdit.stories.d.ts +18 -19
- package/dist/components/form-settings/formSettings.component.d.ts +0 -1
- package/dist/components/form-settings/formSettings.stories.d.ts +1 -2
- package/dist/components/forms-table/components/formCell.component.d.ts +0 -1
- package/dist/components/forms-table/formsTable.component.d.ts +0 -1
- package/dist/components/forms-table/formsTable.stories.d.ts +0 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/input-tags/inputTags.component.d.ts +0 -1
- package/dist/components/input-tags/inputTags.stories.d.ts +2 -3
- package/dist/components/input-text/inputText.component.d.ts +0 -1
- package/dist/components/input-text/inputText.stories.d.ts +0 -1
- package/dist/components/loader/loader.component.d.ts +1 -1
- package/dist/components/loader/loader.stories.d.ts +0 -1
- package/dist/components/modal/modal.component.d.ts +1 -1
- package/dist/components/modal/modal.stories.d.ts +0 -1
- package/dist/components/pagination/pagination.component.d.ts +0 -1
- package/dist/components/pagination/pagination.stories.d.ts +0 -1
- package/dist/components/react-component/reactComponent.component.d.ts +3 -3
- package/dist/components/select/select.stories.d.ts +2 -3
- package/dist/components/submissions-table/submissionsTable.component.d.ts +0 -1
- package/dist/components/submissions-table/submissionsTable.stories.d.ts +13 -14
- package/dist/components/table/components/defaultArrowSort.component.d.ts +0 -1
- package/dist/components/table/components/defaultCell.component.d.ts +0 -1
- package/dist/components/table/components/defaultCellHeader.component.d.ts +1 -2
- package/dist/components/table/components/defaultCellOperations.component.d.ts +0 -1
- package/dist/components/table/components/defaultOperationButton.component.d.ts +0 -1
- package/dist/components/table/filters/defaultColumnFilter.component.d.ts +0 -1
- package/dist/components/table/filters/selectColumnFilter.component.d.ts +0 -1
- package/dist/components/table/filters/sliderColumnFilter.component.d.ts +0 -1
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/table.stories.d.ts +4 -5
- package/dist/components/tabs/tabs.component.stories.d.ts +0 -1
- package/dist/hooks/useTooltip.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7936 -7913
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +7375 -7347
- package/dist/index.modern.js.map +1 -1
- package/dist/stores/actions/index.d.ts +1 -1
- package/dist/stores/auth/auth.selectors.d.ts +1 -1
- package/dist/stores/auth/index.d.ts +4 -4
- package/dist/stores/index.d.ts +2 -2
- package/jest.config.js +6 -1
- package/package.json +8 -5
- package/src/components/__fixtures__/form.fixture.json +23 -0
- package/src/components/actions-table/actionsTable.component.spec.tsx +11 -11
- package/src/components/actions-table/actionsTable.component.tsx +8 -9
- package/src/components/actions-table/actionsTable.stories.tsx +1 -0
- package/src/components/alert/alert.component.spec.tsx +21 -19
- package/src/components/alert/alert.stories.tsx +1 -0
- package/src/components/card/card.component.spec.tsx +5 -4
- package/src/components/card/card.stories.tsx +1 -0
- package/src/components/form/form.component.spec.tsx +57 -0
- package/src/components/form/form.component.tsx +4 -3
- package/src/components/form/form.stories.tsx +157 -65
- package/src/components/form/useForm.hook.ts +35 -33
- package/src/components/form-access/formAccess.component.tsx +3 -2
- package/src/components/form-access/formAccess.schema.ts +1 -0
- package/src/components/form-access/formAccess.stories.tsx +1 -0
- package/src/components/form-access/formAccess.utils.ts +6 -5
- package/src/components/form-action/formAction.component.tsx +5 -4
- package/src/components/form-action/formAction.stories.tsx +225 -227
- package/src/components/form-builder/formBuilder.component.tsx +2 -1
- package/src/components/form-builder/formBuilder.stories.tsx +1 -0
- package/src/components/form-control/formControl.component.spec.tsx +76 -0
- package/src/components/form-control/formControl.component.tsx +15 -7
- package/src/components/form-control/formControl.stories.tsx +65 -0
- package/src/components/form-edit/formCtas.component.tsx +10 -9
- package/src/components/form-edit/formEdit.component.tsx +2 -1
- package/src/components/form-edit/formEdit.reducer.ts +1 -0
- package/src/components/form-edit/formEdit.stories.tsx +1 -0
- package/src/components/form-edit/formParameters.component.tsx +1 -0
- package/src/components/form-edit/useFormEdit.hook.ts +1 -0
- package/src/components/form-settings/formSettings.component.spec.tsx +7 -6
- package/src/components/form-settings/formSettings.component.tsx +12 -14
- package/src/components/form-settings/formSettings.stories.tsx +1 -0
- package/src/components/form-settings/formSettings.utils.ts +4 -3
- package/src/components/forms-table/components/formCell.component.tsx +1 -0
- package/src/components/forms-table/formsTable.component.tsx +23 -25
- package/src/components/forms-table/formsTable.stories.tsx +1 -0
- package/src/components/index.ts +2 -2
- package/src/components/input-tags/inputTags.component.tsx +7 -6
- package/src/components/input-tags/inputTags.stories.tsx +1 -0
- package/src/components/input-text/inputText.component.spec.tsx +13 -12
- package/src/components/input-text/inputText.component.tsx +4 -3
- package/src/components/input-text/inputText.stories.tsx +1 -0
- package/src/components/loader/loader.component.spec.tsx +6 -5
- package/src/components/loader/loader.component.tsx +1 -0
- package/src/components/loader/loader.stories.tsx +1 -0
- package/src/components/modal/modal.component.spec.tsx +36 -33
- package/src/components/modal/modal.component.tsx +3 -3
- package/src/components/modal/modal.stories.tsx +1 -0
- package/src/components/modal/removeModal.component.tsx +1 -0
- package/src/components/pagination/pagination.component.spec.tsx +24 -21
- package/src/components/pagination/pagination.component.tsx +1 -0
- package/src/components/pagination/pagination.stories.tsx +1 -0
- package/src/components/react-component/reactComponent.component.tsx +11 -7
- package/src/components/select/select.component.spec.tsx +17 -18
- package/src/components/select/select.component.tsx +3 -2
- package/src/components/select/select.stories.tsx +1 -0
- package/src/components/submissions-table/submissionsTable.component.tsx +3 -2
- package/src/components/submissions-table/submissionsTable.stories.tsx +1 -0
- package/src/components/table/components/defaultArrowSort.component.tsx +1 -0
- package/src/components/table/components/defaultCellHeader.component.tsx +1 -1
- package/src/components/table/components/defaultCellOperations.component.tsx +1 -0
- package/src/components/table/components/defaultOperationButton.component.tsx +1 -0
- package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +5 -3
- package/src/components/table/filters/defaultColumnFilter.component.tsx +1 -0
- package/src/components/table/filters/selectColumnFilter.component.spec.tsx +9 -7
- package/src/components/table/filters/selectColumnFilter.component.tsx +1 -0
- package/src/components/table/index.ts +1 -1
- package/src/components/table/table.component.tsx +5 -4
- package/src/components/table/table.stories.tsx +2 -1
- package/src/components/table/utils/mapFormToColumns.tsx +3 -2
- package/src/components/table/utils/useOperations.hook.tsx +1 -0
- package/src/components/tabs/tabs.component.spec.tsx +6 -5
- package/src/components/tabs/tabs.component.stories.tsx +1 -0
- package/src/components/tabs/tabs.component.tsx +11 -5
- package/src/hooks/useTooltip.ts +1 -1
- package/src/index.ts +3 -4
- package/src/interfaces/Operation.ts +1 -0
- package/src/stores/action/action.actions.spec.ts +1 -0
- package/src/stores/action/action.actions.ts +1 -0
- package/src/stores/action/action.reducers.ts +1 -1
- package/src/stores/action-info/action-info.actions.spec.ts +1 -0
- package/src/stores/action-info/action-info.actions.ts +2 -1
- package/src/stores/action-info/action-info.reducers.ts +2 -1
- package/src/stores/action-info/action-info.selectors.ts +2 -1
- package/src/stores/actions/actions.actions.spec.ts +1 -0
- package/src/stores/actions/actions.actions.ts +1 -0
- package/src/stores/actions/actions.reducers.ts +1 -0
- package/src/stores/actions/index.ts +1 -1
- package/src/stores/auth/auth.actions.ts +1 -0
- package/src/stores/auth/auth.reducers.ts +1 -0
- package/src/stores/auth/auth.selectors.ts +1 -0
- package/src/stores/auth/auth.utils.tsx +3 -2
- package/src/stores/auth/getAccess.action.spec.ts +1 -0
- package/src/stores/auth/getAccess.action.ts +3 -2
- package/src/stores/auth/getProjectAccess.action.ts +1 -0
- package/src/stores/auth/index.ts +4 -4
- package/src/stores/auth/initAuth.action.spec.ts +1 -0
- package/src/stores/auth/initAuth.action.ts +1 -0
- package/src/stores/auth/logout.action.spec.ts +2 -0
- package/src/stores/auth/logout.action.ts +1 -0
- package/src/stores/auth/setUser.action.spec.ts +1 -0
- package/src/stores/auth/setUser.action.ts +1 -0
- package/src/stores/form/form.actions.spec.ts +1 -0
- package/src/stores/form/form.actions.ts +1 -0
- package/src/stores/form/form.reducers.ts +1 -0
- package/src/stores/form/form.selectors.ts +1 -1
- package/src/stores/forms/forms.actions.spec.ts +1 -0
- package/src/stores/forms/forms.actions.ts +1 -0
- package/src/stores/forms/forms.reducers.ts +1 -0
- package/src/stores/index.ts +3 -2
- package/src/stores/root/root.selectors.ts +3 -3
- package/src/stores/submission/submission.actions.spec.ts +1 -0
- package/src/stores/submission/submission.actions.ts +1 -0
- package/src/stores/submission/submission.reducers.ts +1 -0
- package/src/stores/submissions/submissions.actions.spec.ts +1 -0
- package/src/stores/submissions/submissions.actions.ts +1 -0
- package/src/stores/submissions/submissions.reducers.ts +1 -0
- package/tsconfig.json +10 -27
- package/tsconfig.node.json +8 -0
- package/craco.config.js +0 -11
- package/tsconfig.test.json +0 -6
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from "./utils/useOperations.hook";
|
|
2
1
|
export * from "./components/defaultArrowSort.component";
|
|
3
2
|
export * from "./components/defaultCell.component";
|
|
4
3
|
export * from "./components/defaultCellHeader.component";
|
|
@@ -9,3 +8,4 @@ export * from "./filters/defaultColumnFilter.component";
|
|
|
9
8
|
export * from "./filters/selectColumnFilter.component";
|
|
10
9
|
export * from "./filters/sliderColumnFilter.component";
|
|
11
10
|
export * from "./table.component";
|
|
11
|
+
export * from "./utils/useOperations.hook";
|
|
@@ -2,6 +2,7 @@ import classnames from "classnames";
|
|
|
2
2
|
import noop from "lodash/noop";
|
|
3
3
|
import React, { PropsWithChildren } from "react";
|
|
4
4
|
import { CellProps, FilterProps, Renderer, TableOptions, useFilters, useGroupBy, usePagination, useSortBy, useTable } from "react-table";
|
|
5
|
+
|
|
5
6
|
import { OnClickOperation, Operation, QueryOptions } from "../../interfaces";
|
|
6
7
|
import { Pagination as DefaultPagination } from "../pagination/pagination.component";
|
|
7
8
|
import { DefaultArrowSort } from "./components/defaultArrowSort.component";
|
|
@@ -189,12 +190,12 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
|
|
|
189
190
|
>
|
|
190
191
|
<thead>
|
|
191
192
|
{tableInstance.headerGroups.map((headerGroup, i) => (
|
|
192
|
-
<tr key={`tableInstance.headerGroups${i}`}
|
|
193
|
+
<tr {...headerGroup.getHeaderGroupProps()} key={`tableInstance.headerGroups${i}`}>
|
|
193
194
|
{headerGroup.headers.map((column) => (
|
|
194
195
|
<th
|
|
195
|
-
key={`tableInstance.headers.column.${column.id}`}
|
|
196
196
|
/* className='text-left py-2 align-top' */
|
|
197
197
|
{...column.getHeaderProps()}
|
|
198
|
+
key={`tableInstance.headers.column.${column.id}`}
|
|
198
199
|
>
|
|
199
200
|
<CellHeader column={column} />
|
|
200
201
|
</th>
|
|
@@ -207,14 +208,14 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
|
|
|
207
208
|
{tableInstance.page.map((row) => {
|
|
208
209
|
tableInstance.prepareRow(row);
|
|
209
210
|
return (
|
|
210
|
-
<tr
|
|
211
|
+
<tr onClick={() => _onClick(row.original, "row")} {...row.getRowProps()} key={`tableInstance.page.${row.id}`}>
|
|
211
212
|
{row.cells.map((cell, i) => {
|
|
212
213
|
const { hidden, colspan } = cell.column as any;
|
|
213
214
|
if (hidden) {
|
|
214
215
|
return null;
|
|
215
216
|
}
|
|
216
217
|
return (
|
|
217
|
-
<td key={`tableInstance.page.cells.${cell.value || "value"}.${i}`}
|
|
218
|
+
<td colSpan={colspan} {...cell.getCellProps()} key={`tableInstance.page.cells.${cell.value || "value"}.${i}`}>
|
|
218
219
|
{cell.render("Cell")}
|
|
219
220
|
</td>
|
|
220
221
|
);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { mapPagination } from "../../utils/mapPagination";
|
|
2
4
|
import formSchema from "../__fixtures__/form-schema.json";
|
|
3
5
|
import formSubmissions from "../__fixtures__/form-submissions.json";
|
|
4
6
|
import { Table } from "./table.component";
|
|
5
7
|
import { mapFormToColumns } from "./utils/mapFormToColumns";
|
|
6
|
-
import { mapPagination } from "../../utils/mapPagination";
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: "ReactFormio/Table",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { Components, ExtendedComponentSchema } from "formiojs";
|
|
3
2
|
import FormioUtils from "formiojs/utils";
|
|
3
|
+
import React from "react";
|
|
4
4
|
import { Column } from "react-table";
|
|
5
|
+
|
|
5
6
|
import { FormSchema } from "../../../interfaces";
|
|
6
7
|
import { DefaultCell } from "../components/defaultCell.component";
|
|
7
8
|
import { SelectColumnFilter } from "../filters/selectColumnFilter.component";
|
|
@@ -11,7 +12,7 @@ export function mapFormToColumns(form: FormSchema): Column[] {
|
|
|
11
12
|
|
|
12
13
|
FormioUtils.eachComponent(form.components, (component: ExtendedComponentSchema) => {
|
|
13
14
|
if (component.tableView && component.key) {
|
|
14
|
-
const cmp: any = Components.create(component,
|
|
15
|
+
const cmp: any = Components.create(component, {}, null, true);
|
|
15
16
|
|
|
16
17
|
const column: Column = {
|
|
17
18
|
Header: component.label || component.title || component.key,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
|
|
4
|
+
import { Tabs } from "./tabs.component";
|
|
5
|
+
import { Sandbox } from "./tabs.component.stories";
|
|
5
6
|
|
|
6
7
|
describe("tabs", () => {
|
|
7
8
|
it("should display the tabs component and children", () => {
|
|
@@ -20,7 +21,7 @@ describe("tabs", () => {
|
|
|
20
21
|
}
|
|
21
22
|
];
|
|
22
23
|
|
|
23
|
-
render(<Sandbox {...Sandbox.args} items={items}/>);
|
|
24
|
+
render(<Sandbox {...Sandbox.args} items={items} />);
|
|
24
25
|
|
|
25
26
|
const tabsComponent = screen.getByTestId("tabs-comp");
|
|
26
27
|
|
|
@@ -67,7 +68,7 @@ describe("tabs", () => {
|
|
|
67
68
|
];
|
|
68
69
|
const onClick = jest.fn();
|
|
69
70
|
|
|
70
|
-
render(<Tabs items={items} onClick={onClick}/>);
|
|
71
|
+
render(<Tabs items={items} onClick={onClick} />);
|
|
71
72
|
|
|
72
73
|
const buttonsTab = screen.getAllByTitle("button-tab");
|
|
73
74
|
const chevronLeftButtonTab = buttonsTab[0];
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
2
|
import React, { PropsWithChildren } from "react";
|
|
3
|
+
|
|
3
4
|
import { iconClass } from "../../utils/iconClass";
|
|
4
5
|
|
|
5
6
|
export function ButtonTab({ icon, back, onClick, isActive, reverse, children, className, after }: PropsWithChildren<any>) {
|
|
6
7
|
return (
|
|
7
|
-
<div
|
|
8
|
+
<div
|
|
9
|
+
title={"button-wrapper"}
|
|
10
|
+
className={classnames("tw-tabs__button-wrapper", isActive ? "-active" : "", back ? "-back" : "", className)}
|
|
11
|
+
>
|
|
8
12
|
<button
|
|
9
|
-
title={
|
|
13
|
+
title={"button-tab"}
|
|
10
14
|
className={classnames("tw-tabs__button", reverse ? "-reverse" : "", isActive ? "-active" : "", back ? "-back" : "")}
|
|
11
15
|
onClick={onClick}
|
|
12
16
|
>
|
|
@@ -51,7 +55,7 @@ export function Tabs({
|
|
|
51
55
|
...additionalProps
|
|
52
56
|
}: PropsWithChildren<TabsProps>) {
|
|
53
57
|
return (
|
|
54
|
-
<div data-testid={
|
|
58
|
+
<div data-testid={"tabs-comp"} className={`tw-tabs ${className}`} style={style}>
|
|
55
59
|
<div>
|
|
56
60
|
<nav className='tw-tabs__header'>
|
|
57
61
|
<div className='tw-tabs__header-wrapper'>
|
|
@@ -71,7 +75,7 @@ export function Tabs({
|
|
|
71
75
|
{...additionalProps}
|
|
72
76
|
{...item}
|
|
73
77
|
>
|
|
74
|
-
{i18n(item.label)}
|
|
78
|
+
{i18n(item.label || "")}
|
|
75
79
|
</Button>
|
|
76
80
|
);
|
|
77
81
|
})}
|
|
@@ -80,7 +84,9 @@ export function Tabs({
|
|
|
80
84
|
</nav>
|
|
81
85
|
{HeaderChildren && <HeaderChildren {...additionalProps} current={current} />}
|
|
82
86
|
</div>
|
|
83
|
-
<div title={"tab-body"} className={"tw-tabs__body"}>
|
|
87
|
+
<div title={"tab-body"} className={"tw-tabs__body"}>
|
|
88
|
+
{children}
|
|
89
|
+
</div>
|
|
84
90
|
</div>
|
|
85
91
|
);
|
|
86
92
|
}
|
package/src/hooks/useTooltip.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { useEffect, useRef } from "react";
|
|
|
2
2
|
import Tooltip, { Options } from "tooltip.js";
|
|
3
3
|
|
|
4
4
|
export function useTooltip(options: Options) {
|
|
5
|
-
const ref = useRef();
|
|
5
|
+
const ref = useRef<any>();
|
|
6
6
|
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
ref.current && new Tooltip(ref.current as any, options);
|
package/src/index.ts
CHANGED
|
@@ -11,11 +11,10 @@ export {
|
|
|
11
11
|
// editFormUtils,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export * from "./stores";
|
|
15
|
-
export * from "./interfaces";
|
|
16
14
|
export * from "./components";
|
|
17
15
|
export * from "./hooks/useTooltip";
|
|
16
|
+
export * from "./interfaces";
|
|
17
|
+
export * from "./stores";
|
|
18
18
|
export * from "./utils/iconClass";
|
|
19
19
|
export * from "./utils/url";
|
|
20
|
-
|
|
21
|
-
export { Components, Formio, Utils, Templates } from "formiojs";
|
|
20
|
+
export { Components, Formio, Templates, Utils } from "formiojs";
|
|
@@ -2,6 +2,7 @@ import { createAction } from "@tsed/redux-utils";
|
|
|
2
2
|
import { Formio } from "formiojs";
|
|
3
3
|
import get from "lodash/get";
|
|
4
4
|
import noop from "lodash/noop";
|
|
5
|
+
|
|
5
6
|
import { getActionUrl } from "../../utils/url";
|
|
6
7
|
import { getActionInfo } from "../action-info";
|
|
7
8
|
import { ACTION } from "./action.constant";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
|
|
2
|
-
import { ActionSchema } from "../../interfaces";
|
|
3
2
|
|
|
3
|
+
import { ActionSchema } from "../../interfaces";
|
|
4
4
|
import { clearActionError, failAction, receiveAction, requestAction, resetAction, sendAction } from "./action.actions";
|
|
5
5
|
import { ACTION } from "./action.constant";
|
|
6
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
|
|
2
|
+
|
|
2
3
|
import { ActionSchema } from "../../interfaces";
|
|
3
4
|
import { failActionInfo, receiveActionInfo, requestActionInfo, resetActionInfo } from "./action-info.actions";
|
|
4
5
|
import { ACTION_INFO } from "./action-info.constant";
|
|
@@ -3,4 +3,5 @@ import { selectRoot } from "../root";
|
|
|
3
3
|
import { ACTION_INFO } from "./action-info.constant";
|
|
4
4
|
import { ActionInfoState } from "./action-info.reducers";
|
|
5
5
|
|
|
6
|
-
export const selectActionInfo = (state: Record<string, any>): Partial<ActionSchema> =>
|
|
6
|
+
export const selectActionInfo = (state: Record<string, any>): Partial<ActionSchema> =>
|
|
7
|
+
selectRoot<ActionInfoState>(ACTION_INFO, state).data!;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
|
|
2
|
+
|
|
2
3
|
import { ActionInfoSchema, ActionSchema } from "../../interfaces";
|
|
3
4
|
import { failActions, receiveActions, requestActions, resetActions } from "./actions.actions";
|
|
4
5
|
import { ACTIONS } from "./actions.constant";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import get from "lodash/get";
|
|
2
|
+
|
|
2
3
|
import { FormSchema } from "../../interfaces/FormSchema";
|
|
3
4
|
import { AuthState } from "./auth.reducers";
|
|
4
5
|
|
|
@@ -7,7 +8,7 @@ export function hasRole(auth: AuthState, role: string): boolean {
|
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export function hasRoles(auth: AuthState, roles: string[]): boolean {
|
|
10
|
-
roles = [].concat(roles);
|
|
11
|
+
roles = ([] as string[]).concat(roles);
|
|
11
12
|
|
|
12
13
|
return !!roles.find((role) => hasRole(auth, role));
|
|
13
14
|
}
|
|
@@ -29,7 +30,7 @@ export function checkRoleFormAccess(auth: AuthState, form?: Partial<FormSchema>,
|
|
|
29
30
|
return true;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
return
|
|
33
|
+
return roles.includes("owner") && get(form, "owner") === get(auth, "user._id");
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
return true;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Formio } from "formiojs";
|
|
2
|
+
|
|
2
3
|
import { RoleSchema } from "../../interfaces";
|
|
3
4
|
import { FormSchema } from "../../interfaces/FormSchema";
|
|
4
5
|
import { formAccessUser, submissionAccessUser, userForms, userRoles } from "./auth.actions";
|
|
@@ -8,7 +9,7 @@ function transformSubmissionAccess(forms: Record<string, FormSchema>) {
|
|
|
8
9
|
return Object.values(forms).reduce(
|
|
9
10
|
(result, form) => ({
|
|
10
11
|
...result,
|
|
11
|
-
[form.name]: form.submissionAccess.reduce(
|
|
12
|
+
[form.name as string]: form.submissionAccess.reduce(
|
|
12
13
|
(formSubmissionAccess: any, access: any) => ({
|
|
13
14
|
...formSubmissionAccess,
|
|
14
15
|
[access.type]: access.roles
|
|
@@ -24,7 +25,7 @@ function transformFormAccess(forms: Record<string, FormSchema>) {
|
|
|
24
25
|
return Object.values(forms).reduce(
|
|
25
26
|
(result, form) => ({
|
|
26
27
|
...result,
|
|
27
|
-
[form.name]: form.access.reduce(
|
|
28
|
+
[form.name as string]: form.access.reduce(
|
|
28
29
|
(formAccess: any, access: any) => ({
|
|
29
30
|
...formAccess,
|
|
30
31
|
[access.type]: access.roles
|
package/src/stores/auth/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./auth.constant";
|
|
2
|
-
export * from "./auth.utils";
|
|
3
1
|
export * from "./auth.actions";
|
|
2
|
+
export * from "./auth.constant";
|
|
4
3
|
export * from "./auth.reducers";
|
|
5
4
|
export * from "./auth.selectors";
|
|
6
|
-
export * from "./
|
|
5
|
+
export * from "./auth.utils";
|
|
7
6
|
export * from "./getAccess.action";
|
|
7
|
+
export * from "./getProjectAccess.action";
|
|
8
|
+
export * from "./initAuth.action";
|
|
8
9
|
export * from "./logout.action";
|
|
9
10
|
export * from "./setUser.action";
|
|
10
|
-
export * from "./initAuth.action";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Formio } from "formiojs";
|
|
2
|
+
|
|
2
3
|
import { logoutUser } from "./auth.actions";
|
|
3
4
|
import { AUTH } from "./auth.constant";
|
|
4
5
|
import { logout } from "./logout.action";
|
|
5
6
|
|
|
6
7
|
jest.mock("./auth.actions");
|
|
8
|
+
jest.mock("formiojs");
|
|
7
9
|
|
|
8
10
|
describe("logout()", () => {
|
|
9
11
|
beforeEach(() => {
|
|
@@ -2,4 +2,4 @@ import { FormSchema } from "../../interfaces";
|
|
|
2
2
|
import { selectRoot } from "../root";
|
|
3
3
|
import { FormState } from "./form.reducers";
|
|
4
4
|
|
|
5
|
-
export const selectForm = (name: string, state: any): Partial<FormSchema> => selectRoot<FormState>(name, state).data
|
|
5
|
+
export const selectForm = (name: string, state: any): Partial<FormSchema> => selectRoot<FormState>(name, state).data!;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createAction } from "@tsed/redux-utils";
|
|
2
2
|
import { Formio } from "formiojs";
|
|
3
3
|
import noop from "lodash/noop";
|
|
4
|
+
|
|
4
5
|
import { FormSchema } from "../../interfaces";
|
|
5
6
|
import type { RequestParamsOptions } from "../../utils/mapRequestParams";
|
|
6
7
|
import { mapRequestParams } from "../../utils/mapRequestParams";
|
package/src/stores/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { combine } from "@tsed/redux-utils";
|
|
2
|
+
|
|
2
3
|
import { actionReducer } from "./action";
|
|
3
4
|
import { actionInfoReducer } from "./action-info";
|
|
4
5
|
import { actionsReducer } from "./actions";
|
|
@@ -8,15 +9,15 @@ import { formsReducer } from "./forms";
|
|
|
8
9
|
import { submissionReducer } from "./submission";
|
|
9
10
|
import { submissionsReducer } from "./submissions";
|
|
10
11
|
|
|
11
|
-
export * from "./auth";
|
|
12
12
|
export * from "./action";
|
|
13
13
|
export * from "./action-info";
|
|
14
14
|
export * from "./actions";
|
|
15
|
+
export * from "./auth";
|
|
15
16
|
export * from "./form";
|
|
16
17
|
export * from "./forms";
|
|
18
|
+
export * from "./root";
|
|
17
19
|
export * from "./submission";
|
|
18
20
|
export * from "./submissions";
|
|
19
|
-
export * from "./root";
|
|
20
21
|
|
|
21
22
|
export const defaultFormioReducer = combine(
|
|
22
23
|
authReducer,
|
|
@@ -2,7 +2,7 @@ import get from "lodash/get";
|
|
|
2
2
|
|
|
3
3
|
export function selectRoot<State = Record<string, any>>(name: string): (state: Record<string, any>) => State;
|
|
4
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>): any {
|
|
5
|
+
export function selectRoot<State = Record<string, any>>(name: string, state?: Record<string, any>): State & any {
|
|
6
6
|
if (state) {
|
|
7
7
|
return state[name];
|
|
8
8
|
}
|
|
@@ -10,9 +10,9 @@ export function selectRoot<State = Record<string, any>>(name: string, state?: Re
|
|
|
10
10
|
return (state: Record<string, any>) => selectRoot(name, state);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const selectError = (name: string, state: Record<string, any>): null | Error => get(selectRoot(name, state)
|
|
13
|
+
export const selectError = (name: string, state: Record<string, any>): null | Error => get(selectRoot(name, state)!, "error");
|
|
14
14
|
|
|
15
|
-
export const selectIsActive = (name: string, state: Record<string, any>): boolean => get(selectRoot(name, state)
|
|
15
|
+
export const selectIsActive = (name: string, state: Record<string, any>): boolean => get(selectRoot(name, state)!, "isActive");
|
|
16
16
|
|
|
17
17
|
export function oneOfIsActive(...names: string[]) {
|
|
18
18
|
return (state: any) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createAction } from "@tsed/redux-utils";
|
|
2
2
|
import { Formio } from "formiojs";
|
|
3
3
|
import noop from "lodash/noop";
|
|
4
|
+
|
|
4
5
|
import { mapRequestParams } from "../../utils/mapRequestParams";
|
|
5
6
|
import { getSubmissionUrl } from "../../utils/url";
|
|
6
7
|
import { selectSubmissionsParameters } from "./submissions.selectors";
|