react-admin-base-bootstrap 0.9.17 → 0.9.19
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.
|
@@ -144,7 +144,8 @@ export default function BootstrapTable({ url, bordered, noStrip, defaultParams,
|
|
|
144
144
|
children[2],
|
|
145
145
|
!noSearch && React.createElement(Col, { md: "3", className: "ms-auto" },
|
|
146
146
|
React.createElement(Input, { placeholder: intl.formatMessage({ id: "SEARCH" }), type: "text", value: params.query || '', onChange: e => setParams(Object.assign(Object.assign({}, params), { query: e.currentTarget.value })) }))),
|
|
147
|
-
children[3]
|
|
147
|
+
children[3],
|
|
148
|
+
children[4]),
|
|
148
149
|
data === null ? React.createElement(Alert, { className: "text-center mb-0 mx-3 ", color: "warning" },
|
|
149
150
|
React.createElement("i", { className: "fas fa-spinner fa-spin" })) : !data.length ? React.createElement(Alert, { className: "text-center mx-3", color: "danger" },
|
|
150
151
|
React.createElement("i", { className: "far fa-times-circle" }),
|
|
@@ -19,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
21
|
import React, { useCallback, useContext, useRef, useState } from 'react';
|
|
22
|
-
import { ValidatorProvider } from "react-admin-base";
|
|
22
|
+
import { useRefresh, ValidatorProvider } from "react-admin-base";
|
|
23
23
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
24
24
|
import { Navigate, Routes, useParams, Route } from 'react-router-dom';
|
|
25
25
|
import { Alert, Button, Col, Form, ModalFooter, ModalHeader, Row } from "reactstrap";
|
|
@@ -113,21 +113,16 @@ export function CRUDActions({ id, edit, del, children }) {
|
|
|
113
113
|
function ComponentWrapper(_a) {
|
|
114
114
|
var { Component } = _a, props = __rest(_a, ["Component"]);
|
|
115
115
|
const { id } = useParams();
|
|
116
|
-
|
|
116
|
+
const update = useRefresh();
|
|
117
|
+
return React.createElement(Component, Object.assign({}, props, { id: id, onReload: update }));
|
|
117
118
|
}
|
|
118
119
|
export default function CRUD(props) {
|
|
119
120
|
const ref = useRef(null);
|
|
120
121
|
const { url, apiUrl, Component, defaultParams, noAdd } = props;
|
|
121
|
-
const reload = useCallback(function () {
|
|
122
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
if (ref.current) {
|
|
124
|
-
ref.current({});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}, [ref]);
|
|
128
122
|
return React.createElement(UrlContext.Provider, { value: url },
|
|
129
|
-
React.createElement(
|
|
130
|
-
|
|
131
|
-
React.createElement(
|
|
132
|
-
|
|
123
|
+
React.createElement(BootstrapDataTable, Object.assign({ innerRef: ref, add: (!noAdd && "create") || undefined }, props, { url: apiUrl || url }),
|
|
124
|
+
props.children,
|
|
125
|
+
React.createElement(Routes, null,
|
|
126
|
+
!noAdd && React.createElement(Route, { path: "create", element: React.createElement(ComponentWrapper, Object.assign({ Component: Component, url: url }, (defaultParams || {}))) }),
|
|
127
|
+
React.createElement(Route, { path: ":id/edit", element: React.createElement(ComponentWrapper, Object.assign({ Component: Component, url: url }, (defaultParams || {}))) }))));
|
|
133
128
|
}
|
package/package.json
CHANGED
|
@@ -189,6 +189,7 @@ export default function BootstrapTable({url, bordered, noStrip, defaultParams, a
|
|
|
189
189
|
</Col>}
|
|
190
190
|
</Row>
|
|
191
191
|
{children[3]}
|
|
192
|
+
{children[4]}
|
|
192
193
|
</CardHeader>
|
|
193
194
|
{data === null ? <Alert className="text-center mb-0 mx-3 " color="warning"><i className="fas fa-spinner fa-spin"></i></Alert> : !data.length ? <Alert className="text-center mx-3" color="danger">
|
|
194
195
|
<i className="far fa-times-circle"></i> <FormattedMessage id="NO_DATA_IS_AVAILABLE"/>
|
package/src/Components/CRUD.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useRef, useState } from 'react';
|
|
2
|
-
import { ValidatorProvider } from "react-admin-base";
|
|
2
|
+
import { useRefresh, ValidatorProvider } from "react-admin-base";
|
|
3
3
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
4
4
|
import { Navigate, Routes, useParams, Route } from 'react-router-dom';
|
|
5
5
|
import { Alert, Button, Col, Form, Modal, ModalFooter, ModalHeader, Row } from "reactstrap";
|
|
@@ -130,7 +130,8 @@ export function CRUDActions({ id, edit, del, children }: CrudActionProps) {
|
|
|
130
130
|
|
|
131
131
|
function ComponentWrapper({ Component, ...props }) {
|
|
132
132
|
const { id } = useParams();
|
|
133
|
-
|
|
133
|
+
const update = useRefresh();
|
|
134
|
+
return <Component {...props} id={id} onReload={update} />;
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
interface CRUDProps extends BootstrapTableProps {
|
|
@@ -143,19 +144,13 @@ export default function CRUD(props: CRUDProps) {
|
|
|
143
144
|
const ref = useRef(null as any);
|
|
144
145
|
const { url, apiUrl, Component, defaultParams, noAdd } = props;
|
|
145
146
|
|
|
146
|
-
const reload = useCallback(async function() {
|
|
147
|
-
if (ref.current) {
|
|
148
|
-
ref.current({});
|
|
149
|
-
}
|
|
150
|
-
}, [ref]);
|
|
151
|
-
|
|
152
147
|
return <UrlContext.Provider value={url}>
|
|
153
|
-
<Routes>
|
|
154
|
-
{ !noAdd && <Route path="create" element={<ComponentWrapper Component={Component} url={url} onReload={reload} {...(defaultParams || {})} />} /> }
|
|
155
|
-
<Route path=":id/edit" element={<ComponentWrapper Component={Component} url={url} onReload={reload} {...(defaultParams || {})} />} />
|
|
156
|
-
</Routes>
|
|
157
148
|
<BootstrapDataTable innerRef={ref} add={(!noAdd && "create") || undefined} {...props} url={apiUrl || url}>
|
|
158
149
|
{props.children}
|
|
150
|
+
<Routes>
|
|
151
|
+
{ !noAdd && <Route path="create" element={<ComponentWrapper Component={Component} url={url} {...(defaultParams || {})} />} /> }
|
|
152
|
+
<Route path=":id/edit" element={<ComponentWrapper Component={Component} url={url} {...(defaultParams || {})} />} />
|
|
153
|
+
</Routes>
|
|
159
154
|
</BootstrapDataTable>
|
|
160
155
|
</UrlContext.Provider>;
|
|
161
156
|
}
|