authscape 1.0.282 → 1.0.286

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 CHANGED
@@ -422,6 +422,7 @@ Object.defineProperty(exports, "__esModule", {
422
422
  exports.DocumentManager = void 0;
423
423
  var _material = require("@mui/material");
424
424
  var _react = _interopRequireWildcard(require("react"));
425
+ var _AddRounded = _interopRequireDefault(require("@mui/icons-material/AddRounded"));
425
426
  var _DeleteRounded = _interopRequireDefault(require("@mui/icons-material/DeleteRounded"));
426
427
  var _Folder = _interopRequireDefault(require("@mui/icons-material/Folder"));
427
428
  var _InsertDriveFile = _interopRequireDefault(require("@mui/icons-material/InsertDriveFile"));
@@ -429,6 +430,7 @@ var _styles = require("@mui/material/styles");
429
430
  var _Menu = _interopRequireDefault(require("@mui/material/Menu"));
430
431
  var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
431
432
  var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
433
+ var _KeyboardArrowDown = _interopRequireDefault(require("@mui/icons-material/KeyboardArrowDown"));
432
434
  var _InsertDriveFileOutlined = _interopRequireDefault(require("@mui/icons-material/InsertDriveFileOutlined"));
433
435
  var _Breadcrumbs = _interopRequireDefault(require("@mui/material/Breadcrumbs"));
434
436
  var _Link = _interopRequireDefault(require("@mui/material/Link"));
@@ -456,10 +458,9 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
456
458
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
457
459
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
458
460
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
459
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // import AddRoundedIcon from '@mui/icons-material/AddRounded';
460
- // import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
461
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
461
462
  // remove before merging back
462
- // import { FileUploader, apiService, NextImage } from 'authscape';
463
+ //import { FileUploader, apiService, NextImage } from 'authscape';
463
464
 
464
465
  var DocumentManager = function DocumentManager(_ref) {
465
466
  var loadedUser = _ref.loadedUser,
@@ -480,6 +481,8 @@ var DocumentManager = function DocumentManager(_ref) {
480
481
  lg = _ref$lg === void 0 ? 2 : _ref$lg,
481
482
  _ref$overrideLockMess = _ref.overrideLockMessage,
482
483
  overrideLockMessage = _ref$overrideLockMess === void 0 ? "The directory cannot be removed." : _ref$overrideLockMess,
484
+ _ref$zeroStateView = _ref.zeroStateView,
485
+ zeroStateView = _ref$zeroStateView === void 0 ? null : _ref$zeroStateView,
483
486
  _ref$fieldId = _ref.fieldId1,
484
487
  fieldId1 = _ref$fieldId === void 0 ? null : _ref$fieldId,
485
488
  _ref$fieldId2 = _ref.fieldId2,
@@ -557,7 +560,9 @@ var DocumentManager = function DocumentManager(_ref) {
557
560
  case 5:
558
561
  folderResponse = _context.sent;
559
562
  if (folderResponse != null && folderResponse.status == 200) {
563
+ setFolderParent(folderResponse.data);
560
564
  setMasterFolder(folderResponse.data);
565
+ folderId = folderResponse.id;
561
566
  }
562
567
  _context.next = 10;
563
568
  break;
@@ -586,7 +591,11 @@ var DocumentManager = function DocumentManager(_ref) {
586
591
  case 18:
587
592
  response = _context.sent;
588
593
  if (response != null && response.status == 200) {
589
- setFiles(response.data);
594
+ setIsLoading(true);
595
+ setTimeout(function () {
596
+ // setIsLoading(false);
597
+ setFiles(response.data);
598
+ }, 500);
590
599
  }
591
600
  _context.next = 26;
592
601
  break;
@@ -742,7 +751,7 @@ var DocumentManager = function DocumentManager(_ref) {
742
751
  sx: {
743
752
  flexGrow: 1
744
753
  }
745
- }, /*#__PURE__*/_react["default"].createElement(_material.AppBar, {
754
+ }, (files != null && files.documentSegments.length == 0 || folderParent != null) && /*#__PURE__*/_react["default"].createElement(_material.AppBar, {
746
755
  position: "static",
747
756
  color: "inherit",
748
757
  elevation: 0
@@ -842,7 +851,7 @@ var DocumentManager = function DocumentManager(_ref) {
842
851
  height: "85vh",
843
852
  width: '100%'
844
853
  }
845
- }, files != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, files.documentSegments.length > 0 && folderParent == null && files.documentSegments.map(function (segment, index) {
854
+ }, files != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, masterFolder == null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, files.documentSegments.length > 0 && folderParent == null && files.documentSegments.map(function (segment, index) {
846
855
  return /*#__PURE__*/_react["default"].createElement(_material.Box, {
847
856
  sx: {
848
857
  paddingTop: 3
@@ -925,8 +934,8 @@ var DocumentManager = function DocumentManager(_ref) {
925
934
  fontSize: 11
926
935
  }
927
936
  }, file.lastUpdated)));
928
- })));
929
- }), (files.documentSegments.length == 0 || folderParent != null) && /*#__PURE__*/_react["default"].createElement(_material.Grid, {
937
+ })), files != null && files.documentAndFiles != null && zeroStateView != null && /*#__PURE__*/_react["default"].createElement(_material.Box, null, zeroStateView(segment)));
938
+ })), (files.documentSegments.length == 0 || folderParent != null) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Grid, {
930
939
  container: true,
931
940
  spacing: 2
932
941
  }, files.documentAndFiles.map(function (file, index) {
@@ -999,7 +1008,7 @@ var DocumentManager = function DocumentManager(_ref) {
999
1008
  fontSize: 11
1000
1009
  }
1001
1010
  }, file.lastUpdated)));
