@manuscripts/body-editor 3.0.3 → 3.1.0
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/affiliations/AffiliationsModal.js +79 -126
- package/dist/cjs/components/authors/AffiliationDrawer.js +24 -0
- package/dist/cjs/components/authors/AuthorDetailsForm.js +11 -9
- package/dist/cjs/components/authors/AuthorsModal.js +121 -204
- package/dist/cjs/components/authors/CreditDrawer.js +37 -0
- package/dist/cjs/components/authors/useManageAffiliations.js +41 -0
- package/dist/cjs/components/authors/useManageCredit.js +43 -0
- package/dist/cjs/components/form/FormFooter.js +2 -0
- package/dist/cjs/components/form/ModalFormActions.js +4 -4
- package/dist/cjs/components/modal-drawer/GenericDrawer.js +16 -0
- package/dist/cjs/components/modal-drawer/GenericDrawerGroup.js +75 -0
- package/dist/cjs/lib/normalize.js +49 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/es/components/affiliations/AffiliationsModal.js +80 -127
- package/dist/es/components/authors/AffiliationDrawer.js +17 -0
- package/dist/es/components/authors/AuthorDetailsForm.js +9 -7
- package/dist/es/components/authors/AuthorsModal.js +123 -206
- package/dist/es/components/authors/CreditDrawer.js +30 -0
- package/dist/es/components/authors/useManageAffiliations.js +37 -0
- package/dist/es/components/authors/useManageCredit.js +39 -0
- package/dist/es/components/form/FormFooter.js +2 -0
- package/dist/es/components/form/ModalFormActions.js +4 -4
- package/dist/es/components/modal-drawer/GenericDrawer.js +9 -0
- package/dist/es/components/modal-drawer/GenericDrawerGroup.js +68 -0
- package/dist/es/lib/normalize.js +44 -0
- package/dist/es/versions.js +1 -1
- package/dist/types/components/authors/AffiliationDrawer.d.ts +12 -0
- package/dist/types/components/authors/AuthorDetailsForm.d.ts +4 -1
- package/dist/types/components/authors/AuthorsModal.d.ts +1 -2
- package/dist/types/components/authors/CreditDrawer.d.ts +14 -0
- package/dist/types/components/authors/useManageAffiliations.d.ts +18 -0
- package/dist/types/components/authors/useManageCredit.d.ts +13 -0
- package/dist/types/components/form/ModalFormActions.d.ts +2 -2
- package/dist/types/components/modal-drawer/GenericDrawer.d.ts +14 -0
- package/dist/types/components/modal-drawer/GenericDrawerGroup.d.ts +45 -0
- package/dist/types/lib/normalize.d.ts +25 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/versions.d.ts +1 -1
- package/package.json +3 -3
|
@@ -27,109 +27,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.AffiliationsModal = void 0;
|
|
30
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
31
30
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
31
|
+
const transform_1 = require("@manuscripts/transform");
|
|
32
32
|
const lodash_1 = require("lodash");
|
|
33
33
|
const react_1 = __importStar(require("react"));
|
|
34
34
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
35
35
|
const authors_1 = require("../../lib/authors");
|
|
36
|
+
const normalize_1 = require("../../lib/normalize");
|
|
36
37
|
const AuthorsModal_1 = require("../authors/AuthorsModal");
|
|
38
|
+
const useManageAffiliations_1 = require("../authors/useManageAffiliations");
|
|
37
39
|
const ConfirmationDialog_1 = require("../dialog/ConfirmationDialog");
|
|
38
40
|
const FormFooter_1 = __importDefault(require("../form/FormFooter"));
|
|
39
41
|
const FormPlaceholder_1 = require("../form/FormPlaceholder");
|
|
40
42
|
const ModalFormActions_1 = require("../form/ModalFormActions");
|
|
43
|
+
const GenericDrawer_1 = require("../modal-drawer/GenericDrawer");
|
|
44
|
+
const GenericDrawerGroup_1 = require("../modal-drawer/GenericDrawerGroup");
|
|
41
45
|
const AffiliationForm_1 = require("./AffiliationForm");
|
|
42
46
|
const AffiliationList_1 = require("./AffiliationList");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
padding: 12px 8px 12px 12px;
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
&[data-active='true'] {
|
|
52
|
-
background: ${(props) => props.theme.colors.background.fifth};
|
|
53
|
-
border: 1px solid ${(props) => props.theme.colors.border.primary};
|
|
54
|
-
border-left: 0;
|
|
55
|
-
border-right: 0;
|
|
56
|
-
}
|
|
57
|
-
`;
|
|
58
|
-
const ActionTitle = styled_components_1.default.div `
|
|
59
|
-
padding-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
60
|
-
`;
|
|
61
|
-
const AffiliationForms = styled_components_1.default.div `
|
|
62
|
-
padding-left: ${(props) => props.theme.grid.unit * 3}px;
|
|
63
|
-
padding-right: ${(props) => props.theme.grid.unit * 3}px;
|
|
64
|
-
position: relative;
|
|
65
|
-
margin-top: 20px;
|
|
66
|
-
`;
|
|
67
|
-
const AuthorsSection = styled_components_1.default.div `
|
|
68
|
-
margin-top: ${(props) => props.theme.grid.unit * 4}px;
|
|
69
|
-
padding-top: ${(props) => props.theme.grid.unit * 4}px;
|
|
70
|
-
border-top: 1px solid ${(props) => props.theme.colors.border.tertiary};
|
|
71
|
-
`;
|
|
72
|
-
const AuthorsHeader = styled_components_1.default.div `
|
|
73
|
-
display: flex;
|
|
74
|
-
justify-content: space-between;
|
|
75
|
-
align-items: flex-start;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
margin-bottom: ${(props) => props.theme.grid.unit * 2}px;
|
|
78
|
-
`;
|
|
79
|
-
const AuthorsTitle = styled_components_1.default.h3 `
|
|
80
|
-
margin: 0;
|
|
81
|
-
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
82
|
-
font-size: ${(props) => props.theme.font.size.large};
|
|
83
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
84
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
85
|
-
`;
|
|
86
|
-
const AffiliateButton = styled_components_1.default.button `
|
|
87
|
-
color: ${(props) => props.theme.colors.brand.default};
|
|
88
|
-
background: none;
|
|
89
|
-
border: none;
|
|
90
|
-
cursor: pointer;
|
|
91
|
-
padding: 0;
|
|
92
|
-
font: ${(props) => props.theme.font.weight.normal}
|
|
93
|
-
${(props) => props.theme.font.size.normal}
|
|
94
|
-
${(props) => props.theme.font.family.sans};
|
|
95
|
-
display: flex;
|
|
96
|
-
align-items: center;
|
|
97
|
-
gap: 4px;
|
|
98
|
-
margin-top: ${(props) => props.theme.grid.unit * 2}px;
|
|
99
|
-
&:hover {
|
|
100
|
-
opacity: 0.8;
|
|
101
|
-
}
|
|
102
|
-
`;
|
|
103
|
-
const StyledModalBody = (0, styled_components_1.default)(style_guide_1.ModalBody) `
|
|
104
|
-
position: relative;
|
|
105
|
-
height: calc(90vh - 40px);
|
|
106
|
-
`;
|
|
107
|
-
const StyledModalSidebarHeader = (0, styled_components_1.default)(style_guide_1.ModalSidebarHeader) `
|
|
108
|
-
margin-top: 8px;
|
|
109
|
-
margin-bottom: 16px;
|
|
110
|
-
`;
|
|
111
|
-
const normalize = (affiliation) => ({
|
|
112
|
-
id: affiliation.id || (0, json_schema_1.generateID)(json_schema_1.ObjectTypes.Affiliation),
|
|
113
|
-
institution: affiliation.institution,
|
|
114
|
-
department: affiliation.department,
|
|
115
|
-
addressLine1: affiliation.addressLine1,
|
|
116
|
-
addressLine2: affiliation.addressLine2,
|
|
117
|
-
addressLine3: affiliation.addressLine3,
|
|
118
|
-
postCode: affiliation.postCode,
|
|
119
|
-
country: affiliation.country,
|
|
120
|
-
county: affiliation.county,
|
|
121
|
-
city: affiliation.city,
|
|
122
|
-
email: affiliation.email,
|
|
123
|
-
priority: affiliation.priority,
|
|
124
|
-
});
|
|
47
|
+
function makeAuthorItems(authors) {
|
|
48
|
+
return authors.map((author) => ({
|
|
49
|
+
id: author.id,
|
|
50
|
+
label: `${author.bibliographicName.given} ${author.bibliographicName.family}`,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
125
53
|
const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, affiliation, onSaveAffiliation, onDeleteAffiliation, onUpdateAuthors, addNewAffiliation = false, }) => {
|
|
126
54
|
const [isOpen, setIsOpen] = (0, react_1.useState)(true);
|
|
127
55
|
const [selection, setSelection] = (0, react_1.useState)(affiliation);
|
|
128
|
-
const [
|
|
56
|
+
const [showingDeleteDialog, setShowDeleteDialog] = (0, react_1.useState)(false);
|
|
129
57
|
const valuesRef = (0, react_1.useRef)();
|
|
130
58
|
const actionsRef = (0, react_1.useRef)();
|
|
131
59
|
const [authors, dispatchAuthors] = (0, react_1.useReducer)(AuthorsModal_1.authorsReducer, $authors.sort(authors_1.authorComparator));
|
|
132
|
-
const [affiliations, dispatchAffiliations] = (0, react_1.useReducer)(
|
|
60
|
+
const [affiliations, dispatchAffiliations] = (0, react_1.useReducer)(useManageAffiliations_1.affiliationsReducer, $affiliations);
|
|
133
61
|
const [isDisableSave, setIsDisableSave] = (0, react_1.useState)(true);
|
|
134
62
|
const [newAffiliation, setNewAffiliation] = (0, react_1.useState)(false);
|
|
135
63
|
const [showRequiredFieldConfirmationDialog, setShowRequiredFieldConfirmationDialog,] = (0, react_1.useState)(false);
|
|
@@ -157,7 +85,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
157
85
|
}, []);
|
|
158
86
|
const handleClose = () => {
|
|
159
87
|
const values = valuesRef.current;
|
|
160
|
-
const hasAffiliationChanges = selection && !(0, lodash_1.isEqual)(values,
|
|
88
|
+
const hasAffiliationChanges = selection && !(0, lodash_1.isEqual)(values, (0, normalize_1.checkID)(selection, 'affiliation'));
|
|
161
89
|
const originalAuthors = selection
|
|
162
90
|
? affiliationAuthorMap.get(selection.id) ?? []
|
|
163
91
|
: [];
|
|
@@ -179,7 +107,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
179
107
|
};
|
|
180
108
|
const handleSelect = (affiliation) => {
|
|
181
109
|
const values = valuesRef.current;
|
|
182
|
-
const hasAffiliationChanges = selection && !(0, lodash_1.isEqual)(values,
|
|
110
|
+
const hasAffiliationChanges = selection && !(0, lodash_1.isEqual)(values, (0, normalize_1.checkID)(selection, 'affiliation'));
|
|
183
111
|
const originalAuthors = selection
|
|
184
112
|
? affiliationAuthorMap.get(selection.id) ?? []
|
|
185
113
|
: [];
|
|
@@ -217,7 +145,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
217
145
|
}
|
|
218
146
|
setIsDisableSave(true);
|
|
219
147
|
const affiliation = {
|
|
220
|
-
...
|
|
148
|
+
...(0, normalize_1.checkID)(selection, 'affiliation'),
|
|
221
149
|
...values,
|
|
222
150
|
};
|
|
223
151
|
onSaveAffiliation(affiliation);
|
|
@@ -264,7 +192,8 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
264
192
|
return;
|
|
265
193
|
}
|
|
266
194
|
const isInstitutionEmpty = !values.institution?.trim();
|
|
267
|
-
const hasAffiliationChanges = selection &&
|
|
195
|
+
const hasAffiliationChanges = selection &&
|
|
196
|
+
!(0, lodash_1.isEqual)((0, normalize_1.checkID)(values, 'affiliation'), (0, normalize_1.checkID)(selection, 'affiliation'));
|
|
268
197
|
const originalAuthors = affiliationAuthorMap.get(selection.id) ?? [];
|
|
269
198
|
const hasAuthorChanges = selection && !(0, lodash_1.isEqual)(originalAuthors.sort(), selectedAuthorIds.sort());
|
|
270
199
|
const shouldEnableSave = !isInstitutionEmpty && (hasAffiliationChanges || hasAuthorChanges);
|
|
@@ -294,7 +223,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
294
223
|
setSelectedAuthorIds([]);
|
|
295
224
|
setSelection(undefined);
|
|
296
225
|
};
|
|
297
|
-
const
|
|
226
|
+
const selectAuthor = (authorId) => {
|
|
298
227
|
if (!selection) {
|
|
299
228
|
return;
|
|
300
229
|
}
|
|
@@ -302,17 +231,13 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
302
231
|
? selectedAuthorIds.filter((id) => id !== authorId)
|
|
303
232
|
: [...selectedAuthorIds, authorId];
|
|
304
233
|
setSelectedAuthorIds(newSelectedAuthorIds);
|
|
305
|
-
const hasAffiliationChanges = !(0, lodash_1.isEqual)(valuesRef.current,
|
|
234
|
+
const hasAffiliationChanges = !(0, lodash_1.isEqual)(valuesRef.current, (0, normalize_1.checkID)(selection, 'affiliation'));
|
|
306
235
|
const originalAuthors = affiliationAuthorMap.get(selection.id) ?? [];
|
|
307
236
|
const hasAuthorChanges = !(0, lodash_1.isEqual)(originalAuthors.sort(), newSelectedAuthorIds.sort());
|
|
308
237
|
const isInstitutionEmpty = !valuesRef.current?.institution?.trim();
|
|
309
238
|
const shouldEnableSave = !isInstitutionEmpty && (hasAffiliationChanges || hasAuthorChanges);
|
|
310
239
|
setIsDisableSave(!shouldEnableSave);
|
|
311
240
|
};
|
|
312
|
-
const authorItems = authors.map((author) => ({
|
|
313
|
-
id: author.id,
|
|
314
|
-
label: `${author.bibliographicName.given} ${author.bibliographicName.family}`,
|
|
315
|
-
}));
|
|
316
241
|
const selectedAuthors = selectedAuthorIds
|
|
317
242
|
.map((authorId) => {
|
|
318
243
|
const author = authors.find((a) => a.id === authorId);
|
|
@@ -328,23 +253,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
328
253
|
const values = valuesRef.current;
|
|
329
254
|
const hasChanges = !isDisableSave;
|
|
330
255
|
const isInstitutionEmpty = values?.institution?.trim() === '';
|
|
331
|
-
const emptyAffiliation =
|
|
332
|
-
id: (0, json_schema_1.generateID)(json_schema_1.ObjectTypes.Affiliation),
|
|
333
|
-
institution: '',
|
|
334
|
-
department: '',
|
|
335
|
-
addressLine1: '',
|
|
336
|
-
addressLine2: '',
|
|
337
|
-
addressLine3: '',
|
|
338
|
-
postCode: '',
|
|
339
|
-
country: '',
|
|
340
|
-
county: '',
|
|
341
|
-
city: '',
|
|
342
|
-
email: {
|
|
343
|
-
href: '',
|
|
344
|
-
text: '',
|
|
345
|
-
},
|
|
346
|
-
priority: affiliations.length,
|
|
347
|
-
};
|
|
256
|
+
const emptyAffiliation = createEmptyAffiliation(affiliations.length);
|
|
348
257
|
if (hasChanges) {
|
|
349
258
|
setPendingAction('new');
|
|
350
259
|
if (isInstitutionEmpty) {
|
|
@@ -383,7 +292,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
383
292
|
.filter((author) => author.affiliations?.some((aff) => aff === pendingSelection.id))
|
|
384
293
|
.map((author) => author.id);
|
|
385
294
|
setSelectedAuthorIds(affiliatedAuthorIds);
|
|
386
|
-
valuesRef.current =
|
|
295
|
+
valuesRef.current = (0, normalize_1.checkID)(pendingSelection, 'affiliation');
|
|
387
296
|
setIsDisableSave(true);
|
|
388
297
|
setAffiliationAuthorMap((prevMap) => {
|
|
389
298
|
const newMap = new Map(prevMap);
|
|
@@ -421,7 +330,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
421
330
|
setSelectedAuthorIds([]);
|
|
422
331
|
}
|
|
423
332
|
if (pendingSelection) {
|
|
424
|
-
valuesRef.current =
|
|
333
|
+
valuesRef.current = (0, normalize_1.checkID)(pendingSelection, 'affiliation');
|
|
425
334
|
}
|
|
426
335
|
else {
|
|
427
336
|
valuesRef.current = undefined;
|
|
@@ -446,20 +355,64 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
|
|
|
446
355
|
react_1.default.createElement(ActionTitle, null, "New Affiliation")),
|
|
447
356
|
react_1.default.createElement(AffiliationList_1.AffiliationList, { affiliation: selection, affiliations: affiliations, onSelect: handleSelect, onDelete: handleShowDeleteDialog, lastSavedAffiliationId: savedAffiliationId }))),
|
|
448
357
|
react_1.default.createElement(style_guide_1.ScrollableModalContent, { "data-cy": "affiliations-modal-content" }, selection ? (react_1.default.createElement(AffiliationForms, null,
|
|
449
|
-
react_1.default.createElement(ModalFormActions_1.ModalFormActions, { type: 'affiliation', form: 'affiliation-form', onDelete: handleDeleteAffiliation,
|
|
450
|
-
react_1.default.createElement(AffiliationForm_1.AffiliationForm, { values:
|
|
358
|
+
react_1.default.createElement(ModalFormActions_1.ModalFormActions, { type: 'affiliation', form: 'affiliation-form', onDelete: handleDeleteAffiliation, showingDeleteDialog: showingDeleteDialog, showDeleteDialog: handleShowDeleteDialog, newEntity: newAffiliation, isDisableSave: isDisableSave }),
|
|
359
|
+
react_1.default.createElement(AffiliationForm_1.AffiliationForm, { values: (0, normalize_1.checkID)(selection, 'affiliation'), onSave: () => handleSaveAffiliation(valuesRef.current), onChange: handleAffiliationChange, actionsRef: actionsRef }),
|
|
451
360
|
react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showRequiredFieldConfirmationDialog, onPrimary: () => setShowRequiredFieldConfirmationDialog(false), onSecondary: handleConfirmationCancel, type: ConfirmationDialog_1.DialogType.REQUIRED, entityType: "affiliation" }),
|
|
452
361
|
react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: handleConfirmationSave, onSecondary: handleConfirmationCancel, type: ConfirmationDialog_1.DialogType.SAVE, entityType: "affiliation" }),
|
|
453
|
-
react_1.default.createElement(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
react_1.default.createElement(AffiliateButton, { onClick: () => setShowAuthorDrawer(true), "data-cy": "affiliate-authors-button" },
|
|
457
|
-
react_1.default.createElement(style_guide_1.AddUserIcon, { width: 16, height: 16 }),
|
|
458
|
-
"Affiliate Authors")),
|
|
459
|
-
react_1.default.createElement(style_guide_1.SelectedItemsBox, { "data-cy": "affiliation-authors", items: selectedAuthors, onRemove: (id) => {
|
|
460
|
-
setSelectedAuthorIds((prev) => prev.filter((authorId) => authorId !== id));
|
|
461
|
-
}, placeholder: "No authors assigned" })),
|
|
462
|
-
showAuthorDrawer && (react_1.default.createElement(style_guide_1.Drawer, { items: authorItems, selectedIds: selectedAuthorIds, title: "Authors", onSelect: handleAuthorSelect, onBack: () => setShowAuthorDrawer(false), width: "100%" })))) : (react_1.default.createElement(FormPlaceholder_1.FormPlaceholder, { type: "affiliation", title: "Affiliation Details", message: "Select an affiliation from the list to display it's details here.", placeholderIcon: react_1.default.createElement(style_guide_1.AffiliationPlaceholderIcon, null) })))),
|
|
362
|
+
react_1.default.createElement(GenericDrawerGroup_1.DrawerGroup, { Drawer: GenericDrawer_1.GenericDrawer, removeItem: (id) => {
|
|
363
|
+
setSelectedAuthorIds((prev) => prev.filter((authorId) => authorId !== id));
|
|
364
|
+
}, selectedItems: selectedAuthors, onSelect: selectAuthor, items: makeAuthorItems(authors), showDrawer: showAuthorDrawer, setShowDrawer: setShowAuthorDrawer, title: "Authors", cy: "affiliations", labelField: "label", buttonText: "Affiliate Authors", Icon: react_1.default.createElement(style_guide_1.AddUserIcon, { width: 16, height: 16 }) }))) : (react_1.default.createElement(FormPlaceholder_1.FormPlaceholder, { type: "affiliation", title: "Affiliation Details", message: "Select an affiliation from the list to display it's details here.", placeholderIcon: react_1.default.createElement(style_guide_1.AffiliationPlaceholderIcon, null) })))),
|
|
463
365
|
react_1.default.createElement(FormFooter_1.default, { onCancel: handleClose }))));
|
|
464
366
|
};
|
|
465
367
|
exports.AffiliationsModal = AffiliationsModal;
|
|
368
|
+
function createEmptyAffiliation(priority) {
|
|
369
|
+
return {
|
|
370
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.affiliation),
|
|
371
|
+
institution: '',
|
|
372
|
+
department: '',
|
|
373
|
+
addressLine1: '',
|
|
374
|
+
addressLine2: '',
|
|
375
|
+
addressLine3: '',
|
|
376
|
+
postCode: '',
|
|
377
|
+
country: '',
|
|
378
|
+
county: '',
|
|
379
|
+
city: '',
|
|
380
|
+
email: {
|
|
381
|
+
href: '',
|
|
382
|
+
text: '',
|
|
383
|
+
},
|
|
384
|
+
priority: priority,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
const StyledSidebarContent = (0, styled_components_1.default)(style_guide_1.SidebarContent) `
|
|
388
|
+
padding: 0;
|
|
389
|
+
`;
|
|
390
|
+
const AddAffiliationButton = styled_components_1.default.div `
|
|
391
|
+
display: flex;
|
|
392
|
+
align-items: center;
|
|
393
|
+
padding: 12px 8px 12px 12px;
|
|
394
|
+
cursor: pointer;
|
|
395
|
+
&[data-active='true'] {
|
|
396
|
+
background: ${(props) => props.theme.colors.background.fifth};
|
|
397
|
+
border: 1px solid ${(props) => props.theme.colors.border.primary};
|
|
398
|
+
border-left: 0;
|
|
399
|
+
border-right: 0;
|
|
400
|
+
}
|
|
401
|
+
`;
|
|
402
|
+
const ActionTitle = styled_components_1.default.div `
|
|
403
|
+
padding-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
404
|
+
`;
|
|
405
|
+
const AffiliationForms = styled_components_1.default.div `
|
|
406
|
+
padding-left: ${(props) => props.theme.grid.unit * 3}px;
|
|
407
|
+
padding-right: ${(props) => props.theme.grid.unit * 3}px;
|
|
408
|
+
position: relative;
|
|
409
|
+
margin-top: 20px;
|
|
410
|
+
`;
|
|
411
|
+
const StyledModalBody = (0, styled_components_1.default)(style_guide_1.ModalBody) `
|
|
412
|
+
position: relative;
|
|
413
|
+
height: calc(90vh - 40px);
|
|
414
|
+
`;
|
|
415
|
+
const StyledModalSidebarHeader = (0, styled_components_1.default)(style_guide_1.ModalSidebarHeader) `
|
|
416
|
+
margin-top: 8px;
|
|
417
|
+
margin-bottom: 16px;
|
|
418
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AffiliationsDrawer = void 0;
|
|
7
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const AffiliationsDrawer = ({ items, selectedItems = [], onSelect, ...drawerProps }) => {
|
|
10
|
+
return (react_1.default.createElement(style_guide_1.Drawer, { ...drawerProps },
|
|
11
|
+
react_1.default.createElement(style_guide_1.DrawerItemsList, null, items.map((item) => (react_1.default.createElement(style_guide_1.DrawerListItem, { "data-cy": "item", key: item.id, selected: selectedItems?.map((a) => a.id).includes(item.id), onClick: () => onSelect(item.id) },
|
|
12
|
+
react_1.default.createElement(style_guide_1.DrawerIcon, null, selectedItems?.map((a) => a.id).includes(item.id) ? (react_1.default.createElement(style_guide_1.AddedIcon, { width: 22, height: 22 })) : (react_1.default.createElement(style_guide_1.AddIcon, { width: 22, height: 22 }))),
|
|
13
|
+
react_1.default.createElement(style_guide_1.DrawerLabelContainer, null,
|
|
14
|
+
react_1.default.createElement(style_guide_1.DrawerItemLabel, null, item.institution),
|
|
15
|
+
react_1.default.createElement(style_guide_1.DrawerItemMeta, null,
|
|
16
|
+
item.city && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
17
|
+
item.city,
|
|
18
|
+
item.county || item.country ? ', ' : '')),
|
|
19
|
+
item.county && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
20
|
+
item.county,
|
|
21
|
+
item.country ? ', ' : '')),
|
|
22
|
+
item.country && react_1.default.createElement(react_1.default.Fragment, null, item.country)))))))));
|
|
23
|
+
};
|
|
24
|
+
exports.AffiliationsDrawer = AffiliationsDrawer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
|
-
* ©
|
|
3
|
+
* © 2025 Atypon Systems LLC
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -41,7 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.AuthorDetailsForm = exports.Fieldset = exports.LabelText = void 0;
|
|
44
|
+
exports.AuthorDetailsForm = exports.CheckboxContainer = exports.Fieldset = exports.LabelText = void 0;
|
|
45
45
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
46
46
|
const formik_1 = require("formik");
|
|
47
47
|
const react_1 = __importStar(require("react"));
|
|
@@ -70,18 +70,23 @@ const TextFieldWithError = (0, styled_components_1.default)(style_guide_1.TextFi
|
|
|
70
70
|
color: ${(props) => props.theme.colors.text.error};
|
|
71
71
|
}
|
|
72
72
|
`;
|
|
73
|
-
|
|
73
|
+
exports.CheckboxContainer = styled_components_1.default.div `
|
|
74
74
|
display: flex;
|
|
75
75
|
align-items: center;
|
|
76
76
|
gap: 32px;
|
|
77
77
|
`;
|
|
78
|
-
const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, authorFormRef, }) => {
|
|
78
|
+
const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, selectedCreditRoles, authorFormRef, }) => {
|
|
79
79
|
const formRef = (0, react_1.useRef)(null);
|
|
80
80
|
(0, react_1.useEffect)(() => {
|
|
81
81
|
if (selectedAffiliations && formRef.current) {
|
|
82
82
|
formRef.current.setFieldValue('affiliations', selectedAffiliations);
|
|
83
83
|
}
|
|
84
84
|
}, [selectedAffiliations]);
|
|
85
|
+
(0, react_1.useEffect)(() => {
|
|
86
|
+
if (selectedCreditRoles && formRef.current) {
|
|
87
|
+
formRef.current.setFieldValue('creditRoles', selectedCreditRoles);
|
|
88
|
+
}
|
|
89
|
+
}, [selectedCreditRoles]);
|
|
85
90
|
if (actionsRef && !actionsRef.current) {
|
|
86
91
|
actionsRef.current = {
|
|
87
92
|
reset: () => {
|
|
@@ -103,17 +108,14 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
|
|
|
103
108
|
return (react_1.default.createElement(TextFieldWithError, { id: 'email', type: "email", required: isEmailRequired, placeholder: placeholder, ...props.field }));
|
|
104
109
|
}),
|
|
105
110
|
react_1.default.createElement(formik_1.Field, { name: 'role' }, (props) => (react_1.default.createElement(style_guide_1.TextField, { id: 'role', placeholder: 'Role', ...props.field }))),
|
|
106
|
-
react_1.default.createElement(CheckboxContainer, null,
|
|
111
|
+
react_1.default.createElement(exports.CheckboxContainer, null,
|
|
107
112
|
react_1.default.createElement(style_guide_1.CheckboxLabel, null,
|
|
108
113
|
react_1.default.createElement(formik_1.Field, { name: 'isCorresponding' }, (props) => (react_1.default.createElement(style_guide_1.CheckboxField, { id: 'isCorresponding', checked: props.field.value, ...props.field }))),
|
|
109
114
|
react_1.default.createElement(exports.LabelText, null, "Corresponding Author"))),
|
|
110
115
|
react_1.default.createElement(OrcidContainer, null,
|
|
111
116
|
react_1.default.createElement(style_guide_1.TextFieldLabel, null,
|
|
112
117
|
react_1.default.createElement(exports.LabelText, null, "ORCID"),
|
|
113
|
-
react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(style_guide_1.TextField, { id: 'orcid', placeholder: 'https://orcid.org/...', pattern: "https://orcid\\.org/\\d{4}-\\d{4}-\\d{4}-\\d{4}", title: "Please enter a valid ORCID URL format: https://orcid.org/xxxx-xxxx-xxxx-xxxx", ...props.field })))))
|
|
114
|
-
react_1.default.createElement(formik_1.Field, { name: "affiliations", type: "hidden" }, (props) => {
|
|
115
|
-
return (react_1.default.createElement(style_guide_1.TextField, { type: "hidden", ...props.field, value: selectedAffiliations || [] }));
|
|
116
|
-
}))));
|
|
118
|
+
react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(style_guide_1.TextField, { id: 'orcid', placeholder: 'https://orcid.org/...', pattern: "https://orcid\\.org/\\d{4}-\\d{4}-\\d{4}-\\d{4}", title: "Please enter a valid ORCID URL format: https://orcid.org/xxxx-xxxx-xxxx-xxxx", ...props.field }))))))));
|
|
117
119
|
}));
|
|
118
120
|
};
|
|
119
121
|
exports.AuthorDetailsForm = AuthorDetailsForm;
|