@manuscripts/style-guide 0.31.14 → 0.31.17
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 +40 -32
- package/dist/cjs/components/FileManager/FileSectionItem/DesignationActions.js +3 -3
- package/dist/cjs/components/FileManager/FileSectionItem/DesignationActionsList.js +3 -3
- package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +2 -2
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +5 -5
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +2 -2
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +11 -11
- package/dist/cjs/components/FileManager/FileSectionState.js +5 -6
- package/dist/cjs/components/FileManager/FilesSection.js +11 -4
- package/dist/cjs/components/FileManager/InlineFilesSection.js +6 -6
- package/dist/cjs/components/FileManager/UploadFileArea.js +4 -10
- package/dist/cjs/components/SubmissionInspector/BaseInformation.js +11 -7
- package/dist/es/components/FileManager/FileManager.js +40 -32
- package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +3 -3
- package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +3 -3
- package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +2 -2
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +5 -5
- package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +2 -2
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +11 -11
- package/dist/es/components/FileManager/FileSectionState.js +5 -6
- package/dist/es/components/FileManager/FilesSection.js +11 -4
- package/dist/es/components/FileManager/InlineFilesSection.js +6 -6
- package/dist/es/components/FileManager/UploadFileArea.js +4 -10
- package/dist/es/components/SubmissionInspector/BaseInformation.js +11 -7
- package/dist/types/components/FileManager/FileManager.d.ts +10 -7
- package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +2 -2
- package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +2 -2
- package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +2 -2
- package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +4 -7
- package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -1
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +3 -6
- package/dist/types/components/FileManager/FileSectionState.d.ts +2 -3
- package/dist/types/components/FileManager/FilesSection.d.ts +2 -2
- package/dist/types/components/FileManager/InlineFilesSection.d.ts +2 -6
- package/dist/types/components/FileManager/UploadFileArea.d.ts +2 -2
- package/dist/types/components/SubmissionInspector/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -36,7 +36,6 @@ const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
|
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const react_tooltip_1 = __importDefault(require("react-tooltip"));
|
|
38
38
|
const inlineFiles_1 = __importStar(require("../../lib/inlineFiles"));
|
|
39
|
-
const AlertMessage_1 = require("../AlertMessage");
|
|
40
39
|
const Inspector_1 = require("../Inspector");
|
|
41
40
|
const InspectorSection_1 = require("../InspectorSection");
|
|
42
41
|
const DraggableFileSectionItem_1 = require("./FileSectionItem/DraggableFileSectionItem");
|
|
@@ -48,42 +47,56 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
|
|
|
48
47
|
const TooltipDiv_1 = require("./TooltipDiv");
|
|
49
48
|
const util_1 = require("./util");
|
|
50
49
|
exports.PermissionsContext = (0, react_1.createContext)(null);
|
|
51
|
-
const FileManager = ({
|
|
50
|
+
const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, changeDesignation, replace, upload }, }) => {
|
|
52
51
|
const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
|
|
53
|
-
const handleReplaceFile = (0, react_1.useCallback)((
|
|
52
|
+
const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
53
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
55
54
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.namesWithDesignationMap.get(typeId) || util_1.Designation.Document));
|
|
56
|
-
const res = yield
|
|
55
|
+
const res = yield replace(attachmentId, name, file, typeId);
|
|
57
56
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
57
|
+
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
58
58
|
return res;
|
|
59
|
-
}), [
|
|
60
|
-
const handleUploadFile = (0, react_1.useCallback)((
|
|
59
|
+
}), [replace]);
|
|
60
|
+
const handleUploadFile = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
61
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
62
62
|
if (util_1.namesWithDesignationMap.get(designation) == util_1.Designation.Supplementary) {
|
|
63
63
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
|
|
64
64
|
}
|
|
65
|
-
const res = yield
|
|
65
|
+
const res = yield upload(file, designation);
|
|
66
66
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
67
|
+
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
67
68
|
return res;
|
|
68
|
-
}), [
|
|
69
|
-
const handleUploadFileWithSupplement = (0, react_1.useCallback)((
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
const { id, name } =
|
|
69
|
+
}), [upload]);
|
|
70
|
+
const handleUploadFileWithSupplement = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
const response = yield upload(file, designation);
|
|
72
|
+
if (typeof response === 'object') {
|
|
73
|
+
const { id, name } = response;
|
|
73
74
|
yield saveModel((0, manuscript_transform_1.buildSupplementaryMaterial)(name, `attachment:${id}`));
|
|
74
75
|
}
|
|
75
|
-
return
|
|
76
|
-
}), [
|
|
77
|
-
const handleChangeDesignationFile = (0, react_1.useCallback)((
|
|
78
|
-
const res = yield
|
|
76
|
+
return response;
|
|
77
|
+
}), [upload, saveModel]);
|
|
78
|
+
const handleChangeDesignationFile = (0, react_1.useCallback)((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const res = yield changeDesignation(attachmentId, typeId, name);
|
|
79
80
|
if (res) {
|
|
80
|
-
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE());
|
|
81
|
+
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE(''));
|
|
81
82
|
}
|
|
82
83
|
return res;
|
|
83
|
-
}), [
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
}, [
|
|
84
|
+
}), [changeDesignation]);
|
|
85
|
+
const handleDownload = (0, react_1.useCallback)((url) => {
|
|
86
|
+
window.location.assign(url);
|
|
87
|
+
}, []);
|
|
88
|
+
const handleUpdateInline = (0, react_1.useCallback)((modelId, attachment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
var _a;
|
|
90
|
+
const figureModel = modelMap.get(modelId);
|
|
91
|
+
const imageExternalFileIndex = (_a = figureModel === null || figureModel === void 0 ? void 0 : figureModel.externalFileReferences) === null || _a === void 0 ? void 0 : _a.findIndex((file) => file && file.kind === 'imageRepresentation');
|
|
92
|
+
if (figureModel.externalFileReferences &&
|
|
93
|
+
typeof imageExternalFileIndex !== 'undefined' &&
|
|
94
|
+
imageExternalFileIndex > -1) {
|
|
95
|
+
figureModel.externalFileReferences[imageExternalFileIndex].url = `attachment:${attachment.id}`;
|
|
96
|
+
yield saveModel(figureModel);
|
|
97
|
+
}
|
|
98
|
+
}), [modelMap, saveModel]);
|
|
99
|
+
const attachments = getAttachments();
|
|
87
100
|
const inlineFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.default)(modelMap, attachments), [modelMap.values(), attachments]);
|
|
88
101
|
const supplementFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.getSupplementFiles)(modelMap, attachments), [attachments, modelMap.size]);
|
|
89
102
|
const excludedAttachmentsIds = (0, react_1.useMemo)(() => {
|
|
@@ -99,6 +112,7 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
|
|
|
99
112
|
const getFileSectionExternalFile = (fileSection) => {
|
|
100
113
|
const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
|
|
101
114
|
fileSection === util_1.FileSectionType.OtherFile;
|
|
115
|
+
const isOtherFilesTab = fileSection === util_1.FileSectionType.OtherFile;
|
|
102
116
|
const itemsData = (fileSection === util_1.FileSectionType.Supplements && supplementFiles) ||
|
|
103
117
|
attachments.filter((element) => {
|
|
104
118
|
const designation = util_1.namesWithDesignationMap.get(element.type.label);
|
|
@@ -107,12 +121,12 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
|
|
|
107
121
|
const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
|
|
108
122
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
109
123
|
const itemProps = {
|
|
110
|
-
submissionId: submissionId,
|
|
111
124
|
externalFile: element.externalFile,
|
|
112
125
|
title: element.title,
|
|
113
126
|
showAttachmentName: isSupplementOrOtherFilesTab,
|
|
114
127
|
showDesignationActions: isSupplementOrOtherFilesTab,
|
|
115
|
-
|
|
128
|
+
showReplaceAction: !isOtherFilesTab,
|
|
129
|
+
handleDownload,
|
|
116
130
|
handleReplace: handleReplaceFile,
|
|
117
131
|
handleChangeDesignation: handleChangeDesignationFile,
|
|
118
132
|
dispatch: dispatch,
|
|
@@ -126,9 +140,6 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
|
|
|
126
140
|
});
|
|
127
141
|
return filesItems;
|
|
128
142
|
};
|
|
129
|
-
const handleSuccessMessage = () => {
|
|
130
|
-
return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.info, hideCloseButton: false }, state.successMessage));
|
|
131
|
-
};
|
|
132
143
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
133
144
|
react_1.default.createElement(DragLayer_1.DragLayer, null),
|
|
134
145
|
react_1.default.createElement(exports.PermissionsContext.Provider, { value: can },
|
|
@@ -152,13 +163,10 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
|
|
|
152
163
|
react_1.default.createElement("div", null, "Files excluded from the final submission.")))),
|
|
153
164
|
react_1.default.createElement(Inspector_1.InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
|
|
154
165
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
155
|
-
react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles,
|
|
166
|
+
react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, handleReplace: replace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
|
|
156
167
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
157
|
-
react_1.default.createElement(FilesSection_1.FilesSection, {
|
|
168
|
+
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: util_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(util_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
158
169
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
159
|
-
react_1.default.createElement(FilesSection_1.FilesSection, {
|
|
160
|
-
state.isShowSuccessMessage &&
|
|
161
|
-
state.successMessage !== '' &&
|
|
162
|
-
handleSuccessMessage()));
|
|
170
|
+
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: util_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(util_1.FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))));
|
|
163
171
|
};
|
|
164
172
|
exports.FileManager = FileManager;
|
|
@@ -31,7 +31,7 @@ const ConfirmationPopUp_1 = require("../ConfirmationPopUp");
|
|
|
31
31
|
const TooltipDiv_1 = require("../TooltipDiv");
|
|
32
32
|
const util_1 = require("../util");
|
|
33
33
|
const DesignationActionsList_1 = require("./DesignationActionsList");
|
|
34
|
-
const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation,
|
|
34
|
+
const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, fileName, can, dispatch, }) => {
|
|
35
35
|
const [isActionsShown, setIsActionsShown] = (0, react_1.useState)(false);
|
|
36
36
|
const [confirmationPopUpData, setConfirmationPopUpData] = (0, react_1.useState)({
|
|
37
37
|
isConfirmationPopUpOpen: false,
|
|
@@ -62,7 +62,7 @@ const DesignationActions = ({ designation, attachmentId, fileExtension, handleCh
|
|
|
62
62
|
};
|
|
63
63
|
const handleMoveAction = () => {
|
|
64
64
|
handleChangeDesignation &&
|
|
65
|
-
handleChangeDesignation(
|
|
65
|
+
handleChangeDesignation(attachmentId, confirmationPopUpData.selectedDesignation, fileName);
|
|
66
66
|
handleCloseAction();
|
|
67
67
|
};
|
|
68
68
|
const handleCloseAction = () => {
|
|
@@ -81,7 +81,7 @@ const DesignationActions = ({ designation, attachmentId, fileExtension, handleCh
|
|
|
81
81
|
react_1.default.createElement(SecondaryActionsText, { "data-for": "file-designation", "data-tip": true }, util_1.designationWithReadableNamesMap.get(designation)),
|
|
82
82
|
react_1.default.createElement(BottomArrowIcon_1.default, null),
|
|
83
83
|
isActionsShown && (can === null || can === void 0 ? void 0 : can.changeDesignation) && (react_1.default.createElement(ActionsListContainer, null,
|
|
84
|
-
react_1.default.createElement(DesignationActionsList_1.DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList,
|
|
84
|
+
react_1.default.createElement(DesignationActionsList_1.DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
|
|
85
85
|
confirmationPopUpData.isConfirmationPopUpOpen && (react_1.default.createElement(ConfirmationPopUp_1.ConfirmationPopUp, { popupHeader: confirmationPopUpData.confirmationPopUpHeader !== undefined
|
|
86
86
|
? confirmationPopUpData.confirmationPopUpHeader
|
|
87
87
|
: '', 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,
|
|
11
|
+
const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, 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(
|
|
15
|
+
dispatch(FileSectionState_1.actions.MOVE_FILE(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(
|
|
21
|
+
handleChangeDesignation(attachmentId, (0, util_1.getDesignationName)(designation), fileName);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
const isSupplementaryActionIncluded = designationActionsList.indexOf(util_1.Designation.Supplementary) !== -1;
|
|
@@ -27,11 +27,11 @@ 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, attachmentId, handleChangeDesignation,
|
|
30
|
+
const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, 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
|
-
showDesignationActions && designation !== undefined &&
|
|
34
|
+
showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: submissionAttachmentName, dispatch: dispatch, can: can })),
|
|
35
35
|
react_1.default.createElement(exports.FileNameTitleContainer, null,
|
|
36
36
|
react_1.default.createElement(exports.FileTitle, null,
|
|
37
37
|
!showAttachmentName ? fileName : title,
|
|
@@ -14,7 +14,7 @@ const util_1 = require("../util");
|
|
|
14
14
|
const FileInfo_1 = require("./FileInfo");
|
|
15
15
|
const FileTypeIcon_1 = require("./FileTypeIcon");
|
|
16
16
|
const ItemActions_1 = require("./ItemActions");
|
|
17
|
-
const FileSectionItem = ({
|
|
17
|
+
const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
|
|
18
18
|
const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
|
|
19
19
|
const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
|
|
20
20
|
const designation = util_1.namesWithDesignationMap.get(externalFile.type.label);
|
|
@@ -29,16 +29,16 @@ const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName
|
|
|
29
29
|
}
|
|
30
30
|
} },
|
|
31
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,
|
|
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, dispatch: dispatch })),
|
|
33
33
|
onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
|
|
34
34
|
e.preventDefault();
|
|
35
35
|
onClose();
|
|
36
36
|
} },
|
|
37
37
|
react_1.default.createElement(icons_1.CloseOIcon, { color: '#6E6E6E' }))),
|
|
38
|
-
handleDownload && handleReplace &&
|
|
38
|
+
handleDownload && handleReplace && (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,
|
|
41
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, 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 `
|
|
@@ -85,7 +85,7 @@ exports.Item = styled_components_1.default.div `
|
|
|
85
85
|
${Dropdown_1.DropdownContainer} {
|
|
86
86
|
position: absolute;
|
|
87
87
|
top: 24px;
|
|
88
|
-
right:
|
|
88
|
+
right: 0;
|
|
89
89
|
margin-right: 8px;
|
|
90
90
|
}
|
|
91
91
|
`;
|
|
@@ -10,7 +10,7 @@ const FileInfo_1 = require("./FileInfo");
|
|
|
10
10
|
const FileSectionItem_1 = require("./FileSectionItem");
|
|
11
11
|
const FileTypeIcon_1 = require("./FileTypeIcon");
|
|
12
12
|
const ProgressBarUploadItem_1 = require("./ProgressBarUploadItem");
|
|
13
|
-
const FileSectionUploadItem = ({ fileName, isLoading,
|
|
13
|
+
const FileSectionUploadItem = ({ fileName, isLoading, dragRef, className, style, }) => {
|
|
14
14
|
const fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);
|
|
15
15
|
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
|
16
16
|
return (react_1.default.createElement(FileSectionItem_1.Item, { ref: dragRef, className: className, style: style },
|
|
@@ -31,7 +31,7 @@ exports.UploadItemContainer = (0, styled_components_1.default)(FileSectionItem_1
|
|
|
31
31
|
exports.ProgressBar = styled_components_1.default.div `
|
|
32
32
|
background: #1a9bc7;
|
|
33
33
|
opacity: 0.7;
|
|
34
|
-
border-radius: 8px
|
|
34
|
+
border-radius: 8px 0 0 8px;
|
|
35
35
|
width: 20%;
|
|
36
36
|
height: 100%;
|
|
37
37
|
`;
|
|
@@ -35,17 +35,18 @@ const FileManager_1 = require("../FileManager");
|
|
|
35
35
|
const FileSectionState_1 = require("../FileSectionState");
|
|
36
36
|
const ItemsAction_1 = require("../ItemsAction");
|
|
37
37
|
const util_1 = require("../util");
|
|
38
|
-
const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline,
|
|
38
|
+
const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
|
|
39
39
|
const attachmentDesignation = designation == undefined ? 'undefined' : designation;
|
|
40
40
|
const attachmentDesignationName = attachmentDesignation !== 'undefined'
|
|
41
41
|
? util_1.namesWithDesignationMap.get(attachmentDesignation)
|
|
42
42
|
: undefined;
|
|
43
|
-
const canBeReplaced =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const canBeReplaced = (showReplaceAction == undefined || showReplaceAction) &&
|
|
44
|
+
(attachmentDesignationName == undefined ||
|
|
45
|
+
![
|
|
46
|
+
util_1.Designation.MainManuscript,
|
|
47
|
+
util_1.Designation.SubmissionFile,
|
|
48
|
+
util_1.Designation.SubmissionPdf,
|
|
49
|
+
].includes(attachmentDesignationName));
|
|
49
50
|
const fileInputRef = (0, react_1.useRef)(null);
|
|
50
51
|
const [selectedFile, setSelectedFile] = (0, react_1.useState)();
|
|
51
52
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
@@ -57,10 +58,9 @@ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, hand
|
|
|
57
58
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
58
59
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(attachmentDesignationName || util_1.Designation.Document));
|
|
59
60
|
}
|
|
60
|
-
const result = yield replaceAttachmentHandler(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
handleUpdateInline(uploadAttachment);
|
|
61
|
+
const result = yield replaceAttachmentHandler(attachmentId, fileName, file, attachmentDesignation);
|
|
62
|
+
if (typeof result === 'object' && handleUpdateInline) {
|
|
63
|
+
handleUpdateInline(result);
|
|
64
64
|
}
|
|
65
65
|
if (dispatch) {
|
|
66
66
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
@@ -28,7 +28,6 @@ const reducer = (state, action) => {
|
|
|
28
28
|
}
|
|
29
29
|
case ActionTypes.MOVE_FILE: {
|
|
30
30
|
return Object.assign(Object.assign({}, state), { moveToOtherState: {
|
|
31
|
-
submissionId: action.submissionId,
|
|
32
31
|
typeId: action.typeId,
|
|
33
32
|
name: action.name,
|
|
34
33
|
}, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
|
|
@@ -37,7 +36,7 @@ const reducer = (state, action) => {
|
|
|
37
36
|
return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
|
|
38
37
|
}
|
|
39
38
|
case ActionTypes.HANDLE_UPLOAD_ACTION: {
|
|
40
|
-
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true });
|
|
39
|
+
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
|
|
41
40
|
}
|
|
42
41
|
case ActionTypes.HANDLE_CANCEL_UPLOAD: {
|
|
43
42
|
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false });
|
|
@@ -46,7 +45,7 @@ const reducer = (state, action) => {
|
|
|
46
45
|
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
47
46
|
}
|
|
48
47
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
49
|
-
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
48
|
+
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage });
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
return state;
|
|
@@ -67,9 +66,8 @@ exports.actions = {
|
|
|
67
66
|
type: ActionTypes.SELECT_DESIGNATION,
|
|
68
67
|
designation,
|
|
69
68
|
}),
|
|
70
|
-
MOVE_FILE: (
|
|
69
|
+
MOVE_FILE: (attachmentId, typeId, name, successMoveMessage) => ({
|
|
71
70
|
type: ActionTypes.MOVE_FILE,
|
|
72
|
-
submissionId,
|
|
73
71
|
typeId,
|
|
74
72
|
name,
|
|
75
73
|
successMoveMessage,
|
|
@@ -77,7 +75,8 @@ exports.actions = {
|
|
|
77
75
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
78
76
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
79
77
|
}),
|
|
80
|
-
HANDLE_SUCCESS_MESSAGE: () => ({
|
|
78
|
+
HANDLE_SUCCESS_MESSAGE: (successMessage) => ({
|
|
81
79
|
type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
|
|
80
|
+
successMessage,
|
|
82
81
|
}),
|
|
83
82
|
};
|
|
@@ -21,6 +21,7 @@ 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");
|
|
24
25
|
const DragItemArea_1 = require("./DragItemArea");
|
|
25
26
|
const FileManager_1 = require("./FileManager");
|
|
26
27
|
const FileSectionUploadItem_1 = require("./FileSectionItem/FileSectionUploadItem");
|
|
@@ -28,7 +29,7 @@ const FileSectionState_1 = require("./FileSectionState");
|
|
|
28
29
|
const SelectDialogDesignation_1 = require("./SelectDialogDesignation");
|
|
29
30
|
const UploadFileArea_1 = require("./UploadFileArea");
|
|
30
31
|
const util_1 = require("./util");
|
|
31
|
-
const FilesSection = ({
|
|
32
|
+
const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
|
|
32
33
|
let uploadedFileExtension = '';
|
|
33
34
|
if (state.uploadedFile) {
|
|
34
35
|
uploadedFileExtension = state.uploadedFile.name.substring(state.uploadedFile.name.lastIndexOf('.') + 1);
|
|
@@ -39,15 +40,21 @@ const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSecti
|
|
|
39
40
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
40
41
|
state.uploadedFile &&
|
|
41
42
|
state.selectDesignation !== undefined &&
|
|
42
|
-
handleUpload(
|
|
43
|
+
handleUpload(state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
|
|
43
44
|
};
|
|
44
45
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
46
|
+
const handleSuccessMessage = () => {
|
|
47
|
+
return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.success, hideCloseButton: true, dismissButton: { text: 'OK' } }, state.successMessage));
|
|
48
|
+
};
|
|
45
49
|
return (react_1.default.createElement("div", null,
|
|
46
50
|
(can === null || can === void 0 ? void 0 : can.uploadFile) && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
47
|
-
(isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection,
|
|
51
|
+
(isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
|
|
48
52
|
state.isUploadFile &&
|
|
49
53
|
state.uploadedFile &&
|
|
50
|
-
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, {
|
|
54
|
+
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
|
|
55
|
+
state.isShowSuccessMessage &&
|
|
56
|
+
state.successMessage !== '' &&
|
|
57
|
+
handleSuccessMessage(),
|
|
51
58
|
state.uploadedFile && isOtherFileTab && (react_1.default.createElement(SelectDialogDesignation_1.SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
|
|
52
59
|
dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
|
|
53
60
|
}, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
|
|
@@ -31,7 +31,7 @@ const FileInfo_1 = require("./FileSectionItem/FileInfo");
|
|
|
31
31
|
const FileSectionItem_1 = require("./FileSectionItem/FileSectionItem");
|
|
32
32
|
const ItemActions_1 = require("./FileSectionItem/ItemActions");
|
|
33
33
|
const util_1 = require("./util");
|
|
34
|
-
const InlineFilesSection = ({
|
|
34
|
+
const InlineFilesSection = ({ handleReplace, handleDownload, handleUpdateInline, inlineFiles, isEditor, dispatch, }) => {
|
|
35
35
|
const onElementClick = (0, react_1.useCallback)((e) => {
|
|
36
36
|
if (!isEditor) {
|
|
37
37
|
return;
|
|
@@ -46,7 +46,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handl
|
|
|
46
46
|
return (react_1.default.createElement("div", null, inlineFiles.map((file, index) => {
|
|
47
47
|
var _a;
|
|
48
48
|
return (react_1.default.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
|
|
49
|
-
react_1.default.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (react_1.default.createElement(FileReference, { key: attachment.id, attachment: attachment,
|
|
49
|
+
react_1.default.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (react_1.default.createElement(FileReference, { key: attachment.id, attachment: attachment, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDownload: handleDownload, dispatch: dispatch })))),
|
|
50
50
|
react_1.default.createElement(Element, { className: 'element' },
|
|
51
51
|
util_1.fileTypesWithIconMap.get(file.type),
|
|
52
52
|
react_1.default.createElement(FileInfo_1.FileInfoContainer, null,
|
|
@@ -55,7 +55,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handl
|
|
|
55
55
|
})));
|
|
56
56
|
};
|
|
57
57
|
exports.InlineFilesSection = InlineFilesSection;
|
|
58
|
-
const FileReference = ({ attachment,
|
|
58
|
+
const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdateInline, dispatch, }) => {
|
|
59
59
|
const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
|
|
60
60
|
if (!attachment || !attachment.name) {
|
|
61
61
|
return null;
|
|
@@ -65,12 +65,12 @@ const FileReference = ({ attachment, submissionId, handleReplace, handleDownload
|
|
|
65
65
|
react_1.default.createElement(Container, null,
|
|
66
66
|
util_1.fileTypesWithIconMap.get(util_1.extensionsWithFileTypesMap.get(fileExtension)),
|
|
67
67
|
react_1.default.createElement(FileReferenceName, null, attachment.name)),
|
|
68
|
-
handleDownload && handleReplace &&
|
|
68
|
+
handleDownload && handleReplace && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
|
|
69
69
|
react_1.default.createElement(FileSectionItem_1.ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
70
70
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
71
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
|
|
71
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
|
|
72
72
|
(attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
|
|
73
|
-
handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload,
|
|
73
|
+
handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
|
|
74
74
|
};
|
|
75
75
|
const ElementItem = (0, styled_components_1.default)(FileSectionItem_1.Item) `
|
|
76
76
|
display: flex;
|
|
@@ -26,7 +26,7 @@ const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
|
|
|
26
26
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
27
27
|
const FileSectionState_1 = require("./FileSectionState");
|
|
28
28
|
const util_1 = require("./util");
|
|
29
|
-
const UploadFileArea = ({ handleUploadFile, fileSection,
|
|
29
|
+
const UploadFileArea = ({ handleUploadFile, fileSection, dispatch }) => {
|
|
30
30
|
const [selectedFile, setSelectedFile] = (0, react_1.useState)();
|
|
31
31
|
const fileInputRef = (0, react_1.useRef)(null);
|
|
32
32
|
const isSupplementFilesTab = fileSection === util_1.FileSectionType.Supplements;
|
|
@@ -41,7 +41,7 @@ const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, dispatch
|
|
|
41
41
|
setSelectedFile(file);
|
|
42
42
|
dispatch(FileSectionState_1.actions.UPLOAD_FILE(file));
|
|
43
43
|
if (file && isSupplementFilesTab) {
|
|
44
|
-
handleUploadFile(
|
|
44
|
+
handleUploadFile(file, (0, util_1.getDesignationName)(util_1.Designation.Supplementary));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
};
|
|
@@ -51,16 +51,10 @@ const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, dispatch
|
|
|
51
51
|
setSelectedFile(file);
|
|
52
52
|
dispatch(FileSectionState_1.actions.UPLOAD_FILE(file));
|
|
53
53
|
if (selectedFile && isSupplementFilesTab) {
|
|
54
|
-
handleUploadFile(
|
|
54
|
+
handleUploadFile(selectedFile, (0, util_1.getDesignationName)(util_1.Designation.Supplementary));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
}, [
|
|
58
|
-
dispatch,
|
|
59
|
-
handleUploadFile,
|
|
60
|
-
isSupplementFilesTab,
|
|
61
|
-
selectedFile,
|
|
62
|
-
submissionId,
|
|
63
|
-
]);
|
|
57
|
+
}, [dispatch, handleUploadFile, isSupplementFilesTab, selectedFile]);
|
|
64
58
|
const [{ canDrop, isOver }, dropRef] = (0, react_dnd_1.useDrop)({
|
|
65
59
|
accept: [react_dnd_html5_backend_1.NativeTypes.FILE],
|
|
66
60
|
drop(item, monitor) {
|
|
@@ -102,9 +102,12 @@ const BaseInformation = ({ submission, handleDateChange, userRole }) => {
|
|
|
102
102
|
types_1.SubmissionCriticality.OVERDUE && react_1.default.createElement(AttentionRed_1.default, null))),
|
|
103
103
|
react_1.default.createElement(react_tooltip_1.default, { id: submission.id, place: "bottom", effect: "solid", offset: { top: 10 }, className: "tooltip", disable: userRole == 'pe' }, "No permissions to reschedule")));
|
|
104
104
|
return (react_1.default.createElement(Grid, null,
|
|
105
|
-
react_1.default.createElement(
|
|
106
|
-
|
|
107
|
-
react_1.default.createElement(
|
|
105
|
+
(!submission.isPublished && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
106
|
+
react_1.default.createElement(DateLabel, null, "Due date"),
|
|
107
|
+
react_1.default.createElement(Value, null,
|
|
108
|
+
react_1.default.createElement(CalenderDatePicker, { submission: submission, handleDateChange: handleDateChange, Button: Button }))))) || (react_1.default.createElement(react_1.default.Fragment, null,
|
|
109
|
+
react_1.default.createElement(Label, null, "Published:"),
|
|
110
|
+
react_1.default.createElement(Value, null, (0, date_fns_1.format)(submission.publishedDate || 0, 'd MMM yyyy, EEEE')))),
|
|
108
111
|
react_1.default.createElement(Label, null, "Article ID:"),
|
|
109
112
|
react_1.default.createElement(Value, null, submission.id),
|
|
110
113
|
react_1.default.createElement(Label, null, "DOI:"),
|
|
@@ -120,10 +123,11 @@ const BaseInformation = ({ submission, handleDateChange, userRole }) => {
|
|
|
120
123
|
react_1.default.createElement(Value, null, submission.author.email))),
|
|
121
124
|
react_1.default.createElement(Label, null, "Production Editor:"),
|
|
122
125
|
react_1.default.createElement(Value, null, submission.journal.productionEditor.displayName),
|
|
123
|
-
react_1.default.createElement(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
!submission.isPublished && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
127
|
+
react_1.default.createElement(Label, null, "Publication Due:"),
|
|
128
|
+
react_1.default.createElement(Value, null,
|
|
129
|
+
(0, date_fns_1.format)(submission.dueDate, 'd MMM, EEEE'),
|
|
130
|
+
submission.isAtRisk && (react_1.default.createElement(Pill, { background: criticalityPill[submission.criticality].color }, criticalityPill[submission.criticality].label)))))));
|
|
127
131
|
};
|
|
128
132
|
exports.BaseInformation = BaseInformation;
|
|
129
133
|
const getDay = (date) => ({
|