1002
- }))), /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
1011
+ })), files != null && files.documentAndFiles != null && zeroStateView != null && /*#__PURE__*/_react["default"].createElement(_material.Box, null, zeroStateView()))), /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
1003
1012
  open: contextMenu !== null,
1004
1013
  onClose: handleClose,
1005
1014
  anchorReference: "anchorPosition",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.282",
3
+ "version": "1.0.286",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  import { AppBar, Box, Button, Toolbar, Typography, Grid, Paper } from '@mui/material';
2
2
  import React, {useEffect, useState, useRef} from 'react';
3
- // import AddRoundedIcon from '@mui/icons-material/AddRounded';
3
+ import AddRoundedIcon from '@mui/icons-material/AddRounded';
4
4
  import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded';
5
5
  import FolderIcon from '@mui/icons-material/Folder';
6
6
  import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
@@ -8,7 +8,7 @@ import { styled, alpha } from '@mui/material/styles';
8
8
  import Menu from '@mui/material/Menu';
9
9
  import MenuItem from '@mui/material/MenuItem';
10
10
  import Divider from '@mui/material/Divider';
11
- // import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
11
+ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
12
12
  import InsertDriveFileOutlinedIcon from '@mui/icons-material/InsertDriveFileOutlined';
13
13
  import Breadcrumbs from '@mui/material/Breadcrumbs';
14
14
  import Link from '@mui/material/Link';
@@ -22,9 +22,9 @@ import LockRoundedIcon from '@mui/icons-material/LockRounded';
22
22
  import Tooltip from '@mui/material/Tooltip';
23
23
 
24
24
  // remove before merging back
25
- // import { FileUploader, apiService, NextImage } from 'authscape';
25
+ //import { FileUploader, apiService, NextImage } from 'authscape';
26
26
 
27
- export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1, disablePreview = false, openToFolderId = null, xs=12, sm=6, md=4, lg=2, overrideLockMessage = "The directory cannot be removed.", fieldId1 = null, fieldId2 = null, fieldId3 = null}) => {
27
+ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1, disablePreview = false, openToFolderId = null, xs=12, sm=6, md=4, lg=2, overrideLockMessage = "The directory cannot be removed.", zeroStateView = null, fieldId1 = null, fieldId2 = null, fieldId3 = null}) => {
28
28
 
29
29
  const fileUploaderRef = useRef();
30
30
  const [files, setFiles] = useState(null);
@@ -77,7 +77,9 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
77
77
  let folderResponse = await apiService().get("/Document/GetDocumentByFolderId?folderId=" + folderId);
78
78
  if (folderResponse != null && folderResponse.status == 200)
79
79
  {
80
- setMasterFolder(folderResponse.data);
80
+ setFolderParent(folderResponse.data);
81
+ setMasterFolder(folderResponse.data);
82
+ folderId = folderResponse.id;
81
83
  }
82
84
  }
83
85
  else if (folderParent != null)
