@panneau/form-resource 2.0.68 → 2.0.69
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/es/index.js +10 -11
- package/lib/index.js +10 -11
- package/package.json +9 -9
package/es/index.js
CHANGED
|
@@ -227,10 +227,18 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
227
227
|
value = _useState2[0],
|
|
228
228
|
setValueState = _useState2[1];
|
|
229
229
|
var setValue = useCallback(function (newValue) {
|
|
230
|
-
// console.log('new value in resource form', newValue); // eslint-disable-line
|
|
231
230
|
setValueState(newValue);
|
|
232
231
|
}, [setValueState]);
|
|
232
|
+
|
|
233
|
+
// Form action
|
|
234
|
+
var modifyAction = isCreate ? resourceRoute('store') : resourceRoute('update', {
|
|
235
|
+
id: item.id
|
|
236
|
+
});
|
|
237
|
+
var action = isDelete ? resourceRoute('destroy', {
|
|
238
|
+
id: item.id
|
|
239
|
+
}) : modifyAction;
|
|
233
240
|
var _useForm = useForm({
|
|
241
|
+
action: action,
|
|
234
242
|
fields: finalFields,
|
|
235
243
|
value: value,
|
|
236
244
|
postForm: postForm,
|
|
@@ -243,22 +251,13 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
243
251
|
status = _useForm.status,
|
|
244
252
|
generalError = _useForm.generalError,
|
|
245
253
|
errors = _useForm.errors;
|
|
246
|
-
|
|
247
|
-
// Form action
|
|
248
|
-
var modifyAction = isCreate ? resourceRoute('store') : resourceRoute('update', {
|
|
249
|
-
id: item.id
|
|
250
|
-
});
|
|
251
|
-
var action = isDelete ? resourceRoute('destroy', {
|
|
252
|
-
id: item.id
|
|
253
|
-
}) : modifyAction;
|
|
254
254
|
var defaultFormName = isDelete ? component || formComponent || null : component || formComponent || defaultComponent || 'normal';
|
|
255
255
|
|
|
256
256
|
// Form component
|
|
257
257
|
var FormComponent = getComponentFromName(defaultFormName, FormComponents, isDelete ? DeleteForm : component);
|
|
258
258
|
|
|
259
|
-
//
|
|
259
|
+
// Listen to item value change - this is important
|
|
260
260
|
useEffect(function () {
|
|
261
|
-
// console.log('get initial value from the top'); // eslint-disable-line
|
|
262
261
|
setValue(getInitialValue());
|
|
263
262
|
}, [getInitialValue, setValue]);
|
|
264
263
|
return /*#__PURE__*/React.createElement(FormProvider, {
|
package/lib/index.js
CHANGED
|
@@ -243,10 +243,18 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
243
243
|
value = _useState2[0],
|
|
244
244
|
setValueState = _useState2[1];
|
|
245
245
|
var setValue = React.useCallback(function (newValue) {
|
|
246
|
-
// console.log('new value in resource form', newValue); // eslint-disable-line
|
|
247
246
|
setValueState(newValue);
|
|
248
247
|
}, [setValueState]);
|
|
248
|
+
|
|
249
|
+
// Form action
|
|
250
|
+
var modifyAction = isCreate ? resourceRoute('store') : resourceRoute('update', {
|
|
251
|
+
id: item.id
|
|
252
|
+
});
|
|
253
|
+
var action = isDelete ? resourceRoute('destroy', {
|
|
254
|
+
id: item.id
|
|
255
|
+
}) : modifyAction;
|
|
249
256
|
var _useForm = hooks.useForm({
|
|
257
|
+
action: action,
|
|
250
258
|
fields: finalFields,
|
|
251
259
|
value: value,
|
|
252
260
|
postForm: postForm,
|
|
@@ -259,22 +267,13 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
259
267
|
status = _useForm.status,
|
|
260
268
|
generalError = _useForm.generalError,
|
|
261
269
|
errors = _useForm.errors;
|
|
262
|
-
|
|
263
|
-
// Form action
|
|
264
|
-
var modifyAction = isCreate ? resourceRoute('store') : resourceRoute('update', {
|
|
265
|
-
id: item.id
|
|
266
|
-
});
|
|
267
|
-
var action = isDelete ? resourceRoute('destroy', {
|
|
268
|
-
id: item.id
|
|
269
|
-
}) : modifyAction;
|
|
270
270
|
var defaultFormName = isDelete ? component || formComponent || null : component || formComponent || defaultComponent || 'normal';
|
|
271
271
|
|
|
272
272
|
// Form component
|
|
273
273
|
var FormComponent = utils.getComponentFromName(defaultFormName, FormComponents, isDelete ? DeleteForm : component);
|
|
274
274
|
|
|
275
|
-
//
|
|
275
|
+
// Listen to item value change - this is important
|
|
276
276
|
React.useEffect(function () {
|
|
277
|
-
// console.log('get initial value from the top'); // eslint-disable-line
|
|
278
277
|
setValue(getInitialValue());
|
|
279
278
|
}, [getInitialValue, setValue]);
|
|
280
279
|
return /*#__PURE__*/React__default["default"].createElement(contexts.FormProvider, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/form-resource",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.69",
|
|
4
4
|
"description": "Default resource forms",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/runtime": "^7.12.5",
|
|
48
|
-
"@panneau/core": "^2.0.
|
|
49
|
-
"@panneau/data": "^2.0.
|
|
50
|
-
"@panneau/element-button": "^2.0.
|
|
51
|
-
"@panneau/element-form": "^2.0.
|
|
52
|
-
"@panneau/field-fields": "^2.0.
|
|
53
|
-
"@panneau/intl": "^2.0.
|
|
54
|
-
"@panneau/themes": "^2.0.
|
|
48
|
+
"@panneau/core": "^2.0.69",
|
|
49
|
+
"@panneau/data": "^2.0.69",
|
|
50
|
+
"@panneau/element-button": "^2.0.69",
|
|
51
|
+
"@panneau/element-form": "^2.0.69",
|
|
52
|
+
"@panneau/field-fields": "^2.0.69",
|
|
53
|
+
"@panneau/intl": "^2.0.69",
|
|
54
|
+
"@panneau/themes": "^2.0.69",
|
|
55
55
|
"classnames": "^2.2.6",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
57
57
|
"prop-types": "^15.7.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "270c1e84966861e94a390d20ee525c33f7edadb0"
|
|
64
64
|
}
|