@bigbinary/neeto-folders-frontend 2.0.12 → 2.0.13
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/cjs/components.js +31 -11
- package/dist/cjs/components.js.map +1 -1
- package/dist/cjs/hooks.js +1 -1
- package/dist/components.js +32 -12
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/{useFolderActions-_yrbFSyE.js → useFolderActions-DZ-ywc7_.js} +20 -10
- package/dist/useFolderActions-DZ-ywc7_.js.map +1 -0
- package/dist/{useFolderActions--QXsOnUm.js → useFolderActions-DzLwUir3.js} +21 -11
- package/dist/useFolderActions-DzLwUir3.js.map +1 -0
- package/package.json +5 -5
- package/dist/useFolderActions--QXsOnUm.js.map +0 -1
- package/dist/useFolderActions-_yrbFSyE.js.map +0 -1
package/dist/cjs/hooks.js
CHANGED
package/dist/components.js
CHANGED
|
@@ -7,10 +7,10 @@ import { buildUrl, showThumbsUpToastr } from '@bigbinary/neeto-commons-frontend/
|
|
|
7
7
|
import Alert from '@bigbinary/neetoui/Alert';
|
|
8
8
|
import { useTranslation as useTranslation$1, Trans } from 'react-i18next';
|
|
9
9
|
import { useHistory, Link, NavLink } from 'react-router-dom';
|
|
10
|
-
import { c as useFolderStore, d as useDestroyFolder, a as useFolders, e as useFetchFolders, f as useCreateFolder, g as useUpdateFolder, h as useReorderFolders, D as DEFAULT_CONFIG, u as useFolder, b as useFolderActions } from './useFolderActions
|
|
10
|
+
import { c as useFolderStore, d as useDestroyFolder, a as useFolders, e as useFetchFolders, f as useCreateFolder, g as useUpdateFolder, h as useReorderFolders, D as DEFAULT_CONFIG, u as useFolder, b as useFolderActions } from './useFolderActions-DzLwUir3.js';
|
|
11
11
|
import { QUERY_KEYS } from './constants.js';
|
|
12
12
|
import { p as pathToFolder, t as treeToMap, m as measureDepth, a as mapToTree, b as mapToSortedTree } from './index-DWQZ8Va7.js';
|
|
13
|
-
import { a as isActiveFolder,
|
|
13
|
+
import { a as isActiveFolder, g as getActiveFolderId, i as isArray, m as mapObj } from './internal-PLqSv_EP.js';
|
|
14
14
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
15
|
import Pane from '@bigbinary/neetoui/Pane';
|
|
16
16
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
@@ -21,7 +21,6 @@ import Spinner from '@bigbinary/neetoui/Spinner';
|
|
|
21
21
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
22
22
|
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
23
23
|
import Form from '@bigbinary/neetoui/formik/Form';
|
|
24
|
-
import { isEmpty, assoc } from 'ramda';
|
|
25
24
|
import { t as t$1 } from 'i18next';
|
|
26
25
|
import { object, string } from 'yup';
|
|
27
26
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
@@ -31,6 +30,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
31
30
|
import useHotkeys from '@bigbinary/neeto-hotkeys';
|
|
32
31
|
import Button from '@bigbinary/neetoui/Button';
|
|
33
32
|
import { hyphenate, noop, isNotPresent } from '@bigbinary/neeto-cist';
|
|
33
|
+
import { isEmpty, assoc } from 'ramda';
|
|
34
34
|
import classNames from 'classnames';
|
|
35
35
|
import Radio from '@bigbinary/neetoui/Radio';
|
|
36
36
|
import { useDraggable, useDroppable, DndContext, DragOverlay, useSensors, useSensor, PointerSensor } from '@dnd-kit/core';
|
|
@@ -191,8 +191,18 @@ var createPayload = function createPayload(values, extraAttrs) {
|
|
|
191
191
|
});
|
|
192
192
|
return payload;
|
|
193
193
|
};
|
|
194
|
+
var filterExtraAttributes = function filterExtraAttributes(attributes, isEditing) {
|
|
195
|
+
if (!attributes || !Array.isArray(attributes)) return [];
|
|
196
|
+
return attributes.filter(function (attribute) {
|
|
197
|
+
if (isEditing) {
|
|
198
|
+
return attribute.isEditAttribute !== false;
|
|
199
|
+
}
|
|
200
|
+
return attribute.isCreateAttribute !== false;
|
|
201
|
+
});
|
|
202
|
+
};
|
|
194
203
|
|
|
195
204
|
var AddEditPane = function AddEditPane(_ref) {
|
|
205
|
+
var _config$addEditValida;
|
|
196
206
|
var setFocusField = _ref.setFocusField,
|
|
197
207
|
config = _ref.config,
|
|
198
208
|
onClose = _ref.onClose;
|
|
@@ -214,7 +224,11 @@ var AddEditPane = function AddEditPane(_ref) {
|
|
|
214
224
|
var _useUpdateFolder = useUpdateFolder(config),
|
|
215
225
|
updateFolder = _useUpdateFolder.mutateAsync;
|
|
216
226
|
var isEditing = type === "edit" && item;
|
|
227
|
+
var activeFolderSid = getActiveFolderId(config);
|
|
217
228
|
var extraAttributes = config.extraAttributes;
|
|
229
|
+
var filteredExtraAttributes = useMemo(function () {
|
|
230
|
+
return filterExtraAttributes(extraAttributes, isEditing);
|
|
231
|
+
}, [extraAttributes, isEditing]);
|
|
218
232
|
var handleError = function handleError(setStatus, error) {
|
|
219
233
|
var response = error.response;
|
|
220
234
|
if (response && response.data && response.data.errors) {
|
|
@@ -228,9 +242,14 @@ var AddEditPane = function AddEditPane(_ref) {
|
|
|
228
242
|
while (1) switch (_context.prev = _context.next) {
|
|
229
243
|
case 0:
|
|
230
244
|
setStatus = _ref2.setStatus;
|
|
231
|
-
payload = createPayload(values,
|
|
245
|
+
payload = createPayload(values, filteredExtraAttributes);
|
|
232
246
|
reactQueryOptions = {
|
|
233
|
-
onSuccess: function onSuccess() {
|
|
247
|
+
onSuccess: function onSuccess(_ref4) {
|
|
248
|
+
var sid = _ref4.sid;
|
|
249
|
+
if (isEditing && sid !== item.sid) {
|
|
250
|
+
var newPath = window.location.pathname.replace(activeFolderSid, sid);
|
|
251
|
+
window.location.href = newPath;
|
|
252
|
+
}
|
|
234
253
|
showThumbsUpToastr();
|
|
235
254
|
onClose();
|
|
236
255
|
},
|
|
@@ -249,7 +268,8 @@ var AddEditPane = function AddEditPane(_ref) {
|
|
|
249
268
|
return updateFolder({
|
|
250
269
|
id: item.id,
|
|
251
270
|
payload: payload,
|
|
252
|
-
config: config
|
|
271
|
+
config: config,
|
|
272
|
+
initialSlug: item.sid
|
|
253
273
|
}, reactQueryOptions);
|
|
254
274
|
case 7:
|
|
255
275
|
_context.next = 11;
|
|
@@ -271,8 +291,8 @@ var AddEditPane = function AddEditPane(_ref) {
|
|
|
271
291
|
};
|
|
272
292
|
}();
|
|
273
293
|
var initialValues = useMemo(function () {
|
|
274
|
-
return isEditing ? item : createInitialValues({},
|
|
275
|
-
}, [isEditing, item,
|
|
294
|
+
return isEditing ? item : createInitialValues({}, filteredExtraAttributes);
|
|
295
|
+
}, [isEditing, item, filteredExtraAttributes]);
|
|
276
296
|
if (isFetching) {
|
|
277
297
|
return /*#__PURE__*/jsx(Pane.Body, {
|
|
278
298
|
className: "flex items-center justify-center",
|
|
@@ -290,11 +310,11 @@ var AddEditPane = function AddEditPane(_ref) {
|
|
|
290
310
|
formikProps: {
|
|
291
311
|
initialValues: initialValues,
|
|
292
312
|
enableReinitialize: true,
|
|
293
|
-
validationSchema: FORM_VALIDATION_SCHEMA,
|
|
313
|
+
validationSchema: ((_config$addEditValida = config.addEditValidationSchema) === null || _config$addEditValida === void 0 ? void 0 : _config$addEditValida.call(config, isEditing)) || FORM_VALIDATION_SCHEMA,
|
|
294
314
|
onSubmit: onSubmitForm
|
|
295
315
|
},
|
|
296
|
-
children: function children(
|
|
297
|
-
var dirty =
|
|
316
|
+
children: function children(_ref5) {
|
|
317
|
+
var dirty = _ref5.dirty;
|
|
298
318
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
299
319
|
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
300
320
|
className: "pb-6",
|
|
@@ -306,7 +326,7 @@ var AddEditPane = function AddEditPane(_ref) {
|
|
|
306
326
|
name: "name",
|
|
307
327
|
ref: setFocusField
|
|
308
328
|
}), /*#__PURE__*/jsx(ExtraAttributes, {
|
|
309
|
-
attributes:
|
|
329
|
+
attributes: filteredExtraAttributes
|
|
310
330
|
}), /*#__PURE__*/jsxs("div", {
|
|
311
331
|
children: [/*#__PURE__*/jsx(TreeSelect, {
|
|
312
332
|
config: config,
|