muffin-admin 1.36.5 → 1.36.7
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/dist/esm/admin.js +71 -0
- package/dist/esm/authprovider.js +191 -0
- package/dist/esm/buttons/ActionButton.js +81 -0
- package/dist/esm/buttons/LinkButton.js +23 -0
- package/dist/esm/dashboard.js +60 -0
- package/dist/esm/dataprovider.js +296 -0
- package/dist/esm/fields/AvatarField.js +29 -0
- package/dist/esm/fields/FKField.js +27 -0
- package/dist/esm/fields/JsonField.js +28 -0
- package/dist/esm/hooks/useAction.js +8 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/inputs/FKInput.js +33 -0
- package/dist/esm/inputs/JsonInput.js +63 -0
- package/dist/esm/resources.js +38 -0
- package/dist/esm/ui.js +71 -0
- package/dist/esm/utils.js +38 -0
- package/dist/esm/views/create.js +16 -0
- package/dist/esm/views/edit.js +37 -0
- package/dist/esm/views/list.js +64 -0
- package/dist/esm/views/show.js +26 -0
- package/dist/esm/web.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Admin, AppBar, Layout, Login, ToggleThemeButton, defaultTheme } from "react-admin";
|
|
4
|
+
import { IconButton, SvgIcon, Tooltip, Typography, createTheme } from "@mui/material";
|
|
5
|
+
import * as icons from "@mui/icons-material";
|
|
6
|
+
import authProvider from "./authprovider";
|
|
7
|
+
import dataProvider from "./dataprovider";
|
|
8
|
+
import { processAdmin, setupAdmin } from "./utils";
|
|
9
|
+
import "./dashboard";
|
|
10
|
+
import "./resources";
|
|
11
|
+
var darkTheme = createTheme({
|
|
12
|
+
palette: {
|
|
13
|
+
mode: "dark"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Initialize the admin
|
|
18
|
+
setupAdmin("admin", function (props) {
|
|
19
|
+
var apiUrl = props.apiUrl,
|
|
20
|
+
auth = props.auth,
|
|
21
|
+
adminProps = props.adminProps,
|
|
22
|
+
appBarLinks = props.appBarLinks,
|
|
23
|
+
dashboard = props.dashboard,
|
|
24
|
+
resources = props.resources;
|
|
25
|
+
var appBar = function appBar(props) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(AppBar, props, /*#__PURE__*/React.createElement(Typography, {
|
|
27
|
+
variant: "h6",
|
|
28
|
+
color: "inherit",
|
|
29
|
+
id: "react-admin-title",
|
|
30
|
+
style: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
textOverflow: "ellipsis",
|
|
33
|
+
whiteSpace: "nowrap",
|
|
34
|
+
overflow: "hidden"
|
|
35
|
+
}
|
|
36
|
+
}), /*#__PURE__*/React.createElement(ToggleThemeButton, {
|
|
37
|
+
lightTheme: defaultTheme,
|
|
38
|
+
darkTheme: darkTheme
|
|
39
|
+
}), appBarLinks.map(function (info) {
|
|
40
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
41
|
+
key: info.url,
|
|
42
|
+
title: info.title
|
|
43
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
44
|
+
color: "inherit",
|
|
45
|
+
href: info.url
|
|
46
|
+
}, /*#__PURE__*/React.createElement(SvgIcon, {
|
|
47
|
+
component: icons[info.icon]
|
|
48
|
+
})));
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
return /*#__PURE__*/React.createElement(Admin, _extends({
|
|
52
|
+
authProvider: processAdmin("auth", auth),
|
|
53
|
+
dataProvider: processAdmin("data", apiUrl),
|
|
54
|
+
dashboard: processAdmin("dashboard", dashboard),
|
|
55
|
+
loginPage: processAdmin("login", auth),
|
|
56
|
+
layout: function layout(props) {
|
|
57
|
+
return /*#__PURE__*/React.createElement(Layout, _extends({
|
|
58
|
+
appBar: appBar
|
|
59
|
+
}, props));
|
|
60
|
+
}
|
|
61
|
+
}, adminProps), processAdmin("resources", resources));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Initialize authentication and data providers
|
|
65
|
+
setupAdmin("auth", authProvider);
|
|
66
|
+
setupAdmin("data", dataProvider);
|
|
67
|
+
|
|
68
|
+
// Initialize login page
|
|
69
|
+
setupAdmin("login", function () {
|
|
70
|
+
return Login;
|
|
71
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import Cookies from "js-cookie";
|
|
4
|
+
import { makeRequest, processAdmin, requestHeaders, setupAdmin } from "./utils";
|
|
5
|
+
setupAdmin("auth-get", function (_ref) {
|
|
6
|
+
var storage = _ref.storage;
|
|
7
|
+
return function (name) {
|
|
8
|
+
return storage == "localstorage" ? localStorage.getItem(name) : Cookies.get(name);
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
setupAdmin("auth-set", function (_ref2) {
|
|
12
|
+
var storage = _ref2.storage;
|
|
13
|
+
return function (name, value) {
|
|
14
|
+
if (storage == "localstorage") {
|
|
15
|
+
localStorage.setItem(name, value);
|
|
16
|
+
requestHeaders["Authorization"] = value;
|
|
17
|
+
} else Cookies.set(name, value);
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
export default (function (props) {
|
|
21
|
+
var identityURL = props.identityURL,
|
|
22
|
+
authorizeURL = props.authorizeURL,
|
|
23
|
+
logoutURL = props.logoutURL,
|
|
24
|
+
required = props.required,
|
|
25
|
+
storage_name = props.storage_name;
|
|
26
|
+
var authGet = processAdmin("auth-get", props);
|
|
27
|
+
var authSet = processAdmin("auth-set", props);
|
|
28
|
+
|
|
29
|
+
// Initialize request headers
|
|
30
|
+
authSet(storage_name, authGet(storage_name));
|
|
31
|
+
var getIdentity = /*#__PURE__*/function () {
|
|
32
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
33
|
+
var _yield$makeRequest, json;
|
|
34
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
|
+
while (1) switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
if (!identityURL) {
|
|
38
|
+
_context.next = 6;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
_context.next = 3;
|
|
42
|
+
return makeRequest(identityURL);
|
|
43
|
+
case 3:
|
|
44
|
+
_yield$makeRequest = _context.sent;
|
|
45
|
+
json = _yield$makeRequest.json;
|
|
46
|
+
return _context.abrupt("return", json);
|
|
47
|
+
case 6:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context.stop();
|
|
50
|
+
}
|
|
51
|
+
}, _callee);
|
|
52
|
+
}));
|
|
53
|
+
return function getIdentity() {
|
|
54
|
+
return _ref3.apply(this, arguments);
|
|
55
|
+
};
|
|
56
|
+
}();
|
|
57
|
+
if (required) return {
|
|
58
|
+
login: function () {
|
|
59
|
+
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
60
|
+
var _yield$makeRequest2, json;
|
|
61
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
62
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
if (authorizeURL) {
|
|
65
|
+
_context2.next = 2;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
throw {
|
|
69
|
+
message: "Authorization is not supported"
|
|
70
|
+
};
|
|
71
|
+
case 2:
|
|
72
|
+
_context2.next = 4;
|
|
73
|
+
return makeRequest(authorizeURL, {
|
|
74
|
+
data: data,
|
|
75
|
+
method: "POST"
|
|
76
|
+
});
|
|
77
|
+
case 4:
|
|
78
|
+
_yield$makeRequest2 = _context2.sent;
|
|
79
|
+
json = _yield$makeRequest2.json;
|
|
80
|
+
authSet(storage_name, json);
|
|
81
|
+
case 7:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context2.stop();
|
|
84
|
+
}
|
|
85
|
+
}, _callee2);
|
|
86
|
+
}));
|
|
87
|
+
function login(_x) {
|
|
88
|
+
return _login.apply(this, arguments);
|
|
89
|
+
}
|
|
90
|
+
return login;
|
|
91
|
+
}(),
|
|
92
|
+
checkError: function () {
|
|
93
|
+
var _checkError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(error) {
|
|
94
|
+
var status;
|
|
95
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
96
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
status = error.status;
|
|
99
|
+
if (!(status == 401 || status == 403)) {
|
|
100
|
+
_context3.next = 4;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
// Clean storage
|
|
104
|
+
authSet(storage_name, "");
|
|
105
|
+
throw {
|
|
106
|
+
message: "Invalid authorization",
|
|
107
|
+
redirectTo: logoutURL,
|
|
108
|
+
logoutUser: !logoutURL
|
|
109
|
+
};
|
|
110
|
+
case 4:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context3.stop();
|
|
113
|
+
}
|
|
114
|
+
}, _callee3);
|
|
115
|
+
}));
|
|
116
|
+
function checkError(_x2) {
|
|
117
|
+
return _checkError.apply(this, arguments);
|
|
118
|
+
}
|
|
119
|
+
return checkError;
|
|
120
|
+
}(),
|
|
121
|
+
checkAuth: function () {
|
|
122
|
+
var _checkAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
123
|
+
var auth, user;
|
|
124
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
125
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
126
|
+
case 0:
|
|
127
|
+
auth = authGet(storage_name);
|
|
128
|
+
if (auth) {
|
|
129
|
+
_context4.next = 3;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
throw {
|
|
133
|
+
message: "Authorization required"
|
|
134
|
+
};
|
|
135
|
+
case 3:
|
|
136
|
+
if (identityURL) {
|
|
137
|
+
_context4.next = 5;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return _context4.abrupt("return", auth);
|
|
141
|
+
case 5:
|
|
142
|
+
_context4.next = 7;
|
|
143
|
+
return getIdentity();
|
|
144
|
+
case 7:
|
|
145
|
+
user = _context4.sent;
|
|
146
|
+
if (user) {
|
|
147
|
+
_context4.next = 10;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
throw {
|
|
151
|
+
message: "Authorization required"
|
|
152
|
+
};
|
|
153
|
+
case 10:
|
|
154
|
+
return _context4.abrupt("return", user);
|
|
155
|
+
case 11:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context4.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee4);
|
|
160
|
+
}));
|
|
161
|
+
function checkAuth() {
|
|
162
|
+
return _checkAuth.apply(this, arguments);
|
|
163
|
+
}
|
|
164
|
+
return checkAuth;
|
|
165
|
+
}(),
|
|
166
|
+
logout: function () {
|
|
167
|
+
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
168
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
169
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
170
|
+
case 0:
|
|
171
|
+
// Clean storage
|
|
172
|
+
authSet(storage_name, "");
|
|
173
|
+
if (logoutURL) window.location = logoutURL;
|
|
174
|
+
case 2:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context5.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee5);
|
|
179
|
+
}));
|
|
180
|
+
function logout() {
|
|
181
|
+
return _logout.apply(this, arguments);
|
|
182
|
+
}
|
|
183
|
+
return logout;
|
|
184
|
+
}(),
|
|
185
|
+
getIdentity: getIdentity,
|
|
186
|
+
getPermissions: function getPermissions() {
|
|
187
|
+
var role = authGet(storage_name + "_role");
|
|
188
|
+
return role ? Promise.resolve(role) : Promise.reject();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button, useRefresh, useUnselectAll, useNotify, useRecordContext } from "react-admin";
|
|
3
|
+
import * as icons from "@mui/icons-material";
|
|
4
|
+
import useAction from "../hooks/useAction";
|
|
5
|
+
export var BulkActionButton = function BulkActionButton(_ref) {
|
|
6
|
+
var label = _ref.label,
|
|
7
|
+
icon = _ref.icon,
|
|
8
|
+
title = _ref.title,
|
|
9
|
+
action = _ref.action,
|
|
10
|
+
resource = _ref.resource,
|
|
11
|
+
selectedIds = _ref.selectedIds;
|
|
12
|
+
var refresh = useRefresh(),
|
|
13
|
+
unselectAll = useUnselectAll(resource),
|
|
14
|
+
notify = useNotify(),
|
|
15
|
+
Icon = icons[icon];
|
|
16
|
+
var mutation = useAction(resource, action);
|
|
17
|
+
var onClick = function onClick() {
|
|
18
|
+
mutation.mutate({
|
|
19
|
+
action: action,
|
|
20
|
+
ids: selectedIds
|
|
21
|
+
}, {
|
|
22
|
+
onSuccess: function onSuccess(_ref2) {
|
|
23
|
+
var data = _ref2.data;
|
|
24
|
+
if (data && data.message) notify(data.message, {
|
|
25
|
+
type: "success"
|
|
26
|
+
});
|
|
27
|
+
refresh();
|
|
28
|
+
unselectAll();
|
|
29
|
+
},
|
|
30
|
+
onError: function onError(err) {
|
|
31
|
+
notify(typeof err === "string" ? err : err.message, {
|
|
32
|
+
type: "error"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
38
|
+
label: label,
|
|
39
|
+
title: title,
|
|
40
|
+
onClick: onClick,
|
|
41
|
+
disabled: mutation.isLoading
|
|
42
|
+
}, Icon && /*#__PURE__*/React.createElement(Icon, null));
|
|
43
|
+
};
|
|
44
|
+
export var ActionButton = function ActionButton(props) {
|
|
45
|
+
var icon = props.icon,
|
|
46
|
+
label = props.label,
|
|
47
|
+
title = props.title,
|
|
48
|
+
resource = props.resource,
|
|
49
|
+
action = props.action;
|
|
50
|
+
var record = useRecordContext();
|
|
51
|
+
var mutation = useAction(resource, action);
|
|
52
|
+
var refresh = useRefresh(),
|
|
53
|
+
notify = useNotify(),
|
|
54
|
+
Icon = icons[icon];
|
|
55
|
+
var onClick = function onClick() {
|
|
56
|
+
mutation.mutate({
|
|
57
|
+
record: record
|
|
58
|
+
}, {
|
|
59
|
+
onSuccess: function onSuccess(_ref3) {
|
|
60
|
+
var data = _ref3.data;
|
|
61
|
+
refresh();
|
|
62
|
+
if (data && data.redirectTo) window.location = data.redirectTo;
|
|
63
|
+
if (data && data.message) notify(data.message, {
|
|
64
|
+
type: "success"
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
onError: function onError(error) {
|
|
68
|
+
notify(typeof error === "string" ? error : error.message, {
|
|
69
|
+
type: "error"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
75
|
+
label: label,
|
|
76
|
+
title: title,
|
|
77
|
+
onClick: onClick,
|
|
78
|
+
disabled: mutation.isLoading
|
|
79
|
+
}, Icon && /*#__PURE__*/React.createElement(Icon, null));
|
|
80
|
+
};
|
|
81
|
+
export default ActionButton;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "react-admin";
|
|
3
|
+
import { Link } from "react-router-dom";
|
|
4
|
+
import * as icons from "@mui/icons-material";
|
|
5
|
+
var LinkButton = function LinkButton(_ref) {
|
|
6
|
+
var label = _ref.label,
|
|
7
|
+
icon = _ref.icon,
|
|
8
|
+
title = _ref.title,
|
|
9
|
+
resource = _ref.resource,
|
|
10
|
+
filters = _ref.filters;
|
|
11
|
+
var Icon = icons[icon] || icon;
|
|
12
|
+
var linkParams = {
|
|
13
|
+
pathname: "/".concat(resource),
|
|
14
|
+
search: filters ? "filter=".concat(JSON.stringify(filters)) : undefined
|
|
15
|
+
};
|
|
16
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
17
|
+
label: label,
|
|
18
|
+
title: title,
|
|
19
|
+
component: Link,
|
|
20
|
+
to: linkParams
|
|
21
|
+
}, Icon && /*#__PURE__*/React.createElement(Icon, null));
|
|
22
|
+
};
|
|
23
|
+
export default LinkButton;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Grid, Card, CardContent, Typography, Table, TableBody, TableRow, TableCell } from "@mui/material";
|
|
3
|
+
import { setupAdmin } from "./utils";
|
|
4
|
+
var AdminTableView = function AdminTableView(_ref) {
|
|
5
|
+
var src = _ref.src;
|
|
6
|
+
return /*#__PURE__*/React.createElement(Table, null, /*#__PURE__*/React.createElement(TableBody, null, src.map(function (row, idx) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(TableRow, {
|
|
8
|
+
key: idx,
|
|
9
|
+
hover: true
|
|
10
|
+
}, row.map(function (cell, idx) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(TableCell, {
|
|
12
|
+
key: idx
|
|
13
|
+
}, cell);
|
|
14
|
+
}));
|
|
15
|
+
})));
|
|
16
|
+
};
|
|
17
|
+
var AdminCard = function AdminCard(_ref2) {
|
|
18
|
+
var src = _ref2.src;
|
|
19
|
+
if (Array.isArray(src)) {
|
|
20
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
21
|
+
container: true,
|
|
22
|
+
item: true,
|
|
23
|
+
spacing: 2
|
|
24
|
+
}, src.map(function (card, idx) {
|
|
25
|
+
return /*#__PURE__*/React.createElement(AdminCard, {
|
|
26
|
+
key: idx,
|
|
27
|
+
src: card
|
|
28
|
+
});
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
var title = src.title,
|
|
32
|
+
value = src.value;
|
|
33
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
34
|
+
item: true,
|
|
35
|
+
xs: true
|
|
36
|
+
}, /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(Typography, {
|
|
37
|
+
variant: "h5",
|
|
38
|
+
component: "h2",
|
|
39
|
+
m: 2,
|
|
40
|
+
style: {
|
|
41
|
+
textAlign: "center"
|
|
42
|
+
}
|
|
43
|
+
}, title), Array.isArray(value) && /*#__PURE__*/React.createElement(AdminTableView, {
|
|
44
|
+
src: value
|
|
45
|
+
}) || /*#__PURE__*/React.createElement("pre", null, JSON.stringify(value, null, 2)))));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Process dashboard
|
|
49
|
+
setupAdmin("dashboard", function (props) {
|
|
50
|
+
if (!props) return;
|
|
51
|
+
var Dashboard = function Dashboard() {
|
|
52
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
53
|
+
container: true,
|
|
54
|
+
spacing: 1
|
|
55
|
+
}, /*#__PURE__*/React.createElement(AdminCard, {
|
|
56
|
+
src: props
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
return Dashboard;
|
|
60
|
+
});
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
var _excluded = ["target", "id", "filter"];
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
import { makeRequest } from "./utils";
|
|
9
|
+
export default (function (apiUrl) {
|
|
10
|
+
var methods = {
|
|
11
|
+
getList: function () {
|
|
12
|
+
var _getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resource, _ref) {
|
|
13
|
+
var filter, pagination, sort, query, page, limit, field, order, _yield$makeRequest, headers, json;
|
|
14
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
+
while (1) switch (_context.prev = _context.next) {
|
|
16
|
+
case 0:
|
|
17
|
+
filter = _ref.filter, pagination = _ref.pagination, sort = _ref.sort;
|
|
18
|
+
query = {};
|
|
19
|
+
if (filter) query.where = JSON.stringify(filter);
|
|
20
|
+
if (pagination) {
|
|
21
|
+
page = pagination.page, limit = pagination.perPage;
|
|
22
|
+
query.limit = limit;
|
|
23
|
+
query.offset = limit * (page - 1);
|
|
24
|
+
}
|
|
25
|
+
if (sort) {
|
|
26
|
+
field = sort.field, order = sort.order;
|
|
27
|
+
query.sort = order == "ASC" ? field : "-".concat(field);
|
|
28
|
+
}
|
|
29
|
+
_context.next = 7;
|
|
30
|
+
return makeRequest("".concat(apiUrl, "/").concat(resource), {
|
|
31
|
+
query: query
|
|
32
|
+
});
|
|
33
|
+
case 7:
|
|
34
|
+
_yield$makeRequest = _context.sent;
|
|
35
|
+
headers = _yield$makeRequest.headers;
|
|
36
|
+
json = _yield$makeRequest.json;
|
|
37
|
+
return _context.abrupt("return", {
|
|
38
|
+
data: json,
|
|
39
|
+
total: parseInt(headers.get("x-total"), 10)
|
|
40
|
+
});
|
|
41
|
+
case 11:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee);
|
|
46
|
+
}));
|
|
47
|
+
function getList(_x, _x2) {
|
|
48
|
+
return _getList.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
return getList;
|
|
51
|
+
}(),
|
|
52
|
+
getOne: function () {
|
|
53
|
+
var _getOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource, _ref2) {
|
|
54
|
+
var id, _yield$makeRequest2, json;
|
|
55
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
56
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
57
|
+
case 0:
|
|
58
|
+
id = _ref2.id;
|
|
59
|
+
_context2.next = 3;
|
|
60
|
+
return makeRequest("".concat(apiUrl, "/").concat(resource, "/").concat(id));
|
|
61
|
+
case 3:
|
|
62
|
+
_yield$makeRequest2 = _context2.sent;
|
|
63
|
+
json = _yield$makeRequest2.json;
|
|
64
|
+
return _context2.abrupt("return", {
|
|
65
|
+
data: json
|
|
66
|
+
});
|
|
67
|
+
case 6:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context2.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee2);
|
|
72
|
+
}));
|
|
73
|
+
function getOne(_x3, _x4) {
|
|
74
|
+
return _getOne.apply(this, arguments);
|
|
75
|
+
}
|
|
76
|
+
return getOne;
|
|
77
|
+
}(),
|
|
78
|
+
create: function () {
|
|
79
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resource, _ref3) {
|
|
80
|
+
var data, _yield$makeRequest3, json;
|
|
81
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
82
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
data = _ref3.data;
|
|
85
|
+
_context3.next = 3;
|
|
86
|
+
return makeRequest("".concat(apiUrl, "/").concat(resource), {
|
|
87
|
+
data: data,
|
|
88
|
+
method: "POST"
|
|
89
|
+
});
|
|
90
|
+
case 3:
|
|
91
|
+
_yield$makeRequest3 = _context3.sent;
|
|
92
|
+
json = _yield$makeRequest3.json;
|
|
93
|
+
return _context3.abrupt("return", {
|
|
94
|
+
data: json
|
|
95
|
+
});
|
|
96
|
+
case 6:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context3.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee3);
|
|
101
|
+
}));
|
|
102
|
+
function create(_x5, _x6) {
|
|
103
|
+
return _create.apply(this, arguments);
|
|
104
|
+
}
|
|
105
|
+
return create;
|
|
106
|
+
}(),
|
|
107
|
+
update: function () {
|
|
108
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resource, _ref4) {
|
|
109
|
+
var id, data, _yield$makeRequest4, json;
|
|
110
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
111
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
112
|
+
case 0:
|
|
113
|
+
id = _ref4.id, data = _ref4.data;
|
|
114
|
+
_context4.next = 3;
|
|
115
|
+
return makeRequest("".concat(apiUrl, "/").concat(resource, "/").concat(id), {
|
|
116
|
+
data: data,
|
|
117
|
+
method: "PUT"
|
|
118
|
+
});
|
|
119
|
+
case 3:
|
|
120
|
+
_yield$makeRequest4 = _context4.sent;
|
|
121
|
+
json = _yield$makeRequest4.json;
|
|
122
|
+
return _context4.abrupt("return", {
|
|
123
|
+
data: json
|
|
124
|
+
});
|
|
125
|
+
case 6:
|
|
126
|
+
case "end":
|
|
127
|
+
return _context4.stop();
|
|
128
|
+
}
|
|
129
|
+
}, _callee4);
|
|
130
|
+
}));
|
|
131
|
+
function update(_x7, _x8) {
|
|
132
|
+
return _update.apply(this, arguments);
|
|
133
|
+
}
|
|
134
|
+
return update;
|
|
135
|
+
}(),
|
|
136
|
+
updateMany: function () {
|
|
137
|
+
var _updateMany = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(resource, _ref5) {
|
|
138
|
+
var ids, data;
|
|
139
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
140
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
141
|
+
case 0:
|
|
142
|
+
ids = _ref5.ids, data = _ref5.data;
|
|
143
|
+
_context5.next = 3;
|
|
144
|
+
return Promise.all(ids.map(function (id) {
|
|
145
|
+
return methods.update(resource, {
|
|
146
|
+
id: id,
|
|
147
|
+
data: data
|
|
148
|
+
});
|
|
149
|
+
}));
|
|
150
|
+
case 3:
|
|
151
|
+
return _context5.abrupt("return", {
|
|
152
|
+
data: ids
|
|
153
|
+
});
|
|
154
|
+
case 4:
|
|
155
|
+
case "end":
|
|
156
|
+
return _context5.stop();
|
|
157
|
+
}
|
|
158
|
+
}, _callee5);
|
|
159
|
+
}));
|
|
160
|
+
function updateMany(_x9, _x10) {
|
|
161
|
+
return _updateMany.apply(this, arguments);
|
|
162
|
+
}
|
|
163
|
+
return updateMany;
|
|
164
|
+
}(),
|
|
165
|
+
"delete": function () {
|
|
166
|
+
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(resource, _ref6) {
|
|
167
|
+
var id;
|
|
168
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
169
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
170
|
+
case 0:
|
|
171
|
+
id = _ref6.id;
|
|
172
|
+
_context6.next = 3;
|
|
173
|
+
return makeRequest("".concat(apiUrl, "/").concat(resource, "/").concat(id), {
|
|
174
|
+
method: "DELETE"
|
|
175
|
+
});
|
|
176
|
+
case 3:
|
|
177
|
+
return _context6.abrupt("return", {
|
|
178
|
+
data: {
|
|
179
|
+
id: id
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
case 4:
|
|
183
|
+
case "end":
|
|
184
|
+
return _context6.stop();
|
|
185
|
+
}
|
|
186
|
+
}, _callee6);
|
|
187
|
+
}));
|
|
188
|
+
function _delete(_x11, _x12) {
|
|
189
|
+
return _delete2.apply(this, arguments);
|
|
190
|
+
}
|
|
191
|
+
return _delete;
|
|
192
|
+
}(),
|
|
193
|
+
deleteMany: function () {
|
|
194
|
+
var _deleteMany = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(resource, _ref7) {
|
|
195
|
+
var ids;
|
|
196
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
197
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
198
|
+
case 0:
|
|
199
|
+
ids = _ref7.ids;
|
|
200
|
+
_context7.next = 3;
|
|
201
|
+
return makeRequest("".concat(apiUrl, "/").concat(resource), {
|
|
202
|
+
data: ids,
|
|
203
|
+
method: "DELETE"
|
|
204
|
+
});
|
|
205
|
+
case 3:
|
|
206
|
+
return _context7.abrupt("return", {
|
|
207
|
+
data: ids
|
|
208
|
+
});
|
|
209
|
+
case 4:
|
|
210
|
+
case "end":
|
|
211
|
+
return _context7.stop();
|
|
212
|
+
}
|
|
213
|
+
}, _callee7);
|
|
214
|
+
}));
|
|
215
|
+
function deleteMany(_x13, _x14) {
|
|
216
|
+
return _deleteMany.apply(this, arguments);
|
|
217
|
+
}
|
|
218
|
+
return deleteMany;
|
|
219
|
+
}(),
|
|
220
|
+
getMany: function getMany(resource, _ref8) {
|
|
221
|
+
var ids = _ref8.ids;
|
|
222
|
+
return methods.getList(resource, {
|
|
223
|
+
filter: {
|
|
224
|
+
id: {
|
|
225
|
+
$in: ids
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
getManyReference: function () {
|
|
231
|
+
var _getManyReference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(resource, _ref9) {
|
|
232
|
+
var target, id, filter, opts;
|
|
233
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
234
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
235
|
+
case 0:
|
|
236
|
+
target = _ref9.target, id = _ref9.id, filter = _ref9.filter, opts = _objectWithoutProperties(_ref9, _excluded);
|
|
237
|
+
filter = filter || {};
|
|
238
|
+
filter[target] = id;
|
|
239
|
+
_context8.next = 5;
|
|
240
|
+
return methods.getList(resource, _objectSpread({
|
|
241
|
+
filter: filter
|
|
242
|
+
}, opts));
|
|
243
|
+
case 5:
|
|
244
|
+
return _context8.abrupt("return", _context8.sent);
|
|
245
|
+
case 6:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context8.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee8);
|
|
250
|
+
}));
|
|
251
|
+
function getManyReference(_x15, _x16) {
|
|
252
|
+
return _getManyReference.apply(this, arguments);
|
|
253
|
+
}
|
|
254
|
+
return getManyReference;
|
|
255
|
+
}(),
|
|
256
|
+
runAction: function () {
|
|
257
|
+
var _runAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(resource, action, props) {
|
|
258
|
+
var payload, ids, record, _yield$makeRequest5, json;
|
|
259
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
260
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
261
|
+
case 0:
|
|
262
|
+
payload = props.payload, ids = props.ids, record = props.record;
|
|
263
|
+
action = action.replace(/^\/+/, "");
|
|
264
|
+
if (record) {
|
|
265
|
+
action = action.replace(/\{([^}]+)\}/, function (_, field) {
|
|
266
|
+
return record[field];
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
_context9.next = 5;
|
|
270
|
+
return makeRequest("".concat(apiUrl, "/").concat(action), {
|
|
271
|
+
query: {
|
|
272
|
+
ids: ids
|
|
273
|
+
},
|
|
274
|
+
method: "POST",
|
|
275
|
+
data: payload
|
|
276
|
+
});
|
|
277
|
+
case 5:
|
|
278
|
+
_yield$makeRequest5 = _context9.sent;
|
|
279
|
+
json = _yield$makeRequest5.json;
|
|
280
|
+
return _context9.abrupt("return", {
|
|
281
|
+
data: json
|
|
282
|
+
});
|
|
283
|
+
case 8:
|
|
284
|
+
case "end":
|
|
285
|
+
return _context9.stop();
|
|
286
|
+
}
|
|
287
|
+
}, _callee9);
|
|
288
|
+
}));
|
|
289
|
+
function runAction(_x17, _x18, _x19) {
|
|
290
|
+
return _runAction.apply(this, arguments);
|
|
291
|
+
}
|
|
292
|
+
return runAction;
|
|
293
|
+
}()
|
|
294
|
+
};
|
|
295
|
+
return methods;
|
|
296
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["source", "alt", "style", "nameProp"];
|
|
3
|
+
import React from "react";
|
|
4
|
+
import get from "lodash/get";
|
|
5
|
+
import { useRecordContext } from "ra-core";
|
|
6
|
+
import Avatar from "@mui/material/Avatar";
|
|
7
|
+
var AvatarField = function AvatarField(_ref) {
|
|
8
|
+
var source = _ref.source,
|
|
9
|
+
alt = _ref.alt,
|
|
10
|
+
style = _ref.style,
|
|
11
|
+
nameProp = _ref.nameProp,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
var record = useRecordContext(props);
|
|
14
|
+
var value = get(record, source),
|
|
15
|
+
name = record[nameProp];
|
|
16
|
+
var letters = name ? name.trim(" ").split(/\s+/).slice(0, 2).map(function (n) {
|
|
17
|
+
return n[0].toUpperCase();
|
|
18
|
+
}).join("") : "";
|
|
19
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
20
|
+
src: value,
|
|
21
|
+
alt: alt,
|
|
22
|
+
style: style
|
|
23
|
+
}, letters);
|
|
24
|
+
};
|
|
25
|
+
AvatarField.displayName = "AvatarField";
|
|
26
|
+
AvatarField.defaultProps = {
|
|
27
|
+
addLabel: true
|
|
28
|
+
};
|
|
29
|
+
export default AvatarField;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["refSource", "refID", "link", "reference", "source"];
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { ReferenceField, TextField } from "react-admin";
|
|
6
|
+
var FKField = function FKField(_ref) {
|
|
7
|
+
var refSource = _ref.refSource,
|
|
8
|
+
refID = _ref.refID,
|
|
9
|
+
link = _ref.link,
|
|
10
|
+
reference = _ref.reference,
|
|
11
|
+
source = _ref.source,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
return /*#__PURE__*/React.createElement(ReferenceField, _extends({
|
|
14
|
+
link: link || "show",
|
|
15
|
+
reference: reference,
|
|
16
|
+
source: source
|
|
17
|
+
}, props), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, {
|
|
18
|
+
source: refSource
|
|
19
|
+
}), " (#", /*#__PURE__*/React.createElement(TextField, {
|
|
20
|
+
source: refID || "id"
|
|
21
|
+
}), ")"));
|
|
22
|
+
};
|
|
23
|
+
FKField.displayName = "FKField";
|
|
24
|
+
FKField.defaultProps = {
|
|
25
|
+
addLabel: true
|
|
26
|
+
};
|
|
27
|
+
export default FKField;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import get from "lodash/get";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import { Button, FunctionField, useRecordContext } from "react-admin";
|
|
5
|
+
export default function JsonField(_ref) {
|
|
6
|
+
var label = _ref.label,
|
|
7
|
+
source = _ref.source;
|
|
8
|
+
var _useState = useState(false),
|
|
9
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10
|
+
expand = _useState2[0],
|
|
11
|
+
setExpand = _useState2[1];
|
|
12
|
+
var record = useRecordContext();
|
|
13
|
+
var src = JSON.stringify(get(record, source), null, 2);
|
|
14
|
+
var retval = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null), label, /*#__PURE__*/React.createElement(Button, {
|
|
15
|
+
variant: "contained",
|
|
16
|
+
color: "primary",
|
|
17
|
+
size: "small",
|
|
18
|
+
label: expand ? "colapse" : "expand",
|
|
19
|
+
onClick: function onClick() {
|
|
20
|
+
return setExpand(!expand);
|
|
21
|
+
}
|
|
22
|
+
}), /*#__PURE__*/React.createElement("p", null, expand && /*#__PURE__*/React.createElement("pre", null, src)));
|
|
23
|
+
return /*#__PURE__*/React.createElement(FunctionField, {
|
|
24
|
+
render: function render() {
|
|
25
|
+
return retval;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDataProvider } from "react-admin";
|
|
2
|
+
import { useMutation } from "react-query";
|
|
3
|
+
export default function useAction(resource, action) {
|
|
4
|
+
var dataProvider = useDataProvider();
|
|
5
|
+
return useMutation(function (params) {
|
|
6
|
+
return dataProvider.runAction(resource, action, params);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import "./admin";
|
|
5
|
+
import { processAdmin } from "./utils";
|
|
6
|
+
export * from "./utils";
|
|
7
|
+
export function initAdmin() {
|
|
8
|
+
return _initAdmin.apply(this, arguments);
|
|
9
|
+
}
|
|
10
|
+
function _initAdmin() {
|
|
11
|
+
_initAdmin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
12
|
+
var prefix,
|
|
13
|
+
response,
|
|
14
|
+
props,
|
|
15
|
+
container,
|
|
16
|
+
root,
|
|
17
|
+
_args = arguments;
|
|
18
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
prefix = _args.length > 0 && _args[0] !== undefined ? _args[0] : "";
|
|
22
|
+
_context.next = 3;
|
|
23
|
+
return fetch("".concat(prefix, "/ra.json"));
|
|
24
|
+
case 3:
|
|
25
|
+
response = _context.sent;
|
|
26
|
+
_context.next = 6;
|
|
27
|
+
return response.json();
|
|
28
|
+
case 6:
|
|
29
|
+
props = _context.sent;
|
|
30
|
+
container = document.getElementById("root");
|
|
31
|
+
root = createRoot(container);
|
|
32
|
+
root.render(processAdmin("admin", props));
|
|
33
|
+
case 10:
|
|
34
|
+
case "end":
|
|
35
|
+
return _context.stop();
|
|
36
|
+
}
|
|
37
|
+
}, _callee);
|
|
38
|
+
}));
|
|
39
|
+
return _initAdmin.apply(this, arguments);
|
|
40
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["refProp", "refSource", "fullWidth", "reference", "source"];
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { ReferenceInput, AutocompleteInput } from "react-admin";
|
|
6
|
+
var FKInput = function FKInput(_ref) {
|
|
7
|
+
var refProp = _ref.refProp,
|
|
8
|
+
refSource = _ref.refSource,
|
|
9
|
+
fullWidth = _ref.fullWidth,
|
|
10
|
+
reference = _ref.reference,
|
|
11
|
+
source = _ref.source,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
var filterToQuery = function filterToQuery(search) {
|
|
14
|
+
var filters = {};
|
|
15
|
+
filters[refProp] = search;
|
|
16
|
+
return filters;
|
|
17
|
+
};
|
|
18
|
+
refSource = refSource || "id";
|
|
19
|
+
var renderText = function renderText(record) {
|
|
20
|
+
var pk = record[refSource];
|
|
21
|
+
return pk && "".concat(record[refProp], " (#").concat(pk, ")") || "";
|
|
22
|
+
};
|
|
23
|
+
return /*#__PURE__*/React.createElement(ReferenceInput, _extends({
|
|
24
|
+
reference: reference,
|
|
25
|
+
source: source,
|
|
26
|
+
filterToQuery: filterToQuery
|
|
27
|
+
}, props), /*#__PURE__*/React.createElement(AutocompleteInput, {
|
|
28
|
+
source: refSource,
|
|
29
|
+
optionText: renderText,
|
|
30
|
+
fullWidth: fullWidth
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
export default FKInput;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["validate", "errortext", "multiline", "parse"];
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { TextInput } from "react-admin";
|
|
6
|
+
import isJSON from "validator/lib/isJSON";
|
|
7
|
+
var DEFAULT_ERRORTEXT = "Invalid JSON";
|
|
8
|
+
var parseFunction = function parseFunction(json) {
|
|
9
|
+
var retval = json;
|
|
10
|
+
try {
|
|
11
|
+
retval = JSON.parse(json);
|
|
12
|
+
} finally {
|
|
13
|
+
return retval;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* `JsonInput` validates if the entered value is JSON or not. If entered value is not a invalid JSON, `JsonInput` will throw an error.
|
|
20
|
+
* Default error message is: `Invalid JSON` and can be overridden using `errortext` prop.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <JsonInput source='config' label='JSON Config' errortext='Enter a valid JSON'/>
|
|
24
|
+
*
|
|
25
|
+
* or use translate function:
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <JsonInput source='config' label={translate('resources.resource_name.fields.config')} errortext={translate('myroot.validate.json')}/>
|
|
29
|
+
*
|
|
30
|
+
* By default, `JsonInput` parses and returns the entered string as object. Instead, to send string directly, please pass `parse` prop as `false`
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <JsonInput source='config' label='JSON Config' parse={false}/>
|
|
34
|
+
*/
|
|
35
|
+
export default function JsonInput(props) {
|
|
36
|
+
var _props$validate = props.validate,
|
|
37
|
+
validate = _props$validate === void 0 ? [] : _props$validate,
|
|
38
|
+
_props$errortext = props.errortext,
|
|
39
|
+
errortext = _props$errortext === void 0 ? DEFAULT_ERRORTEXT : _props$errortext,
|
|
40
|
+
_props$multiline = props.multiline,
|
|
41
|
+
multiline = _props$multiline === void 0 ? true : _props$multiline,
|
|
42
|
+
_props$parse = props.parse,
|
|
43
|
+
parse = _props$parse === void 0 ? true : _props$parse,
|
|
44
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
45
|
+
// const errorobj = { message: errortext }
|
|
46
|
+
|
|
47
|
+
var validateJSON = function validateJSON(value) {
|
|
48
|
+
if (!value || _typeof(value) === "object") return undefined;
|
|
49
|
+
return isJSON(value) ? undefined : errortext;
|
|
50
|
+
};
|
|
51
|
+
validate.push(validateJSON);
|
|
52
|
+
rest.validate = validate;
|
|
53
|
+
var formatJSON = function formatJSON(json) {
|
|
54
|
+
var retval = json;
|
|
55
|
+
if (retval && _typeof(retval) === "object") retval = JSON.stringify(retval, null, 2);
|
|
56
|
+
return retval;
|
|
57
|
+
};
|
|
58
|
+
rest.format = formatJSON;
|
|
59
|
+
//
|
|
60
|
+
if (parse) rest.parse = parseFunction;
|
|
61
|
+
if (multiline) rest.multiline = true;
|
|
62
|
+
return /*#__PURE__*/React.createElement(TextInput, rest);
|
|
63
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["create", "edit", "icon", "list", "name", "show"];
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Resource } from "react-admin";
|
|
6
|
+
import * as icons from "@mui/icons-material";
|
|
7
|
+
import { checkParams, processAdmin, setupAdmin } from "./utils";
|
|
8
|
+
import "./views/list";
|
|
9
|
+
import "./views/show";
|
|
10
|
+
import "./views/edit";
|
|
11
|
+
import "./views/create";
|
|
12
|
+
|
|
13
|
+
// Initialize Resources Components
|
|
14
|
+
setupAdmin("resources", function (resources) {
|
|
15
|
+
return resources.map(function (res) {
|
|
16
|
+
return processAdmin("resource", res, res.name);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Initialize a resource's component
|
|
21
|
+
setupAdmin("resource", checkParams(function (props, res) {
|
|
22
|
+
var create = props.create,
|
|
23
|
+
edit = props.edit,
|
|
24
|
+
icon = props.icon,
|
|
25
|
+
list = props.list,
|
|
26
|
+
name = props.name,
|
|
27
|
+
show = props.show,
|
|
28
|
+
resProps = _objectWithoutProperties(props, _excluded);
|
|
29
|
+
return /*#__PURE__*/React.createElement(Resource, _extends({
|
|
30
|
+
key: name,
|
|
31
|
+
name: name,
|
|
32
|
+
icon: icons[icon],
|
|
33
|
+
create: processAdmin("create", create, res),
|
|
34
|
+
edit: processAdmin("edit", edit, res),
|
|
35
|
+
list: processAdmin("list", list, res),
|
|
36
|
+
show: processAdmin("show", show, res)
|
|
37
|
+
}, resProps));
|
|
38
|
+
}));
|
package/dist/esm/ui.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { required } from "react-admin";
|
|
7
|
+
import { BooleanField, ChipField, DateField, EmailField, ImageField, FileField, NumberField, RichTextField, TextField, UrlField, SelectField, ArrayField, ReferenceField, ReferenceManyField, ReferenceArrayField } from "react-admin";
|
|
8
|
+
import { BooleanInput, NullableBooleanInput, DateInput, DateTimeInput, ImageInput, FileInput, NumberInput, PasswordInput, TextInput, AutocompleteInput, RadioButtonGroupInput, SelectInput, ArrayInput, AutocompleteArrayInput, CheckboxGroupInput, ReferenceArrayInput, ReferenceInput } from "react-admin";
|
|
9
|
+
import AvatarField from "./fields/AvatarField";
|
|
10
|
+
import FKField from "./fields/FKField";
|
|
11
|
+
import FKInput from "./inputs/FKInput";
|
|
12
|
+
import JsonField from "./fields/JsonField";
|
|
13
|
+
import JsonInput from "./inputs/JsonInput";
|
|
14
|
+
var ui = {
|
|
15
|
+
// Fields
|
|
16
|
+
BooleanField: BooleanField,
|
|
17
|
+
ChipField: ChipField,
|
|
18
|
+
DateField: DateField,
|
|
19
|
+
EmailField: EmailField,
|
|
20
|
+
ImageField: ImageField,
|
|
21
|
+
FileField: FileField,
|
|
22
|
+
NumberField: NumberField,
|
|
23
|
+
RichTextField: RichTextField,
|
|
24
|
+
TextField: TextField,
|
|
25
|
+
UrlField: UrlField,
|
|
26
|
+
SelectField: SelectField,
|
|
27
|
+
ArrayField: ArrayField,
|
|
28
|
+
ReferenceField: ReferenceField,
|
|
29
|
+
ReferenceManyField: ReferenceManyField,
|
|
30
|
+
ReferenceArrayField: ReferenceArrayField,
|
|
31
|
+
AvatarField: AvatarField,
|
|
32
|
+
JsonField: JsonField,
|
|
33
|
+
FKField: FKField,
|
|
34
|
+
// Inputs
|
|
35
|
+
BooleanInput: BooleanInput,
|
|
36
|
+
NullableBooleanInput: NullableBooleanInput,
|
|
37
|
+
DateInput: DateInput,
|
|
38
|
+
DateTimeInput: DateTimeInput,
|
|
39
|
+
ImageInput: ImageInput,
|
|
40
|
+
FileInput: FileInput,
|
|
41
|
+
NumberInput: NumberInput,
|
|
42
|
+
PasswordInput: PasswordInput,
|
|
43
|
+
TextInput: TextInput,
|
|
44
|
+
AutocompleteInput: AutocompleteInput,
|
|
45
|
+
RadioButtonGroupInput: RadioButtonGroupInput,
|
|
46
|
+
SelectInput: SelectInput,
|
|
47
|
+
ArrayInput: ArrayInput,
|
|
48
|
+
AutocompleteArrayInput: AutocompleteArrayInput,
|
|
49
|
+
CheckboxGroupInput: CheckboxGroupInput,
|
|
50
|
+
ReferenceArrayInput: ReferenceArrayInput,
|
|
51
|
+
ReferenceInput: ReferenceInput,
|
|
52
|
+
JsonInput: JsonInput,
|
|
53
|
+
FKInput: FKInput
|
|
54
|
+
};
|
|
55
|
+
var initRAItems = function initRAItems(itemsProps) {
|
|
56
|
+
return itemsProps.map(function (item) {
|
|
57
|
+
var _props$fullWidth;
|
|
58
|
+
var Item = ui[item[0]],
|
|
59
|
+
props = _objectSpread({}, item[1]);
|
|
60
|
+
if (props.required) {
|
|
61
|
+
props.validate = required();
|
|
62
|
+
delete props.required;
|
|
63
|
+
}
|
|
64
|
+
props.fullWidth = (_props$fullWidth = props.fullWidth) !== null && _props$fullWidth !== void 0 ? _props$fullWidth : true;
|
|
65
|
+
if (props.children) props.children = initRAItems(props.children)[0];
|
|
66
|
+
return /*#__PURE__*/React.createElement(Item, _extends({
|
|
67
|
+
key: props.source
|
|
68
|
+
}, props));
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export default initRAItems;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["data", "query"];
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
/* eslint-disable no-console */
|
|
7
|
+
|
|
8
|
+
import { isValidElement } from "react";
|
|
9
|
+
import { fetchUtils } from "ra-core";
|
|
10
|
+
import { stringify } from "query-string";
|
|
11
|
+
var parts = {};
|
|
12
|
+
export var setupAdmin = function setupAdmin(part, gen) {
|
|
13
|
+
return parts[part] = gen;
|
|
14
|
+
};
|
|
15
|
+
export var checkParams = function checkParams(fn) {
|
|
16
|
+
return function (props, res) {
|
|
17
|
+
if (!props || /*#__PURE__*/isValidElement(props)) return props;
|
|
18
|
+
return fn(props, res);
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export var processAdmin = function processAdmin(type, props, res) {
|
|
22
|
+
if (process.env.NODE_ENV == "development") console.log("".concat(type).concat(res ? "-" + res : ""), props);
|
|
23
|
+
if (parts["".concat(type, "-").concat(res)]) return parts["".concat(type, "-").concat(res)](props, res);
|
|
24
|
+
if (parts[type]) return parts[type](props, res);
|
|
25
|
+
};
|
|
26
|
+
export var requestHeaders = {};
|
|
27
|
+
export var makeRequest = function makeRequest(url, params) {
|
|
28
|
+
var _ref = params || {},
|
|
29
|
+
data = _ref.data,
|
|
30
|
+
query = _ref.query,
|
|
31
|
+
opts = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
if (data) opts.body = JSON.stringify(data);
|
|
33
|
+
if (query) url = "".concat(url, "?").concat(stringify(query));
|
|
34
|
+
opts = _objectSpread(_objectSpread({}, opts), {}, {
|
|
35
|
+
headers: new Headers(_objectSpread(_objectSpread({}, requestHeaders), opts.headers))
|
|
36
|
+
});
|
|
37
|
+
return fetchUtils.fetchJson(url, opts);
|
|
38
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Create, SimpleForm, TopToolbar, ListButton } from "react-admin";
|
|
4
|
+
import initRAItems from "../ui";
|
|
5
|
+
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
6
|
+
|
|
7
|
+
// Initialize a create component
|
|
8
|
+
setupAdmin("create", checkParams(function (inputs, res) {
|
|
9
|
+
return function MACreate(props) {
|
|
10
|
+
var Actions = /*#__PURE__*/React.createElement(TopToolbar, null, /*#__PURE__*/React.createElement(ListButton, null));
|
|
11
|
+
return /*#__PURE__*/React.createElement(Create, _extends({
|
|
12
|
+
actions: Actions
|
|
13
|
+
}, props), /*#__PURE__*/React.createElement(SimpleForm, null, processAdmin("create-inputs", inputs, res)));
|
|
14
|
+
};
|
|
15
|
+
}));
|
|
16
|
+
setupAdmin("create-inputs", initRAItems);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["basePath", "resource"];
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { Edit, ListButton, ShowButton, SimpleForm, TopToolbar } from "react-admin";
|
|
9
|
+
import initRAItems from "../ui";
|
|
10
|
+
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
11
|
+
import { ActionButton } from "../buttons/ActionButton";
|
|
12
|
+
|
|
13
|
+
// Initialize an edit component
|
|
14
|
+
setupAdmin("edit", checkParams(function (_ref, res) {
|
|
15
|
+
var actions = _ref.actions,
|
|
16
|
+
inputs = _ref.inputs;
|
|
17
|
+
return function MAEdit(props) {
|
|
18
|
+
var Actions = function Actions(_ref2) {
|
|
19
|
+
var basePath = _ref2.basePath,
|
|
20
|
+
resource = _ref2.resource,
|
|
21
|
+
baseProps = _objectWithoutProperties(_ref2, _excluded);
|
|
22
|
+
return /*#__PURE__*/React.createElement(TopToolbar, null, actions.map(function (props, idx) {
|
|
23
|
+
var aProps = _objectSpread(_objectSpread({
|
|
24
|
+
resource: resource,
|
|
25
|
+
basePath: basePath
|
|
26
|
+
}, baseProps), props);
|
|
27
|
+
return /*#__PURE__*/React.createElement(ActionButton, _extends({
|
|
28
|
+
key: idx
|
|
29
|
+
}, aProps));
|
|
30
|
+
}), /*#__PURE__*/React.createElement(ListButton, null), /*#__PURE__*/React.createElement(ShowButton, null));
|
|
31
|
+
};
|
|
32
|
+
return /*#__PURE__*/React.createElement(Edit, _extends({
|
|
33
|
+
actions: /*#__PURE__*/React.createElement(Actions, null)
|
|
34
|
+
}, props), /*#__PURE__*/React.createElement(SimpleForm, null, processAdmin("edit-inputs", inputs, res)));
|
|
35
|
+
};
|
|
36
|
+
}));
|
|
37
|
+
setupAdmin("edit-inputs", initRAItems);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["children", "filters", "edit", "pagination", "show", "limit", "limitMax", "actions"];
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { BulkDeleteButton, Datagrid, EditButton, Filter, List, Pagination } from "react-admin";
|
|
9
|
+
import uniq from "lodash/uniq";
|
|
10
|
+
import sortBy from "lodash/sortBy";
|
|
11
|
+
import initRAItems from "../ui";
|
|
12
|
+
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
13
|
+
import { BulkActionButton } from "../buttons/ActionButton";
|
|
14
|
+
var defaultPagination = /*#__PURE__*/React.createElement(Pagination, {
|
|
15
|
+
rowsPerPageOptions: [10, 25, 50, 100]
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Initiliaze a list component
|
|
19
|
+
setupAdmin("list", checkParams(function (props, res) {
|
|
20
|
+
var children = props.children,
|
|
21
|
+
filters = props.filters,
|
|
22
|
+
edit = props.edit,
|
|
23
|
+
pagination = props.pagination,
|
|
24
|
+
show = props.show,
|
|
25
|
+
limit = props.limit,
|
|
26
|
+
limitMax = props.limitMax,
|
|
27
|
+
actions = props.actions,
|
|
28
|
+
listProps = _objectWithoutProperties(props, _excluded);
|
|
29
|
+
children = processAdmin("list-fields", children, res);
|
|
30
|
+
if (edit) children.push( /*#__PURE__*/React.createElement(EditButton, {
|
|
31
|
+
key: "edit-button"
|
|
32
|
+
}));
|
|
33
|
+
pagination = pagination || /*#__PURE__*/React.createElement(Pagination, {
|
|
34
|
+
rowsPerPageOptions: sortBy(uniq([10, 25, 50, 100, limit, limitMax]))
|
|
35
|
+
});
|
|
36
|
+
return function MAList(props) {
|
|
37
|
+
var Filters = function Filters(props) {
|
|
38
|
+
return /*#__PURE__*/React.createElement(Filter, props, processAdmin("list-filters", filters, res));
|
|
39
|
+
};
|
|
40
|
+
var Actions = processAdmin("list-bulkActions", actions);
|
|
41
|
+
props = _objectSpread(_objectSpread({}, props), listProps);
|
|
42
|
+
return /*#__PURE__*/React.createElement(List, _extends({
|
|
43
|
+
filters: /*#__PURE__*/React.createElement(Filters, null),
|
|
44
|
+
bulkActionButtons: /*#__PURE__*/React.createElement(Actions, null),
|
|
45
|
+
perPage: limit,
|
|
46
|
+
pagination: pagination || defaultPagination
|
|
47
|
+
}, props), /*#__PURE__*/React.createElement(Datagrid, {
|
|
48
|
+
rowClick: show ? "show" : null
|
|
49
|
+
}, children));
|
|
50
|
+
};
|
|
51
|
+
}));
|
|
52
|
+
setupAdmin("list-bulkActions", function (actions) {
|
|
53
|
+
return function MABulkActions(props) {
|
|
54
|
+
var buttons = actions.map(function (action, idx) {
|
|
55
|
+
var aProps = _objectSpread(_objectSpread({}, action), props);
|
|
56
|
+
return /*#__PURE__*/React.createElement(BulkActionButton, _extends({
|
|
57
|
+
key: idx
|
|
58
|
+
}, aProps));
|
|
59
|
+
});
|
|
60
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, buttons, /*#__PURE__*/React.createElement(BulkDeleteButton, props));
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
setupAdmin("list-filters", initRAItems);
|
|
64
|
+
setupAdmin("list-fields", initRAItems);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ListButton, EditButton, Show, SimpleShowLayout, TopToolbar } from "react-admin";
|
|
4
|
+
import initRAItems from "../ui";
|
|
5
|
+
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
6
|
+
import { ActionButton } from "../buttons/ActionButton";
|
|
7
|
+
|
|
8
|
+
// Initiliaze a show component
|
|
9
|
+
setupAdmin("show", checkParams(function (_ref, resource) {
|
|
10
|
+
var actions = _ref.actions,
|
|
11
|
+
fields = _ref.fields;
|
|
12
|
+
return function MAShow(props) {
|
|
13
|
+
var Actions = function Actions() {
|
|
14
|
+
return /*#__PURE__*/React.createElement(TopToolbar, null, actions.map(function (props, idx) {
|
|
15
|
+
return /*#__PURE__*/React.createElement(ActionButton, _extends({
|
|
16
|
+
key: idx,
|
|
17
|
+
resource: resource
|
|
18
|
+
}, props));
|
|
19
|
+
}), /*#__PURE__*/React.createElement(ListButton, null), /*#__PURE__*/React.createElement(EditButton, null));
|
|
20
|
+
};
|
|
21
|
+
return /*#__PURE__*/React.createElement(Show, _extends({
|
|
22
|
+
actions: /*#__PURE__*/React.createElement(Actions, null)
|
|
23
|
+
}, props), /*#__PURE__*/React.createElement(SimpleShowLayout, null, processAdmin("show-fields", fields, resource)));
|
|
24
|
+
};
|
|
25
|
+
}));
|
|
26
|
+
setupAdmin("show-fields", initRAItems);
|
package/dist/esm/web.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muffin-admin",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.7",
|
|
4
4
|
"description": "NPM package for https://github.com/klen/muffin-admin",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"js-cookie": "^3.0.1",
|
|
26
26
|
"react": "^18.2.0",
|
|
27
|
-
"react-admin": "^4.
|
|
27
|
+
"react-admin": "^4.8.1",
|
|
28
28
|
"react-dom": "^18.2.0",
|
|
29
29
|
"validator": "^13.7.0"
|
|
30
30
|
},
|