@headless-adminapp/app 0.0.17-alpha.55 → 0.0.17-alpha.57
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/dataform/hooks/useFormSave.js +13 -14
- package/datagrid/DataGridProvider/DataResolver.js +3 -0
- package/datagrid/DataGridProvider/index.d.ts +1 -0
- package/datagrid/DataGridProvider/index.js +6 -0
- package/datagrid/context.d.ts +1 -0
- package/datagrid/hooks/useGridDisabled.d.ts +1 -0
- package/datagrid/hooks/useGridDisabled.js +8 -0
- package/package.json +2 -2
- package/transport/RestDataService/index.d.ts +2 -2
- package/transport/hooks/useRetriveRecords.d.ts +3 -2
- package/transport/hooks/useRetriveRecords.js +2 -1
|
@@ -11,6 +11,7 @@ exports.useFormSave = useFormSave;
|
|
|
11
11
|
// Wrapper - Loader, response message
|
|
12
12
|
// Core - Extract modified fields, prepare operations, perform operations
|
|
13
13
|
const route_1 = require("@headless-adminapp/app/route");
|
|
14
|
+
const app_1 = require("@headless-adminapp/core/experience/app");
|
|
14
15
|
const react_query_1 = require("@tanstack/react-query");
|
|
15
16
|
const react_1 = require("react");
|
|
16
17
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -35,6 +36,7 @@ function useFormSave() {
|
|
|
35
36
|
const dataService = (0, transport_1.useDataService)();
|
|
36
37
|
const { showProgressIndicator, hideProgressIndicator } = (0, useProgressIndicator_1.useProgressIndicator)();
|
|
37
38
|
const openToastNotification = (0, useOpenToastNotification_1.useOpenToastNotification)();
|
|
39
|
+
const routeResolver = (0, route_1.useRouteResolver)();
|
|
38
40
|
const client = (0, react_query_1.useQueryClient)();
|
|
39
41
|
const router = (0, route_1.useRouter)();
|
|
40
42
|
function showMessageAfterSave({ isCreatedMode }) {
|
|
@@ -81,12 +83,17 @@ function useFormSave() {
|
|
|
81
83
|
});
|
|
82
84
|
return;
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
if (mode === 'save') {
|
|
87
|
+
if (record) {
|
|
88
|
+
await refresh();
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
router.replace(routeResolver({
|
|
92
|
+
type: app_1.PageType.EntityForm,
|
|
93
|
+
logicalName: schema.logicalName,
|
|
94
|
+
id: result.recordId,
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
90
97
|
}
|
|
91
98
|
else {
|
|
92
99
|
await client.invalidateQueries({
|
|
@@ -99,14 +106,6 @@ function useFormSave() {
|
|
|
99
106
|
await client.invalidateQueries({
|
|
100
107
|
queryKey: ['data', 'retriveRecords'],
|
|
101
108
|
});
|
|
102
|
-
// redirectAfterSave({
|
|
103
|
-
// navigation,
|
|
104
|
-
// isCreatedMode: !context.state.record,
|
|
105
|
-
// recordId: result.recordId,
|
|
106
|
-
// reset: form.reset,
|
|
107
|
-
// logicalName: schema.logicalName,
|
|
108
|
-
// mode,
|
|
109
|
-
// });
|
|
110
109
|
showMessageAfterSave({
|
|
111
110
|
isCreatedMode: !record,
|
|
112
111
|
});
|
|
@@ -8,6 +8,7 @@ const context_1 = require("../../mutable/context");
|
|
|
8
8
|
const useRetriveRecords_1 = require("../../transport/hooks/useRetriveRecords");
|
|
9
9
|
const context_2 = require("../context");
|
|
10
10
|
const hooks_1 = require("../hooks");
|
|
11
|
+
const useGridDisabled_1 = require("../hooks/useGridDisabled");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
12
13
|
const MAX_RECORDS = 10000;
|
|
13
14
|
function DataResolver() {
|
|
@@ -20,6 +21,7 @@ function DataResolver() {
|
|
|
20
21
|
const gridColumns = (0, hooks_1.useGridColumns)();
|
|
21
22
|
const maxRecords = (0, hooks_1.useMaxRecords)() ?? MAX_RECORDS;
|
|
22
23
|
const [selectedIds] = (0, hooks_1.useGridSelection)();
|
|
24
|
+
const disabled = (0, useGridDisabled_1.useGridDisabled)();
|
|
23
25
|
const { schemaStore } = (0, useMetadata_1.useMetadata)();
|
|
24
26
|
const selectedIdsRef = (0, react_1.useRef)(selectedIds);
|
|
25
27
|
selectedIdsRef.current = selectedIds;
|
|
@@ -57,6 +59,7 @@ function DataResolver() {
|
|
|
57
59
|
schema,
|
|
58
60
|
search,
|
|
59
61
|
sorting,
|
|
62
|
+
disabled,
|
|
60
63
|
});
|
|
61
64
|
(0, react_1.useEffect)(() => {
|
|
62
65
|
setState({
|
|
@@ -19,5 +19,6 @@ export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttrib
|
|
|
19
19
|
};
|
|
20
20
|
allowViewSelection?: boolean;
|
|
21
21
|
maxRecords?: number;
|
|
22
|
+
disabled?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare function DataGridProvider<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext>(props: PropsWithChildren<DataGridProviderProps<S, CommandContext>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -44,6 +44,7 @@ function DataGridProvider(props) {
|
|
|
44
44
|
allowViewSelection: props.allowViewSelection ?? false,
|
|
45
45
|
maxRecords: props.maxRecords,
|
|
46
46
|
associated: props.associated,
|
|
47
|
+
disabled: props.disabled ?? false,
|
|
47
48
|
});
|
|
48
49
|
(0, react_1.useEffect)(() => {
|
|
49
50
|
contextValue.setValue({
|
|
@@ -78,5 +79,10 @@ function DataGridProvider(props) {
|
|
|
78
79
|
associated: props.associated,
|
|
79
80
|
});
|
|
80
81
|
}, [props.isSubGrid, props.associated, contextValue]);
|
|
82
|
+
(0, react_1.useEffect)(() => {
|
|
83
|
+
contextValue.setValue({
|
|
84
|
+
disabled: props.disabled ?? false,
|
|
85
|
+
});
|
|
86
|
+
}, [props.disabled, contextValue]);
|
|
81
87
|
return ((0, jsx_runtime_1.jsxs)(context_2.GridContext.Provider, { value: contextValue, children: [(0, jsx_runtime_1.jsx)(DataResolver_1.DataResolver, {}), props.children] }));
|
|
82
88
|
}
|
package/datagrid/context.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
|
|
|
13
13
|
extraFilter?: Filter;
|
|
14
14
|
commands?: CommandItemExperience<CommandContext>[][];
|
|
15
15
|
maxRecords?: number;
|
|
16
|
+
disabled?: boolean;
|
|
16
17
|
associated?: false | {
|
|
17
18
|
logicalName: string;
|
|
18
19
|
id: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useGridDisabled(): boolean | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGridDisabled = useGridDisabled;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useGridDisabled() {
|
|
7
|
+
return (0, mutable_1.useContextSelector)(context_1.GridContext, (state) => state.disabled);
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.57",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"uuid": "11.0.3",
|
|
34
34
|
"yup": "^1.4.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "94ff249ba308bb261b4835136f2b8d7e2ec1676c"
|
|
37
37
|
}
|
|
@@ -16,8 +16,8 @@ export declare class RestDataService implements IDataService {
|
|
|
16
16
|
[key in keyof T]?: string[];
|
|
17
17
|
}): Promise<Data<T>>;
|
|
18
18
|
retriveRecords<T = unknown>(params: RetriveRecordsFnOptions<T>): Promise<RetriveRecordsResult<T>>;
|
|
19
|
-
createRecord<T>(logicalName: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core").Id>>;
|
|
20
|
-
updateRecord<T>(logicalName: string, id: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core").Id>>;
|
|
19
|
+
createRecord<T>(logicalName: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core/attributes").Id>>;
|
|
20
|
+
updateRecord<T>(logicalName: string, id: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core/attributes").Id>>;
|
|
21
21
|
deleteRecord(logicalName: string, id: string): Promise<void>;
|
|
22
22
|
retriveAggregate<Q extends Record<string, AggregateAttribute> = Record<string, AggregateAttribute>>(query: AggregateQuery<Q>): Promise<InferredAggregateQueryResult<Q>[]>;
|
|
23
23
|
customAction<T = unknown>(_actionName: string, _payload: unknown): Promise<T>;
|
|
@@ -10,10 +10,11 @@ interface UseRetriveRecordProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
|
10
10
|
columns: string[];
|
|
11
11
|
expand?: Partial<Record<string, string[]>>;
|
|
12
12
|
maxRecords: number;
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
}
|
|
14
|
-
export declare function useRetrieveRecordsKey<S extends SchemaAttributes = SchemaAttributes>({ schema, search, filter, sorting, columns, expand, maxRecords, }: UseRetriveRecordProps<S>): (string | number | string[] |
|
|
15
|
+
export declare function useRetrieveRecordsKey<S extends SchemaAttributes = SchemaAttributes>({ schema, search, filter, sorting, columns, expand, maxRecords, }: UseRetriveRecordProps<S>): (string | number | Filter | SortingState<S> | string[] | Partial<Record<string, string[]>> | null | undefined)[];
|
|
15
16
|
export declare function useClearDataExceptFirstPage(queryKey: QueryKey): void;
|
|
16
|
-
export declare function useRetriveRecords<S extends SchemaAttributes = SchemaAttributes>(queryKey: QueryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }: UseRetriveRecordProps): {
|
|
17
|
+
export declare function useRetriveRecords<S extends SchemaAttributes = SchemaAttributes>(queryKey: QueryKey, { columns, expand, filter, maxRecords, schema, search, sorting, disabled, }: UseRetriveRecordProps): {
|
|
17
18
|
data: {
|
|
18
19
|
logicalName: string;
|
|
19
20
|
count: number;
|
|
@@ -41,7 +41,7 @@ function useClearDataExceptFirstPage(queryKey) {
|
|
|
41
41
|
};
|
|
42
42
|
}, [queryClient, queryKey]);
|
|
43
43
|
}
|
|
44
|
-
function useRetriveRecords(queryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }) {
|
|
44
|
+
function useRetriveRecords(queryKey, { columns, expand, filter, maxRecords, schema, search, sorting, disabled, }) {
|
|
45
45
|
const dataService = (0, transport_1.useDataService)();
|
|
46
46
|
const { data, isFetching, hasNextPage, fetchNextPage, isFetchingNextPage } = (0, react_query_1.useInfiniteQuery)({
|
|
47
47
|
queryKey: queryKey,
|
|
@@ -88,6 +88,7 @@ function useRetriveRecords(queryKey, { columns, expand, filter, maxRecords, sche
|
|
|
88
88
|
initialPageParam: {
|
|
89
89
|
pageIndex: 0,
|
|
90
90
|
},
|
|
91
|
+
enabled: !disabled,
|
|
91
92
|
});
|
|
92
93
|
const finalData = (0, react_1.useMemo)(() => {
|
|
93
94
|
if (!data?.pages.length) {
|