gomtm 0.0.327 → 0.0.329
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.
|
@@ -4,6 +4,8 @@ import { flexRender } from "mtxuilib/lib/render";
|
|
|
4
4
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
5
5
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
6
6
|
import { FullScreenPanel } from "mtxuilib/ui/ui-mt/FullScreenEditPanel";
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
import { useGomtmSuspenseQuery } from "../../gomtmQuery";
|
|
7
9
|
import { useListview } from "../listview/list-store";
|
|
8
10
|
function CurdEditPanel(props) {
|
|
9
11
|
const { fullScreen } = props;
|
|
@@ -14,7 +16,7 @@ function CurdEditPanel(props) {
|
|
|
14
16
|
return null;
|
|
15
17
|
}
|
|
16
18
|
if (fullScreen) {
|
|
17
|
-
return /* @__PURE__ */ jsx(FullScreenPanel, { children: openEdit && editRender && flexRender(editRender, {}) });
|
|
19
|
+
return /* @__PURE__ */ jsx(WithLoadGetData, { children: /* @__PURE__ */ jsx(FullScreenPanel, { children: openEdit && editRender && flexRender(editRender, {}) }) });
|
|
18
20
|
}
|
|
19
21
|
return /* @__PURE__ */ jsx(Dialog, { open: openEdit, onOpenChange: setOpenEdit, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
20
22
|
/* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }),
|
|
@@ -24,6 +26,26 @@ function CurdEditPanel(props) {
|
|
|
24
26
|
}, children: "xxxxx" })
|
|
25
27
|
] }) });
|
|
26
28
|
}
|
|
29
|
+
const WithLoadGetData = (props) => {
|
|
30
|
+
const { children } = props;
|
|
31
|
+
const methodGet = useListview((x) => x.methodGet);
|
|
32
|
+
const svc = useListview((x) => x.svc);
|
|
33
|
+
const activateItem = useListview((x) => x.activateItem);
|
|
34
|
+
const setDetailData = useListview((x) => x.setDetailData);
|
|
35
|
+
const detailQuery = useGomtmSuspenseQuery(svc, methodGet, {
|
|
36
|
+
id: parseInt(activateItem.id)
|
|
37
|
+
});
|
|
38
|
+
useMemo(() => {
|
|
39
|
+
setDetailData(detailQuery.data);
|
|
40
|
+
}, [detailQuery.data, setDetailData]);
|
|
41
|
+
if (detailQuery.isLoading) {
|
|
42
|
+
return /* @__PURE__ */ jsx("div", { children: "loading detail" });
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-red-200 p-2", children: [
|
|
45
|
+
"WithLoadGetData",
|
|
46
|
+
children
|
|
47
|
+
] });
|
|
48
|
+
};
|
|
27
49
|
const CurdEditPanelTriggerButton = () => {
|
|
28
50
|
const setOpenEdit = useListview((x) => x.setOpenEdit);
|
|
29
51
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
@@ -5,8 +5,9 @@ interface ListViewStateProps {
|
|
|
5
5
|
svc: string;
|
|
6
6
|
methodList: string;
|
|
7
7
|
methodGet: string;
|
|
8
|
-
|
|
8
|
+
methodUpdate: string;
|
|
9
9
|
methodCreate?: string;
|
|
10
|
+
methodDelete: string;
|
|
10
11
|
paramsGet?: any;
|
|
11
12
|
paramsList?: any;
|
|
12
13
|
slugPath?: string;
|
|
@@ -29,6 +30,7 @@ export interface ListViewState extends ListViewStateProps {
|
|
|
29
30
|
loadListData: () => Promise<any>;
|
|
30
31
|
nextPage: () => void;
|
|
31
32
|
setEditRender: (a: Renderable<any>) => void;
|
|
33
|
+
setDetailData: (detailData: any) => void;
|
|
32
34
|
}
|
|
33
35
|
export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
|
|
34
36
|
type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
|
|
@@ -62,6 +62,7 @@ const createListviewStore = (initProps) => {
|
|
|
62
62
|
const DEFAULT_PROPS = {
|
|
63
63
|
svc: initProps.svc || "",
|
|
64
64
|
methodList: initProps.methodList || "",
|
|
65
|
+
methodUpdate: "",
|
|
65
66
|
methodGet: "",
|
|
66
67
|
methodDelete: "",
|
|
67
68
|
methodCreate: "",
|
|
@@ -96,7 +97,8 @@ const createListviewStore = (initProps) => {
|
|
|
96
97
|
}),
|
|
97
98
|
nextPage: () => {
|
|
98
99
|
},
|
|
99
|
-
setEditRender: (editRender) => set({ editRender })
|
|
100
|
+
setEditRender: (editRender) => set({ editRender }),
|
|
101
|
+
setDetailData: (detailData) => set({ detailData })
|
|
100
102
|
}));
|
|
101
103
|
};
|
|
102
104
|
const listViewContext = createContext(null);
|
package/dist/esm/gomtmQuery.js
CHANGED
|
@@ -63,7 +63,7 @@ function useGomtmSuspenseInfiniteQuery(svc, method, input) {
|
|
|
63
63
|
const useGomtmMutation = (svc, method) => {
|
|
64
64
|
const fn = useGmtmQjeryFn();
|
|
65
65
|
return useMutation({
|
|
66
|
-
mutationFn: (input) => fn(svc, method)
|
|
66
|
+
mutationFn: (input) => fn(svc, method, input)
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
69
|
export {
|