@steroidsjs/core 2.2.71 → 2.2.72
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/package.json +1 -1
- package/ui/crud/Crud/Crud.d.ts +2 -0
- package/ui/crud/Crud/Crud.js +2 -1
- package/ui/crud/Crud/utils.js +12 -5
package/package.json
CHANGED
package/ui/crud/Crud/Crud.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export interface ICrudClickProps {
|
|
|
34
34
|
record?: Record<string, unknown>;
|
|
35
35
|
components: IComponents;
|
|
36
36
|
goToAction: (nextAction: string) => any;
|
|
37
|
+
errorHandler?: (error: any, dispatch: any) => void;
|
|
37
38
|
}
|
|
38
39
|
export interface ICrudProps {
|
|
39
40
|
crudId?: string;
|
|
@@ -56,6 +57,7 @@ export interface ICrudProps {
|
|
|
56
57
|
form?: IFormProps | React.ReactNode;
|
|
57
58
|
detail?: any;
|
|
58
59
|
crudView?: CustomView;
|
|
60
|
+
errorHandler?: (error: any, dispatch: any) => void;
|
|
59
61
|
[key: string]: any;
|
|
60
62
|
}
|
|
61
63
|
export interface ICrudChildrenProps extends ICrudProps, IConnectHocOutput, IComponentsHocOutput {
|
package/ui/crud/Crud/Crud.js
CHANGED
|
@@ -112,7 +112,8 @@ function Crud(props) {
|
|
|
112
112
|
recordId: recordId,
|
|
113
113
|
record: record,
|
|
114
114
|
components: components,
|
|
115
|
-
goToAction: goToAction
|
|
115
|
+
goToAction: goToAction,
|
|
116
|
+
errorHandler: props.errorHandler
|
|
116
117
|
}); }, [components, goToAction, props.crudId, props.mode, props.primaryKey, props.queryKey,
|
|
117
118
|
props.restApi, props.restUrl, record, recordId, routeAction, routeId, routeParams]);
|
|
118
119
|
// Handler for convert control item to props for button
|
package/ui/crud/Crud/utils.js
CHANGED
|
@@ -101,16 +101,23 @@ var normalizeItems = function (sourceItems, fromProps) {
|
|
|
101
101
|
return [4 /*yield*/, props.restApi["delete"](props.components.api, (_a = {}, _a[props.primaryKey] = props.recordId, _a))];
|
|
102
102
|
case 1:
|
|
103
103
|
_b.sent();
|
|
104
|
-
|
|
104
|
+
props.goToAction(exports.CRUD_ACTION_INDEX);
|
|
105
|
+
return [2 /*return*/];
|
|
105
106
|
case 2:
|
|
106
107
|
if (!props.restUrl) return [3 /*break*/, 4];
|
|
107
|
-
return [4 /*yield*/, props.components.http["delete"](props.restUrl + "/" + props.recordId)
|
|
108
|
+
return [4 /*yield*/, props.components.http["delete"](props.restUrl + "/" + props.recordId)
|
|
109
|
+
.then(function () { return props.goToAction(exports.CRUD_ACTION_INDEX); })["catch"](function (error) {
|
|
110
|
+
if (props.errorHandler) {
|
|
111
|
+
props.errorHandler(error, props.components.store.dispatch);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
})];
|
|
108
117
|
case 3:
|
|
109
118
|
_b.sent();
|
|
110
|
-
_b.label = 4;
|
|
111
|
-
case 4:
|
|
112
|
-
props.goToAction(exports.CRUD_ACTION_INDEX);
|
|
113
119
|
return [2 /*return*/];
|
|
120
|
+
case 4: throw new Error('Either restApi or restUrl must be set');
|
|
114
121
|
}
|
|
115
122
|
});
|
|
116
123
|
}); }
|