@@ -111,7 +113,11 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
111
113
  let response = await apiService().get("/Document/GetDocumentsAndFiles?parentFolderId=" + folderId + "&ViewDocumentType=" + viewDocumentType + params);
112
114
  if (response != null && response.status == 200)
113
115
  {
114
- setFiles(response.data);
116
+ setIsLoading(true);
117
+ setTimeout(() => {
118
+ // setIsLoading(false);
119
+ setFiles(response.data);
120
+ }, 500);
115
121
  }
116
122
  }
117
123
  else
@@ -238,8 +244,12 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
238
244
  return (
239
245
  <>
240
246
  <Box sx={{ flexGrow: 1 }}>
247
+
248
+ {(files != null && files.documentSegments.length == 0 || folderParent != null) &&
241
249
  <AppBar position="static" color='inherit' elevation={0}>
242
250
  <Toolbar>
251
+
252
+
243
253
  <Box>
244
254
  <Button
245
255
  id="demo-customized-button"
@@ -272,55 +282,7 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
272
282
  New Folder
273
283
  </Button>
274
284
  </Box>
275
- {/* <Box>
276
- <Button
277
- id="demo-customized-button"
278
- aria-controls={open ? 'demo-customized-menu' : undefined}
279
- aria-haspopup="true"
280
- aria-expanded={open ? 'true' : undefined}
281
- variant="contained"
282
- disableElevation
283
- onClick={handleClick}
284
- startIcon={<AddRoundedIcon />}
285
- endIcon={<KeyboardArrowDownIcon />}
286
- >
287
- New
288
- </Button>
289
- <StyledMenu
290
- id="demo-customized-menu"
291
- MenuListProps={{
292
- 'aria-labelledby': 'demo-customized-button',
293
- }}
294
- anchorEl={anchorEl}
295
- open={open}
296
- onClose={handleClose}
297
- >
298
- <MenuItem onClick={async () => {
299
-
300
- let newDocumentName = prompt("New folder name");
301
- if (newDocumentName != null && newDocumentName != "")
302
- {
303
- let response = await apiService().post("/Document/CreateFolder", {
304
- folderName: newDocumentName,
305
- parentFolderId: folderParent != null ? folderParent.id : null,
306
- viewDocumentType: viewDocumentType
307
- });
308
-
309
- if (response != null && response.status == 200)
310
- {
311
- // refresh
312
- setUpdate(!update);
313
- }
314
-
315
- }
316
-
317
- handleClose();
318
- }} disableRipple>
319
- <InsertDriveFileIcon />
320
- New Folder
321
- </MenuItem>
322
- </StyledMenu>
323
- </Box> */}
285
+
324
286
 
325
287
  {(files != null && files.documentSegments.length == 0 || folderParent != null) &&
326
288
  <FileUploader refOveride={fileUploaderRef} url={"/Document/UploadFile"} params={{
@@ -349,9 +311,10 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
349
311
  }
350
312
  </Toolbar>
351
313
  </AppBar>
314
+ }
352
315
 
353
316
  <Divider />
354
-
317
+
355
318
  <Breadcrumbs aria-label="breadcrumb" separator={">"} sx={{marginLeft:1, marginBottom:2, marginTop:2}}>
356
319
  <Link underline="hover" color="inherit" sx={{cursor:"pointer", fontWeight:"bold"}} onClick={() => {
357
320
 
@@ -383,119 +346,143 @@ export const DocumentManager = ({loadedUser, setIsLoading, viewDocumentType = 1,
383
346
  {files != null &&
384
347
  <>
385
348
 
349
+ {masterFolder == null &&
350
+ <>
351
+ {(files.documentSegments.length > 0 && folderParent == null) && files.documentSegments.map((segment, index) => (
352
+
353
+ <Box sx={{paddingTop:3}}>
354
+ <Typography variant="h6" gutterBottom>
355
+ {segment.name}
356
+ </Typography>
386
357
 
387
-
388
- {(files.documentSegments.length > 0 && folderParent == null) && files.documentSegments.map((segment, index) => (
389
-
390
- <Box sx={{paddingTop:3}}>
391
- <Typography variant="h6" gutterBottom>
392
- {segment.name}
393
- </Typography>
394
-
395
-
396
- <Grid container spacing={2}>
397
- {files.documentAndFiles.filter(item => item.segmentId == segment.id).map((file, index) => (
398
-
399
- <Grid onContextMenu={(event) => {
400
- handleContextMenu(event, file);
401
- }} item key={index} xs={xs} sm={sm} md={md} lg={lg} onClick={() => handleFileClick(file)}>
402
- <Paper
403
- sx={{
404
- padding: 2,
405
- flexDirection: 'column',
406
- height: "100%", display: "flex", alignItems: "center",
407
- cursor: 'pointer',
408
- maxHeight:300,
409
- position:"relative",
410
- '&:hover': {
411
- backgroundColor: '#F5F5F5'
412
- }
413
- }}>
414
358
 
415
- {file.type === 'folder' &&
416
- <Box sx={{position:"absolute", top:45, color:"white"}}>
417
- {file.count}
418
- </Box>}
419
-
420
- {file.isLocked &&
421
- <Box sx={{position:"absolute", top:10, right: 10, color:"black"}}>
422
- <Tooltip title={overrideLockMessage}>
423
- <LockRoundedIcon />
424
- </Tooltip>
425
- </Box>
426
- }
427
-
428
- {file.type === 'folder' ? (
429
- <FolderIcon sx={{ fontSize: 80, color:"orange" }} />
430
- ) : (
431
-
432
- file.documentFileExtentionType == 0 || disablePreview ? <InsertDriveFileOutlinedIcon sx={{ fontSize: 60 }} /> : <NextImage src={file.uri} alt={"Image"} width={80} height={80} />
433
-
434
- )}
435
- <Typography variant="subtitle1" sx={{paddingTop:1, fontSize:14}}>{file.name}</Typography>
436
- <Typography variant="subtitle2" sx={{paddingTop:0, fontSize:11}}>{file.lastUpdated}</Typography>
437
- </Paper>
438
- </Grid>
439
-
440
- ))}
441
- </Grid>
359
+ <Grid container spacing={2}>
360
+ {files.documentAndFiles.filter(item => item.segmentId == segment.id).map((file, index) => (
361
+
362
+ <Grid onContextMenu={(event) => {
363
+ handleContextMenu(event, file);
364
+ }} item key={index} xs={xs} sm={sm} md={md} lg={lg} onClick={() => handleFileClick(file)}>
365
+ <Paper
366
+ sx={{
367
+ padding: 2,
368
+ flexDirection: 'column',
369
+ height: "100%", display: "flex", alignItems: "center",
370
+ cursor: 'pointer',
371
+ maxHeight:300,
372
+ position:"relative",
373
+ '&:hover': {
374
+ backgroundColor: '#F5F5F5'
375
+ }
376
+ }}>
377
+
378
+ {file.type === 'folder' &&
379
+ <Box sx={{position:"absolute", top:45, color:"white"}}>
380
+ {file.count}
381
+ </Box>}
382
+
383
+ {file.isLocked &&
384
+ <Box sx={{position:"absolute", top:10, right: 10, color:"black"}}>
385
+ <Tooltip title={overrideLockMessage}>
386
+ <LockRoundedIcon />
387
+ </Tooltip>
388
+ </Box>
389
+ }
390
+
391
+ {file.type === 'folder' ? (
392
+ <FolderIcon sx={{ fontSize: 80, color:"orange" }} />
393
+ ) : (
394
+
395
+ file.documentFileExtentionType == 0 || disablePreview ? <InsertDriveFileOutlinedIcon sx={{ fontSize: 60 }} /> : <NextImage src={file.uri} alt={"Image"} width={80} height={80} />
396
+
397
+ )}
398
+ <Typography variant="subtitle1" sx={{paddingTop:1, fontSize:14}}>{file.name}</Typography>
399
+ <Typography variant="subtitle2" sx={{paddingTop:0, fontSize:11}}>{file.lastUpdated}</Typography>
400
+ </Paper>
401
+ </Grid>
402
+
403
+ ))}
404
+ </Grid>
405
+
406
+
407
+ {(files != null && files.documentAndFiles != null && zeroStateView != null) &&
408
+
409
+ <Box>
410
+ {zeroStateView(segment)}
411
+ </Box>
412
+ }
442
413
 
443
- </Box>
414
+ </Box>
444
415
 
445
- ))}
446
-
416
+ ))}
417
+ </>
418
+ }
447
419
 
448
420
  {(files.documentSegments.length == 0 || folderParent != null) &&
449
- <Grid container spacing={2}>
450
- {files.documentAndFiles.map((file, index) => (
421
+ <>
422
+ <Grid container spacing={2}>
423
+ {files.documentAndFiles.map((file, index) => (
424
+
425
+ <Grid onContextMenu={(event) => {
426
+ handleContextMenu(event, file);
427
+ }} item key={index} xs={xs} sm={sm} md={md} lg={lg} onClick={() => handleFileClick(file)}>
428
+ <Paper
429
+ sx={{
430
+ padding: 2,
431
+ flexDirection: 'column',
432
+ height: "100%", display: "flex", alignItems: "center",
433
+ cursor: 'pointer',
434
+ maxHeight:300,
435
+ position:"relative",
436
+ '&:hover': {
437
+ backgroundColor: '#F5F5F5'
438
+ }
439
+ }}>
440
+
441
+ {file.type === 'folder' &&
442
+ <Box sx={{position:"absolute", top:45, color:"white"}}>
443
+ {file.count}
444
+ </Box>}
445
+
446
+ {file.isLocked &&
447
+ <Box sx={{position:"absolute", top:10, right: 10, color:"black"}}>
448
+ <Tooltip title={overrideLockMessage}>
449
+ <LockRoundedIcon />
450
+ </Tooltip>
451
+ </Box>
452
+ }
453
+
454
+ {file.type === 'folder' ? (
455
+ <FolderIcon sx={{ fontSize: 80, color:"orange" }} />
456
+ ) : (
457
+
458
+ file.documentFileExtentionType == 0 || disablePreview ? <InsertDriveFileOutlinedIcon sx={{ fontSize: 60 }} /> : <NextImage src={file.uri} alt={"Image"} width={80} height={80} />
459
+
460
+ )}
461
+ <Typography variant="subtitle1" sx={{paddingTop:1, fontSize:14}}>{file.name}</Typography>
462
+ <Typography variant="subtitle2" sx={{paddingTop:0, fontSize:11}}>{file.lastUpdated}</Typography>
463
+ </Paper>
464
+ </Grid>
465
+
466
+ ))}
467
+ </Grid>
468
+
469
+ {(files != null && files.documentAndFiles != null && zeroStateView != null) &&
451
470
 
452
- <Grid onContextMenu={(event) => {
453
- handleContextMenu(event, file);
454
- }} item key={index} xs={xs} sm={sm} md={md} lg={lg} onClick={() => handleFileClick(file)}>
455
- <Paper
456
- sx={{
457
- padding: 2,
458
- flexDirection: 'column',
459
- height: "100%", display: "flex", alignItems: "center",
460
- cursor: 'pointer',
461
- maxHeight:300,
462
- position:"relative",
463
- '&:hover': {
464
- backgroundColor: '#F5F5F5'
465
- }
466
- }}>
467
-
468
- {file.type === 'folder' &&
469
- <Box sx={{position:"absolute", top:45, color:"white"}}>
470
- {file.count}
471
- </Box>}
472
-
473
- {file.isLocked &&
474
- <Box sx={{position:"absolute", top:10, right: 10, color:"black"}}>
475
- <Tooltip title={overrideLockMessage}>
476
- <LockRoundedIcon />
477
- </Tooltip>
478
- </Box>
479
- }
480
-
481
- {file.type === 'folder' ? (
482
- <FolderIcon sx={{ fontSize: 80, color:"orange" }} />
483
- ) : (
484
-
485
- file.documentFileExtentionType == 0 || disablePreview ? <InsertDriveFileOutlinedIcon sx={{ fontSize: 60 }} /> : <NextImage src={file.uri} alt={"Image"} width={80} height={80} />
486
-
487
- )}
488
- <Typography variant="subtitle1" sx={{paddingTop:1, fontSize:14}}>{file.name}</Typography>
489
- <Typography variant="subtitle2" sx={{paddingTop:0, fontSize:11}}>{file.lastUpdated}</Typography>
490
- </Paper>
491
- </Grid>
471
+ <Box>
472
+ {zeroStateView()}
473
+ </Box>
474
+ }
492
475
 
493
- ))}
494
- </Grid>
476
+ </>
495
477
  }
496
478
 
497
479
  </>
498
480
  }
481
+
482
+
483
+
484
+
485
+
499
486
  <Menu
500
487
  open={contextMenu !== null}
501
488
  onClose={handleClose}