@manuscripts/body-editor 3.12.33 → 3.12.34
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/ChangeHandlingForm.js +3 -2
- package/dist/cjs/components/affiliations/AffiliationForm.js +77 -44
- package/dist/cjs/components/affiliations/AffiliationsModal.js +69 -58
- package/dist/cjs/components/affiliations/AffiliationsPanel.js +1 -1
- package/dist/cjs/components/affiliations/CreateAffiliationModal.js +96 -0
- package/dist/cjs/components/authors/AuthorDetailsForm.js +110 -54
- package/dist/cjs/components/authors/AuthorsModal.js +71 -48
- package/dist/cjs/components/authors/AuthorsPanel.js +2 -2
- package/dist/cjs/components/authors/CreateAuthorModal.js +121 -0
- package/dist/cjs/components/authors/CreditDrawer.js +14 -12
- package/dist/cjs/components/authors-affiliations/AuthorsAndAffiliationsModals.js +8 -24
- package/dist/cjs/components/authors-affiliations/GenericPanel.js +2 -2
- package/dist/cjs/components/authors-affiliations/ModalTabs.js +80 -0
- package/dist/cjs/components/dialog/ConfirmationDialog.js +3 -2
- package/dist/cjs/components/form/CreateModalStyles.js +24 -0
- package/dist/cjs/components/form/FormFooter.js +8 -3
- package/dist/cjs/components/form/ModalFormActions.js +19 -42
- package/dist/cjs/components/form/UnsavedLabel.js +25 -0
- package/dist/cjs/components/hooks/useAffiliationShowsErrorIndicator.js +27 -0
- package/dist/cjs/components/hooks/useAuthorShowsErrorIndicator.js +40 -0
- package/dist/cjs/lib/authors-and-affiliations.js +51 -0
- package/dist/cjs/lib/normalize.js +17 -5
- package/dist/cjs/versions.js +1 -1
- package/dist/es/components/ChangeHandlingForm.js +3 -2
- package/dist/es/components/affiliations/AffiliationForm.js +75 -46
- package/dist/es/components/affiliations/AffiliationsModal.js +71 -60
- package/dist/es/components/affiliations/AffiliationsPanel.js +2 -2
- package/dist/es/components/affiliations/CreateAffiliationModal.js +56 -0
- package/dist/es/components/authors/AuthorDetailsForm.js +111 -56
- package/dist/es/components/authors/AuthorsModal.js +74 -51
- package/dist/es/components/authors/AuthorsPanel.js +3 -3
- package/dist/es/components/authors/CreateAuthorModal.js +81 -0
- package/dist/es/components/authors/CreditDrawer.js +13 -11
- package/dist/es/components/authors-affiliations/AuthorsAndAffiliationsModals.js +8 -24
- package/dist/es/components/authors-affiliations/GenericPanel.js +2 -2
- package/dist/es/components/authors-affiliations/ModalTabs.js +73 -0
- package/dist/es/components/dialog/ConfirmationDialog.js +3 -2
- package/dist/es/components/form/CreateModalStyles.js +18 -0
- package/dist/es/components/form/FormFooter.js +9 -4
- package/dist/es/components/form/ModalFormActions.js +18 -42
- package/dist/es/components/form/UnsavedLabel.js +18 -0
- package/dist/es/components/hooks/useAffiliationShowsErrorIndicator.js +21 -0
- package/dist/es/components/hooks/useAuthorShowsErrorIndicator.js +34 -0
- package/dist/es/lib/authors-and-affiliations.js +48 -0
- package/dist/es/lib/normalize.js +15 -4
- package/dist/es/versions.js +1 -1
- package/dist/es/views/affiliations.js +1 -1
- package/dist/types/components/affiliations/AffiliationForm.d.ts +6 -2
- package/dist/types/components/affiliations/AffiliationsModal.d.ts +1 -1
- package/dist/types/components/affiliations/CreateAffiliationModal.d.ts +8 -0
- package/dist/types/components/authors/AuthorDetailsForm.d.ts +11 -1
- package/dist/types/components/authors/AuthorsPanel.d.ts +1 -1
- package/dist/types/components/authors/CreateAuthorModal.d.ts +9 -0
- package/dist/types/components/authors/CreditDrawer.d.ts +2 -4
- package/dist/types/components/authors-affiliations/ModalTabs.d.ts +22 -0
- package/dist/types/components/form/CreateModalStyles.d.ts +4 -0
- package/dist/types/components/form/FormFooter.d.ts +2 -1
- package/dist/types/components/form/ModalFormActions.d.ts +12 -6
- package/dist/types/components/form/UnsavedLabel.d.ts +10 -0
- package/dist/types/components/hooks/useAffiliationShowsErrorIndicator.d.ts +5 -0
- package/dist/types/components/hooks/useAuthorShowsErrorIndicator.d.ts +5 -0
- package/dist/types/lib/authors-and-affiliations.d.ts +19 -0
- package/dist/types/lib/normalize.d.ts +2 -1
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
|
@@ -51,36 +51,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
51
51
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.CheckboxContainer = exports.Fieldset = exports.AuthorDetailsForm = void 0;
|
|
54
|
+
exports.StyledFormRow = exports.StyledFormGroup = exports.CheckboxContainer = exports.Fieldset = exports.AuthorDetailsForm = exports.authorDetailsTabShowsErrorIndicator = void 0;
|
|
55
55
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
56
56
|
const formik_1 = require("formik");
|
|
57
57
|
const react_1 = __importStar(require("react"));
|
|
58
58
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
59
59
|
const normalize_1 = require("../../lib/normalize");
|
|
60
60
|
const ChangeHandlingForm_1 = require("../ChangeHandlingForm");
|
|
61
|
+
const UnsavedLabel_1 = require("../form/UnsavedLabel");
|
|
62
|
+
const useAuthorShowsErrorIndicator_1 = require("../hooks/useAuthorShowsErrorIndicator");
|
|
61
63
|
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
62
64
|
const ORCID_URL_REGEX = /^https:\/\/orcid\.org\/\d{4}-\d{4}-\d{4}-\d{3}[0-9Xx]\/?$/;
|
|
63
65
|
const ORCID_INPUT_PATTERN = ORCID_URL_REGEX.source.slice(1, -1);
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
(0,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
formRef.current.setFieldValue('creditRoles', selectedCreditRoles);
|
|
74
|
-
}
|
|
75
|
-
}, [selectedCreditRoles]);
|
|
76
|
-
if (actionsRef) {
|
|
77
|
-
actionsRef.current = {
|
|
78
|
-
reset: () => formRef.current?.resetForm(),
|
|
79
|
-
submitForm: () => formRef.current?.submitForm(),
|
|
80
|
-
};
|
|
66
|
+
const NAME_PAIR_REQUIRED_MESSAGE = 'Please enter Given Name or Family Name';
|
|
67
|
+
function isAuthorFieldChanged(formik, key) {
|
|
68
|
+
const v = (0, normalize_1.normalizeAuthor)(formik.values);
|
|
69
|
+
const i = (0, normalize_1.normalizeAuthor)(formik.initialValues);
|
|
70
|
+
const va = (0, formik_1.getIn)(v, key);
|
|
71
|
+
const vb = (0, formik_1.getIn)(i, key);
|
|
72
|
+
if (key === 'affiliationIDs' || key === 'creditRoles' || key === 'degrees') {
|
|
73
|
+
return (va.length !== vb.length ||
|
|
74
|
+
va.some((item, i) => item !== vb[i]));
|
|
81
75
|
}
|
|
76
|
+
return va !== vb;
|
|
77
|
+
}
|
|
78
|
+
var useAuthorShowsErrorIndicator_2 = require("../hooks/useAuthorShowsErrorIndicator");
|
|
79
|
+
Object.defineProperty(exports, "authorDetailsTabShowsErrorIndicator", { enumerable: true, get: function () { return useAuthorShowsErrorIndicator_2.authorShowsErrorIndicator; } });
|
|
80
|
+
const AuthorErrorEffect = ({ newEntity, requiredContinueActive, onChange }) => {
|
|
81
|
+
(0, useAuthorShowsErrorIndicator_1.useAuthorShowsErrorIndicator)(newEntity, requiredContinueActive, onChange);
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, selectedCreditRoles, authorFormRef, newEntity, onAuthorDetailsTabErrorChange, unsavedContinueActive = false, requiredContinueActive = false, }) => {
|
|
82
85
|
const validateAuthor = (values) => {
|
|
83
86
|
const errors = {};
|
|
87
|
+
const given = values.given?.trim() ?? '';
|
|
88
|
+
const family = values.family?.trim() ?? '';
|
|
89
|
+
if (!given && !family) {
|
|
90
|
+
errors.given = NAME_PAIR_REQUIRED_MESSAGE;
|
|
91
|
+
errors.family = NAME_PAIR_REQUIRED_MESSAGE;
|
|
92
|
+
}
|
|
84
93
|
const email = values.email?.trim();
|
|
85
94
|
if (isEmailRequired && !email) {
|
|
86
95
|
errors.email = 'Email address is required';
|
|
@@ -95,57 +104,93 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
|
|
|
95
104
|
}
|
|
96
105
|
return errors;
|
|
97
106
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
const formik = (0, formik_1.useFormik)({
|
|
108
|
+
initialValues: values,
|
|
109
|
+
onSubmit: (submitted) => onSave((0, normalize_1.normalizeAuthor)(submitted)),
|
|
110
|
+
enableReinitialize: true,
|
|
111
|
+
validateOnChange: true,
|
|
112
|
+
validate: validateAuthor,
|
|
113
|
+
});
|
|
114
|
+
(0, react_1.useEffect)(() => {
|
|
115
|
+
if (selectedAffiliations) {
|
|
116
|
+
formik.setFieldValue('affiliationIDs', selectedAffiliations);
|
|
117
|
+
}
|
|
118
|
+
}, [selectedAffiliations]);
|
|
119
|
+
(0, react_1.useEffect)(() => {
|
|
120
|
+
if (selectedCreditRoles) {
|
|
121
|
+
formik.setFieldValue('creditRoles', selectedCreditRoles);
|
|
122
|
+
}
|
|
123
|
+
}, [selectedCreditRoles]);
|
|
124
|
+
if (actionsRef) {
|
|
125
|
+
actionsRef.current = {
|
|
126
|
+
reset: () => formik.resetForm(),
|
|
127
|
+
submitForm: () => formik.submitForm(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const showNamePairError = (0, useAuthorShowsErrorIndicator_1.isNamePairError)(formik, newEntity, requiredContinueActive);
|
|
131
|
+
const showUnsavedDot = (key) => unsavedContinueActive && isAuthorFieldChanged(formik, key);
|
|
132
|
+
return (react_1.default.createElement(formik_1.FormikProvider, { value: formik },
|
|
133
|
+
react_1.default.createElement(AuthorErrorEffect, { newEntity: newEntity, requiredContinueActive: requiredContinueActive, onChange: onAuthorDetailsTabErrorChange }),
|
|
134
|
+
react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: (next) => onChange((0, normalize_1.normalizeAuthor)(next)), id: "author-details-form", formRef: authorFormRef, noValidate: true },
|
|
135
|
+
react_1.default.createElement(exports.StyledFormGroup, null,
|
|
136
|
+
react_1.default.createElement(style_guide_1.FormRow, null,
|
|
137
|
+
react_1.default.createElement(formik_1.Field, { name: 'prefix' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
138
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "prefix", showDot: showUnsavedDot('prefix') }, "Prefix"),
|
|
139
|
+
react_1.default.createElement(style_guide_1.TextField, { id: 'prefix', ...props.field, placeholder: "E.g. Doctor" }))))),
|
|
140
|
+
react_1.default.createElement(exports.StyledFormRow, null,
|
|
141
|
+
react_1.default.createElement(formik_1.Field, { name: 'given' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
142
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "given-name", showDot: showUnsavedDot('given') },
|
|
143
|
+
"Given name",
|
|
144
|
+
react_1.default.createElement(style_guide_1.RequiredIndicator, null, "*")),
|
|
145
|
+
react_1.default.createElement(TextFieldWithError, { id: 'given-name', ...props.field, error: showNamePairError }),
|
|
146
|
+
showNamePairError && (react_1.default.createElement(style_guide_1.InputErrorText, null, NAME_PAIR_REQUIRED_MESSAGE))))))),
|
|
147
|
+
react_1.default.createElement(exports.StyledFormGroup, null,
|
|
148
|
+
react_1.default.createElement(exports.StyledFormRow, null,
|
|
149
|
+
react_1.default.createElement(formik_1.Field, { name: 'family' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
150
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "family-name", showDot: showUnsavedDot('family') },
|
|
151
|
+
"Family name",
|
|
152
|
+
react_1.default.createElement(style_guide_1.RequiredIndicator, null, "*")),
|
|
153
|
+
react_1.default.createElement(TextFieldWithError, { id: 'family-name', ...props.field, error: showNamePairError }),
|
|
154
|
+
showNamePairError && (react_1.default.createElement(style_guide_1.InputErrorText, null, NAME_PAIR_REQUIRED_MESSAGE)))))),
|
|
155
|
+
react_1.default.createElement(style_guide_1.FormRow, null,
|
|
156
|
+
react_1.default.createElement(formik_1.Field, { name: 'suffix' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
157
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "suffix", showDot: showUnsavedDot('suffix') }, "Suffix"),
|
|
158
|
+
react_1.default.createElement(style_guide_1.TextField, { id: 'suffix', ...props.field, placeholder: "E.g. Junior" })))))),
|
|
116
159
|
react_1.default.createElement(style_guide_1.FormRow, null,
|
|
117
|
-
react_1.default.createElement(
|
|
118
|
-
react_1.default.createElement(style_guide_1.
|
|
119
|
-
|
|
160
|
+
react_1.default.createElement(exports.CheckboxContainer, { "data-cy": "corresponding-author-container" },
|
|
161
|
+
react_1.default.createElement(style_guide_1.CheckboxLabel, null,
|
|
162
|
+
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 }))),
|
|
163
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabelRow, null,
|
|
164
|
+
showUnsavedDot('isCorresponding') ? (react_1.default.createElement(UnsavedLabel_1.FieldUnsavedDot, { "aria-hidden": true })) : null,
|
|
165
|
+
react_1.default.createElement(style_guide_1.LabelText, null, "Corresponding Author"))))),
|
|
120
166
|
react_1.default.createElement(style_guide_1.FormRow, null,
|
|
121
167
|
react_1.default.createElement(formik_1.Field, { name: 'email', type: 'email' }, (props) => {
|
|
122
|
-
const hasError = (0, formik_1.getIn)(formik.touched, 'email') &&
|
|
168
|
+
const hasError = ((0, formik_1.getIn)(formik.touched, 'email') || requiredContinueActive) &&
|
|
123
169
|
(0, formik_1.getIn)(formik.errors, 'email');
|
|
124
170
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
125
|
-
react_1.default.createElement(
|
|
171
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "email", showDot: showUnsavedDot('email') }, isEmailRequired ? (react_1.default.createElement(style_guide_1.LabelText, null,
|
|
172
|
+
"Email address",
|
|
173
|
+
react_1.default.createElement(style_guide_1.RequiredIndicator, null, "*"))) : ('Email address')),
|
|
126
174
|
react_1.default.createElement(TextFieldWithError, { id: 'email', type: "email", required: isEmailRequired, ...props.field, error: hasError }),
|
|
127
175
|
hasError && (react_1.default.createElement(style_guide_1.InputErrorText, null, (0, formik_1.getIn)(formik.errors, 'email')))));
|
|
128
176
|
})),
|
|
129
177
|
react_1.default.createElement(style_guide_1.FormRow, null,
|
|
130
|
-
react_1.default.createElement(
|
|
131
|
-
react_1.default.createElement(
|
|
132
|
-
|
|
133
|
-
react_1.default.createElement(style_guide_1.LabelText, null, "Corresponding Author")))),
|
|
178
|
+
react_1.default.createElement(formik_1.Field, { name: 'role' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
179
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "role", showDot: showUnsavedDot('role') }, "Job Title"),
|
|
180
|
+
react_1.default.createElement(style_guide_1.TextField, { id: 'role', ...props.field }))))),
|
|
134
181
|
react_1.default.createElement(style_guide_1.FormRow, null,
|
|
135
182
|
react_1.default.createElement(formik_1.Field, { name: 'ORCID', type: 'text' }, (props) => {
|
|
136
|
-
const hasError = (0, formik_1.getIn)(formik.touched, 'ORCID') &&
|
|
137
|
-
(0, formik_1.getIn)(formik.errors, 'ORCID');
|
|
183
|
+
const hasError = (0, formik_1.getIn)(formik.touched, 'ORCID') && (0, formik_1.getIn)(formik.errors, 'ORCID');
|
|
138
184
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
139
|
-
react_1.default.createElement(
|
|
140
|
-
react_1.default.createElement(TextFieldWithError, { id: 'orcid',
|
|
185
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "orcid", showDot: showUnsavedDot('ORCID') }, "ORCID"),
|
|
186
|
+
react_1.default.createElement(TextFieldWithError, { id: 'orcid', type: "url", placeholder: 'https://orcid.org/...', disabled: values.isAuthenticated, ...props.field, pattern: ORCID_INPUT_PATTERN, title: "Please enter a valid ORCID URL: https://orcid.org/xxxx-xxxx-xxxx-xxxx", error: hasError }),
|
|
141
187
|
hasError && (react_1.default.createElement(style_guide_1.InputErrorText, null, (0, formik_1.getIn)(formik.errors, 'ORCID')))));
|
|
142
188
|
})),
|
|
143
189
|
react_1.default.createElement(style_guide_1.FormRow, null,
|
|
144
|
-
react_1.default.createElement(
|
|
145
|
-
react_1.default.createElement(style_guide_1.MultiValueInput, { id:
|
|
146
|
-
formik.setFieldValue('degrees',
|
|
147
|
-
} }))));
|
|
148
|
-
}));
|
|
190
|
+
react_1.default.createElement(UnsavedLabel_1.UnsavedLabel, { htmlFor: "degrees", showDot: showUnsavedDot('degrees') }, "Qualification"),
|
|
191
|
+
react_1.default.createElement(style_guide_1.MultiValueInput, { id: 'degrees', inputType: "text", placeholder: "E.g. Bsc Computer Science", initialValues: Array.isArray(formik.values.degrees) ? formik.values.degrees : [], onChange: (values) => {
|
|
192
|
+
formik.setFieldValue('degrees', values);
|
|
193
|
+
} })))));
|
|
149
194
|
};
|
|
150
195
|
exports.AuthorDetailsForm = AuthorDetailsForm;
|
|
151
196
|
exports.Fieldset = styled_components_1.default.fieldset `
|
|
@@ -163,3 +208,14 @@ exports.CheckboxContainer = styled_components_1.default.div `
|
|
|
163
208
|
align-items: center;
|
|
164
209
|
gap: 32px;
|
|
165
210
|
`;
|
|
211
|
+
exports.StyledFormGroup = (0, styled_components_1.default)(style_guide_1.FormGroup) `
|
|
212
|
+
[name='prefix'] {
|
|
213
|
+
width: 180px;
|
|
214
|
+
}
|
|
215
|
+
[name='suffix'] {
|
|
216
|
+
width: 180px;
|
|
217
|
+
}
|
|
218
|
+
`;
|
|
219
|
+
exports.StyledFormRow = (0, styled_components_1.default)(style_guide_1.FormRow) `
|
|
220
|
+
flex: 1;
|
|
221
|
+
`;
|
|
@@ -64,20 +64,25 @@ const ConfirmationDialog_1 = require("../dialog/ConfirmationDialog");
|
|
|
64
64
|
const FormFooter_1 = __importDefault(require("../form/FormFooter"));
|
|
65
65
|
const FormPlaceholder_1 = require("../form/FormPlaceholder");
|
|
66
66
|
const ModalFormActions_1 = require("../form/ModalFormActions");
|
|
67
|
-
const
|
|
67
|
+
const ModalTabs_1 = require("../authors-affiliations/ModalTabs");
|
|
68
68
|
const AffiliationsPanel_1 = require("../affiliations/AffiliationsPanel");
|
|
69
69
|
const AuthorDetailsForm_1 = require("./AuthorDetailsForm");
|
|
70
70
|
const AuthorList_1 = require("./AuthorList");
|
|
71
71
|
const CreditDrawer_1 = require("./CreditDrawer");
|
|
72
72
|
const useManageAffiliations_1 = require("./useManageAffiliations");
|
|
73
73
|
const useManageCredit_1 = require("./useManageCredit");
|
|
74
|
+
const MODAL_ON_CLOSE_NOTIFY_DELAY_MS = 220;
|
|
74
75
|
exports.authorsReducer = (0, array_reducer_1.arrayReducer)((a, b) => a.id === b.id);
|
|
75
76
|
const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author, onSaveAuthor, onDeleteAuthor, addNewAuthor = false, onOpenAffiliationsModal, onClose, }) => {
|
|
76
77
|
const [isOpen, setOpen] = (0, react_1.useState)(true);
|
|
77
78
|
const prevIsOpenRef = (0, react_1.useRef)(true);
|
|
78
79
|
(0, react_1.useEffect)(() => {
|
|
79
80
|
if (prevIsOpenRef.current && !isOpen) {
|
|
80
|
-
|
|
81
|
+
prevIsOpenRef.current = isOpen;
|
|
82
|
+
const id = window.setTimeout(() => {
|
|
83
|
+
onClose?.();
|
|
84
|
+
}, MODAL_ON_CLOSE_NOTIFY_DELAY_MS);
|
|
85
|
+
return () => window.clearTimeout(id);
|
|
81
86
|
}
|
|
82
87
|
prevIsOpenRef.current = isOpen;
|
|
83
88
|
}, [isOpen, onClose]);
|
|
@@ -92,7 +97,10 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
|
|
|
92
97
|
const [nextAuthor, setNextAuthor] = (0, react_1.useState)(null);
|
|
93
98
|
const [isSwitchingAuthor, setIsSwitchingAuthor] = (0, react_1.useState)(false);
|
|
94
99
|
const [isCreatingNewAuthor, setIsCreatingNewAuthor] = (0, react_1.useState)(false);
|
|
95
|
-
const [
|
|
100
|
+
const [authorHasError, setAuthorDetailsTabHasError] = (0, react_1.useState)(false);
|
|
101
|
+
const [authorDetailsUnsavedContinue, setAuthorDetailsUnsavedContinue] = (0, react_1.useState)(false);
|
|
102
|
+
const [authorDetailsRequiredContinue, setAuthorDetailsRequiredContinue] = (0, react_1.useState)(false);
|
|
103
|
+
const [authorTabIndex, setAuthorTabIndex] = (0, react_1.useState)(0);
|
|
96
104
|
const valuesRef = (0, react_1.useRef)(undefined);
|
|
97
105
|
const actionsRef = (0, react_1.useRef)(undefined);
|
|
98
106
|
const authorFormRef = (0, react_1.useRef)(null);
|
|
@@ -109,6 +117,19 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
|
|
|
109
117
|
const relevantAffiliations = affiliations.filter((item) => currentAuthor?.affiliationIDs?.includes(item.id));
|
|
110
118
|
setSelectedAffiliations(relevantAffiliations);
|
|
111
119
|
}, []);
|
|
120
|
+
(0, react_1.useEffect)(() => {
|
|
121
|
+
if (!unSavedChanges) {
|
|
122
|
+
setAuthorDetailsUnsavedContinue(false);
|
|
123
|
+
setAuthorDetailsRequiredContinue(false);
|
|
124
|
+
}
|
|
125
|
+
}, [unSavedChanges]);
|
|
126
|
+
(0, react_1.useEffect)(() => {
|
|
127
|
+
setAuthorDetailsUnsavedContinue(false);
|
|
128
|
+
setAuthorDetailsRequiredContinue(false);
|
|
129
|
+
if (selection?.id) {
|
|
130
|
+
setAuthorTabIndex(0);
|
|
131
|
+
}
|
|
132
|
+
}, [selection?.id]);
|
|
112
133
|
const selectAuthor = (author) => {
|
|
113
134
|
if (author.id === selection?.id) {
|
|
114
135
|
return;
|
|
@@ -159,31 +180,6 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
|
|
|
159
180
|
setSelection(undefined);
|
|
160
181
|
}
|
|
161
182
|
};
|
|
162
|
-
const save = () => {
|
|
163
|
-
if (!authorFormRef.current?.checkValidity()) {
|
|
164
|
-
setShowConfirmationDialog(false);
|
|
165
|
-
setTimeout(() => {
|
|
166
|
-
authorFormRef.current?.reportValidity();
|
|
167
|
-
}, 830);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
if (valuesRef.current && selection) {
|
|
171
|
-
saveAuthor(valuesRef.current);
|
|
172
|
-
}
|
|
173
|
-
if (nextAuthor) {
|
|
174
|
-
setSelection(nextAuthor);
|
|
175
|
-
setNextAuthor(null);
|
|
176
|
-
setNewAuthor(false);
|
|
177
|
-
updateAffiliationSelection(nextAuthor);
|
|
178
|
-
setIsCreatingNewAuthor(false);
|
|
179
|
-
}
|
|
180
|
-
else if (isCreatingNewAuthor) {
|
|
181
|
-
createNewAuthor();
|
|
182
|
-
setIsCreatingNewAuthor(false);
|
|
183
|
-
}
|
|
184
|
-
setShowConfirmationDialog(false);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
183
|
const cancel = () => {
|
|
188
184
|
resetAuthor();
|
|
189
185
|
if (nextAuthor) {
|
|
@@ -332,7 +328,11 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
|
|
|
332
328
|
}
|
|
333
329
|
setEmailRequired(isCorresponding);
|
|
334
330
|
};
|
|
335
|
-
const {
|
|
331
|
+
const { selectCreditRole, selectedCreditRoles, setSelectedCreditRoles, vocabTermItems, } = (0, useManageCredit_1.useManageCredit)(selection);
|
|
332
|
+
const newEntity = newAuthor ||
|
|
333
|
+
(isCreatingNewAuthor &&
|
|
334
|
+
!showConfirmationDialog &&
|
|
335
|
+
!showRequiredFieldConfirmationDialog);
|
|
336
336
|
return (react_1.default.createElement(style_guide_1.StyledModal, { isOpen: isOpen, onRequestClose: () => close(), shouldCloseOnOverlayClick: true },
|
|
337
337
|
react_1.default.createElement(style_guide_1.ModalContainer, { "data-cy": "authors-modal" },
|
|
338
338
|
react_1.default.createElement(style_guide_1.ModalHeader, null,
|
|
@@ -340,35 +340,50 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
|
|
|
340
340
|
react_1.default.createElement(StyledModalBody, null,
|
|
341
341
|
react_1.default.createElement(style_guide_1.ModalSidebar, { "data-cy": "authors-sidebar" },
|
|
342
342
|
react_1.default.createElement(StyledModalSidebarHeader, null,
|
|
343
|
-
react_1.default.createElement(style_guide_1.ModalSidebarTitle, null, "Authors")),
|
|
343
|
+
react_1.default.createElement(style_guide_1.ModalSidebarTitle, null, "Manage Authors")),
|
|
344
344
|
react_1.default.createElement(StyledSidebarContent, null,
|
|
345
345
|
react_1.default.createElement(AddAuthorButton, { "data-cy": "add-author-button", onClick: addAuthor, "data-active": isCreatingNewAuthor || newAuthor },
|
|
346
346
|
react_1.default.createElement(style_guide_1.AddIcon, { width: 18, height: 18 }),
|
|
347
347
|
react_1.default.createElement(ActionTitle, null, "New Author")),
|
|
348
348
|
react_1.default.createElement(AuthorList_1.AuthorList, { author: selection, authors: authors, onSelect: selectAuthor, onDelete: () => setShowDeleteDialog((prev) => !prev), moveAuthor: moveAuthor, lastSavedAuthor: lastSavedAuthor }))),
|
|
349
|
-
react_1.default.createElement(
|
|
350
|
-
react_1.default.createElement(AuthorTabs,
|
|
351
|
-
react_1.default.createElement(ModalFormActions_1.ModalFormActions, {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
349
|
+
react_1.default.createElement(StyledScrollableModalContent, { "data-cy": "author-modal-content" }, selection ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
350
|
+
react_1.default.createElement(AuthorTabs, { selectedIndex: authorTabIndex, onChange: setAuthorTabIndex },
|
|
351
|
+
react_1.default.createElement(ModalFormActions_1.ModalFormActions, { type: "author", onDelete: deleteAuthor, showingDeleteDialog: showingDeleteDialog, showDeleteDialog: () => setShowDeleteDialog((prev) => !prev) }),
|
|
352
|
+
react_1.default.createElement(ModalTabs_1.ModalTabs, { tabLabels: [
|
|
353
|
+
'Author Details',
|
|
354
|
+
...(onOpenAffiliationsModal ? ['Affiliations'] : []),
|
|
355
|
+
'Contributions',
|
|
356
|
+
], tabErrorIndicators: [
|
|
357
|
+
authorHasError,
|
|
358
|
+
...(onOpenAffiliationsModal ? [false] : []),
|
|
359
|
+
false,
|
|
360
|
+
], tabWarningIndicators: [
|
|
361
|
+
authorDetailsUnsavedContinue && !authorHasError,
|
|
362
|
+
...(onOpenAffiliationsModal ? [false] : []),
|
|
363
|
+
false,
|
|
364
|
+
] }),
|
|
359
365
|
react_1.default.createElement(style_guide_1.InspectorTabPanels, null,
|
|
360
366
|
react_1.default.createElement(AuthorTabPanel, null,
|
|
361
|
-
react_1.default.createElement(AuthorDetailsForm_1.AuthorDetailsForm, { values: (0, normalize_1.normalizeAuthor)(selection), onChange: changeAuthor, onSave: saveAuthor, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliations.map((a) => a.id), authorFormRef: authorFormRef, selectedCreditRoles: selectedCreditRoles })),
|
|
367
|
+
react_1.default.createElement(AuthorDetailsForm_1.AuthorDetailsForm, { values: (0, normalize_1.normalizeAuthor)(selection), onChange: changeAuthor, onSave: saveAuthor, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliations.map((a) => a.id), authorFormRef: authorFormRef, selectedCreditRoles: selectedCreditRoles, newEntity: newEntity, onAuthorDetailsTabErrorChange: setAuthorDetailsTabHasError, unsavedContinueActive: authorDetailsUnsavedContinue, requiredContinueActive: authorDetailsRequiredContinue })),
|
|
362
368
|
onOpenAffiliationsModal && (react_1.default.createElement(AuthorTabPanel, null,
|
|
363
369
|
react_1.default.createElement(AffiliationsPanel_1.AffiliationsPanel, { items: affiliations, selectedItems: selectedAffiliations, onSelect: selectAffiliation, onOpenAffiliationsModal: onOpenAffiliationsModal }))),
|
|
364
370
|
react_1.default.createElement(AuthorTabPanel, null,
|
|
365
|
-
react_1.default.createElement(
|
|
371
|
+
react_1.default.createElement(style_guide_1.FormSubtitle, null, "Contributions (CRediT)"),
|
|
372
|
+
react_1.default.createElement(ContributionsDescriptionSubtitle, null, "Select the roles this author contributed to according to the CRediT taxonomy"),
|
|
373
|
+
react_1.default.createElement(CreditDrawer_1.CreditContributionsCheckboxes, { items: vocabTermItems, selectedItems: selectedCreditRoles.map((r) => ({
|
|
366
374
|
id: r.vocabTerm,
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
375
|
+
})), onSelect: selectCreditRole })))),
|
|
376
|
+
react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showRequiredFieldConfirmationDialog, onPrimary: () => {
|
|
377
|
+
setShowRequiredFieldConfirmationDialog(false);
|
|
378
|
+
setNextAuthor(null);
|
|
379
|
+
setAuthorDetailsRequiredContinue(true);
|
|
380
|
+
}, onSecondary: cancel, type: ConfirmationDialog_1.DialogType.REQUIRED, entityType: "author" }),
|
|
381
|
+
react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: () => {
|
|
382
|
+
setShowConfirmationDialog(false);
|
|
383
|
+
setNextAuthor(null);
|
|
384
|
+
setAuthorDetailsUnsavedContinue(true);
|
|
385
|
+
}, onSecondary: cancel, type: ConfirmationDialog_1.DialogType.SAVE, entityType: "author" }))) : (react_1.default.createElement(FormPlaceholder_1.FormPlaceholder, { type: "author", title: "Author Details", message: "Select an author from the list to display their details here.", placeholderIcon: react_1.default.createElement(style_guide_1.AuthorPlaceholderIcon, null) })))),
|
|
386
|
+
react_1.default.createElement(FormFooter_1.default, { onCancel: close, primaryAction: selection ? (react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "author-details-form", newEntity: newEntity, isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
|
|
372
387
|
};
|
|
373
388
|
exports.AuthorsModal = AuthorsModal;
|
|
374
389
|
function createEmptyAuthor(priority) {
|
|
@@ -388,6 +403,7 @@ function createEmptyAuthor(priority) {
|
|
|
388
403
|
correspIDs: [],
|
|
389
404
|
footnoteIDs: [],
|
|
390
405
|
prefix: '',
|
|
406
|
+
creditRoles: [],
|
|
391
407
|
};
|
|
392
408
|
}
|
|
393
409
|
const AddAuthorButton = styled_components_1.default.button `
|
|
@@ -421,6 +437,10 @@ const AuthorTabPanel = (0, styled_components_1.default)(style_guide_1.InspectorT
|
|
|
421
437
|
}) `
|
|
422
438
|
margin-top: ${(props) => props.theme.grid.unit * 4}px;
|
|
423
439
|
`;
|
|
440
|
+
const ContributionsDescriptionSubtitle = (0, styled_components_1.default)(style_guide_1.FormSubtitle) `
|
|
441
|
+
font-size: ${(props) => props.theme.font.size.small};
|
|
442
|
+
line-height: ${(props) => props.theme.font.lineHeight.normal};
|
|
443
|
+
`;
|
|
424
444
|
const StyledSidebarContent = (0, styled_components_1.default)(style_guide_1.SidebarContent) `
|
|
425
445
|
padding: 8px;
|
|
426
446
|
`;
|
|
@@ -429,5 +449,8 @@ const StyledModalBody = (0, styled_components_1.default)(style_guide_1.ModalBody
|
|
|
429
449
|
height: calc(90vh - 40px);
|
|
430
450
|
`;
|
|
431
451
|
const StyledModalSidebarHeader = (0, styled_components_1.default)(style_guide_1.ModalSidebarHeader) `
|
|
432
|
-
margin-bottom:
|
|
452
|
+
margin-bottom: 12px;
|
|
453
|
+
`;
|
|
454
|
+
const StyledScrollableModalContent = (0, styled_components_1.default)(style_guide_1.ScrollableModalContent) `
|
|
455
|
+
padding: 45px 16px 16px;
|
|
433
456
|
`;
|
|
@@ -7,9 +7,9 @@ exports.AuthorsPanel = void 0;
|
|
|
7
7
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const GenericPanel_1 = require("../authors-affiliations/GenericPanel");
|
|
10
|
-
const AuthorsPanel = ({ items, selectedItems = [], onSelect,
|
|
10
|
+
const AuthorsPanel = ({ items, selectedItems = [], onSelect, openAuthorsModal, }) => {
|
|
11
11
|
const selectedIds = (0, GenericPanel_1.useListSelectedIds)(selectedItems);
|
|
12
|
-
return (react_1.default.createElement(GenericPanel_1.GenericPanel, { title: "Authors", createLabel: "Add New Author", onCreate:
|
|
12
|
+
return (react_1.default.createElement(GenericPanel_1.GenericPanel, { title: "Authors", createLabel: "Add New Author", onCreate: openAuthorsModal, createDataCy: "add-authors-link", emptyDataCy: "authors-panel-empty", isEmpty: items.length === 0, emptyIcon: react_1.default.createElement(style_guide_1.InfoCircleIcon, null), emptyMessage: react_1.default.createElement(react_1.default.Fragment, null,
|
|
13
13
|
"There are no authors attributed yet!",
|
|
14
14
|
react_1.default.createElement("br", null),
|
|
15
15
|
"Click \u2018Add New Author\u2019") },
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.CreateAuthorModal = void 0;
|
|
40
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
41
|
+
const transform_1 = require("@manuscripts/transform");
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const normalize_1 = require("../../lib/normalize");
|
|
44
|
+
const CreateModalStyles_1 = require("../form/CreateModalStyles");
|
|
45
|
+
const FormFooter_1 = __importDefault(require("../form/FormFooter"));
|
|
46
|
+
const ModalFormActions_1 = require("../form/ModalFormActions");
|
|
47
|
+
const AuthorDetailsForm_1 = require("./AuthorDetailsForm");
|
|
48
|
+
const useManageAffiliations_1 = require("./useManageAffiliations");
|
|
49
|
+
const useManageCredit_1 = require("./useManageCredit");
|
|
50
|
+
const CreateAuthorModal = ({ authorsCount, affiliations: $affiliations, onSave, onClose, }) => {
|
|
51
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(true);
|
|
52
|
+
const [isDisableSave, setDisableSave] = (0, react_1.useState)(true);
|
|
53
|
+
const [isEmailRequired, setEmailRequired] = (0, react_1.useState)(false);
|
|
54
|
+
const [hasError, setHasError] = (0, react_1.useState)(false);
|
|
55
|
+
const actionsRef = (0, react_1.useRef)(undefined);
|
|
56
|
+
const authorFormRef = (0, react_1.useRef)(null);
|
|
57
|
+
const selection = (0, react_1.useMemo)(() => createEmptyAuthor(authorsCount), []);
|
|
58
|
+
const prevIsOpenRef = (0, react_1.useRef)(true);
|
|
59
|
+
(0, react_1.useEffect)(() => {
|
|
60
|
+
if (prevIsOpenRef.current && !isOpen) {
|
|
61
|
+
prevIsOpenRef.current = isOpen;
|
|
62
|
+
const id = window.setTimeout(() => {
|
|
63
|
+
onClose();
|
|
64
|
+
}, CreateModalStyles_1.MODAL_ON_CLOSE_NOTIFY_DELAY_MS);
|
|
65
|
+
return () => window.clearTimeout(id);
|
|
66
|
+
}
|
|
67
|
+
prevIsOpenRef.current = isOpen;
|
|
68
|
+
}, [isOpen, onClose]);
|
|
69
|
+
const { selectedAffiliations } = (0, useManageAffiliations_1.useManageAffiliations)(selection, $affiliations);
|
|
70
|
+
const { selectedCreditRoles } = (0, useManageCredit_1.useManageCredit)(selection);
|
|
71
|
+
const handleSave = (values) => {
|
|
72
|
+
onSave({ ...selection, ...values });
|
|
73
|
+
setIsOpen(false);
|
|
74
|
+
};
|
|
75
|
+
const handleChange = (values) => {
|
|
76
|
+
const { given, family, email, isCorresponding } = values;
|
|
77
|
+
const isNameFilled = given?.length || family?.length;
|
|
78
|
+
if (isNameFilled) {
|
|
79
|
+
if (isCorresponding) {
|
|
80
|
+
setDisableSave(!email?.length);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
setDisableSave(false);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
setDisableSave(true);
|
|
88
|
+
}
|
|
89
|
+
setEmailRequired(!!isCorresponding);
|
|
90
|
+
};
|
|
91
|
+
return (react_1.default.createElement(style_guide_1.StyledModal, { isOpen: isOpen, onRequestClose: () => setIsOpen(false), shouldCloseOnOverlayClick: true },
|
|
92
|
+
react_1.default.createElement(style_guide_1.ModalContainer, { "data-cy": "create-author-modal" },
|
|
93
|
+
react_1.default.createElement(style_guide_1.ModalHeader, null,
|
|
94
|
+
react_1.default.createElement(style_guide_1.CloseButton, { onClick: () => setIsOpen(false), "data-cy": "modal-close-button" })),
|
|
95
|
+
react_1.default.createElement(CreateModalStyles_1.StyledModalBody, null,
|
|
96
|
+
react_1.default.createElement(CreateModalStyles_1.StyledScrollableModalContent, null,
|
|
97
|
+
react_1.default.createElement(CreateModalStyles_1.FormTitle, null, "Create New Author"),
|
|
98
|
+
react_1.default.createElement(AuthorDetailsForm_1.AuthorDetailsForm, { values: (0, normalize_1.normalizeAuthor)(selection), onChange: handleChange, onSave: handleSave, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliations.map((a) => a.id), authorFormRef: authorFormRef, selectedCreditRoles: selectedCreditRoles, newEntity: true, onAuthorDetailsTabErrorChange: setHasError }))),
|
|
99
|
+
react_1.default.createElement(FormFooter_1.default, { onCancel: () => setIsOpen(false), primaryAction: react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "author-details-form", newEntity: true, isDisableSave: isDisableSave || hasError, createLabel: "Create New Author", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
|
|
100
|
+
};
|
|
101
|
+
exports.CreateAuthorModal = CreateAuthorModal;
|
|
102
|
+
function createEmptyAuthor(priority) {
|
|
103
|
+
return {
|
|
104
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.contributor),
|
|
105
|
+
role: '',
|
|
106
|
+
affiliationIDs: [],
|
|
107
|
+
degrees: [],
|
|
108
|
+
given: '',
|
|
109
|
+
family: '',
|
|
110
|
+
email: '',
|
|
111
|
+
suffix: '',
|
|
112
|
+
isCorresponding: false,
|
|
113
|
+
ORCID: '',
|
|
114
|
+
priority,
|
|
115
|
+
isJointContributor: false,
|
|
116
|
+
correspIDs: [],
|
|
117
|
+
footnoteIDs: [],
|
|
118
|
+
prefix: '',
|
|
119
|
+
creditRoles: [],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -3,25 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.CreditContributionsCheckboxes = void 0;
|
|
7
7
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
10
|
const AuthorDetailsForm_1 = require("./AuthorDetailsForm");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const CreditContributionsCheckboxes = ({ items, selectedItems = [], onSelect }) => {
|
|
12
|
+
const selectedIds = selectedItems.map((a) => a.id);
|
|
13
|
+
return (react_1.default.createElement(TwoColumnContainer, { "data-cy": "credit-taxnonomy", role: "group", "aria-label": "Contributions (CRediT)" }, items.map((item) => (react_1.default.createElement(TwoColumnCheckbox, { key: item.id },
|
|
14
|
+
react_1.default.createElement(style_guide_1.CheckboxLabel, null,
|
|
15
|
+
react_1.default.createElement(style_guide_1.CheckboxField, { name: item.id, checked: selectedIds.includes(item.id), onChange: () => {
|
|
16
|
+
onSelect(item.id);
|
|
17
|
+
} }),
|
|
18
|
+
react_1.default.createElement(style_guide_1.LabelText, null, item.vocabTerm)))))));
|
|
19
19
|
};
|
|
20
|
-
exports.
|
|
21
|
-
const TwoColumnContainer =
|
|
20
|
+
exports.CreditContributionsCheckboxes = CreditContributionsCheckboxes;
|
|
21
|
+
const TwoColumnContainer = styled_components_1.default.ul `
|
|
22
|
+
list-style: none;
|
|
23
|
+
padding: 0 ${(props) => props.theme.grid.unit * 4}px;
|
|
24
|
+
margin: 0;
|
|
22
25
|
display: flex;
|
|
23
26
|
flex-flow: row wrap;
|
|
24
|
-
padding: 0 ${(props) => props.theme.grid.unit * 4}px;
|
|
25
27
|
position: relative;
|
|
26
28
|
`;
|
|
27
29
|
const TwoColumnCheckbox = (0, styled_components_1.default)(AuthorDetailsForm_1.CheckboxContainer) `
|