@uxf/cms 11.0.0-beta.2 → 11.0.0-beta.20
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uxf/cms",
|
3
|
-
"version": "11.0.0-beta.
|
3
|
+
"version": "11.0.0-beta.20",
|
4
4
|
"description": "UXF Cms",
|
5
5
|
"author": "UXFans <dev@uxf.cz>",
|
6
6
|
"homepage": "https://gitlab.com/uxf-npm/cms#readme",
|
@@ -31,11 +31,11 @@
|
|
31
31
|
"@floating-ui/react": "0.26.0",
|
32
32
|
"@redux-devtools/extension": "3.2.5",
|
33
33
|
"@uxf/core": "10.0.0",
|
34
|
-
"@uxf/data-grid": "11.0.0-beta.
|
35
|
-
"@uxf/form": "
|
34
|
+
"@uxf/data-grid": "11.0.0-beta.20",
|
35
|
+
"@uxf/form": "11.0.0-beta.17",
|
36
36
|
"@uxf/router": "10.0.0",
|
37
|
-
"@uxf/ui": "
|
38
|
-
"@uxf/wysiwyg": "
|
37
|
+
"@uxf/ui": "11.0.0-beta.17",
|
38
|
+
"@uxf/wysiwyg": "11.0.0-beta.17",
|
39
39
|
"axios": "1.5.1",
|
40
40
|
"axios-hooks": "5.0.0",
|
41
41
|
"es6-error": "4.1.1",
|
@@ -27,11 +27,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.GridPage = exports.dataGridLoader = void 0;
|
30
|
+
const buildArray_1 = require("@uxf/core/utils/buildArray");
|
31
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
30
32
|
const data_grid_1 = require("@uxf/data-grid");
|
33
|
+
const table_1 = require("@uxf/data-grid/table");
|
31
34
|
const use_data_grid_control_1 = require("@uxf/data-grid/use-data-grid-control");
|
32
35
|
const use_data_grid_fetching_1 = require("@uxf/data-grid/use-data-grid-fetching");
|
33
36
|
const router_1 = require("@uxf/router");
|
34
|
-
const context_1 = require("@uxf/ui/context");
|
35
37
|
const icon_1 = require("@uxf/ui/icon");
|
36
38
|
const router_2 = __importDefault(require("next/router"));
|
37
39
|
const qs_1 = require("qs");
|
@@ -49,9 +51,9 @@ const dataGridLoader = (gridName, request) => {
|
|
49
51
|
exports.dataGridLoader = dataGridLoader;
|
50
52
|
const DefaultLayout = (props) => react_1.default.createElement("div", { ...props });
|
51
53
|
const GridPageComponent = (props) => {
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
54
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
53
55
|
// eslint-disable-next-line react/destructuring-assignment
|
54
|
-
const {
|
56
|
+
const { query, AddIcon = react_1.default.createElement(icon_1.Icon, { name: "plus" }), onAddTitle = "Přidat záznam" } = props;
|
55
57
|
const Layout = (_b = (_a = props.ui) === null || _a === void 0 ? void 0 : _a.Layout) !== null && _b !== void 0 ? _b : DefaultLayout;
|
56
58
|
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
|
57
59
|
schema: props.gridSchema,
|
@@ -66,27 +68,64 @@ const GridPageComponent = (props) => {
|
|
66
68
|
router_2.default.replace(`${(0, url_1.parse)(((_a = window.history.state) === null || _a === void 0 ? void 0 : _a.url) || "").pathname}?${(0, qs_1.stringify)(newQuery)}`, `${(0, url_1.parse)(((_b = window.history.state) === null || _b === void 0 ? void 0 : _b.as) || "").pathname}?${(0, qs_1.stringify)(newQuery)}`, { shallow: true });
|
67
69
|
return response;
|
68
70
|
}, [query]);
|
69
|
-
const { data, isLoading, error, onReload } = (0, use_data_grid_fetching_1.useDataGridFetching)(
|
70
|
-
|
71
|
+
const { data, isLoading, error, onReload } = (0, use_data_grid_fetching_1.useDataGridFetching)({
|
72
|
+
loader: (_c = props.loader) !== null && _c !== void 0 ? _c : universalLoader,
|
73
|
+
schema: props.gridSchema,
|
74
|
+
gridName: (_e = (_d = props.metaSchema) === null || _d === void 0 ? void 0 : _d.entityAlias) !== null && _e !== void 0 ? _e : "",
|
75
|
+
state,
|
76
|
+
});
|
71
77
|
const actionsBag = (0, react_1.useMemo)(() => ({
|
72
78
|
reload: onReload,
|
73
79
|
}), [onReload]);
|
74
|
-
const hasOnAdd = onAdd && (!metaSchema || metaSchema.actions.includes("add"));
|
80
|
+
const hasOnAdd = props.onAdd && (!props.metaSchema || props.metaSchema.actions.includes("add"));
|
75
81
|
const cActions = [
|
76
|
-
...customActions,
|
82
|
+
...((_f = props.customActions) !== null && _f !== void 0 ? _f : []),
|
77
83
|
hasOnAdd
|
78
84
|
? {
|
79
85
|
label: (react_1.default.createElement(react_1.default.Fragment, null,
|
80
86
|
AddIcon,
|
81
87
|
"\u00A0",
|
82
88
|
onAddTitle)),
|
83
|
-
onClick: () => onAdd(entityAlias, actionsBag),
|
89
|
+
onClick: () => { var _a; return (_a = props.onAdd) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionsBag); },
|
84
90
|
}
|
85
91
|
: undefined,
|
86
92
|
].filter(Boolean);
|
87
|
-
|
93
|
+
const actionColumnButtonsCount = (props.onEdit || props.getEditUrl ? 1 : 0) +
|
94
|
+
(props.onOpen || props.getOpenUrl ? 1 : 0) +
|
95
|
+
(props.onRemove ? 1 : 0);
|
96
|
+
const actionCell = actionColumnButtonsCount > 0
|
97
|
+
? {
|
98
|
+
width: actionColumnButtonsCount * 40,
|
99
|
+
Component: (actionCellProps) => {
|
100
|
+
var _a, _b, _c, _d, _e, _f;
|
101
|
+
const buttons = (0, buildArray_1.buildArray)()
|
102
|
+
.when((0, is_not_nil_1.isNotNil)((_a = props.onOpen) !== null && _a !== void 0 ? _a : props.getOpenUrl), {
|
103
|
+
icon: "circle-info",
|
104
|
+
onClick: () => { var _a; return (_a = props.onOpen) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionCellProps.row, actionsBag); },
|
105
|
+
href: (_c = (_b = props.getOpenUrl) === null || _b === void 0 ? void 0 : _b.call(props, props.entityAlias, actionCellProps.row)) !== null && _c !== void 0 ? _c : undefined,
|
106
|
+
isIconButton: true,
|
107
|
+
title: "Detail",
|
108
|
+
})
|
109
|
+
.when((0, is_not_nil_1.isNotNil)((_d = props.onEdit) !== null && _d !== void 0 ? _d : props.getEditUrl), {
|
110
|
+
icon: "pen",
|
111
|
+
onClick: () => { var _a; return (_a = props.onEdit) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionCellProps.row, actionsBag); },
|
112
|
+
href: (_f = (_e = props.getEditUrl) === null || _e === void 0 ? void 0 : _e.call(props, props.entityAlias, actionCellProps.row)) !== null && _f !== void 0 ? _f : undefined,
|
113
|
+
isIconButton: true,
|
114
|
+
title: "Upravit",
|
115
|
+
})
|
116
|
+
.when((0, is_not_nil_1.isNotNil)(props.onRemove), {
|
117
|
+
icon: "trash",
|
118
|
+
onClick: () => { var _a; return (_a = props.onRemove) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionCellProps.row, actionsBag); },
|
119
|
+
isIconButton: true,
|
120
|
+
title: "Smazat",
|
121
|
+
});
|
122
|
+
return react_1.default.createElement(table_1.ActionCell, { buttons: buttons, visibleButtonsCount: 3 });
|
123
|
+
},
|
124
|
+
}
|
125
|
+
: undefined;
|
126
|
+
return (react_1.default.createElement(Layout, { key: props.entityAlias, title: (_j = (_g = props.title) !== null && _g !== void 0 ? _g : (_h = props.metaSchema) === null || _h === void 0 ? void 0 : _h.title) !== null && _j !== void 0 ? _j : "" },
|
88
127
|
react_1.default.createElement("div", { className: "mb-10" },
|
89
|
-
react_1.default.createElement(data_grid_1.DataGrid, { state: state, actions: actions, data: data, isLoading: isLoading, error: error, onReload: onReload, noBorder: true,
|
128
|
+
react_1.default.createElement(data_grid_1.DataGrid, { state: state, actions: actions, data: data, isLoading: isLoading, error: error, onReload: onReload, noBorder: true, actionCell: actionCell, schema: props.gridSchema, gridName: props.entityAlias, rowHeight: props.rowHeight, customActions: cActions, onCsvDownload: (r) => window.open(`/api/cms/datagrid/export/${props.entityAlias}?${(0, qs_1.stringify)(r)}`), isRowSelectable: props.selectable }))));
|
90
129
|
};
|
91
130
|
GridPageComponent.displayName = "GridPageComponent";
|
92
131
|
const GridPage = (config) => {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { DataGridProps,
|
2
|
+
import { DataGridProps, Loader, Schema } from "@uxf/data-grid";
|
3
3
|
import { NextPageContext } from "next";
|
4
4
|
import { ParsedUrlQuery } from "querystring";
|
5
5
|
import { FC, ReactElement } from "react";
|
@@ -31,7 +31,11 @@ export type GridPageComponentProps = {
|
|
31
31
|
customActions?: DataGridProps<any, any>["customActions"];
|
32
32
|
};
|
33
33
|
export type EntityAliasExtractor = (ctx: NextPageContext) => string;
|
34
|
-
type UIComponents =
|
34
|
+
type UIComponents = {
|
35
|
+
BodyCells?: DataGridProps<any, any>["bodyCells"];
|
36
|
+
FilterHandlers?: DataGridProps<any, any>["filterHandlers"];
|
37
|
+
NoRowsFallback?: DataGridProps<any, any>["NoRowsFallback"];
|
38
|
+
SelectedRowsToolbarActions?: DataGridProps<any, any>["SelectedRowsToolbarActions"];
|
35
39
|
Layout?: LayoutComponent;
|
36
40
|
};
|
37
41
|
export type GridPageConfig<T extends object = any> = {
|