@manuscripts/style-guide 1.1.4 → 1.1.5-LEAN-2192
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/EditorHeader/EditorHeader.js +2 -2
- package/dist/cjs/components/EditorHeader/ProceedView.js +5 -5
- package/dist/cjs/components/FileManager/FileManager.js +8 -20
- package/dist/cjs/components/FileManager/FileSectionItem/DragLayer.js +1 -1
- package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +1 -3
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +4 -6
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +3 -16
- package/dist/cjs/components/FileManager/FileSectionState.js +5 -14
- package/dist/cjs/components/FileManager/FilesSection.js +7 -20
- package/dist/cjs/components/FileManager/InlineFilesSection.js +1 -1
- package/dist/cjs/components/FileManager/util.js +1 -323
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/lib/capabilities.js +0 -1
- package/dist/es/components/EditorHeader/EditorHeader.js +2 -2
- package/dist/es/components/EditorHeader/ProceedView.js +5 -5
- package/dist/es/components/FileManager/FileManager.js +9 -21
- package/dist/es/components/FileManager/FileSectionItem/DragLayer.js +1 -1
- package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +1 -3
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +4 -6
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +4 -17
- package/dist/es/components/FileManager/FileSectionState.js +5 -14
- package/dist/es/components/FileManager/FilesSection.js +9 -22
- package/dist/es/components/FileManager/InlineFilesSection.js +1 -1
- package/dist/es/components/FileManager/util.js +0 -318
- package/dist/es/index.js +0 -1
- package/dist/es/lib/capabilities.js +0 -1
- package/dist/types/components/EditorHeader/EditorHeader.d.ts +1 -1
- package/dist/types/components/EditorHeader/ProceedView.d.ts +1 -1
- package/dist/types/components/FileManager/FileManager.d.ts +2 -4
- package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -5
- package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +1 -3
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -2
- package/dist/types/components/FileManager/FileSectionState.d.ts +2 -5
- package/dist/types/components/FileManager/util.d.ts +0 -30
- package/dist/types/index.d.ts +0 -1
- package/dist/types/lib/capabilities.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/components/FileManager/FileSectionItem/DesignationActions.js +0 -131
- package/dist/cjs/components/FileManager/FileSectionItem/DesignationActionsList.js +0 -54
- package/dist/cjs/components/FileManager/SelectDesignationActions.js +0 -74
- package/dist/cjs/components/FileManager/SelectDialogDesignation.js +0 -33
- package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +0 -101
- package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +0 -47
- package/dist/es/components/FileManager/SelectDesignationActions.js +0 -44
- package/dist/es/components/FileManager/SelectDialogDesignation.js +0 -26
- package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +0 -14
- package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +0 -13
- package/dist/types/components/FileManager/SelectDesignationActions.d.ts +0 -12
- package/dist/types/components/FileManager/SelectDialogDesignation.d.ts +0 -11
|
@@ -49,7 +49,7 @@ const MapUserRole = {
|
|
|
49
49
|
Viewer: { label: 'Reading...', icon: __1.ReadingIcon },
|
|
50
50
|
};
|
|
51
51
|
const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
|
|
52
|
-
var _a, _b, _c;
|
|
52
|
+
var _a, _b, _c, _d;
|
|
53
53
|
const [confirmationDialog, toggleConfirmationDialog] = (0, react_1.useState)(false);
|
|
54
54
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
55
55
|
const [noteValue, setNoteValue] = (0, react_1.useState)('');
|
|
@@ -95,7 +95,7 @@ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userR
|
|
|
95
95
|
react_1.default.createElement("span", null, "Dashboard"))),
|
|
96
96
|
handleSnapshot &&
|
|
97
97
|
typeof hasPendingSuggestions == 'boolean' &&
|
|
98
|
-
submission.
|
|
98
|
+
submission.previousStep && (react_1.default.createElement(ProceedView_1.ProceedView, { isAnnotator: isAnnotator, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, loading: loading, showComplete: showComplete, noteValue: noteValue, currentStepTransition: currentStepTransition, error: error, currentStepType: submission.currentStep.type, previousStepType: (_d = submission.previousStep) === null || _d === void 0 ? void 0 : _d.type, confirmationDialog: confirmationDialog, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
|
|
99
99
|
status && (react_1.default.createElement(ChildWrapper, null,
|
|
100
100
|
react_1.default.createElement(__1.SaveStatus, { status: status }))),
|
|
101
101
|
react_1.default.createElement(Spacer, null),
|
|
@@ -46,7 +46,7 @@ const StepDetails = ({ icon, label, description, role }) => (react_1.default.cre
|
|
|
46
46
|
react_1.default.createElement(__1.SecondarySmallText, null,
|
|
47
47
|
"Actor: ",
|
|
48
48
|
role.label))));
|
|
49
|
-
const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loading, showComplete, confirmationDialog,
|
|
49
|
+
const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loading, showComplete, confirmationDialog, currentStepType, previousStepType, isAnnotator, hasPendingSuggestions, error, noteValue, onNoteChange, onCancelClick, continueDialogAction, message: Message, }) => {
|
|
50
50
|
const dialogMessages = (0, react_1.useMemo)(() => hasPendingSuggestions && !isAnnotator
|
|
51
51
|
? {
|
|
52
52
|
header: 'The task can not be transitioned to the next step',
|
|
@@ -62,7 +62,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loadin
|
|
|
62
62
|
: showComplete
|
|
63
63
|
? {
|
|
64
64
|
header: 'Content reassigned successfully',
|
|
65
|
-
message: `to the ${
|
|
65
|
+
message: `to the ${currentStepType.label}`,
|
|
66
66
|
actions: {
|
|
67
67
|
primary: {
|
|
68
68
|
action: onCancelClick,
|
|
@@ -87,7 +87,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loadin
|
|
|
87
87
|
showComplete,
|
|
88
88
|
continueDialogAction,
|
|
89
89
|
onCancelClick,
|
|
90
|
-
|
|
90
|
+
currentStepType,
|
|
91
91
|
hasPendingSuggestions,
|
|
92
92
|
isAnnotator,
|
|
93
93
|
]);
|
|
@@ -100,10 +100,10 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loadin
|
|
|
100
100
|
(loading && (react_1.default.createElement(__1.LoadingOverlay, null,
|
|
101
101
|
react_1.default.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026")))) || (react_1.default.createElement(__1.Dialog, { isOpen: confirmationDialog && !loading, category: __1.Category.confirmation, header: dialogMessages.header, message: dialogMessages.message, actions: dialogMessages.actions },
|
|
102
102
|
(showComplete && (react_1.default.createElement(Grid, null,
|
|
103
|
-
react_1.default.createElement(StepDetails, Object.assign({},
|
|
103
|
+
react_1.default.createElement(StepDetails, Object.assign({}, previousStepType, { icon: react_1.default.createElement(react_1.default.Fragment, null,
|
|
104
104
|
react_1.default.createElement(__1.TaskStepDoneIcon, null),
|
|
105
105
|
react_1.default.createElement(Line, null)) })),
|
|
106
|
-
react_1.default.createElement(StepDetails, Object.assign({},
|
|
106
|
+
react_1.default.createElement(StepDetails, Object.assign({}, currentStepType))))) ||
|
|
107
107
|
((!hasPendingSuggestions || isAnnotator) && onNoteChange && (react_1.default.createElement(TextAreaWrapper, null,
|
|
108
108
|
react_1.default.createElement(EditorHeader_1.MediumTextArea, { value: noteValue, onChange: onNoteChange, rows: 5, placeholder: 'Add any additional comment here...' })))),
|
|
109
109
|
error && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.error, hideCloseButton: true }, error))))));
|
|
@@ -52,32 +52,29 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
|
|
|
52
52
|
const TooltipDiv_1 = require("./TooltipDiv");
|
|
53
53
|
const util_1 = require("./util");
|
|
54
54
|
exports.PermissionsContext = (0, react_1.createContext)(null);
|
|
55
|
-
const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments,
|
|
55
|
+
const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, replace, upload }, addAttachmentToState, }) => {
|
|
56
56
|
const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
|
|
57
|
-
const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file
|
|
57
|
+
const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
58
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
59
|
-
|
|
60
|
-
const res = yield replace(attachmentId, name, file, typeId);
|
|
59
|
+
const res = yield replace(attachmentId, name, file);
|
|
61
60
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
62
61
|
if (res) {
|
|
63
62
|
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
64
63
|
}
|
|
65
64
|
return res;
|
|
66
65
|
}), [replace]);
|
|
67
|
-
const handleUploadFile = (0, react_1.useCallback)((file
|
|
66
|
+
const handleUploadFile = (0, react_1.useCallback)((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
67
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
69
|
-
|
|
70
|
-
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
|
|
71
|
-
}
|
|
72
|
-
const res = yield upload(file, designation);
|
|
68
|
+
const res = yield upload(file);
|
|
73
69
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
74
70
|
if (res) {
|
|
75
71
|
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.', index_1.FileSectionType.OtherFile));
|
|
76
72
|
}
|
|
77
73
|
return res;
|
|
78
74
|
}), [upload]);
|
|
79
|
-
const handleUploadFileWithSupplement = (0, react_1.useCallback)((file
|
|
80
|
-
|
|
75
|
+
const handleUploadFileWithSupplement = (0, react_1.useCallback)((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
77
|
+
const response = yield upload(file);
|
|
81
78
|
if (typeof response === 'object') {
|
|
82
79
|
const { id, name } = response;
|
|
83
80
|
yield saveModel((0, transform_1.buildSupplementaryMaterial)(name, `attachment:${id}`));
|
|
@@ -92,13 +89,6 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
92
89
|
const model = (0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === oldAttachmentId);
|
|
93
90
|
yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
|
|
94
91
|
}), [modelMap, saveModel]);
|
|
95
|
-
const handleChangeDesignationFile = (0, react_1.useCallback)((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
const res = yield changeDesignation(attachmentId, typeId, name);
|
|
97
|
-
if (res) {
|
|
98
|
-
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE(''));
|
|
99
|
-
}
|
|
100
|
-
return res;
|
|
101
|
-
}), [changeDesignation]);
|
|
102
92
|
const handleDownload = (0, react_1.useCallback)((url) => {
|
|
103
93
|
window.location.assign(url);
|
|
104
94
|
}, []);
|
|
@@ -131,12 +121,10 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
131
121
|
externalFile: element.externalFile,
|
|
132
122
|
title: element.title,
|
|
133
123
|
showAttachmentName: isSupplementOrOtherFilesTab,
|
|
134
|
-
showDesignationActions: isSupplementOrOtherFilesTab,
|
|
135
124
|
showReplaceAction: !isOtherFilesTab,
|
|
136
125
|
handleDownload,
|
|
137
126
|
handleReplace: handleReplaceFile,
|
|
138
127
|
handleSupplementReplace,
|
|
139
|
-
handleChangeDesignation: handleChangeDesignationFile,
|
|
140
128
|
dispatch: dispatch,
|
|
141
129
|
};
|
|
142
130
|
if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
|
|
@@ -55,7 +55,7 @@ const DragLayer = () => {
|
|
|
55
55
|
const renderItem = (0, react_1.useCallback)(() => {
|
|
56
56
|
switch (itemType) {
|
|
57
57
|
case 'FileSectionItem':
|
|
58
|
-
return (react_1.default.createElement(CustomFileSectionItem, { title: item.title, externalFile: item.externalFile, showAttachmentName: item.showAttachmentName, withDot: item.withDot, showSecondaryActions: false,
|
|
58
|
+
return (react_1.default.createElement(CustomFileSectionItem, { title: item.title, externalFile: item.externalFile, showAttachmentName: item.showAttachmentName, withDot: item.withDot, showSecondaryActions: false, style: { width: item.width } }));
|
|
59
59
|
default:
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
@@ -30,12 +30,10 @@ exports.FileDescription = exports.FileName = exports.FileNameContainer = exports
|
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const FileManager_1 = require("../FileManager");
|
|
33
|
-
const
|
|
34
|
-
const FileInfo = ({ showAttachmentName, showDesignationActions, title, fileAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
|
|
33
|
+
const FileInfo = ({ showAttachmentName, title, fileAttachmentName, fileExtension, attachmentId, dispatch, }) => {
|
|
35
34
|
const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
|
|
36
35
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
37
36
|
return (react_1.default.createElement(exports.FileInfoContainer, null,
|
|
38
|
-
showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: fileAttachmentName, dispatch: dispatch, can: can })),
|
|
39
37
|
react_1.default.createElement(exports.FileNameTitleContainer, null,
|
|
40
38
|
react_1.default.createElement(exports.FileTitle, null,
|
|
41
39
|
!showAttachmentName ? fileName : title,
|
|
@@ -10,15 +10,13 @@ const use_dropdown_1 = require("../../../hooks/use-dropdown");
|
|
|
10
10
|
const Dropdown_1 = require("../../Dropdown");
|
|
11
11
|
const icons_1 = require("../../icons/");
|
|
12
12
|
const dots_icon_1 = __importDefault(require("../../icons/dots-icon"));
|
|
13
|
-
const util_1 = require("../util");
|
|
14
13
|
const FileInfo_1 = require("./FileInfo");
|
|
15
14
|
const FileTypeIcon_1 = require("./FileTypeIcon");
|
|
16
15
|
const ItemActions_1 = require("./ItemActions");
|
|
17
|
-
const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false,
|
|
16
|
+
const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showReplaceAction = true, handleDownload, handleReplace, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
|
|
18
17
|
const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
|
|
19
18
|
const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
|
|
20
|
-
const
|
|
21
|
-
const isMainManuscript = designation === util_1.Designation.MainManuscript;
|
|
19
|
+
const isMainManuscript = externalFile.type.label === 'main-manuscript';
|
|
22
20
|
const isSelected = externalFile.id == window.location.hash.substr(1);
|
|
23
21
|
return (react_1.default.createElement(exports.Item, { ref: dragRef, className: className, style: style },
|
|
24
22
|
react_1.default.createElement(exports.ItemContainer, { onClick: () => {
|
|
@@ -29,7 +27,7 @@ const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName
|
|
|
29
27
|
}
|
|
30
28
|
} },
|
|
31
29
|
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,
|
|
30
|
+
react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, fileAttachmentName: externalFile.name, title: title, attachmentId: externalFile.id, dispatch: dispatch })),
|
|
33
31
|
onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
|
|
34
32
|
e.preventDefault();
|
|
35
33
|
onClose();
|
|
@@ -38,7 +36,7 @@ const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName
|
|
|
38
36
|
handleDownload && handleReplace && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
|
|
39
37
|
react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
40
38
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
41
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name,
|
|
39
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
42
40
|
};
|
|
43
41
|
exports.FileSectionItem = FileSectionItem;
|
|
44
42
|
const IconCloseButton = styled_components_1.default.button `
|
|
@@ -39,21 +39,9 @@ const FileManager_1 = require("../FileManager");
|
|
|
39
39
|
const FileSectionState_1 = require("../FileSectionState");
|
|
40
40
|
const ItemsAction_1 = require("../ItemsAction");
|
|
41
41
|
const util_1 = require("../util");
|
|
42
|
-
const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName,
|
|
43
|
-
const attachmentDesignation = designation == undefined ? 'undefined' : designation;
|
|
44
|
-
const attachmentDesignationName = attachmentDesignation !== 'undefined'
|
|
45
|
-
? util_1.namesWithDesignationMap.get(attachmentDesignation)
|
|
46
|
-
: undefined;
|
|
42
|
+
const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
|
|
47
43
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
48
|
-
const canBeReplaced =
|
|
49
|
-
(attachmentDesignationName == undefined ||
|
|
50
|
-
![
|
|
51
|
-
util_1.Designation.MainManuscript,
|
|
52
|
-
util_1.Designation.SubmissionFile,
|
|
53
|
-
util_1.Designation.SubmissionPdf,
|
|
54
|
-
].includes(attachmentDesignationName))) ||
|
|
55
|
-
(attachmentDesignationName == util_1.Designation.MainManuscript &&
|
|
56
|
-
(can === null || can === void 0 ? void 0 : can.setMainManuscript));
|
|
44
|
+
const canBeReplaced = showReplaceAction == undefined || showReplaceAction;
|
|
57
45
|
const fileInputRef = (0, react_1.useRef)(null);
|
|
58
46
|
const [selectedFile, setSelectedFile] = (0, react_1.useState)();
|
|
59
47
|
const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -62,9 +50,8 @@ const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachment
|
|
|
62
50
|
setSelectedFile(file);
|
|
63
51
|
if (dispatch) {
|
|
64
52
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
65
|
-
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(attachmentDesignationName || util_1.Designation.Document));
|
|
66
53
|
}
|
|
67
|
-
const result = yield replaceAttachmentHandler(attachmentId, fileName, file
|
|
54
|
+
const result = yield replaceAttachmentHandler(attachmentId, fileName, file);
|
|
68
55
|
if (fileSection === util_1.FileSectionType.Supplements &&
|
|
69
56
|
typeof result === 'object' &&
|
|
70
57
|
handleSupplementReplace) {
|
|
@@ -8,15 +8,13 @@ const getInitialState = () => ({
|
|
|
8
8
|
fileUploadedSuccessfullySection: undefined,
|
|
9
9
|
successMessage: '',
|
|
10
10
|
isShowSuccessMessage: false,
|
|
11
|
-
|
|
12
|
-
showDesignationPopup: undefined,
|
|
11
|
+
currentSection: undefined,
|
|
13
12
|
});
|
|
14
13
|
exports.getInitialState = getInitialState;
|
|
15
14
|
var ActionTypes;
|
|
16
15
|
(function (ActionTypes) {
|
|
17
16
|
ActionTypes["UPLOAD_FILE"] = "UploadFile";
|
|
18
17
|
ActionTypes["MOVE_FILE"] = "moveFile";
|
|
19
|
-
ActionTypes["SELECT_DESIGNATION"] = "selectDesignation";
|
|
20
18
|
ActionTypes["HANDLE_CANCEL_UPLOAD"] = "handleCancel";
|
|
21
19
|
ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
|
|
22
20
|
ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
|
|
@@ -26,7 +24,7 @@ var ActionTypes;
|
|
|
26
24
|
const reducer = (state, action) => {
|
|
27
25
|
switch (action.type) {
|
|
28
26
|
case ActionTypes.UPLOAD_FILE: {
|
|
29
|
-
return Object.assign(Object.assign({}, state), {
|
|
27
|
+
return Object.assign(Object.assign({}, state), { uploadedFile: action.uploadFile, currentSection: action.sectionType });
|
|
30
28
|
}
|
|
31
29
|
case ActionTypes.MOVE_FILE: {
|
|
32
30
|
return Object.assign(Object.assign({}, state), { moveToOtherState: {
|
|
@@ -34,17 +32,14 @@ const reducer = (state, action) => {
|
|
|
34
32
|
name: action.name,
|
|
35
33
|
}, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
|
|
36
34
|
}
|
|
37
|
-
case ActionTypes.SELECT_DESIGNATION: {
|
|
38
|
-
return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
|
|
39
|
-
}
|
|
40
35
|
case ActionTypes.HANDLE_UPLOAD_ACTION: {
|
|
41
|
-
return Object.assign(Object.assign({}, state), {
|
|
36
|
+
return Object.assign(Object.assign({}, state), { isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
|
|
42
37
|
}
|
|
43
38
|
case ActionTypes.HANDLE_CANCEL_UPLOAD: {
|
|
44
|
-
return Object.assign(
|
|
39
|
+
return Object.assign({}, state);
|
|
45
40
|
}
|
|
46
41
|
case ActionTypes.HANDLE_FINISH_UPLOAD: {
|
|
47
|
-
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined
|
|
42
|
+
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined });
|
|
48
43
|
}
|
|
49
44
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
50
45
|
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage, fileUploadedSuccessfullySection: action.sectionType });
|
|
@@ -68,10 +63,6 @@ exports.actions = {
|
|
|
68
63
|
HANDLE_CANCEL_UPLOAD: () => ({
|
|
69
64
|
type: ActionTypes.HANDLE_CANCEL_UPLOAD,
|
|
70
65
|
}),
|
|
71
|
-
SELECT_DESIGNATION: (designation) => ({
|
|
72
|
-
type: ActionTypes.SELECT_DESIGNATION,
|
|
73
|
-
designation,
|
|
74
|
-
}),
|
|
75
66
|
MOVE_FILE: (attachmentId, typeId, name, successMoveMessage) => ({
|
|
76
67
|
type: ActionTypes.MOVE_FILE,
|
|
77
68
|
typeId,
|
|
@@ -26,11 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.FilesSection = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const AlertMessage_1 = require("../AlertMessage");
|
|
29
|
-
const DragItemArea_1 = require("./DragItemArea");
|
|
30
29
|
const FileManager_1 = require("./FileManager");
|
|
31
30
|
const FileSectionUploadItem_1 = require("./FileSectionItem/FileSectionUploadItem");
|
|
32
31
|
const FileSectionState_1 = require("./FileSectionState");
|
|
33
|
-
const SelectDialogDesignation_1 = require("./SelectDialogDesignation");
|
|
34
32
|
const UploadFileArea_1 = require("./UploadFileArea");
|
|
35
33
|
const util_1 = require("./util");
|
|
36
34
|
const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
|
|
@@ -40,13 +38,12 @@ const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem,
|
|
|
40
38
|
}
|
|
41
39
|
const isSupplementFilesTab = fileSection === util_1.FileSectionType.Supplements;
|
|
42
40
|
const isOtherFileTab = fileSection === util_1.FileSectionType.OtherFile;
|
|
43
|
-
const handleUploadOtherFile = () => {
|
|
44
|
-
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
45
|
-
state.uploadedFile &&
|
|
46
|
-
state.selectDesignation !== undefined &&
|
|
47
|
-
handleUpload(state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
|
|
48
|
-
};
|
|
49
41
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
state.uploadedFile &&
|
|
44
|
+
fileSection === state.currentSection &&
|
|
45
|
+
handleUpload(state.uploadedFile);
|
|
46
|
+
}, [state.uploadedFile]);
|
|
50
47
|
const handleSuccessMessage = () => {
|
|
51
48
|
return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.success, hideCloseButton: true, dismissButton: {
|
|
52
49
|
text: 'OK',
|
|
@@ -56,19 +53,9 @@ const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem,
|
|
|
56
53
|
return (react_1.default.createElement("div", null,
|
|
57
54
|
(can === null || can === void 0 ? void 0 : can.uploadFile) && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
58
55
|
(isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
|
|
59
|
-
state.isUploadFile &&
|
|
60
|
-
state.uploadedFile &&
|
|
61
|
-
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
|
|
56
|
+
state.isUploadFile && state.uploadedFile && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
|
|
62
57
|
state.fileUploadedSuccessfullySection === fileSection &&
|
|
63
58
|
handleSuccessMessage(),
|
|
64
|
-
|
|
65
|
-
dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
|
|
66
|
-
}, uploadFileHandler: handleUploadOtherFile, dispatch: dispatch, fileSection: fileSection }),
|
|
67
|
-
filesItem,
|
|
68
|
-
(can === null || can === void 0 ? void 0 : can.changeDesignation) &&
|
|
69
|
-
enableDragAndDrop &&
|
|
70
|
-
(isSupplementFilesTab || isOtherFileTab) && (react_1.default.createElement(DragItemArea_1.DragItemArea, { text: isSupplementFilesTab
|
|
71
|
-
? 'Drag the items to place them in the text'
|
|
72
|
-
: 'Drag the items to place in the Supplements section or in the text' }))));
|
|
59
|
+
filesItem));
|
|
73
60
|
};
|
|
74
61
|
exports.FilesSection = FilesSection;
|
|
@@ -78,7 +78,7 @@ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdate
|
|
|
78
78
|
(attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
|
|
79
79
|
handleUpdateInline(attachment.modelId, uploadAttachment), detachAttachmnetHandler: () => handleDetachFile &&
|
|
80
80
|
attachment.modelId &&
|
|
81
|
-
handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name,
|
|
81
|
+
handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
|
|
82
82
|
};
|
|
83
83
|
const ElementItem = (0, styled_components_1.default)(FileSectionItem_1.Item) `
|
|
84
84
|
display: flex;
|