authscape 1.0.252 → 1.0.256
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/index.js +54 -37
- package/package.json +1 -1
- package/src/components/DocumentManager.js +15 -6
- package/src/components/FileUploader.js +2 -2
package/index.js
CHANGED
|
@@ -457,8 +457,8 @@ var DocumentManager = function DocumentManager(_ref) {
|
|
|
457
457
|
setIsLoading = _ref.setIsLoading,
|
|
458
458
|
_ref$viewDocumentType = _ref.viewDocumentType,
|
|
459
459
|
viewDocumentType = _ref$viewDocumentType === void 0 ? 1 : _ref$viewDocumentType,
|
|
460
|
-
_ref$
|
|
461
|
-
|
|
460
|
+
_ref$disablePreview = _ref.disablePreview,
|
|
461
|
+
disablePreview = _ref$disablePreview === void 0 ? false : _ref$disablePreview,
|
|
462
462
|
_ref$openToFolderId = _ref.openToFolderId,
|
|
463
463
|
openToFolderId = _ref$openToFolderId === void 0 ? null : _ref$openToFolderId,
|
|
464
464
|
_ref$overrideLockMess = _ref.overrideLockMessage,
|
|
@@ -476,22 +476,26 @@ var DocumentManager = function DocumentManager(_ref) {
|
|
|
476
476
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
477
477
|
folderParent = _useState6[0],
|
|
478
478
|
setFolderParent = _useState6[1];
|
|
479
|
-
var _useState7 = (0, _react.useState)(
|
|
479
|
+
var _useState7 = (0, _react.useState)(null),
|
|
480
480
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
var _useState9 = (0, _react.useState)(
|
|
481
|
+
masterFolder = _useState8[0],
|
|
482
|
+
setMasterFolder = _useState8[1];
|
|
483
|
+
var _useState9 = (0, _react.useState)([]),
|
|
484
484
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
485
|
-
|
|
486
|
-
|
|
485
|
+
breadCrumb = _useState10[0],
|
|
486
|
+
setBreadCrumb = _useState10[1];
|
|
487
487
|
var _useState11 = (0, _react.useState)(null),
|
|
488
488
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
var _useState13 = (0, _react.useState)(
|
|
489
|
+
contextMenu = _useState12[0],
|
|
490
|
+
setContextMenu = _useState12[1];
|
|
491
|
+
var _useState13 = (0, _react.useState)(null),
|
|
492
492
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
493
|
-
|
|
494
|
-
|
|
493
|
+
contextFile = _useState14[0],
|
|
494
|
+
setContextFile = _useState14[1];
|
|
495
|
+
var _useState15 = (0, _react.useState)(false),
|
|
496
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
497
|
+
dialogDelete = _useState16[0],
|
|
498
|
+
setDialogDelete = _useState16[1];
|
|
495
499
|
var handleContextMenu = function handleContextMenu(event, file) {
|
|
496
500
|
event.preventDefault();
|
|
497
501
|
setContextFile(file);
|
|
@@ -510,40 +514,53 @@ var DocumentManager = function DocumentManager(_ref) {
|
|
|
510
514
|
if (loadedUser) {
|
|
511
515
|
var fetchDocuments = /*#__PURE__*/function () {
|
|
512
516
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
513
|
-
var folderId, response, _response;
|
|
517
|
+
var folderId, folderResponse, response, _response;
|
|
514
518
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
515
519
|
while (1) switch (_context.prev = _context.next) {
|
|
516
520
|
case 0:
|
|
517
521
|
folderId = null;
|
|
518
|
-
if (folderParent == null && openToFolderId != null) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
522
|
+
if (!(folderParent == null && openToFolderId != null)) {
|
|
523
|
+
_context.next = 9;
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
folderId = openToFolderId;
|
|
527
|
+
// should get the current document...
|
|
528
|
+
_context.next = 5;
|
|
529
|
+
return apiService().get("/Document/GetDocumentByFolderId?folderId=" + folderId);
|
|
530
|
+
case 5:
|
|
531
|
+
folderResponse = _context.sent;
|
|
532
|
+
if (folderResponse != null && folderResponse.status == 200) {
|
|
533
|
+
setMasterFolder(folderResponse.data);
|
|
534
|
+
}
|
|
535
|
+
_context.next = 10;
|
|
536
|
+
break;
|
|
537
|
+
case 9:
|
|
538
|
+
if (folderParent != null) {
|
|
523
539
|
folderId = folderParent.id;
|
|
524
540
|
}
|
|
541
|
+
case 10:
|
|
525
542
|
if (!(folderId != null)) {
|
|
526
|
-
_context.next =
|
|
543
|
+
_context.next = 17;
|
|
527
544
|
break;
|
|
528
545
|
}
|
|
529
|
-
_context.next =
|
|
546
|
+
_context.next = 13;
|
|
530
547
|
return apiService().get("/Document/GetDocumentsAndFiles?parentFolderId=" + folderId + "&ViewDocumentType=" + viewDocumentType);
|
|
531
|
-
case
|
|
548
|
+
case 13:
|
|
532
549
|
response = _context.sent;
|
|
533
550
|
if (response != null && response.status == 200) {
|
|
534
551
|
setFiles(response.data);
|
|
535
552
|
}
|
|
536
|
-
_context.next =
|
|
553
|
+
_context.next = 21;
|
|
537
554
|
break;
|
|
538
|
-
case
|
|
539
|
-
_context.next =
|
|
555
|
+
case 17:
|
|
556
|
+
_context.next = 19;
|
|
540
557
|
return apiService().get("/Document/GetDocumentsAndFiles?ViewDocumentType=" + viewDocumentType);
|
|
541
|
-
case
|
|
558
|
+
case 19:
|
|
542
559
|
_response = _context.sent;
|
|
543
560
|
if (_response != null && _response.status == 200) {
|
|
544
561
|
setFiles(_response.data);
|
|
545
562
|
}
|
|
546
|
-
case
|
|
563
|
+
case 21:
|
|
547
564
|
case "end":
|
|
548
565
|
return _context.stop();
|
|
549
566
|
}
|
|
@@ -556,10 +573,10 @@ var DocumentManager = function DocumentManager(_ref) {
|
|
|
556
573
|
fetchDocuments();
|
|
557
574
|
}
|
|
558
575
|
}, [loadedUser, folderParent, update]);
|
|
559
|
-
var
|
|
560
|
-
|
|
561
|
-
anchorEl =
|
|
562
|
-
setAnchorEl =
|
|
576
|
+
var _useState17 = (0, _react.useState)(null),
|
|
577
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
578
|
+
anchorEl = _useState18[0],
|
|
579
|
+
setAnchorEl = _useState18[1];
|
|
563
580
|
var open = Boolean(anchorEl);
|
|
564
581
|
var handleClick = function handleClick(event) {
|
|
565
582
|
setAnchorEl(event.currentTarget);
|
|
@@ -745,8 +762,8 @@ var DocumentManager = function DocumentManager(_ref) {
|
|
|
745
762
|
refOveride: fileUploaderRef,
|
|
746
763
|
url: "/Document/UploadFile",
|
|
747
764
|
params: {
|
|
748
|
-
|
|
749
|
-
|
|
765
|
+
viewType: viewDocumentType,
|
|
766
|
+
parentFolderId: folderParent != null ? folderParent.id : ""
|
|
750
767
|
},
|
|
751
768
|
multiple: true,
|
|
752
769
|
variant: "custom",
|
|
@@ -784,7 +801,7 @@ var DocumentManager = function DocumentManager(_ref) {
|
|
|
784
801
|
setFolderParent(null);
|
|
785
802
|
setBreadCrumb([]);
|
|
786
803
|
}
|
|
787
|
-
}, "My Files"), breadCrumb.map(function (bread, index) {
|
|
804
|
+
}, masterFolder == null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, "My Files"), masterFolder != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, masterFolder.name)), breadCrumb.map(function (bread, index) {
|
|
788
805
|
return /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
789
806
|
key: index,
|
|
790
807
|
underline: "hover",
|
|
@@ -852,7 +869,7 @@ var DocumentManager = function DocumentManager(_ref) {
|
|
|
852
869
|
fontSize: 80,
|
|
853
870
|
color: "orange"
|
|
854
871
|
}
|
|
855
|
-
}) : file.documentFileExtentionType == 0 ||
|
|
872
|
+
}) : file.documentFileExtentionType == 0 || disablePreview ? /*#__PURE__*/_react["default"].createElement(_InsertDriveFileOutlined["default"], {
|
|
856
873
|
sx: {
|
|
857
874
|
fontSize: 60
|
|
858
875
|
}
|
|
@@ -1268,8 +1285,8 @@ var FileUploader = function FileUploader(_ref) {
|
|
|
1268
1285
|
var array = [];
|
|
1269
1286
|
for (var index = 0; index < propertyNames.length; index++) {
|
|
1270
1287
|
array.push({
|
|
1271
|
-
key: propertyNames[
|
|
1272
|
-
value: propertyValues[
|
|
1288
|
+
key: propertyNames[index],
|
|
1289
|
+
value: propertyValues[index]
|
|
1273
1290
|
});
|
|
1274
1291
|
}
|
|
1275
1292
|
setParameters(array);
|
package/package.json
CHANGED
|
@@ -24,12 +24,13 @@ import Tooltip from '@mui/material/Tooltip';
|
|
|
24
24
|
// remove before merging back
|
|
25
25
|
// import { FileUploader, apiService, NextImage } from 'authscape';
|
|
26
26
|
|
|
27
|
-
export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
|
|
27
|
+
export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1, disablePreview = false, openToFolderId = null, overrideLockMessage = "The directory cannot be removed."}) => {
|
|
28
28
|
|
|
29
29
|
const fileUploaderRef = useRef();
|
|
30
30
|
const [files, setFiles] = useState(null);
|
|
31
31
|
const [update, setUpdate] = useState(false);
|
|
32
32
|
const [folderParent, setFolderParent] = useState(null);
|
|
33
|
+
const [masterFolder, setMasterFolder] = useState(null);
|
|
33
34
|
const [breadCrumb, setBreadCrumb] = useState([]);
|
|
34
35
|
|
|
35
36
|
const [contextMenu, setContextMenu] = useState(null);
|
|
@@ -68,7 +69,14 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
|
|
|
68
69
|
let folderId = null;
|
|
69
70
|
if (folderParent == null && openToFolderId != null)
|
|
70
71
|
{
|
|
71
|
-
folderId =
|
|
72
|
+
folderId = openToFolderId;
|
|
73
|
+
// should get the current document...
|
|
74
|
+
|
|
75
|
+
let folderResponse = await apiService().get("/Document/GetDocumentByFolderId?folderId=" + folderId);
|
|
76
|
+
if (folderResponse != null && folderResponse.status == 200)
|
|
77
|
+
{
|
|
78
|
+
setMasterFolder(folderResponse.data);
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
81
|
else if (folderParent != null)
|
|
74
82
|
{
|
|
@@ -259,10 +267,10 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
|
|
|
259
267
|
</StyledMenu>
|
|
260
268
|
</Box>
|
|
261
269
|
|
|
262
|
-
|
|
263
270
|
<FileUploader refOveride={fileUploaderRef} url={"/Document/UploadFile"} params={{
|
|
271
|
+
|
|
272
|
+
viewType : viewDocumentType,
|
|
264
273
|
parentFolderId: (folderParent != null ? folderParent.id : ""),
|
|
265
|
-
viewDocumentType: viewDocumentType
|
|
266
274
|
|
|
267
275
|
}} multiple={true} variant='custom' onUploadCompleted={() => {
|
|
268
276
|
setUpdate(!update);
|
|
@@ -294,7 +302,8 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
|
|
|
294
302
|
setBreadCrumb([]);
|
|
295
303
|
|
|
296
304
|
}}>
|
|
297
|
-
My Files
|
|
305
|
+
{masterFolder == null && <>My Files</>}
|
|
306
|
+
{masterFolder != null && <>{masterFolder.name}</>}
|
|
298
307
|
</Link>
|
|
299
308
|
{breadCrumb.map((bread, index) => {
|
|
300
309
|
return (
|
|
@@ -349,7 +358,7 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
|
|
|
349
358
|
<FolderIcon sx={{ fontSize: 80, color:"orange" }} />
|
|
350
359
|
) : (
|
|
351
360
|
|
|
352
|
-
file.documentFileExtentionType == 0 ||
|
|
361
|
+
file.documentFileExtentionType == 0 || disablePreview ? <InsertDriveFileOutlinedIcon sx={{ fontSize: 60 }} /> : <NextImage src={file.uri} alt={"Image"} width={80} height={80} />
|
|
353
362
|
|
|
354
363
|
)}
|
|
355
364
|
<Typography variant="subtitle1" sx={{paddingTop:1, fontSize:14}}>{file.name}</Typography>
|
|
@@ -132,8 +132,8 @@ export const FileUploader = ({
|
|
|
132
132
|
|
|
133
133
|
for (let index = 0; index < propertyNames.length; index++) {
|
|
134
134
|
array.push({
|
|
135
|
-
key: propertyNames[
|
|
136
|
-
value: propertyValues[
|
|
135
|
+
key: propertyNames[index],
|
|
136
|
+
value: propertyValues[index],
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|