@manuscripts/body-editor 2.7.7 → 2.7.8-LEAN-4213.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.
Files changed (72) hide show
  1. package/dist/cjs/components/affiliations/AffiliationForm.js +106 -0
  2. package/dist/cjs/components/affiliations/AffiliationItem.js +112 -0
  3. package/dist/cjs/components/affiliations/AffiliationList.js +47 -0
  4. package/dist/cjs/components/affiliations/AffiliationsModal.js +418 -0
  5. package/dist/cjs/components/authors/AuthorDetailsForm.js +10 -2
  6. package/dist/cjs/components/authors/AuthorList.js +1 -1
  7. package/dist/cjs/components/authors/AuthorsModal.js +184 -80
  8. package/dist/cjs/components/authors/DraggableAuthor.js +0 -3
  9. package/dist/cjs/components/dialog/ConfirmationDialog.js +86 -0
  10. package/dist/cjs/components/form/FormFooter.js +32 -0
  11. package/dist/cjs/components/form/FormPlaceholder.js +43 -0
  12. package/dist/cjs/components/{authors/AuthorActions.js → form/ModalFormActions.js} +12 -11
  13. package/dist/cjs/plugins/affiliations.js +5 -38
  14. package/dist/cjs/useEditor.js +0 -1
  15. package/dist/cjs/versions.js +1 -1
  16. package/dist/cjs/views/affiliations.js +82 -14
  17. package/dist/cjs/views/contributors.js +1 -9
  18. package/dist/es/components/affiliations/AffiliationForm.js +76 -0
  19. package/dist/es/components/affiliations/AffiliationItem.js +82 -0
  20. package/dist/es/components/affiliations/AffiliationList.js +40 -0
  21. package/dist/es/components/affiliations/AffiliationsModal.js +388 -0
  22. package/dist/es/components/authors/AuthorDetailsForm.js +11 -3
  23. package/dist/es/components/authors/AuthorList.js +1 -1
  24. package/dist/es/components/authors/AuthorsModal.js +183 -79
  25. package/dist/es/components/authors/DraggableAuthor.js +0 -3
  26. package/dist/es/components/dialog/ConfirmationDialog.js +79 -0
  27. package/dist/es/components/form/FormFooter.js +27 -0
  28. package/dist/es/components/form/FormPlaceholder.js +36 -0
  29. package/dist/es/components/{authors/AuthorActions.js → form/ModalFormActions.js} +10 -9
  30. package/dist/es/plugins/affiliations.js +6 -39
  31. package/dist/es/useEditor.js +0 -1
  32. package/dist/es/versions.js +1 -1
  33. package/dist/es/views/affiliations.js +85 -17
  34. package/dist/es/views/contributors.js +1 -9
  35. package/dist/types/components/{authors → affiliations}/AffiliationForm.d.ts +5 -0
  36. package/dist/types/components/affiliations/AffiliationItem.d.ts +10 -0
  37. package/dist/types/components/affiliations/AffiliationList.d.ts +26 -0
  38. package/dist/types/components/affiliations/AffiliationsModal.d.ts +11 -0
  39. package/dist/types/components/authors/AuthorDetailsForm.d.ts +1 -0
  40. package/dist/types/components/authors/AuthorsModal.d.ts +2 -1
  41. package/dist/types/components/dialog/ConfirmationDialog.d.ts +15 -0
  42. package/dist/types/components/form/FormFooter.d.ts +5 -0
  43. package/dist/types/components/form/FormPlaceholder.d.ts +9 -0
  44. package/dist/types/components/{authors/AuthorActions.d.ts → form/ModalFormActions.d.ts} +4 -3
  45. package/dist/types/lib/dnd.d.ts +1 -1
  46. package/dist/types/selection.d.ts +7 -1
  47. package/dist/types/versions.d.ts +1 -1
  48. package/dist/types/views/affiliations.d.ts +11 -0
  49. package/dist/types/views/contributors.d.ts +0 -1
  50. package/package.json +2 -2
  51. package/styles/AdvancedEditor.css +8 -4
  52. package/styles/Editor.css +7 -0
  53. package/dist/cjs/components/authors/AffiliationButton.js +0 -104
  54. package/dist/cjs/components/authors/AffiliationForm.js +0 -50
  55. package/dist/cjs/components/authors/AuthorAffiliations.js +0 -120
  56. package/dist/cjs/components/authors/AuthorFormPlaceholder.js +0 -71
  57. package/dist/cjs/components/authors/DeleteAuthorConfirmationDialog.js +0 -36
  58. package/dist/cjs/components/authors/RequiredFieldConfirmationDialog.js +0 -39
  59. package/dist/cjs/components/authors/SaveAuthorConfirmationDialog.js +0 -39
  60. package/dist/es/components/authors/AffiliationButton.js +0 -74
  61. package/dist/es/components/authors/AffiliationForm.js +0 -43
  62. package/dist/es/components/authors/AuthorAffiliations.js +0 -89
  63. package/dist/es/components/authors/AuthorFormPlaceholder.js +0 -64
  64. package/dist/es/components/authors/DeleteAuthorConfirmationDialog.js +0 -29
  65. package/dist/es/components/authors/RequiredFieldConfirmationDialog.js +0 -32
  66. package/dist/es/components/authors/SaveAuthorConfirmationDialog.js +0 -32
  67. package/dist/types/components/authors/AffiliationButton.d.ts +0 -8
  68. package/dist/types/components/authors/AuthorAffiliations.d.ts +0 -11
  69. package/dist/types/components/authors/AuthorFormPlaceholder.d.ts +0 -2
  70. package/dist/types/components/authors/DeleteAuthorConfirmationDialog.d.ts +0 -7
  71. package/dist/types/components/authors/RequiredFieldConfirmationDialog.d.ts +0 -7
  72. package/dist/types/components/authors/SaveAuthorConfirmationDialog.d.ts +0 -7
