@manuscripts/style-guide 0.30.24 → 0.30.25
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/FileManager/FileManager.js +19 -37
- package/dist/cjs/components/FileManager/FileSectionItem/DesignationActions.js +4 -4
- package/dist/cjs/components/FileManager/FileSectionItem/DesignationActionsList.js +5 -5
- package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +4 -5
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +8 -8
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +2 -2
- package/dist/cjs/components/FileManager/FileSectionState.js +1 -16
- package/dist/cjs/components/FileManager/FilesSection.js +1 -6
- package/dist/cjs/components/FileManager/InlineFilesSection.js +1 -1
- package/dist/cjs/components/FileManager/util.js +7 -23
- package/dist/cjs/lib/inlineFiles.js +23 -15
- package/dist/es/components/FileManager/FileManager.js +20 -38
- package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +4 -4
- package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +5 -5
- package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +4 -5
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +8 -8
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +2 -2
- package/dist/es/components/FileManager/FileSectionState.js +1 -16
- package/dist/es/components/FileManager/FilesSection.js +1 -6
- package/dist/es/components/FileManager/InlineFilesSection.js +1 -1
- package/dist/es/components/FileManager/util.js +5 -19
- package/dist/es/lib/inlineFiles.js +23 -15
- package/dist/types/components/FileManager/FileManager.d.ts +6 -5
- package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +2 -1
- package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +2 -1
- package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +2 -2
- package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +14 -4
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +4 -2
- package/dist/types/components/FileManager/FileSectionState.d.ts +2 -7
- package/dist/types/components/FileManager/FilesSection.d.ts +1 -1
- package/dist/types/components/FileManager/InlineFilesSection.d.ts +1 -1
- package/dist/types/components/FileManager/UploadFileArea.d.ts +1 -1
- package/dist/types/components/FileManager/util.d.ts +5 -6
- package/package.json +1 -1
|
@@ -46,48 +46,30 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
|
|
|
46
46
|
const TooltipDiv_1 = require("./TooltipDiv");
|
|
47
47
|
const util_1 = require("./util");
|
|
48
48
|
exports.PermissionsContext = (0, react_1.createContext)(null);
|
|
49
|
-
const FileManager = ({ submissionId,
|
|
49
|
+
const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
50
50
|
const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
|
|
51
|
-
const handleReplaceFile = (0, react_1.useCallback)((submissionId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
const handleReplaceFile = (0, react_1.useCallback)((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
52
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
53
53
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.namesWithDesignationMap.get(typeId) || util_1.Designation.Document));
|
|
54
|
-
const res = yield handleReplace(submissionId, name, file, typeId);
|
|
55
|
-
if (res) {
|
|
56
|
-
dispatch(FileSectionState_1.actions.SHOW_FILE_UPLOADED_ALERT());
|
|
57
|
-
}
|
|
54
|
+
const res = yield handleReplace(submissionId, attachmentId, name, file, typeId);
|
|
58
55
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
59
56
|
return res;
|
|
60
57
|
}), [handleReplace]);
|
|
61
58
|
const handleUploadFile = (0, react_1.useCallback)((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
|
|
66
|
-
}
|
|
67
|
-
const res = yield handleUpload(submissionId, file, designation);
|
|
68
|
-
if (res) {
|
|
69
|
-
dispatch(FileSectionState_1.actions.SHOW_FILE_UPLOADED_ALERT());
|
|
70
|
-
}
|
|
71
|
-
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
72
|
-
return res;
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
console.error(e);
|
|
76
|
-
return false;
|
|
59
|
+
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
60
|
+
if (util_1.namesWithDesignationMap.get(designation) == util_1.Designation.Supplementary) {
|
|
61
|
+
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
|
|
77
62
|
}
|
|
63
|
+
const res = yield handleUpload(submissionId, file, designation);
|
|
64
|
+
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
65
|
+
return res;
|
|
78
66
|
}), [handleUpload]);
|
|
79
|
-
const handleChangeDesignationFile = (0, react_1.useCallback)((submissionId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE());
|
|
84
|
-
}
|
|
85
|
-
return res;
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
console.log(e);
|
|
89
|
-
return false;
|
|
67
|
+
const handleChangeDesignationFile = (0, react_1.useCallback)((submissionId, attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
const res = yield handleChangeDesignation(submissionId, attachmentId, typeId, name);
|
|
69
|
+
if (res) {
|
|
70
|
+
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE());
|
|
90
71
|
}
|
|
72
|
+
return res;
|
|
91
73
|
}), [handleChangeDesignation]);
|
|
92
74
|
const handleDownloadFile = (0, react_1.useCallback)((publicUrl) => {
|
|
93
75
|
return handleDownload(publicUrl);
|
|
@@ -95,12 +77,12 @@ const FileManager = ({ submissionId, externalFiles, modelMap, enableDragAndDrop,
|
|
|
95
77
|
const getFileSectionExternalFile = (fileSection) => {
|
|
96
78
|
const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
|
|
97
79
|
fileSection === util_1.FileSectionType.OtherFile;
|
|
98
|
-
const itemsData =
|
|
99
|
-
const designation = util_1.namesWithDesignationMap.get(element.
|
|
80
|
+
const itemsData = attachments.filter((element) => {
|
|
81
|
+
const designation = util_1.namesWithDesignationMap.get(element.type.label);
|
|
100
82
|
return (designation !== undefined &&
|
|
101
83
|
util_1.designationWithFileSectionsMap.get(designation) === fileSection);
|
|
102
84
|
});
|
|
103
|
-
const itemsDataWithTitle = (0, util_1.
|
|
85
|
+
const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
|
|
104
86
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
105
87
|
const itemProps = {
|
|
106
88
|
submissionId: submissionId,
|
|
@@ -114,10 +96,10 @@ const FileManager = ({ submissionId, externalFiles, modelMap, enableDragAndDrop,
|
|
|
114
96
|
dispatch: dispatch,
|
|
115
97
|
};
|
|
116
98
|
if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
|
|
117
|
-
return (react_1.default.createElement(DraggableFileSectionItem_1.DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.
|
|
99
|
+
return (react_1.default.createElement(DraggableFileSectionItem_1.DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id })));
|
|
118
100
|
}
|
|
119
101
|
else {
|
|
120
|
-
return (react_1.default.createElement(FileSectionItem_1.FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.
|
|
102
|
+
return (react_1.default.createElement(FileSectionItem_1.FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id, isEditor: enableDragAndDrop })));
|
|
121
103
|
}
|
|
122
104
|
});
|
|
123
105
|
return filesItems;
|
|
@@ -29,7 +29,7 @@ const BottomArrowIcon_1 = __importDefault(require("../../icons/BottomArrowIcon")
|
|
|
29
29
|
const ConfirmationPopUp_1 = require("../ConfirmationPopUp");
|
|
30
30
|
const util_1 = require("../util");
|
|
31
31
|
const DesignationActionsList_1 = require("./DesignationActionsList");
|
|
32
|
-
const DesignationActions = ({ designation, fileExtension, handleChangeDesignation, submissionId, fileName, dispatch, }) => {
|
|
32
|
+
const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, submissionId, fileName, dispatch, }) => {
|
|
33
33
|
const [isActionsShown, setIsActionsShown] = (0, react_1.useState)(false);
|
|
34
34
|
const [confirmationPopUpData, setConfirmationPopUpData] = (0, react_1.useState)({
|
|
35
35
|
isConfirmationPopUpOpen: false,
|
|
@@ -45,7 +45,7 @@ const DesignationActions = ({ designation, fileExtension, handleChangeDesignatio
|
|
|
45
45
|
const hideActionsList = () => {
|
|
46
46
|
setIsActionsShown(false);
|
|
47
47
|
};
|
|
48
|
-
if (designation && fileExtension) {
|
|
48
|
+
if (designation !== undefined && fileExtension) {
|
|
49
49
|
const designationActionsList = (0, util_1.getDesignationActionsList)(designation, fileExtension);
|
|
50
50
|
if (!designationActionsList.length) {
|
|
51
51
|
return null;
|
|
@@ -60,7 +60,7 @@ const DesignationActions = ({ designation, fileExtension, handleChangeDesignatio
|
|
|
60
60
|
};
|
|
61
61
|
const handleMoveAction = () => {
|
|
62
62
|
handleChangeDesignation &&
|
|
63
|
-
handleChangeDesignation(submissionId, confirmationPopUpData.selectedDesignation, fileName);
|
|
63
|
+
handleChangeDesignation(submissionId, attachmentId, confirmationPopUpData.selectedDesignation, fileName);
|
|
64
64
|
handleCloseAction();
|
|
65
65
|
};
|
|
66
66
|
const handleCloseAction = () => {
|
|
@@ -76,7 +76,7 @@ const DesignationActions = ({ designation, fileExtension, handleChangeDesignatio
|
|
|
76
76
|
react_1.default.createElement(SecondaryActionsText, null, util_1.designationWithReadableNamesMap.get(designation)),
|
|
77
77
|
react_1.default.createElement(BottomArrowIcon_1.default, null),
|
|
78
78
|
isActionsShown && (react_1.default.createElement(ActionsListContainer, null,
|
|
79
|
-
react_1.default.createElement(DesignationActionsList_1.DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
|
|
79
|
+
react_1.default.createElement(DesignationActionsList_1.DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
|
|
80
80
|
confirmationPopUpData.isConfirmationPopUpOpen && (react_1.default.createElement(ConfirmationPopUp_1.ConfirmationPopUp, { popupHeader: confirmationPopUpData.confirmationPopUpHeader !== undefined
|
|
81
81
|
? confirmationPopUpData.confirmationPopUpHeader
|
|
82
82
|
: '', popUpMessage: confirmationPopUpData.confirmationPopUpMessage !== undefined
|
|
@@ -8,17 +8,17 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const FileSectionState_1 = require("../FileSectionState");
|
|
9
9
|
const ItemsAction_1 = require("../ItemsAction");
|
|
10
10
|
const util_1 = require("../util");
|
|
11
|
-
const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, submissionId, fileName, designation, dispatch, handleOpenConfirmationPopup, }) => {
|
|
11
|
+
const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, submissionId, fileName, designation, attachmentId, dispatch, handleOpenConfirmationPopup, }) => {
|
|
12
12
|
const handleChangeOtherFilesTabDesignation = (designation, isMoveInOtherFileSection, confirmationPopupHeader, confirmationPopupMessage, successMoveMessage) => {
|
|
13
13
|
if (isMoveInOtherFileSection) {
|
|
14
14
|
if (dispatch) {
|
|
15
|
-
dispatch(FileSectionState_1.actions.MOVE_FILE(submissionId, (0, util_1.getDesignationName)(designation), fileName, successMoveMessage));
|
|
15
|
+
dispatch(FileSectionState_1.actions.MOVE_FILE(submissionId, attachmentId, (0, util_1.getDesignationName)(designation), fileName, successMoveMessage));
|
|
16
16
|
handleOpenConfirmationPopup(confirmationPopupHeader, confirmationPopupMessage, (0, util_1.getDesignationName)(designation));
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
handleChangeDesignation &&
|
|
21
|
-
handleChangeDesignation(submissionId, (0, util_1.getDesignationName)(designation), fileName);
|
|
21
|
+
handleChangeDesignation(submissionId, attachmentId, (0, util_1.getDesignationName)(designation), fileName);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
const isSupplementaryActionIncluded = designationActionsList.indexOf(util_1.Designation.Supplementary) !== -1;
|
|
@@ -27,7 +27,7 @@ const DesignationActionsList = ({ handleChangeDesignation, designationActionsLis
|
|
|
27
27
|
.map((value) => {
|
|
28
28
|
return (react_1.default.createElement(ItemsAction_1.ActionsItem, { key: value, onClick: () => {
|
|
29
29
|
let isMoveToOtherFileSection = true;
|
|
30
|
-
if (designation) {
|
|
30
|
+
if (designation !== undefined) {
|
|
31
31
|
isMoveToOtherFileSection =
|
|
32
32
|
util_1.designationWithFileSectionsMap.get(designation) !==
|
|
33
33
|
util_1.FileSectionType.OtherFile;
|
|
@@ -43,7 +43,7 @@ const DesignationActionsList = ({ handleChangeDesignation, designationActionsLis
|
|
|
43
43
|
react_1.default.createElement(ItemsAction_1.ActionsSeparator, null),
|
|
44
44
|
react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: () => {
|
|
45
45
|
let isMoveToOtherFileSection = true;
|
|
46
|
-
if (designation) {
|
|
46
|
+
if (designation !== undefined) {
|
|
47
47
|
isMoveToOtherFileSection =
|
|
48
48
|
util_1.designationWithFileSectionsMap.get(designation) !==
|
|
49
49
|
util_1.FileSectionType.Supplements;
|
|
@@ -27,14 +27,14 @@ const react_1 = __importStar(require("react"));
|
|
|
27
27
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
28
28
|
const FileManager_1 = require("../FileManager");
|
|
29
29
|
const DesignationActions_1 = require("./DesignationActions");
|
|
30
|
-
const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation,
|
|
30
|
+
const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, submissionId, dispatch, }) => {
|
|
31
31
|
const fileName = submissionAttachmentName.substring(0, submissionAttachmentName.lastIndexOf('.'));
|
|
32
32
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
33
33
|
return (react_1.default.createElement(exports.FileInfoContainer, null,
|
|
34
34
|
(can === null || can === void 0 ? void 0 : can.changeDesignation) &&
|
|
35
35
|
showDesignationActions &&
|
|
36
|
-
designation &&
|
|
37
|
-
submissionId && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch })),
|
|
36
|
+
designation !== undefined &&
|
|
37
|
+
submissionId && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch })),
|
|
38
38
|
react_1.default.createElement(exports.FileNameTitleContainer, null,
|
|
39
39
|
react_1.default.createElement(exports.FileTitle, null,
|
|
40
40
|
!showAttachmentName ? fileName : title,
|
|
@@ -43,8 +43,7 @@ const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissio
|
|
|
43
43
|
react_1.default.createElement(exports.FileName, null, fileName),
|
|
44
44
|
react_1.default.createElement("div", null,
|
|
45
45
|
".",
|
|
46
|
-
fileExtension))))
|
|
47
|
-
description && react_1.default.createElement(exports.FileDescription, null, description)));
|
|
46
|
+
fileExtension))))));
|
|
48
47
|
};
|
|
49
48
|
exports.FileInfo = FileInfo;
|
|
50
49
|
exports.FileInfoContainer = styled_components_1.default.div `
|
|
@@ -16,20 +16,20 @@ const FileTypeIcon_1 = require("./FileTypeIcon");
|
|
|
16
16
|
const ItemActions_1 = require("./ItemActions");
|
|
17
17
|
const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName = false, showDesignationActions = false, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
|
|
18
18
|
const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
|
|
19
|
-
const fileExtension = externalFile.
|
|
20
|
-
const designation = util_1.namesWithDesignationMap.get(externalFile.
|
|
19
|
+
const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
|
|
20
|
+
const designation = util_1.namesWithDesignationMap.get(externalFile.type.label);
|
|
21
21
|
const isMainManuscript = designation === util_1.Designation.MainManuscript;
|
|
22
|
-
const isSelected = externalFile.
|
|
22
|
+
const isSelected = externalFile.id == window.location.hash.substr(1);
|
|
23
23
|
return (react_1.default.createElement(exports.Item, { ref: dragRef, className: className, style: style },
|
|
24
24
|
react_1.default.createElement(exports.ItemContainer, { onClick: () => {
|
|
25
25
|
window.location.hash =
|
|
26
|
-
isEditor && !isSelected ? `#${externalFile.
|
|
26
|
+
isEditor && !isSelected ? `#${externalFile.id}` : '#';
|
|
27
27
|
if (isSelected) {
|
|
28
|
-
window.location.hash = `#${externalFile.
|
|
28
|
+
window.location.hash = `#${externalFile.id}`;
|
|
29
29
|
}
|
|
30
30
|
} },
|
|
31
|
-
react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.
|
|
32
|
-
react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.
|
|
31
|
+
react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
|
|
32
|
+
react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, dispatch: dispatch })),
|
|
33
33
|
onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
|
|
34
34
|
e.preventDefault();
|
|
35
35
|
onClose();
|
|
@@ -38,7 +38,7 @@ const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName
|
|
|
38
38
|
handleDownload && handleReplace && submissionId && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
|
|
39
39
|
react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
40
40
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
41
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.
|
|
41
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
42
42
|
};
|
|
43
43
|
exports.FileSectionItem = FileSectionItem;
|
|
44
44
|
const IconCloseButton = styled_components_1.default.button `
|
|
@@ -25,7 +25,7 @@ const Dropdown_1 = require("../../Dropdown");
|
|
|
25
25
|
const FileManager_1 = require("../FileManager");
|
|
26
26
|
const FileSectionState_1 = require("../FileSectionState");
|
|
27
27
|
const ItemsAction_1 = require("../ItemsAction");
|
|
28
|
-
const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
|
|
28
|
+
const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
|
|
29
29
|
const attachmentDesignation = designation == undefined ? 'undefined' : designation;
|
|
30
30
|
const fileInputRef = (0, react_1.useRef)(null);
|
|
31
31
|
const [selectedFile, setSelectedFile] = (0, react_1.useState)();
|
|
@@ -37,7 +37,7 @@ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, subm
|
|
|
37
37
|
if (dispatch) {
|
|
38
38
|
dispatch(FileSectionState_1.actions.UPLOAD_FILE(file));
|
|
39
39
|
}
|
|
40
|
-
replaceAttachmentHandler(submissionId, fileName, file, attachmentDesignation);
|
|
40
|
+
replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
|
|
41
41
|
hideActionList();
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -4,7 +4,6 @@ exports.actions = exports.reducer = exports.getInitialState = void 0;
|
|
|
4
4
|
const getInitialState = () => ({
|
|
5
5
|
uploadedFile: undefined,
|
|
6
6
|
isUploadFile: false,
|
|
7
|
-
isFileUploaded: false,
|
|
8
7
|
moveToOtherState: undefined,
|
|
9
8
|
successMessage: '',
|
|
10
9
|
isShowSuccessMessage: false,
|
|
@@ -21,8 +20,6 @@ var ActionTypes;
|
|
|
21
20
|
ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
|
|
22
21
|
ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
|
|
23
22
|
ActionTypes["HANDLE_SUCCESS_MESSAGE"] = "handleSuccessMessage";
|
|
24
|
-
ActionTypes["SHOW_FILE_UPLOADED_ALERT"] = "showFileUploadedAlert";
|
|
25
|
-
ActionTypes["CLOSE_FILE_UPLOADED_ALERT"] = "closeFileUploadedAlert";
|
|
26
23
|
})(ActionTypes || (ActionTypes = {}));
|
|
27
24
|
const reducer = (state, action) => {
|
|
28
25
|
switch (action.type) {
|
|
@@ -48,15 +45,9 @@ const reducer = (state, action) => {
|
|
|
48
45
|
case ActionTypes.HANDLE_FINISH_UPLOAD: {
|
|
49
46
|
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
50
47
|
}
|
|
51
|
-
case ActionTypes.SHOW_FILE_UPLOADED_ALERT: {
|
|
52
|
-
return Object.assign(Object.assign({}, state), { isFileUploaded: true });
|
|
53
|
-
}
|
|
54
48
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
55
49
|
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
56
50
|
}
|
|
57
|
-
case ActionTypes.CLOSE_FILE_UPLOADED_ALERT: {
|
|
58
|
-
return Object.assign(Object.assign({}, state), { isFileUploaded: false });
|
|
59
|
-
}
|
|
60
51
|
}
|
|
61
52
|
return state;
|
|
62
53
|
};
|
|
@@ -76,7 +67,7 @@ exports.actions = {
|
|
|
76
67
|
type: ActionTypes.SELECT_DESIGNATION,
|
|
77
68
|
designation,
|
|
78
69
|
}),
|
|
79
|
-
MOVE_FILE: (submissionId, typeId, name, successMoveMessage) => ({
|
|
70
|
+
MOVE_FILE: (submissionId, attachmentId, typeId, name, successMoveMessage) => ({
|
|
80
71
|
type: ActionTypes.MOVE_FILE,
|
|
81
72
|
submissionId,
|
|
82
73
|
typeId,
|
|
@@ -86,12 +77,6 @@ exports.actions = {
|
|
|
86
77
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
87
78
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
88
79
|
}),
|
|
89
|
-
SHOW_FILE_UPLOADED_ALERT: () => ({
|
|
90
|
-
type: ActionTypes.SHOW_FILE_UPLOADED_ALERT,
|
|
91
|
-
}),
|
|
92
|
-
CLOSE_FILE_UPLOADED_ALERT: () => ({
|
|
93
|
-
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
94
|
-
}),
|
|
95
80
|
HANDLE_SUCCESS_MESSAGE: () => ({
|
|
96
81
|
type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
|
|
97
82
|
}),
|
|
@@ -21,7 +21,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.FilesSection = void 0;
|
|
23
23
|
const react_1 = __importStar(require("react"));
|
|
24
|
-
const AlertMessage_1 = require("../AlertMessage");
|
|
25
24
|
const DragItemArea_1 = require("./DragItemArea");
|
|
26
25
|
const FileManager_1 = require("./FileManager");
|
|
27
26
|
const FileSectionUploadItem_1 = require("./FileSectionItem/FileSectionUploadItem");
|
|
@@ -48,11 +47,7 @@ const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSecti
|
|
|
48
47
|
(isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, submissionId: submissionId, dispatch: dispatch })),
|
|
49
48
|
state.isUploadFile &&
|
|
50
49
|
state.uploadedFile &&
|
|
51
|
-
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })),
|
|
52
|
-
state.isFileUploaded && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.info, hideCloseButton: true, dismissButton: {
|
|
53
|
-
action: () => dispatch(FileSectionState_1.actions.CLOSE_FILE_UPLOADED_ALERT()),
|
|
54
|
-
text: 'Close',
|
|
55
|
-
} }, "File uploaded successfully. It may take a few moments to show the new file in the Inspector.")))),
|
|
50
|
+
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
|
|
56
51
|
state.uploadedFile && isOtherFileTab && (react_1.default.createElement(SelectDialogDesignation_1.SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
|
|
57
52
|
dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
|
|
58
53
|
}, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
|
|
@@ -71,7 +71,7 @@ const FileReference = ({ externalFile, submissionId, handleReplace, handleDownlo
|
|
|
71
71
|
handleDownload && handleReplace && submissionId && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
|
|
72
72
|
react_1.default.createElement(FileSectionItem_1.ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
73
73
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
74
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
|
|
74
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: undefined, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
|
|
75
75
|
};
|
|
76
76
|
const ElementItem = (0, styled_components_1.default)(FileSectionItem_1.Item) `
|
|
77
77
|
display: flex;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.droppableSections = exports.getUploadFileDesignationList = exports.getDesignationByFileSection = exports.getDesignationName = exports.getDesignationActionsList = exports.generateAttachmentsTitles = exports.fileTypesWithIconMap = exports.fileTypesWithTitlesMap = exports.extensionsWithFileTypesMap = exports.designationWithAllowedDesignationsToTransitionMap = exports.designationWithAllowedMediaTypesMap = exports.designationWithReadableNamesMap = exports.namesWithDesignationMap = exports.designationWithFileSectionsMap = exports.Designation = exports.FileType = exports.FileSectionType = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const audio_icon_1 = __importDefault(require("../icons/audio-icon"));
|
|
9
9
|
const code_file_icon_1 = __importDefault(require("../icons/code-file-icon"));
|
|
@@ -56,8 +56,8 @@ var Designation;
|
|
|
56
56
|
Designation[Designation["MainManuscript"] = 13] = "MainManuscript";
|
|
57
57
|
})(Designation = exports.Designation || (exports.Designation = {}));
|
|
58
58
|
exports.designationWithFileSectionsMap = new Map([
|
|
59
|
-
[Designation.Figure, FileSectionType.
|
|
60
|
-
[Designation.Table, FileSectionType.
|
|
59
|
+
[Designation.Figure, FileSectionType.OtherFile],
|
|
60
|
+
[Designation.Table, FileSectionType.OtherFile],
|
|
61
61
|
[Designation.Supplementary, FileSectionType.Supplements],
|
|
62
62
|
[Designation.ConflictOfInterest, FileSectionType.OtherFile],
|
|
63
63
|
[Designation.Document, FileSectionType.OtherFile],
|
|
@@ -352,15 +352,15 @@ exports.fileTypesWithIconMap = new Map([
|
|
|
352
352
|
],
|
|
353
353
|
[undefined, react_1.default.createElement(unknown_format_file_icon_1.default, { key: undefined })],
|
|
354
354
|
]);
|
|
355
|
-
const
|
|
355
|
+
const generateAttachmentsTitles = (externalFiles, fileSectionType) => {
|
|
356
356
|
const titleCountersMap = new Map();
|
|
357
357
|
const externalFilesWithTitlesMap = new Map();
|
|
358
358
|
externalFiles.forEach((element) => {
|
|
359
|
-
const fileExtension = element.
|
|
359
|
+
const fileExtension = element.name.substring(element.name.lastIndexOf('.') + 1);
|
|
360
360
|
const fileType = exports.extensionsWithFileTypesMap.get(fileExtension.toLowerCase());
|
|
361
361
|
const fileTitle = exports.fileTypesWithTitlesMap.get(fileType);
|
|
362
362
|
if (fileSectionType === FileSectionType.Inline) {
|
|
363
|
-
externalFilesWithTitlesMap.set(element.
|
|
363
|
+
externalFilesWithTitlesMap.set(element.name, element);
|
|
364
364
|
}
|
|
365
365
|
else {
|
|
366
366
|
if (fileTitle !== undefined) {
|
|
@@ -383,15 +383,7 @@ const generateExternalFilesTitles = (externalFiles, fileSectionType) => {
|
|
|
383
383
|
}));
|
|
384
384
|
return result;
|
|
385
385
|
};
|
|
386
|
-
exports.
|
|
387
|
-
const sortExternalFiles = (externalFile) => externalFile
|
|
388
|
-
.sort((a, b) => Number(a.createdAt) - Number(b.createdAt))
|
|
389
|
-
.sort((a, b) => b.designation === 'main-manuscript'
|
|
390
|
-
? 1
|
|
391
|
-
: a.designation === 'main-manuscript'
|
|
392
|
-
? -1
|
|
393
|
-
: 0);
|
|
394
|
-
exports.sortExternalFiles = sortExternalFiles;
|
|
386
|
+
exports.generateAttachmentsTitles = generateAttachmentsTitles;
|
|
395
387
|
const getDesignationActionsList = (designation, fileExtension) => {
|
|
396
388
|
const allowedDesignationsToTransition = exports.designationWithAllowedDesignationsToTransitionMap.get(designation);
|
|
397
389
|
if (allowedDesignationsToTransition) {
|
|
@@ -479,11 +471,3 @@ exports.droppableSections = [
|
|
|
479
471
|
FileSectionType.Supplements,
|
|
480
472
|
FileSectionType.OtherFile,
|
|
481
473
|
];
|
|
482
|
-
const isOfDesignation = (file, designation) => {
|
|
483
|
-
const formats = exports.designationWithAllowedMediaTypesMap.get(designation);
|
|
484
|
-
return !!(formats === null || formats === void 0 ? void 0 : formats.find((type) => file.MIME.indexOf('/' + type) >= 0));
|
|
485
|
-
};
|
|
486
|
-
const isFigure = (file) => {
|
|
487
|
-
return isOfDesignation(file, Designation.Figure);
|
|
488
|
-
};
|
|
489
|
-
exports.isFigure = isFigure;
|
|
@@ -7,14 +7,17 @@ const getCaptionText = (caption) => caption &&
|
|
|
7
7
|
new DOMParser().parseFromString(caption, 'text/html').documentElement
|
|
8
8
|
.innerText;
|
|
9
9
|
const getFigureData = (element, modelMap) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const externalFileReferences = [];
|
|
11
|
+
element.containedObjectIDs.map((e) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const object = modelMap.get(e);
|
|
14
|
+
if (object && object.objectType === manuscripts_json_schema_1.ObjectTypes.Figure) {
|
|
15
|
+
const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
|
|
16
|
+
if (externalFileRef) {
|
|
17
|
+
externalFileReferences.push(externalFileRef);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
13
20
|
});
|
|
14
|
-
const { externalFileReferences } = (figureId &&
|
|
15
|
-
modelMap.get(figureId)) || {
|
|
16
|
-
externalFileReferences: undefined,
|
|
17
|
-
};
|
|
18
21
|
return {
|
|
19
22
|
id: element._id,
|
|
20
23
|
externalFileReferences,
|
|
@@ -36,25 +39,30 @@ exports.default = (modelMap) => {
|
|
|
36
39
|
}
|
|
37
40
|
else {
|
|
38
41
|
(_b = section.elementIDs) === null || _b === void 0 ? void 0 : _b.map((elementId) => {
|
|
42
|
+
var _a;
|
|
39
43
|
const element = modelMap.get(elementId);
|
|
40
44
|
if (!element) {
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
43
47
|
switch (element.objectType) {
|
|
44
|
-
case manuscripts_json_schema_1.ObjectTypes.FigureElement:
|
|
48
|
+
case manuscripts_json_schema_1.ObjectTypes.FigureElement:
|
|
49
|
+
case manuscripts_json_schema_1.ObjectTypes.MultiGraphicFigureElement: {
|
|
45
50
|
files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Figure`, type: util_1.FileType.Figure }));
|
|
46
51
|
break;
|
|
47
52
|
}
|
|
48
53
|
case manuscripts_json_schema_1.ObjectTypes.TableElement: {
|
|
49
54
|
const tableElement = element;
|
|
50
55
|
const table = modelMap.get(tableElement.containedObjectID);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const externalFileReferences = (_a = table.externalFileReferences) === null || _a === void 0 ? void 0 : _a.filter((file) => file.kind === 'dataset' && file.ref);
|
|
57
|
+
if (externalFileReferences && externalFileReferences.length > 0) {
|
|
58
|
+
files.push({
|
|
59
|
+
id: element._id,
|
|
60
|
+
label: `Table`,
|
|
61
|
+
type: util_1.FileType.SheetsWorkbooks,
|
|
62
|
+
externalFileReferences: table.externalFileReferences,
|
|
63
|
+
caption: getCaptionText(tableElement.caption),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
58
66
|
break;
|
|
59
67
|
}
|
|
60
68
|
}
|
|
@@ -19,50 +19,32 @@ import { actions, getInitialState, reducer } from './FileSectionState';
|
|
|
19
19
|
import { FilesSection } from './FilesSection';
|
|
20
20
|
import { InlineFilesSection } from './InlineFilesSection';
|
|
21
21
|
import { TooltipDiv } from './TooltipDiv';
|
|
22
|
-
import { Designation, designationWithFileSectionsMap, FileSectionType,
|
|
22
|
+
import { Designation, designationWithFileSectionsMap, FileSectionType, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
|
|
23
23
|
export const PermissionsContext = createContext(null);
|
|
24
|
-
export const FileManager = ({ submissionId,
|
|
24
|
+
export const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
25
25
|
const [state, dispatch] = useReducer(reducer, getInitialState());
|
|
26
|
-
const handleReplaceFile = useCallback((submissionId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const handleReplaceFile = useCallback((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
27
|
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
28
28
|
dispatch(actions.SELECT_DESIGNATION(namesWithDesignationMap.get(typeId) || Designation.Document));
|
|
29
|
-
const res = yield handleReplace(submissionId, name, file, typeId);
|
|
30
|
-
if (res) {
|
|
31
|
-
dispatch(actions.SHOW_FILE_UPLOADED_ALERT());
|
|
32
|
-
}
|
|
29
|
+
const res = yield handleReplace(submissionId, attachmentId, name, file, typeId);
|
|
33
30
|
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
34
31
|
return res;
|
|
35
32
|
}), [handleReplace]);
|
|
36
33
|
const handleUploadFile = useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
|
|
41
|
-
}
|
|
42
|
-
const res = yield handleUpload(submissionId, file, designation);
|
|
43
|
-
if (res) {
|
|
44
|
-
dispatch(actions.SHOW_FILE_UPLOADED_ALERT());
|
|
45
|
-
}
|
|
46
|
-
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
47
|
-
return res;
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
console.error(e);
|
|
51
|
-
return false;
|
|
34
|
+
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
35
|
+
if (namesWithDesignationMap.get(designation) == Designation.Supplementary) {
|
|
36
|
+
dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
|
|
52
37
|
}
|
|
38
|
+
const res = yield handleUpload(submissionId, file, designation);
|
|
39
|
+
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
40
|
+
return res;
|
|
53
41
|
}), [handleUpload]);
|
|
54
|
-
const handleChangeDesignationFile = useCallback((submissionId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
dispatch(actions.HANDLE_SUCCESS_MESSAGE());
|
|
59
|
-
}
|
|
60
|
-
return res;
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
console.log(e);
|
|
64
|
-
return false;
|
|
42
|
+
const handleChangeDesignationFile = useCallback((submissionId, attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
const res = yield handleChangeDesignation(submissionId, attachmentId, typeId, name);
|
|
44
|
+
if (res) {
|
|
45
|
+
dispatch(actions.HANDLE_SUCCESS_MESSAGE());
|
|
65
46
|
}
|
|
47
|
+
return res;
|
|
66
48
|
}), [handleChangeDesignation]);
|
|
67
49
|
const handleDownloadFile = useCallback((publicUrl) => {
|
|
68
50
|
return handleDownload(publicUrl);
|
|
@@ -70,12 +52,12 @@ export const FileManager = ({ submissionId, externalFiles, modelMap, enableDragA
|
|
|
70
52
|
const getFileSectionExternalFile = (fileSection) => {
|
|
71
53
|
const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
|
|
72
54
|
fileSection === FileSectionType.OtherFile;
|
|
73
|
-
const itemsData =
|
|
74
|
-
const designation = namesWithDesignationMap.get(element.
|
|
55
|
+
const itemsData = attachments.filter((element) => {
|
|
56
|
+
const designation = namesWithDesignationMap.get(element.type.label);
|
|
75
57
|
return (designation !== undefined &&
|
|
76
58
|
designationWithFileSectionsMap.get(designation) === fileSection);
|
|
77
59
|
});
|
|
78
|
-
const itemsDataWithTitle =
|
|
60
|
+
const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
|
|
79
61
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
80
62
|
const itemProps = {
|
|
81
63
|
submissionId: submissionId,
|
|
@@ -89,10 +71,10 @@ export const FileManager = ({ submissionId, externalFiles, modelMap, enableDragA
|
|
|
89
71
|
dispatch: dispatch,
|
|
90
72
|
};
|
|
91
73
|
if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
|
|
92
|
-
return (React.createElement(DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.
|
|
74
|
+
return (React.createElement(DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id })));
|
|
93
75
|
}
|
|
94
76
|
else {
|
|
95
|
-
return (React.createElement(FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.
|
|
77
|
+
return (React.createElement(FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id, isEditor: enableDragAndDrop })));
|
|
96
78
|
}
|
|
97
79
|
});
|
|
98
80
|
return filesItems;
|
|
@@ -4,7 +4,7 @@ import BottomArrowIcon from '../../icons/BottomArrowIcon';
|
|
|
4
4
|
import { ConfirmationPopUp } from '../ConfirmationPopUp';
|
|
5
5
|
import { designationWithReadableNamesMap, getDesignationActionsList, } from '../util';
|
|
6
6
|
import { DesignationActionsList } from './DesignationActionsList';
|
|
7
|
-
export const DesignationActions = ({ designation, fileExtension, handleChangeDesignation, submissionId, fileName, dispatch, }) => {
|
|
7
|
+
export const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, submissionId, fileName, dispatch, }) => {
|
|
8
8
|
const [isActionsShown, setIsActionsShown] = useState(false);
|
|
9
9
|
const [confirmationPopUpData, setConfirmationPopUpData] = useState({
|
|
10
10
|
isConfirmationPopUpOpen: false,
|
|
@@ -20,7 +20,7 @@ export const DesignationActions = ({ designation, fileExtension, handleChangeDes
|
|
|
20
20
|
const hideActionsList = () => {
|
|
21
21
|
setIsActionsShown(false);
|
|
22
22
|
};
|
|
23
|
-
if (designation && fileExtension) {
|
|
23
|
+
if (designation !== undefined && fileExtension) {
|
|
24
24
|
const designationActionsList = getDesignationActionsList(designation, fileExtension);
|
|
25
25
|
if (!designationActionsList.length) {
|
|
26
26
|
return null;
|
|
@@ -35,7 +35,7 @@ export const DesignationActions = ({ designation, fileExtension, handleChangeDes
|
|
|
35
35
|
};
|
|
36
36
|
const handleMoveAction = () => {
|
|
37
37
|
handleChangeDesignation &&
|
|
38
|
-
handleChangeDesignation(submissionId, confirmationPopUpData.selectedDesignation, fileName);
|
|
38
|
+
handleChangeDesignation(submissionId, attachmentId, confirmationPopUpData.selectedDesignation, fileName);
|
|
39
39
|
handleCloseAction();
|
|
40
40
|
};
|
|
41
41
|
const handleCloseAction = () => {
|
|
@@ -51,7 +51,7 @@ export const DesignationActions = ({ designation, fileExtension, handleChangeDes
|
|
|
51
51
|
React.createElement(SecondaryActionsText, null, designationWithReadableNamesMap.get(designation)),
|
|
52
52
|
React.createElement(BottomArrowIcon, null),
|
|
53
53
|
isActionsShown && (React.createElement(ActionsListContainer, null,
|
|
54
|
-
React.createElement(DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
|
|
54
|
+
React.createElement(DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
|
|
55
55
|
confirmationPopUpData.isConfirmationPopUpOpen && (React.createElement(ConfirmationPopUp, { popupHeader: confirmationPopUpData.confirmationPopUpHeader !== undefined
|
|
56
56
|
? confirmationPopUpData.confirmationPopUpHeader
|
|
57
57
|
: '', popUpMessage: confirmationPopUpData.confirmationPopUpMessage !== undefined
|
|
@@ -2,17 +2,17 @@ import React from 'react';
|
|
|
2
2
|
import { actions } from '../FileSectionState';
|
|
3
3
|
import { ActionsBox, ActionsItem, ActionsLabel, ActionsSeparator, } from '../ItemsAction';
|
|
4
4
|
import { Designation, designationWithFileSectionsMap, designationWithReadableNamesMap, FileSectionType, getDesignationName, } from '../util';
|
|
5
|
-
export const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, submissionId, fileName, designation, dispatch, handleOpenConfirmationPopup, }) => {
|
|
5
|
+
export const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, submissionId, fileName, designation, attachmentId, dispatch, handleOpenConfirmationPopup, }) => {
|
|
6
6
|
const handleChangeOtherFilesTabDesignation = (designation, isMoveInOtherFileSection, confirmationPopupHeader, confirmationPopupMessage, successMoveMessage) => {
|
|
7
7
|
if (isMoveInOtherFileSection) {
|
|
8
8
|
if (dispatch) {
|
|
9
|
-
dispatch(actions.MOVE_FILE(submissionId, getDesignationName(designation), fileName, successMoveMessage));
|
|
9
|
+
dispatch(actions.MOVE_FILE(submissionId, attachmentId, getDesignationName(designation), fileName, successMoveMessage));
|
|
10
10
|
handleOpenConfirmationPopup(confirmationPopupHeader, confirmationPopupMessage, getDesignationName(designation));
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
handleChangeDesignation &&
|
|
15
|
-
handleChangeDesignation(submissionId, getDesignationName(designation), fileName);
|
|
15
|
+
handleChangeDesignation(submissionId, attachmentId, getDesignationName(designation), fileName);
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
const isSupplementaryActionIncluded = designationActionsList.indexOf(Designation.Supplementary) !== -1;
|
|
@@ -21,7 +21,7 @@ export const DesignationActionsList = ({ handleChangeDesignation, designationAct
|
|
|
21
21
|
.map((value) => {
|
|
22
22
|
return (React.createElement(ActionsItem, { key: value, onClick: () => {
|
|
23
23
|
let isMoveToOtherFileSection = true;
|
|
24
|
-
if (designation) {
|
|
24
|
+
if (designation !== undefined) {
|
|
25
25
|
isMoveToOtherFileSection =
|
|
26
26
|
designationWithFileSectionsMap.get(designation) !==
|
|
27
27
|
FileSectionType.OtherFile;
|
|
@@ -37,7 +37,7 @@ export const DesignationActionsList = ({ handleChangeDesignation, designationAct
|
|
|
37
37
|
React.createElement(ActionsSeparator, null),
|
|
38
38
|
React.createElement(ActionsItem, { onClick: () => {
|
|
39
39
|
let isMoveToOtherFileSection = true;
|
|
40
|
-
if (designation) {
|
|
40
|
+
if (designation !== undefined) {
|
|
41
41
|
isMoveToOtherFileSection =
|
|
42
42
|
designationWithFileSectionsMap.get(designation) !==
|
|
43
43
|
FileSectionType.Supplements;
|
|
@@ -2,14 +2,14 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { PermissionsContext } from '../FileManager';
|
|
4
4
|
import { DesignationActions } from './DesignationActions';
|
|
5
|
-
export const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation,
|
|
5
|
+
export const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, submissionId, dispatch, }) => {
|
|
6
6
|
const fileName = submissionAttachmentName.substring(0, submissionAttachmentName.lastIndexOf('.'));
|
|
7
7
|
const can = useContext(PermissionsContext);
|
|
8
8
|
return (React.createElement(FileInfoContainer, null,
|
|
9
9
|
(can === null || can === void 0 ? void 0 : can.changeDesignation) &&
|
|
10
10
|
showDesignationActions &&
|
|
11
|
-
designation &&
|
|
12
|
-
submissionId && (React.createElement(DesignationActions, { designation: designation, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch })),
|
|
11
|
+
designation !== undefined &&
|
|
12
|
+
submissionId && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch })),
|
|
13
13
|
React.createElement(FileNameTitleContainer, null,
|
|
14
14
|
React.createElement(FileTitle, null,
|
|
15
15
|
!showAttachmentName ? fileName : title,
|
|
@@ -18,8 +18,7 @@ export const FileInfo = ({ showAttachmentName, showDesignationActions, title, su
|
|
|
18
18
|
React.createElement(FileName, null, fileName),
|
|
19
19
|
React.createElement("div", null,
|
|
20
20
|
".",
|
|
21
|
-
fileExtension))))
|
|
22
|
-
description && React.createElement(FileDescription, null, description)));
|
|
21
|
+
fileExtension))))));
|
|
23
22
|
};
|
|
24
23
|
export const FileInfoContainer = styled.div `
|
|
25
24
|
margin-left: 8px;
|
|
@@ -10,20 +10,20 @@ import { FileTypeIcon } from './FileTypeIcon';
|
|
|
10
10
|
import { ItemActions } from './ItemActions';
|
|
11
11
|
export const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName = false, showDesignationActions = false, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
|
|
12
12
|
const { isOpen, toggleOpen, wrapperRef } = useDropdown();
|
|
13
|
-
const fileExtension = externalFile.
|
|
14
|
-
const designation = namesWithDesignationMap.get(externalFile.
|
|
13
|
+
const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
|
|
14
|
+
const designation = namesWithDesignationMap.get(externalFile.type.label);
|
|
15
15
|
const isMainManuscript = designation === Designation.MainManuscript;
|
|
16
|
-
const isSelected = externalFile.
|
|
16
|
+
const isSelected = externalFile.id == window.location.hash.substr(1);
|
|
17
17
|
return (React.createElement(Item, { ref: dragRef, className: className, style: style },
|
|
18
18
|
React.createElement(ItemContainer, { onClick: () => {
|
|
19
19
|
window.location.hash =
|
|
20
|
-
isEditor && !isSelected ? `#${externalFile.
|
|
20
|
+
isEditor && !isSelected ? `#${externalFile.id}` : '#';
|
|
21
21
|
if (isSelected) {
|
|
22
|
-
window.location.hash = `#${externalFile.
|
|
22
|
+
window.location.hash = `#${externalFile.id}`;
|
|
23
23
|
}
|
|
24
24
|
} },
|
|
25
|
-
React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.
|
|
26
|
-
React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.
|
|
25
|
+
React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
|
|
26
|
+
React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, dispatch: dispatch })),
|
|
27
27
|
onClose && (React.createElement(IconCloseButton, { onClick: (e) => {
|
|
28
28
|
e.preventDefault();
|
|
29
29
|
onClose();
|
|
@@ -32,7 +32,7 @@ export const FileSectionItem = ({ submissionId, externalFile, title, showAttachm
|
|
|
32
32
|
handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
|
|
33
33
|
React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
34
34
|
React.createElement(DotsIcon, null)),
|
|
35
|
-
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.
|
|
35
|
+
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
36
36
|
};
|
|
37
37
|
const IconCloseButton = styled.button `
|
|
38
38
|
border: none;
|
|
@@ -3,7 +3,7 @@ import { DropdownList } from '../../Dropdown';
|
|
|
3
3
|
import { PermissionsContext } from '../FileManager';
|
|
4
4
|
import { actions } from '../FileSectionState';
|
|
5
5
|
import { ActionsItem } from '../ItemsAction';
|
|
6
|
-
export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
|
|
6
|
+
export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
|
|
7
7
|
const attachmentDesignation = designation == undefined ? 'undefined' : designation;
|
|
8
8
|
const fileInputRef = useRef(null);
|
|
9
9
|
const [selectedFile, setSelectedFile] = useState();
|
|
@@ -15,7 +15,7 @@ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandle
|
|
|
15
15
|
if (dispatch) {
|
|
16
16
|
dispatch(actions.UPLOAD_FILE(file));
|
|
17
17
|
}
|
|
18
|
-
replaceAttachmentHandler(submissionId, fileName, file, attachmentDesignation);
|
|
18
|
+
replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
|
|
19
19
|
hideActionList();
|
|
20
20
|
}
|
|
21
21
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export const getInitialState = () => ({
|
|
2
2
|
uploadedFile: undefined,
|
|
3
3
|
isUploadFile: false,
|
|
4
|
-
isFileUploaded: false,
|
|
5
4
|
moveToOtherState: undefined,
|
|
6
5
|
successMessage: '',
|
|
7
6
|
isShowSuccessMessage: false,
|
|
@@ -17,8 +16,6 @@ var ActionTypes;
|
|
|
17
16
|
ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
|
|
18
17
|
ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
|
|
19
18
|
ActionTypes["HANDLE_SUCCESS_MESSAGE"] = "handleSuccessMessage";
|
|
20
|
-
ActionTypes["SHOW_FILE_UPLOADED_ALERT"] = "showFileUploadedAlert";
|
|
21
|
-
ActionTypes["CLOSE_FILE_UPLOADED_ALERT"] = "closeFileUploadedAlert";
|
|
22
19
|
})(ActionTypes || (ActionTypes = {}));
|
|
23
20
|
export const reducer = (state, action) => {
|
|
24
21
|
switch (action.type) {
|
|
@@ -44,15 +41,9 @@ export const reducer = (state, action) => {
|
|
|
44
41
|
case ActionTypes.HANDLE_FINISH_UPLOAD: {
|
|
45
42
|
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
46
43
|
}
|
|
47
|
-
case ActionTypes.SHOW_FILE_UPLOADED_ALERT: {
|
|
48
|
-
return Object.assign(Object.assign({}, state), { isFileUploaded: true });
|
|
49
|
-
}
|
|
50
44
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
51
45
|
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
52
46
|
}
|
|
53
|
-
case ActionTypes.CLOSE_FILE_UPLOADED_ALERT: {
|
|
54
|
-
return Object.assign(Object.assign({}, state), { isFileUploaded: false });
|
|
55
|
-
}
|
|
56
47
|
}
|
|
57
48
|
return state;
|
|
58
49
|
};
|
|
@@ -71,7 +62,7 @@ export const actions = {
|
|
|
71
62
|
type: ActionTypes.SELECT_DESIGNATION,
|
|
72
63
|
designation,
|
|
73
64
|
}),
|
|
74
|
-
MOVE_FILE: (submissionId, typeId, name, successMoveMessage) => ({
|
|
65
|
+
MOVE_FILE: (submissionId, attachmentId, typeId, name, successMoveMessage) => ({
|
|
75
66
|
type: ActionTypes.MOVE_FILE,
|
|
76
67
|
submissionId,
|
|
77
68
|
typeId,
|
|
@@ -81,12 +72,6 @@ export const actions = {
|
|
|
81
72
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
82
73
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
83
74
|
}),
|
|
84
|
-
SHOW_FILE_UPLOADED_ALERT: () => ({
|
|
85
|
-
type: ActionTypes.SHOW_FILE_UPLOADED_ALERT,
|
|
86
|
-
}),
|
|
87
|
-
CLOSE_FILE_UPLOADED_ALERT: () => ({
|
|
88
|
-
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
89
|
-
}),
|
|
90
75
|
HANDLE_SUCCESS_MESSAGE: () => ({
|
|
91
76
|
type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
|
|
92
77
|
}),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { AlertMessage, AlertMessageType } from '../AlertMessage';
|
|
3
2
|
import { DragItemArea } from './DragItemArea';
|
|
4
3
|
import { PermissionsContext } from './FileManager';
|
|
5
4
|
import { FileSectionUploadItem } from './FileSectionItem/FileSectionUploadItem';
|
|
@@ -26,11 +25,7 @@ export const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fi
|
|
|
26
25
|
(isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, submissionId: submissionId, dispatch: dispatch })),
|
|
27
26
|
state.isUploadFile &&
|
|
28
27
|
state.uploadedFile &&
|
|
29
|
-
state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })),
|
|
30
|
-
state.isFileUploaded && (React.createElement(AlertMessage, { type: AlertMessageType.info, hideCloseButton: true, dismissButton: {
|
|
31
|
-
action: () => dispatch(actions.CLOSE_FILE_UPLOADED_ALERT()),
|
|
32
|
-
text: 'Close',
|
|
33
|
-
} }, "File uploaded successfully. It may take a few moments to show the new file in the Inspector.")))),
|
|
28
|
+
state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
|
|
34
29
|
state.uploadedFile && isOtherFileTab && (React.createElement(SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
|
|
35
30
|
dispatch(actions.HANDLE_CANCEL_UPLOAD());
|
|
36
31
|
}, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
|
|
@@ -45,7 +45,7 @@ const FileReference = ({ externalFile, submissionId, handleReplace, handleDownlo
|
|
|
45
45
|
handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
|
|
46
46
|
React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
47
47
|
React.createElement(DotsIcon, null)),
|
|
48
|
-
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
|
|
48
|
+
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: undefined, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
|
|
49
49
|
};
|
|
50
50
|
const ElementItem = styled(Item) `
|
|
51
51
|
display: flex;
|
|
@@ -50,8 +50,8 @@ export var Designation;
|
|
|
50
50
|
Designation[Designation["MainManuscript"] = 13] = "MainManuscript";
|
|
51
51
|
})(Designation || (Designation = {}));
|
|
52
52
|
export const designationWithFileSectionsMap = new Map([
|
|
53
|
-
[Designation.Figure, FileSectionType.
|
|
54
|
-
[Designation.Table, FileSectionType.
|
|
53
|
+
[Designation.Figure, FileSectionType.OtherFile],
|
|
54
|
+
[Designation.Table, FileSectionType.OtherFile],
|
|
55
55
|
[Designation.Supplementary, FileSectionType.Supplements],
|
|
56
56
|
[Designation.ConflictOfInterest, FileSectionType.OtherFile],
|
|
57
57
|
[Designation.Document, FileSectionType.OtherFile],
|
|
@@ -346,15 +346,15 @@ export const fileTypesWithIconMap = new Map([
|
|
|
346
346
|
],
|
|
347
347
|
[undefined, React.createElement(UnknownFormatFileIcon, { key: undefined })],
|
|
348
348
|
]);
|
|
349
|
-
export const
|
|
349
|
+
export const generateAttachmentsTitles = (externalFiles, fileSectionType) => {
|
|
350
350
|
const titleCountersMap = new Map();
|
|
351
351
|
const externalFilesWithTitlesMap = new Map();
|
|
352
352
|
externalFiles.forEach((element) => {
|
|
353
|
-
const fileExtension = element.
|
|
353
|
+
const fileExtension = element.name.substring(element.name.lastIndexOf('.') + 1);
|
|
354
354
|
const fileType = extensionsWithFileTypesMap.get(fileExtension.toLowerCase());
|
|
355
355
|
const fileTitle = fileTypesWithTitlesMap.get(fileType);
|
|
356
356
|
if (fileSectionType === FileSectionType.Inline) {
|
|
357
|
-
externalFilesWithTitlesMap.set(element.
|
|
357
|
+
externalFilesWithTitlesMap.set(element.name, element);
|
|
358
358
|
}
|
|
359
359
|
else {
|
|
360
360
|
if (fileTitle !== undefined) {
|
|
@@ -377,13 +377,6 @@ export const generateExternalFilesTitles = (externalFiles, fileSectionType) => {
|
|
|
377
377
|
}));
|
|
378
378
|
return result;
|
|
379
379
|
};
|
|
380
|
-
export const sortExternalFiles = (externalFile) => externalFile
|
|
381
|
-
.sort((a, b) => Number(a.createdAt) - Number(b.createdAt))
|
|
382
|
-
.sort((a, b) => b.designation === 'main-manuscript'
|
|
383
|
-
? 1
|
|
384
|
-
: a.designation === 'main-manuscript'
|
|
385
|
-
? -1
|
|
386
|
-
: 0);
|
|
387
380
|
export const getDesignationActionsList = (designation, fileExtension) => {
|
|
388
381
|
const allowedDesignationsToTransition = designationWithAllowedDesignationsToTransitionMap.get(designation);
|
|
389
382
|
if (allowedDesignationsToTransition) {
|
|
@@ -467,10 +460,3 @@ export const droppableSections = [
|
|
|
467
460
|
FileSectionType.Supplements,
|
|
468
461
|
FileSectionType.OtherFile,
|
|
469
462
|
];
|
|
470
|
-
const isOfDesignation = (file, designation) => {
|
|
471
|
-
const formats = designationWithAllowedMediaTypesMap.get(designation);
|
|
472
|
-
return !!(formats === null || formats === void 0 ? void 0 : formats.find((type) => file.MIME.indexOf('/' + type) >= 0));
|
|
473
|
-
};
|
|
474
|
-
export const isFigure = (file) => {
|
|
475
|
-
return isOfDesignation(file, Designation.Figure);
|
|
476
|
-
};
|
|
@@ -5,14 +5,17 @@ const getCaptionText = (caption) => caption &&
|
|
|
5
5
|
new DOMParser().parseFromString(caption, 'text/html').documentElement
|
|
6
6
|
.innerText;
|
|
7
7
|
const getFigureData = (element, modelMap) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const externalFileReferences = [];
|
|
9
|
+
element.containedObjectIDs.map((e) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const object = modelMap.get(e);
|
|
12
|
+
if (object && object.objectType === ObjectTypes.Figure) {
|
|
13
|
+
const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
|
|
14
|
+
if (externalFileRef) {
|
|
15
|
+
externalFileReferences.push(externalFileRef);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
});
|
|
12
|
-
const { externalFileReferences } = (figureId &&
|
|
13
|
-
modelMap.get(figureId)) || {
|
|
14
|
-
externalFileReferences: undefined,
|
|
15
|
-
};
|
|
16
19
|
return {
|
|
17
20
|
id: element._id,
|
|
18
21
|
externalFileReferences,
|
|
@@ -34,25 +37,30 @@ export default (modelMap) => {
|
|
|
34
37
|
}
|
|
35
38
|
else {
|
|
36
39
|
(_b = section.elementIDs) === null || _b === void 0 ? void 0 : _b.map((elementId) => {
|
|
40
|
+
var _a;
|
|
37
41
|
const element = modelMap.get(elementId);
|
|
38
42
|
if (!element) {
|
|
39
43
|
return;
|
|
40
44
|
}
|
|
41
45
|
switch (element.objectType) {
|
|
42
|
-
case ObjectTypes.FigureElement:
|
|
46
|
+
case ObjectTypes.FigureElement:
|
|
47
|
+
case ObjectTypes.MultiGraphicFigureElement: {
|
|
43
48
|
files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Figure`, type: FileType.Figure }));
|
|
44
49
|
break;
|
|
45
50
|
}
|
|
46
51
|
case ObjectTypes.TableElement: {
|
|
47
52
|
const tableElement = element;
|
|
48
53
|
const table = modelMap.get(tableElement.containedObjectID);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const externalFileReferences = (_a = table.externalFileReferences) === null || _a === void 0 ? void 0 : _a.filter((file) => file.kind === 'dataset' && file.ref);
|
|
55
|
+
if (externalFileReferences && externalFileReferences.length > 0) {
|
|
56
|
+
files.push({
|
|
57
|
+
id: element._id,
|
|
58
|
+
label: `Table`,
|
|
59
|
+
type: FileType.SheetsWorkbooks,
|
|
60
|
+
externalFileReferences: table.externalFileReferences,
|
|
61
|
+
caption: getCaptionText(tableElement.caption),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
56
64
|
break;
|
|
57
65
|
}
|
|
58
66
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model } from '@manuscripts/manuscripts-json-schema';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Capabilities } from '../../lib/capabilities';
|
|
4
|
+
import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
|
|
4
5
|
export declare const PermissionsContext: React.Context<Capabilities | null>;
|
|
5
6
|
export declare const FileManager: React.FC<{
|
|
6
7
|
submissionId: string;
|
|
7
|
-
|
|
8
|
+
attachments: SubmissionAttachment[];
|
|
8
9
|
modelMap: Map<string, Model>;
|
|
9
10
|
enableDragAndDrop: boolean;
|
|
10
11
|
can: Capabilities;
|
|
11
|
-
handleUpload: (submissionId: string, file: File, designation: string) => Promise<
|
|
12
|
+
handleUpload: (submissionId: string, file: File, designation: string) => Promise<any>;
|
|
12
13
|
handleDownload: (url: string) => void;
|
|
13
|
-
handleReplace: (submissionId: string, name: string, file: File, typeId: string) => Promise<
|
|
14
|
-
handleChangeDesignation: (submissionId: string, typeId: string, name: string) => Promise<
|
|
14
|
+
handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<any>;
|
|
15
|
+
handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<any>;
|
|
15
16
|
}>;
|
|
@@ -3,8 +3,9 @@ import { Action } from '../FileSectionState';
|
|
|
3
3
|
import { Designation } from '../util';
|
|
4
4
|
export declare const DesignationActions: React.FC<{
|
|
5
5
|
designation?: Designation;
|
|
6
|
+
attachmentId: string;
|
|
6
7
|
fileExtension?: string;
|
|
7
|
-
handleChangeDesignation?: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
|
|
8
|
+
handleChangeDesignation?: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
|
|
8
9
|
submissionId: string;
|
|
9
10
|
fileName: string;
|
|
10
11
|
dispatch?: Dispatch<Action>;
|
|
@@ -2,11 +2,12 @@ import React, { Dispatch } from 'react';
|
|
|
2
2
|
import { Action } from '../FileSectionState';
|
|
3
3
|
import { Designation } from '../util';
|
|
4
4
|
export declare const DesignationActionsList: React.FC<{
|
|
5
|
-
handleChangeDesignation?: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
|
|
5
|
+
handleChangeDesignation?: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
|
|
6
6
|
designationActionsList: Array<Designation>;
|
|
7
7
|
submissionId: string;
|
|
8
8
|
fileName: string;
|
|
9
9
|
designation?: Designation;
|
|
10
|
+
attachmentId: string;
|
|
10
11
|
dispatch?: Dispatch<Action>;
|
|
11
12
|
handleOpenConfirmationPopup: (popupHeader: string, popupMessage: string, designation: string) => void;
|
|
12
13
|
}>;
|
|
@@ -5,11 +5,11 @@ export declare const FileInfo: React.FC<{
|
|
|
5
5
|
showAttachmentName: boolean;
|
|
6
6
|
showDesignationActions: boolean;
|
|
7
7
|
title: string;
|
|
8
|
-
description?: string;
|
|
9
8
|
submissionAttachmentName: string;
|
|
10
9
|
fileExtension: string;
|
|
11
10
|
designation?: Designation;
|
|
12
|
-
|
|
11
|
+
attachmentId: string;
|
|
12
|
+
handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
|
|
13
13
|
submissionId?: string;
|
|
14
14
|
dispatch?: Dispatch<Action>;
|
|
15
15
|
}>;
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import { ExternalFile } from '@manuscripts/manuscripts-json-schema';
|
|
2
1
|
import React, { CSSProperties, Dispatch } from 'react';
|
|
3
2
|
import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
|
|
3
|
+
import { Maybe } from '../../SubmissionInspector/types';
|
|
4
4
|
import { Action } from '../FileSectionState';
|
|
5
|
+
export declare type SubmissionAttachment = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: SubmissionAttachmentType;
|
|
9
|
+
link: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type SubmissionAttachmentType = {
|
|
12
|
+
id: string;
|
|
13
|
+
label?: Maybe<string> | undefined;
|
|
14
|
+
};
|
|
5
15
|
export interface FileSectionItemProps {
|
|
6
16
|
submissionId?: string;
|
|
7
|
-
externalFile:
|
|
17
|
+
externalFile: SubmissionAttachment;
|
|
8
18
|
title: string;
|
|
9
19
|
showAttachmentName?: boolean;
|
|
10
20
|
showDesignationActions?: boolean;
|
|
11
21
|
showActions?: boolean;
|
|
12
22
|
handleDownload?: (url: string) => void;
|
|
13
|
-
handleReplace?: (submissionId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
14
|
-
handleChangeDesignation: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
|
|
23
|
+
handleReplace?: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
24
|
+
handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
|
|
15
25
|
dispatch?: Dispatch<Action>;
|
|
16
26
|
dragRef?: DragElementWrapper<DragSourceOptions>;
|
|
17
27
|
className?: string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { Dispatch } from 'react';
|
|
2
|
+
import { Maybe } from '../../SubmissionInspector/types';
|
|
2
3
|
import { Action } from '../FileSectionState';
|
|
3
4
|
export declare const ItemActions: React.FC<{
|
|
4
5
|
downloadAttachmentHandler: (url: string) => void;
|
|
5
|
-
replaceAttachmentHandler: (submissionId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
6
|
+
replaceAttachmentHandler: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
6
7
|
submissionId: string;
|
|
8
|
+
attachmentId: string;
|
|
7
9
|
fileName: string;
|
|
8
|
-
designation?: string | undefined;
|
|
10
|
+
designation?: Maybe<string> | undefined;
|
|
9
11
|
publicUrl: string | undefined;
|
|
10
12
|
hideActionList: (e?: React.MouseEvent) => void;
|
|
11
13
|
dispatch?: Dispatch<Action>;
|
|
@@ -3,7 +3,6 @@ export declare const getInitialState: () => State;
|
|
|
3
3
|
export interface State {
|
|
4
4
|
uploadedFile: File | undefined;
|
|
5
5
|
isUploadFile: boolean;
|
|
6
|
-
isFileUploaded: boolean;
|
|
7
6
|
moveToOtherState: {
|
|
8
7
|
submissionId: string;
|
|
9
8
|
typeId: string;
|
|
@@ -21,9 +20,7 @@ declare enum ActionTypes {
|
|
|
21
20
|
HANDLE_CANCEL_UPLOAD = "handleCancel",
|
|
22
21
|
HANDLE_UPLOAD_ACTION = "handleUpload",
|
|
23
22
|
HANDLE_FINISH_UPLOAD = "handleFinishUpload",
|
|
24
|
-
HANDLE_SUCCESS_MESSAGE = "handleSuccessMessage"
|
|
25
|
-
SHOW_FILE_UPLOADED_ALERT = "showFileUploadedAlert",
|
|
26
|
-
CLOSE_FILE_UPLOADED_ALERT = "closeFileUploadedAlert"
|
|
23
|
+
HANDLE_SUCCESS_MESSAGE = "handleSuccessMessage"
|
|
27
24
|
}
|
|
28
25
|
export declare const reducer: (state: State, action: Action) => State;
|
|
29
26
|
export interface Action {
|
|
@@ -35,10 +32,8 @@ export declare const actions: {
|
|
|
35
32
|
HANDLE_UPLOAD_ACTION: () => Action;
|
|
36
33
|
HANDLE_CANCEL_UPLOAD: () => Action;
|
|
37
34
|
SELECT_DESIGNATION: (designation: Designation) => Action;
|
|
38
|
-
MOVE_FILE: (submissionId: string, typeId: string, name: string, successMoveMessage: string) => Action;
|
|
35
|
+
MOVE_FILE: (submissionId: string, attachmentId: string, typeId: string, name: string, successMoveMessage: string) => Action;
|
|
39
36
|
HANDLE_FINISH_UPLOAD: () => Action;
|
|
40
|
-
SHOW_FILE_UPLOADED_ALERT: () => Action;
|
|
41
|
-
CLOSE_FILE_UPLOADED_ALERT: () => Action;
|
|
42
37
|
HANDLE_SUCCESS_MESSAGE: () => Action;
|
|
43
38
|
};
|
|
44
39
|
export {};
|
|
@@ -4,7 +4,7 @@ import { FileSectionType } from './util';
|
|
|
4
4
|
export declare const FilesSection: React.FC<{
|
|
5
5
|
submissionId: string;
|
|
6
6
|
enableDragAndDrop: boolean;
|
|
7
|
-
handleUpload: (submissionId: string, file: File, designation: string) => Promise<
|
|
7
|
+
handleUpload: (submissionId: string, file: File, designation: string) => Promise<any>;
|
|
8
8
|
fileSection: FileSectionType;
|
|
9
9
|
filesItem: JSX.Element[];
|
|
10
10
|
dispatch: Dispatch<Action>;
|
|
@@ -9,7 +9,7 @@ export interface ExternalFileRef {
|
|
|
9
9
|
export declare const InlineFilesSection: React.FC<{
|
|
10
10
|
submissionId: string;
|
|
11
11
|
modelMap: Map<string, Model>;
|
|
12
|
-
handleReplace: (submissionId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
12
|
+
handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
13
13
|
handleDownload: (url: string) => void;
|
|
14
14
|
isEditor: boolean;
|
|
15
15
|
dispatch: Dispatch<Action>;
|
|
@@ -2,7 +2,7 @@ import React, { Dispatch } from 'react';
|
|
|
2
2
|
import { Action } from './FileSectionState';
|
|
3
3
|
import { FileSectionType } from './util';
|
|
4
4
|
export declare const UploadFileArea: React.FC<{
|
|
5
|
-
handleUploadFile: (submissionId: string, file: File, designation: string) => Promise<
|
|
5
|
+
handleUploadFile: (submissionId: string, file: File, designation: string) => Promise<any>;
|
|
6
6
|
fileSection: FileSectionType;
|
|
7
7
|
submissionId: string;
|
|
8
8
|
dispatch: Dispatch<Action>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ExternalFile } from '@manuscripts/manuscripts-json-schema';
|
|
2
1
|
import { Capabilities } from '../../lib/capabilities';
|
|
2
|
+
import { Maybe } from '../SubmissionInspector/types';
|
|
3
|
+
import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
|
|
3
4
|
export declare enum FileSectionType {
|
|
4
5
|
Inline = 0,
|
|
5
6
|
Supplements = 1,
|
|
@@ -36,18 +37,17 @@ export declare enum Designation {
|
|
|
36
37
|
MainManuscript = 13
|
|
37
38
|
}
|
|
38
39
|
export declare const designationWithFileSectionsMap: Map<Designation, FileSectionType>;
|
|
39
|
-
export declare const namesWithDesignationMap: Map<string | undefined, Designation>;
|
|
40
|
+
export declare const namesWithDesignationMap: Map<Maybe<string> | undefined, Designation>;
|
|
40
41
|
export declare const designationWithReadableNamesMap: Map<Designation, string>;
|
|
41
42
|
export declare const designationWithAllowedMediaTypesMap: Map<Designation, string[]>;
|
|
42
43
|
export declare const designationWithAllowedDesignationsToTransitionMap: Map<Designation, Designation[]>;
|
|
43
44
|
export declare const extensionsWithFileTypesMap: Map<string, FileType>;
|
|
44
45
|
export declare const fileTypesWithTitlesMap: Map<FileType | undefined, string>;
|
|
45
46
|
export declare const fileTypesWithIconMap: Map<FileType | undefined, JSX.Element>;
|
|
46
|
-
export declare const
|
|
47
|
+
export declare const generateAttachmentsTitles: (externalFiles: SubmissionAttachment[], fileSectionType: FileSectionType) => Array<{
|
|
47
48
|
title: string;
|
|
48
|
-
externalFile:
|
|
49
|
+
externalFile: SubmissionAttachment;
|
|
49
50
|
}>;
|
|
50
|
-
export declare const sortExternalFiles: (externalFile: ExternalFile[]) => ExternalFile[];
|
|
51
51
|
export declare const getDesignationActionsList: (designation: Designation, fileExtension: string) => Array<Designation>;
|
|
52
52
|
export declare const getDesignationName: (designation: Designation) => string;
|
|
53
53
|
export declare const getDesignationByFileSection: (fileSectionType: FileSectionType) => Array<Designation>;
|
|
@@ -56,4 +56,3 @@ export declare const getUploadFileDesignationList: (fileExtension: string, fileS
|
|
|
56
56
|
label: string;
|
|
57
57
|
}>;
|
|
58
58
|
export declare const droppableSections: FileSectionType[];
|
|
59
|
-
export declare const isFigure: (file: ExternalFile) => boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "0.30.
|
|
4
|
+
"version": "0.30.25",
|
|
5
5
|
"repository": "gitlab:atypon-opensource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|