@akanjs/ui 0.9.42 → 0.9.43
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/Data/CardList.d.ts +1 -1
- package/Data/Dashboard.d.ts +2 -3
- package/Data/Item.d.ts +4 -4
- package/Data/ListContainer.d.ts +10 -6
- package/Data/TableList.d.ts +1 -1
- package/Model/AdminPanel.d.ts +31 -0
- package/Model/index.d.ts +1 -0
- package/Model/index_.d.ts +1 -0
- package/cjs/Data/Item.js +2 -5
- package/cjs/Data/ListContainer.js +7 -14
- package/cjs/Data/QueryMaker.js +1 -1
- package/cjs/Model/AdminPanel.js +49 -0
- package/cjs/Model/index.js +2 -1
- package/cjs/Model/index_.js +2 -0
- package/esm/Data/Item.js +2 -5
- package/esm/Data/ListContainer.js +7 -14
- package/esm/Data/QueryMaker.js +1 -1
- package/esm/Model/AdminPanel.js +30 -0
- package/esm/Model/index.js +3 -1
- package/esm/Model/index_.js +2 -0
- package/package.json +1 -1
package/Data/CardList.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ interface CardListProps<T extends string, Input, Full extends {
|
|
|
21
21
|
init?: FetchInitForm<Input, Full, Filter>;
|
|
22
22
|
sliceName: string;
|
|
23
23
|
columns: DataColumn<any>[];
|
|
24
|
-
actions?: DataAction
|
|
24
|
+
actions?: DataAction[] | ((item: Light, idx: number) => DataAction[]);
|
|
25
25
|
renderItem: (args: DataItemProps<T, Full, Light>) => ReactNode;
|
|
26
26
|
renderLoading?: () => ReactNode;
|
|
27
27
|
renderTemplate?: (props: any) => ReactNode | null;
|
package/Data/Dashboard.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export interface DashboardProps<T extends string, State, SL extends StoreOf<T, State>> {
|
|
1
|
+
export interface DashboardProps<T extends string, State> {
|
|
3
2
|
className?: string;
|
|
4
3
|
summary: {
|
|
5
4
|
[key: string]: any;
|
|
@@ -12,4 +11,4 @@ export interface DashboardProps<T extends string, State, SL extends StoreOf<T, S
|
|
|
12
11
|
presents?: string[];
|
|
13
12
|
hidePresents?: boolean;
|
|
14
13
|
}
|
|
15
|
-
export default function Dashboard<T extends string, State
|
|
14
|
+
export default function Dashboard<T extends string, State>({ className, summary, sliceName, queryMap, columns, presents, hidePresents, }: DashboardProps<T, State>): import("react/jsx-runtime").JSX.Element;
|
package/Data/Item.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dayjs } from "@akanjs/base";
|
|
2
2
|
import { DataAction, DataColumn } from "@akanjs/client";
|
|
3
|
-
import
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
4
|
export declare const convToAntdColumn: (column: DataColumn<any>) => {
|
|
5
5
|
key: string;
|
|
6
6
|
dataIndex: string;
|
|
@@ -37,7 +37,7 @@ interface ItemProps<T extends string, Full extends {
|
|
|
37
37
|
onClick?: () => void;
|
|
38
38
|
cover?: ReactNode;
|
|
39
39
|
title?: ReactNode;
|
|
40
|
-
actions?: DataAction
|
|
40
|
+
actions?: DataAction[];
|
|
41
41
|
columns?: DataColumn<any>[];
|
|
42
42
|
children?: ReactNode;
|
|
43
43
|
}
|
|
@@ -61,7 +61,7 @@ interface ActionProps<T extends string, M extends {
|
|
|
61
61
|
}, L extends {
|
|
62
62
|
id: string;
|
|
63
63
|
}> {
|
|
64
|
-
action: DataAction
|
|
64
|
+
action: DataAction;
|
|
65
65
|
model: L;
|
|
66
66
|
sliceName: string;
|
|
67
67
|
}
|
|
@@ -71,4 +71,4 @@ export declare const Action: <T extends string, M extends {
|
|
|
71
71
|
id: string;
|
|
72
72
|
}>({ action, model, sliceName, outline, }: ActionProps<T, M, L> & {
|
|
73
73
|
outline?: boolean;
|
|
74
|
-
}) =>
|
|
74
|
+
}) => import("react/jsx-runtime").JSX.Element | null | undefined;
|
package/Data/ListContainer.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DataAction, DataColumn, DataTool, ModelInsightProps, ModelProps } from
|
|
|
2
2
|
import { SortType } from "@akanjs/constant";
|
|
3
3
|
import { type FetchInitForm } from "@akanjs/signal";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
|
-
interface ListContainerProps<T extends string, State, Input, Full extends {
|
|
5
|
+
export interface ListContainerProps<T extends string, State, Input, Full extends {
|
|
6
6
|
id: string;
|
|
7
7
|
}, Light extends {
|
|
8
8
|
id: string;
|
|
@@ -14,20 +14,25 @@ interface ListContainerProps<T extends string, State, Input, Full extends {
|
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
};
|
|
16
16
|
init?: FetchInitForm<Input, Full, Sort>;
|
|
17
|
-
sliceName:
|
|
17
|
+
sliceName: T;
|
|
18
18
|
create?: boolean;
|
|
19
19
|
title?: string;
|
|
20
20
|
sort?: SortType;
|
|
21
21
|
columns?: DataColumn<any>[];
|
|
22
22
|
tools?: DataTool[] | ((modelList: Light[]) => DataTool[]);
|
|
23
|
-
actions?: DataAction
|
|
24
|
-
renderDashboard?: ({ summary, hidePresents }:
|
|
23
|
+
actions?: DataAction[] | ((item: Light, idx: number) => DataAction[]);
|
|
24
|
+
renderDashboard?: ({ summary, hidePresents, }: {
|
|
25
|
+
summary: {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
hidePresents?: boolean;
|
|
29
|
+
}) => ReactNode;
|
|
25
30
|
renderItem?: (props: ModelProps<any, any>) => ReactNode;
|
|
26
31
|
renderTemplate?: (props: any) => ReactNode | null;
|
|
27
32
|
renderTitle?: (model: Full) => string | ReactNode;
|
|
28
33
|
renderView?: (model: Full) => ReactNode | null;
|
|
29
34
|
renderQueryMaker?: () => ReactNode;
|
|
30
|
-
renderInsight?: (props: ModelInsightProps
|
|
35
|
+
renderInsight?: (props: ModelInsightProps) => ReactNode;
|
|
31
36
|
renderLoading?: () => ReactNode;
|
|
32
37
|
}
|
|
33
38
|
export default function ListContainer<T extends string, State, Input, Full extends {
|
|
@@ -35,4 +40,3 @@ export default function ListContainer<T extends string, State, Input, Full exten
|
|
|
35
40
|
}, Light extends {
|
|
36
41
|
id: string;
|
|
37
42
|
}, Sort extends SortType>({ className, cardListClassName, type, query, init, create, sliceName, title, sort, columns, actions, tools, renderDashboard, renderItem, renderTemplate, renderTitle, renderView, renderQueryMaker, renderInsight, renderLoading, }: ListContainerProps<T, State, Input, Full, Light, Sort>): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
export {};
|
package/Data/TableList.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface TableListProps<T extends string, Input, Full extends {
|
|
|
15
15
|
renderTemplate?: (props: any) => ReactNode | null;
|
|
16
16
|
renderTitle?: (model: Full) => string | ReactNode;
|
|
17
17
|
renderView?: (model: Full) => ReactNode | null;
|
|
18
|
-
actions?: DataAction
|
|
18
|
+
actions?: DataAction[] | ((item: Light, idx: number) => DataAction[]);
|
|
19
19
|
onItemClick?: (item: Light, idx: number) => void;
|
|
20
20
|
}
|
|
21
21
|
export default function TableList<T extends string, Input, Full extends {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type SortType } from "@akanjs/constant";
|
|
2
|
+
import type { ListContainerProps } from "../Data/ListContainer";
|
|
3
|
+
interface AdminPanelProps<T extends string, State, Input, Full extends {
|
|
4
|
+
id: string;
|
|
5
|
+
}, Light extends {
|
|
6
|
+
id: string;
|
|
7
|
+
}, Sort extends SortType> extends ListContainerProps<T, State, Input, Full, Light, Sort> {
|
|
8
|
+
sliceName: T;
|
|
9
|
+
components: {
|
|
10
|
+
Template: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
Unit: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
View: {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
queryMap?: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
summaryColumns?: string[];
|
|
24
|
+
insightColumns?: string[];
|
|
25
|
+
}
|
|
26
|
+
export default function AdminPanel<T extends string, State, Input, Full extends {
|
|
27
|
+
id: string;
|
|
28
|
+
}, Light extends {
|
|
29
|
+
id: string;
|
|
30
|
+
}, Sort extends SortType>({ sliceName, components, queryMap, summaryColumns, insightColumns, renderInsight, renderDashboard, ...props }: AdminPanelProps<T, State, Input, Full, Light, Sort>): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
package/Model/index.d.ts
CHANGED
package/Model/index_.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare const ViewWrapper: typeof import("./ViewWrapper").default;
|
|
|
11
11
|
export declare const ViewEditModal: typeof import("./ViewEditModal").default;
|
|
12
12
|
export declare const Edit: typeof import("./Edit").default;
|
|
13
13
|
export declare const New: typeof import("./New").default;
|
|
14
|
+
export declare const AdminPanel: typeof import("./AdminPanel").default;
|
package/cjs/Data/Item.js
CHANGED
|
@@ -89,10 +89,7 @@ function Item({
|
|
|
89
89
|
}) {
|
|
90
90
|
const { l } = (0, import_next.usePage)();
|
|
91
91
|
const strActions = actions.filter((action) => typeof action === "string").map((action, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Action, { action, outline: false, model, sliceName }, idx));
|
|
92
|
-
const customActions = actions.filter((action) => typeof action !== "string").map((action, idx) => ({
|
|
93
|
-
key: idx,
|
|
94
|
-
label: typeof action !== "string" ? action.render() : null
|
|
95
|
-
}));
|
|
92
|
+
const customActions = actions.filter((action) => typeof action !== "string").map((action, idx) => ({ key: idx, label: action }));
|
|
96
93
|
const extraCols = columns.filter((column) => {
|
|
97
94
|
const key = typeof column === "string" ? column : column.key;
|
|
98
95
|
return !["id", "status", "createdAt"].includes(key);
|
|
@@ -184,7 +181,7 @@ const Action = ({
|
|
|
184
181
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: `btn btn-square btn-ghost btn-sm m-1 text-center ${outline && "btn-outline border-dashed"}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ai.AiOutlineDelete, {}) })
|
|
185
182
|
},
|
|
186
183
|
action
|
|
187
|
-
) : action
|
|
184
|
+
) : action;
|
|
188
185
|
};
|
|
189
186
|
const statusColors = {
|
|
190
187
|
active: "badge-info badge-outline",
|
|
@@ -57,19 +57,12 @@ function ListContainer({
|
|
|
57
57
|
title,
|
|
58
58
|
sort,
|
|
59
59
|
columns = ["id", "createdAt", "updatedAt"],
|
|
60
|
-
actions,
|
|
60
|
+
actions = ["remove", "edit", "view"],
|
|
61
61
|
tools = [],
|
|
62
62
|
renderDashboard,
|
|
63
63
|
renderItem,
|
|
64
64
|
renderTemplate,
|
|
65
|
-
renderTitle
|
|
66
|
-
sliceName,
|
|
67
|
-
" - ",
|
|
68
|
-
model.id
|
|
69
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: "flex items-center justify-center py-3 text-lg sm:justify-start md:text-2xl", children: [
|
|
70
|
-
"New ",
|
|
71
|
-
sliceName
|
|
72
|
-
] }),
|
|
65
|
+
renderTitle,
|
|
73
66
|
renderView,
|
|
74
67
|
renderQueryMaker = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}),
|
|
75
68
|
renderInsight,
|
|
@@ -78,7 +71,6 @@ function ListContainer({
|
|
|
78
71
|
const { l } = (0, import_next.usePage)();
|
|
79
72
|
const storeUse = import_store.st.use;
|
|
80
73
|
const storeDo = import_store.st.do;
|
|
81
|
-
const storeGet = import_store.st.get;
|
|
82
74
|
const refName = import_store.st.slice[sliceName].refName;
|
|
83
75
|
const [modelName, modelClassName] = [refName, (0, import_common.capitalize)(refName)];
|
|
84
76
|
if (refName !== sliceName)
|
|
@@ -111,6 +103,7 @@ function ListContainer({
|
|
|
111
103
|
const cnst = (0, import_constant.getCnstMeta)(sliceName);
|
|
112
104
|
const limitOfModel = storeUse[namesOfSlice.limitOfModel]();
|
|
113
105
|
const sortOfModel = storeUse[namesOfSlice.sortOfModel]();
|
|
106
|
+
const RenderTitle = renderTitle ?? ((model) => `${l(`${refName}.modelName`)} - ${model.id ? model.id : "New"}`);
|
|
114
107
|
const ModelDashboard = () => {
|
|
115
108
|
const summary = storeUse.summary();
|
|
116
109
|
const summaryLoading = storeUse.summaryLoading();
|
|
@@ -260,11 +253,11 @@ ${body}`], { type: "text/csv;charset=utf-8" });
|
|
|
260
253
|
import_CardList.default,
|
|
261
254
|
{
|
|
262
255
|
sliceName,
|
|
263
|
-
renderItem: renderItem ?? (({ [sliceName]: model }) =>
|
|
256
|
+
renderItem: renderItem ?? (({ [sliceName]: model }) => null),
|
|
264
257
|
renderLoading,
|
|
265
258
|
renderTemplate,
|
|
266
259
|
renderView,
|
|
267
|
-
renderTitle,
|
|
260
|
+
renderTitle: RenderTitle,
|
|
268
261
|
columns,
|
|
269
262
|
actions,
|
|
270
263
|
cardListClassName
|
|
@@ -276,10 +269,10 @@ ${body}`], { type: "text/csv;charset=utf-8" });
|
|
|
276
269
|
sliceName,
|
|
277
270
|
actions,
|
|
278
271
|
renderTemplate,
|
|
279
|
-
renderTitle,
|
|
272
|
+
renderTitle: RenderTitle,
|
|
280
273
|
renderView
|
|
281
274
|
}
|
|
282
275
|
),
|
|
283
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Model.Model.EditModal, { sliceName, renderTitle, children: RenderTemplate ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderTemplate, {}) : null })
|
|
276
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Model.Model.EditModal, { sliceName, renderTitle: RenderTitle, children: RenderTemplate ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderTemplate, {}) : null })
|
|
284
277
|
] });
|
|
285
278
|
}
|
package/cjs/Data/QueryMaker.js
CHANGED
|
@@ -92,7 +92,7 @@ function QueryMaker({ className, sliceName, query }) {
|
|
|
92
92
|
{
|
|
93
93
|
value: querySetting.queryKey,
|
|
94
94
|
options: Object.keys(summaryQueryMap).map((queryKey) => ({
|
|
95
|
-
label: l.
|
|
95
|
+
label: l.field("summary", queryKey),
|
|
96
96
|
value: queryKey
|
|
97
97
|
})),
|
|
98
98
|
onChange: (queryKey) => {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var AdminPanel_exports = {};
|
|
19
|
+
__export(AdminPanel_exports, {
|
|
20
|
+
default: () => AdminPanel
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(AdminPanel_exports);
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_common = require("@akanjs/common");
|
|
25
|
+
var import_constant = require("@akanjs/constant");
|
|
26
|
+
var import_Data = require("../Data");
|
|
27
|
+
function AdminPanel({
|
|
28
|
+
sliceName,
|
|
29
|
+
components,
|
|
30
|
+
queryMap = (0, import_constant.getQueryMap)((0, import_constant.getScalarModelRef)(`${(0, import_common.capitalize)(sliceName)}Summary`)),
|
|
31
|
+
summaryColumns = ["totalAdmin"],
|
|
32
|
+
insightColumns = ["count"],
|
|
33
|
+
renderInsight = ({ insight }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Data.Data.Insight, { insight, sliceName, columns: insightColumns }),
|
|
34
|
+
renderDashboard = ({ summary }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Data.Data.Dashboard, { summary, sliceName, columns: summaryColumns, queryMap }),
|
|
35
|
+
...props
|
|
36
|
+
}) {
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
38
|
+
import_Data.Data.ListContainer,
|
|
39
|
+
{
|
|
40
|
+
sliceName,
|
|
41
|
+
renderItem: components.Unit.General,
|
|
42
|
+
renderInsight,
|
|
43
|
+
renderDashboard,
|
|
44
|
+
renderTemplate: components.Template.General,
|
|
45
|
+
renderView: (model) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(components.View.General, { ...{ [sliceName]: model } }),
|
|
46
|
+
...props
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
package/cjs/Model/index.js
CHANGED
package/cjs/Model/index_.js
CHANGED
|
@@ -27,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var index_exports = {};
|
|
29
29
|
__export(index_exports, {
|
|
30
|
+
AdminPanel: () => AdminPanel,
|
|
30
31
|
Edit: () => Edit,
|
|
31
32
|
EditModal: () => EditModal,
|
|
32
33
|
EditWrapper: () => EditWrapper,
|
|
@@ -56,3 +57,4 @@ const ViewWrapper = (0, import_next.lazy)(() => import("./ViewWrapper"));
|
|
|
56
57
|
const ViewEditModal = (0, import_next.lazy)(() => import("./ViewEditModal"));
|
|
57
58
|
const Edit = (0, import_next.lazy)(() => import("./Edit"));
|
|
58
59
|
const New = (0, import_next.lazy)(() => import("./New"));
|
|
60
|
+
const AdminPanel = (0, import_next.lazy)(() => import("./AdminPanel"));
|
package/esm/Data/Item.js
CHANGED
|
@@ -65,10 +65,7 @@ function Item({
|
|
|
65
65
|
}) {
|
|
66
66
|
const { l } = usePage();
|
|
67
67
|
const strActions = actions.filter((action) => typeof action === "string").map((action, idx) => /* @__PURE__ */ jsx(Action, { action, outline: false, model, sliceName }, idx));
|
|
68
|
-
const customActions = actions.filter((action) => typeof action !== "string").map((action, idx) => ({
|
|
69
|
-
key: idx,
|
|
70
|
-
label: typeof action !== "string" ? action.render() : null
|
|
71
|
-
}));
|
|
68
|
+
const customActions = actions.filter((action) => typeof action !== "string").map((action, idx) => ({ key: idx, label: action }));
|
|
72
69
|
const extraCols = columns.filter((column) => {
|
|
73
70
|
const key = typeof column === "string" ? column : column.key;
|
|
74
71
|
return !["id", "status", "createdAt"].includes(key);
|
|
@@ -160,7 +157,7 @@ const Action = ({
|
|
|
160
157
|
children: /* @__PURE__ */ jsx("button", { className: `btn btn-square btn-ghost btn-sm m-1 text-center ${outline && "btn-outline border-dashed"}`, children: /* @__PURE__ */ jsx(AiOutlineDelete, {}) })
|
|
161
158
|
},
|
|
162
159
|
action
|
|
163
|
-
) : action
|
|
160
|
+
) : action;
|
|
164
161
|
};
|
|
165
162
|
const statusColors = {
|
|
166
163
|
active: "badge-info badge-outline",
|
|
@@ -31,19 +31,12 @@ function ListContainer({
|
|
|
31
31
|
title,
|
|
32
32
|
sort,
|
|
33
33
|
columns = ["id", "createdAt", "updatedAt"],
|
|
34
|
-
actions,
|
|
34
|
+
actions = ["remove", "edit", "view"],
|
|
35
35
|
tools = [],
|
|
36
36
|
renderDashboard,
|
|
37
37
|
renderItem,
|
|
38
38
|
renderTemplate,
|
|
39
|
-
renderTitle
|
|
40
|
-
sliceName,
|
|
41
|
-
" - ",
|
|
42
|
-
model.id
|
|
43
|
-
] }) : /* @__PURE__ */ jsxs("h2", { className: "flex items-center justify-center py-3 text-lg sm:justify-start md:text-2xl", children: [
|
|
44
|
-
"New ",
|
|
45
|
-
sliceName
|
|
46
|
-
] }),
|
|
39
|
+
renderTitle,
|
|
47
40
|
renderView,
|
|
48
41
|
renderQueryMaker = () => /* @__PURE__ */ jsx(Fragment, {}),
|
|
49
42
|
renderInsight,
|
|
@@ -52,7 +45,6 @@ function ListContainer({
|
|
|
52
45
|
const { l } = usePage();
|
|
53
46
|
const storeUse = st.use;
|
|
54
47
|
const storeDo = st.do;
|
|
55
|
-
const storeGet = st.get;
|
|
56
48
|
const refName = st.slice[sliceName].refName;
|
|
57
49
|
const [modelName, modelClassName] = [refName, capitalize(refName)];
|
|
58
50
|
if (refName !== sliceName)
|
|
@@ -85,6 +77,7 @@ function ListContainer({
|
|
|
85
77
|
const cnst = getCnstMeta(sliceName);
|
|
86
78
|
const limitOfModel = storeUse[namesOfSlice.limitOfModel]();
|
|
87
79
|
const sortOfModel = storeUse[namesOfSlice.sortOfModel]();
|
|
80
|
+
const RenderTitle = renderTitle ?? ((model) => `${l(`${refName}.modelName`)} - ${model.id ? model.id : "New"}`);
|
|
88
81
|
const ModelDashboard = () => {
|
|
89
82
|
const summary = storeUse.summary();
|
|
90
83
|
const summaryLoading = storeUse.summaryLoading();
|
|
@@ -234,11 +227,11 @@ ${body}`], { type: "text/csv;charset=utf-8" });
|
|
|
234
227
|
DataCardList,
|
|
235
228
|
{
|
|
236
229
|
sliceName,
|
|
237
|
-
renderItem: renderItem ?? (({ [sliceName]: model }) =>
|
|
230
|
+
renderItem: renderItem ?? (({ [sliceName]: model }) => null),
|
|
238
231
|
renderLoading,
|
|
239
232
|
renderTemplate,
|
|
240
233
|
renderView,
|
|
241
|
-
renderTitle,
|
|
234
|
+
renderTitle: RenderTitle,
|
|
242
235
|
columns,
|
|
243
236
|
actions,
|
|
244
237
|
cardListClassName
|
|
@@ -250,11 +243,11 @@ ${body}`], { type: "text/csv;charset=utf-8" });
|
|
|
250
243
|
sliceName,
|
|
251
244
|
actions,
|
|
252
245
|
renderTemplate,
|
|
253
|
-
renderTitle,
|
|
246
|
+
renderTitle: RenderTitle,
|
|
254
247
|
renderView
|
|
255
248
|
}
|
|
256
249
|
),
|
|
257
|
-
/* @__PURE__ */ jsx(Model.EditModal, { sliceName, renderTitle, children: RenderTemplate ? /* @__PURE__ */ jsx(RenderTemplate, {}) : null })
|
|
250
|
+
/* @__PURE__ */ jsx(Model.EditModal, { sliceName, renderTitle: RenderTitle, children: RenderTemplate ? /* @__PURE__ */ jsx(RenderTemplate, {}) : null })
|
|
258
251
|
] });
|
|
259
252
|
}
|
|
260
253
|
export {
|
package/esm/Data/QueryMaker.js
CHANGED
|
@@ -78,7 +78,7 @@ function QueryMaker({ className, sliceName, query }) {
|
|
|
78
78
|
{
|
|
79
79
|
value: querySetting.queryKey,
|
|
80
80
|
options: Object.keys(summaryQueryMap).map((queryKey) => ({
|
|
81
|
-
label: l.
|
|
81
|
+
label: l.field("summary", queryKey),
|
|
82
82
|
value: queryKey
|
|
83
83
|
})),
|
|
84
84
|
onChange: (queryKey) => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { capitalize } from "@akanjs/common";
|
|
3
|
+
import { getQueryMap, getScalarModelRef } from "@akanjs/constant";
|
|
4
|
+
import { Data } from "../Data";
|
|
5
|
+
function AdminPanel({
|
|
6
|
+
sliceName,
|
|
7
|
+
components,
|
|
8
|
+
queryMap = getQueryMap(getScalarModelRef(`${capitalize(sliceName)}Summary`)),
|
|
9
|
+
summaryColumns = ["totalAdmin"],
|
|
10
|
+
insightColumns = ["count"],
|
|
11
|
+
renderInsight = ({ insight }) => /* @__PURE__ */ jsx(Data.Insight, { insight, sliceName, columns: insightColumns }),
|
|
12
|
+
renderDashboard = ({ summary }) => /* @__PURE__ */ jsx(Data.Dashboard, { summary, sliceName, columns: summaryColumns, queryMap }),
|
|
13
|
+
...props
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
Data.ListContainer,
|
|
17
|
+
{
|
|
18
|
+
sliceName,
|
|
19
|
+
renderItem: components.Unit.General,
|
|
20
|
+
renderInsight,
|
|
21
|
+
renderDashboard,
|
|
22
|
+
renderTemplate: components.Template.General,
|
|
23
|
+
renderView: (model) => /* @__PURE__ */ jsx(components.View.General, { ...{ [sliceName]: model } }),
|
|
24
|
+
...props
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
AdminPanel as default
|
|
30
|
+
};
|
package/esm/Model/index.js
CHANGED
package/esm/Model/index_.js
CHANGED
|
@@ -12,7 +12,9 @@ const ViewWrapper = lazy(() => import("./ViewWrapper"));
|
|
|
12
12
|
const ViewEditModal = lazy(() => import("./ViewEditModal"));
|
|
13
13
|
const Edit = lazy(() => import("./Edit"));
|
|
14
14
|
const New = lazy(() => import("./New"));
|
|
15
|
+
const AdminPanel = lazy(() => import("./AdminPanel"));
|
|
15
16
|
export {
|
|
17
|
+
AdminPanel,
|
|
16
18
|
Edit,
|
|
17
19
|
EditModal,
|
|
18
20
|
EditWrapper,
|