@@ -0,0 +1,388 @@
1
+ import { generateID, ObjectTypes } from '@manuscripts/json-schema';
2
+ import { AddIcon, AddUserIcon, AffiliationPlaceholderIcon, CloseButton, Drawer, ModalBody, ModalContainer, ModalHeader, ModalSidebar, ModalSidebarHeader, ModalSidebarTitle, ScrollableModalContent, SelectedItemsBox, SidebarContent, StyledModal, } from '@manuscripts/style-guide';
3
+ import { isEqual } from 'lodash';
4
+ import React, { useEffect, useReducer, useRef, useState } from 'react';
5
+ import styled from 'styled-components';
6
+ import { authorComparator, } from '../../lib/authors';
7
+ import { affiliationsReducer, authorsReducer } from '../authors/AuthorsModal';
8
+ import { ConfirmationDialog, DialogType } from '../dialog/ConfirmationDialog';
9
+ import FormFooter from '../form/FormFooter';
10
+ import { FormPlaceholder } from '../form/FormPlaceholder';
11
+ import { ModalFormActions } from '../form/ModalFormActions';
12
+ import { AffiliationForm } from './AffiliationForm';
13
+ import { AffiliationList } from './AffiliationList';
14
+ const StyledSidebarContent = styled(SidebarContent) `
15
+ padding: 0;
16
+ `;
17
+ const AddAffiliationButton = styled.div `
18
+ display: flex;
19
+ align-items: center;
20
+ padding: 12px 8px 12px 12px;
21
+ cursor: pointer;
22
+ &[data-active='true'] {
23
+ background: ${(props) => props.theme.colors.background.fifth};
24
+ border: 1px solid ${(props) => props.theme.colors.border.primary};
25
+ border-left: 0;
26
+ border-right: 0;
27
+ }
28
+ `;
29
+ const ActionTitle = styled.div `
30
+ padding-left: ${(props) => props.theme.grid.unit * 2}px;
31
+ `;
32
+ const AffiliationForms = styled.div `
33
+ padding-left: ${(props) => props.theme.grid.unit * 3}px;
34
+ padding-right: ${(props) => props.theme.grid.unit * 3}px;
35
+ position: relative;
36
+ margin-top: 20px;
37
+ `;
38
+ const AuthorsSection = styled.div `
39
+ margin-top: ${(props) => props.theme.grid.unit * 4}px;
40
+ padding-top: ${(props) => props.theme.grid.unit * 4}px;
41
+ border-top: 1px solid ${(props) => props.theme.colors.border.tertiary};
42
+ `;
43
+ const AuthorsHeader = styled.div `
44
+ display: flex;
45
+ justify-content: space-between;
46
+ align-items: flex-start;
47
+ flex-direction: column;
48
+ margin-bottom: ${(props) => props.theme.grid.unit * 2}px;
49
+ `;
50
+ const AuthorsTitle = styled.h3 `
51
+ margin: 0;
52
+ font-weight: ${(props) => props.theme.font.weight.normal};
53
+ font-size: ${(props) => props.theme.font.size.large};
54
+ font-family: ${(props) => props.theme.font.family.sans};
55
+ color: ${(props) => props.theme.colors.text.secondary};
56
+ `;
57
+ const AffiliateButton = styled.button `
58
+ color: ${(props) => props.theme.colors.brand.default};
59
+ background: none;
60
+ border: none;
61
+ cursor: pointer;
62
+ padding: 0;
63
+ font: ${(props) => props.theme.font.weight.normal}
64
+ ${(props) => props.theme.font.size.normal}
65
+ ${(props) => props.theme.font.family.sans};
66
+ display: flex;
67
+ align-items: center;
68
+ gap: 4px;
69
+ margin-top: ${(props) => props.theme.grid.unit * 2}px;
70
+ &:hover {
71
+ opacity: 0.8;
72
+ }
73
+ `;
74
+ const StyledModalBody = styled(ModalBody) `
75
+ position: relative;
76
+ height: calc(90vh - 40px);
77
+ `;
78
+ const StyledModalSidebarHeader = styled(ModalSidebarHeader) `
79
+ margin-top: 8px;
80
+ margin-bottom: 16px;
81
+ `;
82
+ const normalize = (affiliation) => ({
83
+ id: affiliation.id,
84
+ institution: affiliation.institution,
85
+ department: affiliation.department,
86
+ addressLine1: affiliation.addressLine1,
87
+ addressLine2: affiliation.addressLine2,
88
+ addressLine3: affiliation.addressLine3,
89
+ postCode: affiliation.postCode,
90
+ country: affiliation.country,
91
+ county: affiliation.county,
92
+ city: affiliation.city,
93
+ email: affiliation.email,
94
+ priority: affiliation.priority,
95
+ });
96
+ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, onSaveAffiliation, onDeleteAffiliation, onUpdateAuthors, addNewAffiliation = false, }) => {
97
+ const [isOpen, setIsOpen] = useState(true);
98
+ const [selection, setSelection] = useState(undefined);
99
+ const [showDeleteDialog, setShowDeleteDialog] = useState(false);
100
+ const valuesRef = useRef();
101
+ const actionsRef = useRef();
102
+ const [authors, dispatchAuthors] = useReducer(authorsReducer, $authors.sort(authorComparator));
103
+ const [affiliations, dispatchAffiliations] = useReducer(affiliationsReducer, $affiliations);
104
+ const [isDisableSave, setIsDisableSave] = useState(true);
105
+ const [newAffiliation, setNewAffiliation] = useState(false);
106
+ const [showRequiredFieldConfirmationDialog, setShowRequiredFieldConfirmationDialog,] = useState(false);
107
+ const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);
108
+ const affiliation = {
109
+ id: generateID(ObjectTypes.Affiliation),
110
+ institution: '',
111
+ department: '',
112
+ addressLine1: '',
113
+ addressLine2: '',
114
+ addressLine3: '',
115
+ postCode: '',
116
+ country: '',
117
+ county: '',
118
+ city: '',
119
+ email: {
120
+ href: '',
121
+ text: '',
122
+ },
123
+ priority: affiliations.length,
124
+ };
125
+ const [showAuthorDrawer, setShowAuthorDrawer] = useState(false);
126
+ const [selectedIds, setSelectedIds] = useState([]);
127
+ const [pendingSelection, setPendingSelection] = useState(null);
128
+ const [pendingAction, setPendingAction] = useState(null);
129
+ const [savedAffiliationId, setSavedAffiliationId] = useState(undefined);
130
+ const [affiliationAuthorMap, setAffiliationAuthorMap] = useState({});
131
+ const handleClose = () => {
132
+ var _a;
133
+ const values = valuesRef.current;
134
+ const hasAffiliationChanges = selection && !isEqual(values, normalize(selection));
135
+ const originalAuthors = affiliationAuthorMap[(selection === null || selection === void 0 ? void 0 : selection.id) || ''] || [];
136
+ const hasAuthorChanges = !isEqual(originalAuthors.sort(), selectedIds.sort());
137
+ const hasChanges = hasAffiliationChanges || (selection && hasAuthorChanges);
138
+ const isInstitutionEmpty = ((_a = values === null || values === void 0 ? void 0 : values.institution) === null || _a === void 0 ? void 0 : _a.trim()) === '';
139
+ if (hasChanges) {
140
+ if (isInstitutionEmpty && hasAffiliationChanges) {
141
+ setShowRequiredFieldConfirmationDialog(true);
142
+ }
143
+ else {
144
+ setShowConfirmationDialog(true);
145
+ }
146
+ setPendingAction('close');
147
+ }
148
+ else {
149
+ setIsOpen(false);
150
+ }
151
+ };
152
+ const handleSelect = (affiliation) => {
153
+ var _a;
154
+ const values = valuesRef.current;
155
+ const hasAffiliationChanges = selection && !isEqual(values, normalize(selection));
156
+ const originalAuthors = affiliationAuthorMap[(selection === null || selection === void 0 ? void 0 : selection.id) || ''] || [];
157
+ const hasAuthorChanges = !isEqual(originalAuthors.sort(), selectedIds.sort());
158
+ const hasChanges = hasAffiliationChanges || hasAuthorChanges;
159
+ const isInstitutionEmpty = ((_a = values === null || values === void 0 ? void 0 : values.institution) === null || _a === void 0 ? void 0 : _a.trim()) === '';
160
+ if (hasChanges) {
161
+ setPendingSelection(affiliation);
162
+ setPendingAction('select');
163
+ if (isInstitutionEmpty && hasAffiliationChanges) {
164
+ setShowRequiredFieldConfirmationDialog(true);
165
+ }
166
+ else {
167
+ setShowConfirmationDialog(true);
168
+ }
169
+ }
170
+ else {
171
+ const affiliatedAuthorIds = authors
172
+ .filter((author) => { var _a; return (_a = author.affiliations) === null || _a === void 0 ? void 0 : _a.includes(affiliation.id); })
173
+ .map((author) => author.id);
174
+ setNewAffiliation(false);
175
+ setSelection(affiliation);
176
+ setSelectedIds(affiliatedAuthorIds);
177
+ setShowAuthorDrawer(false);
178
+ setAffiliationAuthorMap((prevMap) => (Object.assign(Object.assign({}, prevMap), { [affiliation.id]: affiliatedAuthorIds })));
179
+ }
180
+ };
181
+ const handleSaveAffiliation = (values) => {
182
+ if (!values || !selection) {
183
+ return;
184
+ }
185
+ setIsDisableSave(true);
186
+ const affiliation = Object.assign(Object.assign({}, normalize(selection)), values);
187
+ onSaveAffiliation(affiliation);
188
+ dispatchAffiliations({
189
+ type: 'update',
190
+ items: [affiliation],
191
+ });
192
+ setSelection(affiliation);
193
+ const updatedAuthors = authors.map((author) => (Object.assign(Object.assign({}, author), { affiliations: selectedIds.includes(author.id)
194
+ ? [...new Set([...(author.affiliations || []), affiliation.id])]
195
+ : (author.affiliations || []).filter((id) => id !== affiliation.id) })));
196
+ dispatchAuthors({
197
+ type: 'update',
198
+ items: updatedAuthors,
199
+ });
200
+ onUpdateAuthors(updatedAuthors);
201
+ setNewAffiliation(false);
202
+ setAffiliationAuthorMap((prevMap) => (Object.assign(Object.assign({}, prevMap), { [affiliation.id]: selectedIds })));
203
+ setShowAuthorDrawer(false);
204
+ setSavedAffiliationId(affiliation.id);
205
+ setTimeout(() => {
206
+ setSavedAffiliationId(undefined);
207
+ }, 3200);
208
+ };
209
+ const handleAffiliationChange = (values) => {
210
+ var _a;
211
+ valuesRef.current = values;
212
+ if (!selection || selection.id !== values.id) {
213
+ setIsDisableSave(true);
214
+ return;
215
+ }
216
+ const isInstitutionEmpty = !((_a = values.institution) === null || _a === void 0 ? void 0 : _a.trim());
217
+ const hasAffiliationChanges = selection && !isEqual(normalize(values), normalize(selection));
218
+ const originalAuthors = affiliationAuthorMap[(selection === null || selection === void 0 ? void 0 : selection.id) || ''] || [];
219
+ const hasAuthorChanges = selection && !isEqual(originalAuthors.sort(), selectedIds.sort());
220
+ const shouldEnableSave = !isInstitutionEmpty && (hasAffiliationChanges || hasAuthorChanges);
221
+ setIsDisableSave(!shouldEnableSave);
222
+ };
223
+ const handleShowDeleteDialog = () => {
224
+ setShowDeleteDialog((prev) => !prev);
225
+ };
226
+ const handleDeleteAffiliation = () => {
227
+ if (!selection) {
228
+ return;
229
+ }
230
+ const updatedAuthors = authors.map((author) => (Object.assign(Object.assign({}, author), { affiliations: (author.affiliations || []).filter((id) => id !== selection.id) })));
231
+ dispatchAuthors({
232
+ type: 'update',
233
+ items: updatedAuthors,
234
+ });
235
+ onUpdateAuthors(updatedAuthors);
236
+ onDeleteAffiliation(selection);
237
+ dispatchAffiliations({
238
+ type: 'delete',
239
+ item: selection,
240
+ });
241
+ setSelectedIds([]);
242
+ setSelection(undefined);
243
+ };
244
+ const handleAuthorSelect = (authorId) => {
245
+ var _a, _b;
246
+ if (!selection) {
247
+ return;
248
+ }
249
+ const newSelectedAuthorIds = selectedIds.includes(authorId)
250
+ ? selectedIds.filter((id) => id !== authorId)
251
+ : [...selectedIds, authorId];
252
+ setSelectedIds(newSelectedAuthorIds);
253
+ const hasAffiliationChanges = !isEqual(valuesRef.current, normalize(selection));
254
+ const originalAuthors = affiliationAuthorMap[selection.id] || [];
255
+ const hasAuthorChanges = !isEqual(originalAuthors.sort(), newSelectedAuthorIds.sort());
256
+ const isInstitutionEmpty = !((_b = (_a = valuesRef.current) === null || _a === void 0 ? void 0 : _a.institution) === null || _b === void 0 ? void 0 : _b.trim());
257
+ const shouldEnableSave = !isInstitutionEmpty && (hasAffiliationChanges || hasAuthorChanges);
258
+ setIsDisableSave(!shouldEnableSave);
259
+ };
260
+ const authorItems = authors.map((author) => ({
261
+ id: author.id,
262
+ label: `${author.bibliographicName.given} ${author.bibliographicName.family}`,
263
+ }));
264
+ const selectedAuthors = selectedIds
265
+ .map((authorId) => {
266
+ const author = authors.find((a) => a.id === authorId);
267
+ return {
268
+ id: authorId,
269
+ label: author
270
+ ? `${author.bibliographicName.given} ${author.bibliographicName.family}`
271
+ : '',
272
+ };
273
+ })
274
+ .filter((author) => author.label);
275
+ const handleAddAffiliation = () => {
276
+ var _a;
277
+ const values = valuesRef.current;
278
+ const hasChanges = !isDisableSave;
279
+ const isInstitutionEmpty = ((_a = values === null || values === void 0 ? void 0 : values.institution) === null || _a === void 0 ? void 0 : _a.trim()) === '';
280
+ if (hasChanges) {
281
+ setPendingAction('new');
282
+ if (isInstitutionEmpty) {
283
+ setShowRequiredFieldConfirmationDialog(true);
284
+ }
285
+ else {
286
+ setShowConfirmationDialog(true);
287
+ }
288
+ return;
289
+ }
290
+ setNewAffiliation(true);
291
+ setSelection(affiliation);
292
+ setSelectedIds([]);
293
+ setShowAuthorDrawer(false);
294
+ };
295
+ useEffect(() => {
296
+ if (addNewAffiliation) {
297
+ handleAddAffiliation();
298
+ setNewAffiliation(true);
299
+ }
300
+ }, [addNewAffiliation]);
301
+ const handleConfirmationSave = () => {
302
+ handleSaveAffiliation(valuesRef.current);
303
+ setShowConfirmationDialog(false);
304
+ setShowRequiredFieldConfirmationDialog(false);
305
+ if (pendingAction === 'new') {
306
+ setNewAffiliation(true);
307
+ setSelection(affiliation);
308
+ setSelectedIds([]);
309
+ setIsDisableSave(true);
310
+ }
311
+ else if (pendingAction === 'select' && pendingSelection) {
312
+ setSelection(pendingSelection);
313
+ setNewAffiliation(false);
314
+ const affiliatedAuthorIds = authors
315
+ .filter((author) => { var _a; return (_a = author.affiliations) === null || _a === void 0 ? void 0 : _a.some((aff) => aff === pendingSelection.id); })
316
+ .map((author) => author.id);
317
+ setSelectedIds(affiliatedAuthorIds);
318
+ valuesRef.current = normalize(pendingSelection);
319
+ setIsDisableSave(true);
320
+ setAffiliationAuthorMap((prevMap) => (Object.assign(Object.assign({}, prevMap), { [pendingSelection.id]: affiliatedAuthorIds })));
321
+ }
322
+ setPendingSelection(null);
323
+ setPendingAction(null);
324
+ if (pendingAction === 'close') {
325
+ setIsOpen(false);
326
+ }
327
+ };
328
+ const handleConfirmationCancel = () => {
329
+ setShowConfirmationDialog(false);
330
+ setShowRequiredFieldConfirmationDialog(false);
331
+ setShowAuthorDrawer(false);
332
+ if (pendingAction === 'select' && pendingSelection) {
333
+ setSelection(pendingSelection);
334
+ setNewAffiliation(false);
335
+ const affiliatedAuthorIds = authors
336
+ .filter((author) => { var _a; return (_a = author.affiliations) === null || _a === void 0 ? void 0 : _a.some((aff) => aff === pendingSelection.id); })
337
+ .map((author) => author.id);
338
+ setSelectedIds(affiliatedAuthorIds);
339
+ }
340
+ else if (pendingAction === 'new') {
341
+ setNewAffiliation(true);
342
+ setSelection(affiliation);
343
+ setSelectedIds([]);
344
+ }
345
+ if (pendingSelection) {
346
+ valuesRef.current = normalize(pendingSelection);
347
+ }
348
+ else {
349
+ valuesRef.current = undefined;
350
+ }
351
+ setPendingSelection(null);
352
+ setPendingAction(null);
353
+ if (pendingAction === 'close') {
354
+ setIsOpen(false);
355
+ }
356
+ };
357
+ return (React.createElement(StyledModal, { isOpen: isOpen, onRequestClose: () => handleClose(), shouldCloseOnOverlayClick: true },
358
+ React.createElement(ModalContainer, null,
359
+ React.createElement(ModalHeader, null,
360
+ React.createElement(CloseButton, { onClick: () => handleClose(), "data-cy": "modal-close-button" })),
361
+ React.createElement(StyledModalBody, null,
362
+ React.createElement(ModalSidebar, null,
363
+ React.createElement(StyledModalSidebarHeader, null,
364
+ React.createElement(ModalSidebarTitle, null, "Affiliations")),
365
+ React.createElement(StyledSidebarContent, null,
366
+ React.createElement(AddAffiliationButton, { "data-cy": "add-affiliation-button", onClick: handleAddAffiliation, "data-active": newAffiliation },
367
+ React.createElement(AddIcon, { width: 18, height: 18 }),
368
+ React.createElement(ActionTitle, null, "New Affiliation")),
369
+ React.createElement(AffiliationList, { affiliation: selection, affiliations: affiliations, onSelect: handleSelect, onDelete: handleShowDeleteDialog, lastSavedAffiliationId: savedAffiliationId }))),
370
+ React.createElement(ScrollableModalContent, { "data-cy": "affiliations-modal-content" },
371
+ React.createElement(AffiliationForms, null,
372
+ selection ? (React.createElement(React.Fragment, null,
373
+ React.createElement(ModalFormActions, { type: 'affiliation', onSave: () => handleSaveAffiliation(valuesRef.current), onDelete: handleDeleteAffiliation, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAffiliation, isDisableSave: isDisableSave }),
374
+ React.createElement(AffiliationForm, { values: normalize(selection), onSave: handleSaveAffiliation, onChange: handleAffiliationChange, actionsRef: actionsRef }),
375
+ React.createElement(ConfirmationDialog, { isOpen: showRequiredFieldConfirmationDialog, onPrimary: () => setShowRequiredFieldConfirmationDialog(false), onSecondary: handleConfirmationCancel, type: DialogType.REQUIRED, entityType: "affiliation" }),
376
+ React.createElement(ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: handleConfirmationSave, onSecondary: handleConfirmationCancel, type: DialogType.SAVE, entityType: "affiliation" }),
377
+ React.createElement(AuthorsSection, null,
378
+ React.createElement(AuthorsHeader, null,
379
+ React.createElement(AuthorsTitle, null, "Authors"),
380
+ React.createElement(AffiliateButton, { onClick: () => setShowAuthorDrawer(true), "data-cy": "affiliate-authors-button" },
381
+ React.createElement(AddUserIcon, { width: 16, height: 16 }),
382
+ "Affiliate Authors")),
383
+ React.createElement(SelectedItemsBox, { items: selectedAuthors, onRemove: (id) => {
384
+ setSelectedIds((prev) => prev.filter((authorId) => authorId !== id));
385
+ }, placeholder: "No authors assigned" })))) : (React.createElement(FormPlaceholder, { type: "affiliation", title: 'Affiliation Details', message: "Select an affiliation from the list to display it's details here.", placeholderIcon: React.createElement(AffiliationPlaceholderIcon, null) })),
386
+ showAuthorDrawer && (React.createElement(Drawer, { items: authorItems, selectedIds: selectedIds, title: "Authors", onSelect: handleAuthorSelect, onBack: () => setShowAuthorDrawer(false), width: "100%" }))))),
387
+ React.createElement(FormFooter, { onCancel: handleClose }))));
388
+ };
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { CheckboxField, CheckboxLabel, TextField, TextFieldGroupContainer, TextFieldLabel, } from '@manuscripts/style-guide';
17
17
  import { Field, Formik } from 'formik';
