react-admin-base-bootstrap 0.9.19 → 0.9.22
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,8 +144,7 @@ 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],
|
|
148
|
-
children[4]),
|
|
147
|
+
children[3]),
|
|
149
148
|
data === null ? React.createElement(Alert, { className: "text-center mb-0 mx-3 ", color: "warning" },
|
|
150
149
|
React.createElement("i", { className: "fas fa-spinner fa-spin" })) : !data.length ? React.createElement(Alert, { className: "text-center mx-3", color: "danger" },
|
|
151
150
|
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 {
|
|
22
|
+
import { 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,16 +113,21 @@ 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
|
-
|
|
117
|
-
return React.createElement(Component, Object.assign({}, props, { id: id, onReload: update }));
|
|
116
|
+
return React.createElement(Component, Object.assign({}, props, { id: id }));
|
|
118
117
|
}
|
|
119
118
|
export default function CRUD(props) {
|
|
120
119
|
const ref = useRef(null);
|
|
121
120
|
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]);
|
|
122
128
|
return React.createElement(UrlContext.Provider, { value: url },
|
|
123
|
-
React.createElement(
|
|
124
|
-
|
|
125
|
-
React.createElement(
|
|
126
|
-
|
|
127
|
-
React.createElement(Route, { path: ":id/edit", element: React.createElement(ComponentWrapper, Object.assign({ Component: Component, url: url }, (defaultParams || {}))) }))));
|
|
129
|
+
React.createElement(Routes, null,
|
|
130
|
+
!noAdd && React.createElement(Route, { path: "create", element: React.createElement(ComponentWrapper, Object.assign({ Component: Component, url: url, onReload: reload }, (defaultParams || {}))) }),
|
|
131
|
+
React.createElement(Route, { path: ":id/edit", element: React.createElement(ComponentWrapper, Object.assign({ Component: Component, url: url, onReload: reload }, (defaultParams || {}))) })),
|
|
132
|
+
React.createElement(BootstrapDataTable, Object.assign({ innerRef: ref, add: (!noAdd && "create") || undefined }, props, { url: apiUrl || url }), props.children));
|
|
128
133
|
}
|
package/package.json
CHANGED
|
@@ -189,7 +189,6 @@ export default function BootstrapTable({url, bordered, noStrip, defaultParams, a
|
|
|
189
189
|
</Col>}
|
|
190
190
|
</Row>
|
|
191
191
|
{children[3]}
|
|
192
|
-
{children[4]}
|
|
193
192
|
</CardHeader>
|
|
194
193
|
{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">
|
|
195
194
|
<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 {
|
|
2
|
+
import { 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,8 +130,7 @@ export function CRUDActions({ id, edit, del, children }: CrudActionProps) {
|
|
|
130
130
|
|
|
131
131
|
function ComponentWrapper({ Component, ...props }) {
|
|
132
132
|
const { id } = useParams();
|
|
133
|
-
|
|
134
|
-
return <Component {...props} id={id} onReload={update} />;
|
|
133
|
+
return <Component {...props} id={id} />;
|
|
135
134
|
}
|
|
136
135
|
|
|
137
136
|
interface CRUDProps extends BootstrapTableProps {
|
|
@@ -144,13 +143,19 @@ export default function CRUD(props: CRUDProps) {
|
|
|
144
143
|
const ref = useRef(null as any);
|
|
145
144
|
const { url, apiUrl, Component, defaultParams, noAdd } = props;
|
|
146
145
|
|
|
146
|
+
const reload = useCallback(async function() {
|
|
147
|
+
if (ref.current) {
|
|
148
|
+
ref.current({});
|
|
149
|
+
}
|
|
150
|
+
}, [ref]);
|
|
151
|
+
|
|
147
152
|
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>
|
|
148
157
|
<BootstrapDataTable innerRef={ref} add={(!noAdd && "create") || undefined} {...props} url={apiUrl || url}>
|
|
149
158
|
{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>
|
|
154
159
|
</BootstrapDataTable>
|
|
155
160
|
</UrlContext.Provider>;
|
|
156
161
|
}
|