18
- import React, { useRef } from 'react';
18
+ import React, { useEffect, useRef } from 'react';
19
19
  import styled from 'styled-components';
20
20
  import { ChangeHandlingForm } from '../ChangeHandlingForm';
21
21
  export const LabelText = styled.div `
@@ -46,8 +46,13 @@ const CheckboxContainer = styled.div `
46
46
  align-items: center;
47
47
  gap: 32px;
48
48
  `;
49
- export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, }) => {
49
+ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, }) => {
50
50
  const formRef = useRef(null);
51
+ useEffect(() => {
52
+ if (selectedAffiliations && formRef.current) {
53
+ formRef.current.setFieldValue('affiliations', selectedAffiliations);
54
+ }
55
+ }, [selectedAffiliations]);
51
56
  if (actionsRef && !actionsRef.current) {
52
57
  actionsRef.current = {
53
58
  reset: () => {
@@ -81,6 +86,9 @@ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmai
81
86
  React.createElement(OrcidContainer, null,
82
87
  React.createElement(TextFieldLabel, null,
83
88
  React.createElement(LabelText, null, "ORCID"),
84
- React.createElement(Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (React.createElement(TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...' }, props.field)))))))));
89
+ React.createElement(Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (React.createElement(TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...' }, props.field)))))),
90
+ React.createElement(Field, { name: "affiliations", type: "hidden" }, (props) => {
91
+ return (React.createElement(TextField, Object.assign({ type: "hidden" }, props.field, { value: selectedAffiliations || [] })));
92
+ }))));
85
93
  }));
86
94
  };
@@ -28,7 +28,7 @@ const AuthorListTitle = styled.h2 `
28
28
  font-weight: 400;
29
29
  line-height: 24px;
30
30
  margin-left: 14px;
31
- margin-top: 28px;
31
+ margin-top: 20px;
32
32
  `;
33
33
  export const AuthorList = ({ author, authors, onSelect, onDelete, moveAuthor, lastSavedAuthor, }) => {
34
34
  return (React.createElement(DndProvider, { backend: HTML5Backend },