From 0f998976105e1d14acd7ac3d2377d1ba463ee224 Mon Sep 17 00:00:00 2001 From: GaziYucel Date: Sun, 17 Nov 2024 21:28:00 +0100 Subject: [PATCH] multiple author affiliations --- public/globals.js | 15 + .../DropdownActions/DropdownActions.vue | 4 +- src/components/Form/FormGroup.vue | 2 + .../Form/fields/FieldAffiliations.mdx | 26 + .../Form/fields/FieldAffiliations.stories.js | 40 ++ .../Form/fields/FieldAffiliations.vue | 599 ++++++++++++++++++ .../Form/mocks/field-affiliations.js | 350 ++++++++++ src/components/Icon/Icon.stories.js | 1 + src/components/Icon/Icon.vue | 62 +- src/components/Icon/icons/Ror.vue | 45 ++ .../contributors/ContributorsListPanel.vue | 12 + 11 files changed, 1154 insertions(+), 2 deletions(-) create mode 100644 src/components/Form/fields/FieldAffiliations.mdx create mode 100644 src/components/Form/fields/FieldAffiliations.stories.js create mode 100644 src/components/Form/fields/FieldAffiliations.vue create mode 100644 src/components/Form/mocks/field-affiliations.js create mode 100644 src/components/Icon/icons/Ror.vue diff --git a/public/globals.js b/public/globals.js index 0c8538abb..f3308d31a 100644 --- a/public/globals.js +++ b/public/globals.js @@ -747,6 +747,21 @@ window.pkp = { "Invitation not accepted. You're logged in as a different user.", 'acceptInvitation.authorization.message': 'Please log out and sign in with the correct account to accept this invitation.', + 'user.affiliations': 'Affiliations', + 'user.affiliations.description': 'Enter the full name of the institution below, avoiding any acronyms. Select the name from the dropdown and click "Add" to include the affiliation in your profile. (e.g. "Simon Fraser University")', + 'user.affiliations.institution': 'Institution', + 'user.affiliations.translation': 'Translation', + 'user.affiliations.translationEditActionLabel': 'Edit institution name', + 'user.affiliations.translationDeleteActionLabel': 'Remove institution', + 'user.affiliations.translationActionsAriaLabel': 'Click to edit or delete', + 'user.affiliations.translationsAllAvailable': 'All translations available', + 'user.affiliations.translationsSomeAvailable': '{$translated} of {$total} languages completed', + 'user.affiliations.typeTranslationNameInLanguageLabel': 'Type the institute name in {$language}', + 'user.affiliations.translationNameInLanguage': 'Institute name in {$language}', + 'user.affiliations.deleteModal.title': 'Are you sure?', + 'user.affiliations.deleteModal.message': 'The institution {$institution} will be deleted.', + 'user.affiliations.searchPhraseLabel': 'Type the institute name in {$language}', + 'user.affiliations.searchPhraseNothingFound': 'Your search phrase could not be found' }, tinyMCE: { diff --git a/src/components/DropdownActions/DropdownActions.vue b/src/components/DropdownActions/DropdownActions.vue index 923fccb0a..ac379afbb 100644 --- a/src/components/DropdownActions/DropdownActions.vue +++ b/src/components/DropdownActions/DropdownActions.vue @@ -124,7 +124,9 @@ const emit = defineEmits([ ]); const emitAction = (action) => { - if (action.name) { + if (action.name && (action.id || action.id === 0)) { + emit('action', [action.name, action.id]); + } else if (action.name) { emit('action', action.name); } }; diff --git a/src/components/Form/FormGroup.vue b/src/components/Form/FormGroup.vue index ce7b6087c..843506640 100644 --- a/src/components/Form/FormGroup.vue +++ b/src/components/Form/FormGroup.vue @@ -53,6 +53,7 @@ + + diff --git a/src/components/Form/mocks/field-affiliations.js b/src/components/Form/mocks/field-affiliations.js new file mode 100644 index 000000000..57f11f247 --- /dev/null +++ b/src/components/Form/mocks/field-affiliations.js @@ -0,0 +1,350 @@ +export default { + name: 'author-affiliations', + component: 'author-affiliations', + currentLocale: 'en', + supportedLocales: ['en', 'de', 'fr_CA'], + localeDisplayNames: {"en": "English", "fr_CA": "French (Canada)", "de": "German"}, + apiResponse: { + "itemsMax": 110723, + "items": [ + { + "displayLocale": "en", + "id": 1, + "isActive": true, + "name": { + "en": "RMIT University", + "fr_CA": "" + }, + "ror": "https://ror.org/04ttjf776" + }, + { + "displayLocale": "en", + "id": 2, + "isActive": true, + "name": { + "en": "La Trobe University", + "fr_CA": "" + }, + "ror": "https://ror.org/01rxfrp27" + }, + { + "displayLocale": "en", + "id": 3, + "isActive": true, + "name": { + "en": "Victoria University", + "fr_CA": "" + }, + "ror": "https://ror.org/04j757h98" + }, + { + "displayLocale": "en", + "id": 4, + "isActive": true, + "name": { + "en": "University of New England", + "fr_CA": "" + }, + "ror": "https://ror.org/04r659a56" + }, + { + "displayLocale": "en", + "id": 5, + "isActive": true, + "name": { + "en": "Griffith University", + "fr_CA": "" + }, + "ror": "https://ror.org/02sc3r913" + }, + { + "displayLocale": "en", + "id": 6, + "isActive": true, + "name": { + "en": "Central Queensland University", + "fr_CA": "" + }, + "ror": "https://ror.org/023q4bk22" + }, + { + "displayLocale": "en", + "id": 7, + "isActive": true, + "name": { + "en": "University of South Australia", + "fr_CA": "" + }, + "ror": "https://ror.org/01p93h210" + }, + { + "displayLocale": "en", + "id": 8, + "isActive": true, + "name": { + "en": "Bond University", + "fr_CA": "" + }, + "ror": "https://ror.org/006jxzx88" + }, + { + "displayLocale": "en", + "id": 9, + "isActive": true, + "name": { + "en": "Charles Sturt University", + "fr_CA": "" + }, + "ror": "https://ror.org/00wfvh315" + }, + { + "displayLocale": "en", + "id": 10, + "isActive": true, + "name": { + "en": "Federation University", + "fr_CA": "" + }, + "ror": "https://ror.org/05qbzwv83" + }, + { + "displayLocale": "en", + "id": 11, + "isActive": true, + "name": { + "en": "Burnet Institute", + "fr_CA": "" + }, + "ror": "https://ror.org/05ktbsm52" + }, + { + "displayLocale": "en", + "id": 12, + "isActive": true, + "name": { + "en": "Mater Research", + "fr_CA": "" + }, + "ror": "https://ror.org/00nx6aa03" + }, + { + "displayLocale": "en", + "id": 13, + "isActive": true, + "name": { + "en": "St Vincents Institute of Medical Research", + "fr_CA": "" + }, + "ror": "https://ror.org/02k3cxs74" + }, + { + "displayLocale": "en", + "id": 14, + "isActive": true, + "name": { + "en": "The Heart Research Institute", + "fr_CA": "" + }, + "ror": "https://ror.org/046fa4y88" + }, + { + "displayLocale": "en", + "id": 15, + "isActive": true, + "name": { + "en": "University Mental Health Research Institute", + "fr_CA": "" + }, + "ror": "https://ror.org/02d439m40" + }, + { + "displayLocale": "en", + "id": 16, + "isActive": true, + "name": { + "en": "Rolls-Royce (United Kingdom)", + "fr_CA": "" + }, + "ror": "https://ror.org/04h08p482" + }, + { + "displayLocale": "en", + "id": 17, + "isActive": true, + "name": { + "en": "BP (United Kingdom)", + "fr_CA": "" + }, + "ror": "https://ror.org/01zctcs90" + }, + { + "displayLocale": "en", + "id": 18, + "isActive": true, + "name": { + "en": "Rio Tinto (United Kingdom)", + "fr_CA": "" + }, + "ror": "https://ror.org/05m7zw681" + }, + { + "displayLocale": "en", + "id": 19, + "isActive": true, + "name": { + "en": "Arup Group (United States)", + "fr_CA": "" + }, + "ror": "https://ror.org/03awtex73" + }, + { + "displayLocale": "en", + "id": 20, + "isActive": true, + "name": { + "en": "BT Group (United Kingdom)", + "fr_CA": "" + }, + "ror": "https://ror.org/00kv9pj15" + }, + { + "displayLocale": "en", + "id": 21, + "isActive": true, + "name": { + "en": "Mater Health Services", + "fr_CA": "" + }, + "ror": "https://ror.org/03mjtdk61" + }, + { + "displayLocale": "en", + "id": 22, + "isActive": true, + "name": { + "en": "Pilkington (United Kingdom)", + "fr_CA": "" + }, + "ror": "https://ror.org/04yyp8h20" + }, + { + "displayLocale": "en", + "id": 23, + "isActive": true, + "name": { + "en": "Trojan Technologies (Canada)", + "fr_CA": "" + }, + "ror": "https://ror.org/022rkxt86" + }, + { + "displayLocale": "en", + "id": 24, + "isActive": true, + "name": { + "en": "The Alfred Hospital", + "fr_CA": "" + }, + "ror": "https://ror.org/01wddqe20" + }, + { + "displayLocale": "en", + "id": 25, + "isActive": true, + "name": { + "en": "Washington State Department of Health", + "fr_CA": "" + }, + "ror": "https://ror.org/02x2akc96" + }, + { + "displayLocale": "en", + "id": 26, + "isActive": true, + "name": { + "en": "Women's and Children's Hospital", + "fr_CA": "" + }, + "ror": "https://ror.org/03kwrfk72" + }, + { + "displayLocale": "en", + "id": 27, + "isActive": true, + "name": { + "en": "Xstrata (United Kingdom)", + "fr_CA": "" + }, + "ror": "https://ror.org/037mpqg03" + }, + { + "displayLocale": "en", + "id": 28, + "isActive": true, + "name": { + "en": "Teck (Canada)", + "fr_CA": "" + }, + "ror": "https://ror.org/05cggb038" + }, + { + "displayLocale": "en", + "id": 29, + "isActive": true, + "name": { + "en": "Hunter New England Local Health District", + "fr_CA": "" + }, + "ror": "https://ror.org/050b31k83" + }, + { + "displayLocale": "en", + "id": 30, + "isActive": true, + "name": { + "en": "Cancer Council Victoria", + "fr_CA": "" + }, + "ror": "https://ror.org/023m51b03" + } + ] + }, + value: [ + { + "id": 12, + "authorId": 5, + "ror": "https://ror.org/0213rcc28", + "name": { + "en": "Simon Fraser University", + "fr_CA": "Simon Fraser University", + "de": "Simon Fraser University", + } + }, + { + "id": 13, + "authorId": 5, + "ror": "https://ror.org/02e2c7k09", + "name": { + "en": "Delft University of Technology", + "fr_CA": "", + "de": "Technische Universität Delft", + } + }, + { + "id": 14, + "authorId": 5, + "ror": "", + "name": { + "en": "German National Library of Science and Technology", + "fr_CA": "", + "de": "Technische Informationsbibliothek (TIB)", + } + }, + ], + newAffiliationPending: { + "id": null, + "authorId": null, + "ror": null, + "name": {} + } +}; diff --git a/src/components/Icon/Icon.stories.js b/src/components/Icon/Icon.stories.js index 7afae93da..d4cfe95e4 100644 --- a/src/components/Icon/Icon.stories.js +++ b/src/components/Icon/Icon.stories.js @@ -122,6 +122,7 @@ export const iconGallery = { 'ReviewAssignments', 'ReviewRequestDeclined', 'ReviewSent', + 'Ror', 'Search', 'Settings', 'Sort', diff --git a/src/components/Icon/Icon.vue b/src/components/Icon/Icon.vue index a67339d1d..a51c7422a 100644 --- a/src/components/Icon/Icon.vue +++ b/src/components/Icon/Icon.vue @@ -27,6 +27,53 @@ /> + + @@ -100,6 +147,7 @@ import ReadRecommendation from './icons/ReadRecommendation.vue'; import ReviewAssignments from './icons/ReviewAssignments.vue'; import ReviewRequestDeclined from './icons/ReviewRequestDeclined.vue'; import ReviewSent from './icons/ReviewSent.vue'; +import Ror from './icons/Ror.vue'; import Search from './icons/Search.vue'; import Settings from './icons/Settings.vue'; import Sort from './icons/Sort.vue'; @@ -176,6 +224,7 @@ const svgIcons = { ReviewAssignments, ReviewRequestDeclined, ReviewSent, + Ror, Search, Settings, Sort, @@ -200,7 +249,8 @@ const isSvgIcon = computed(() => !!svgIcons[props.icon]); const classes = computed(() => { let classes = []; - if (props.icon !== 'orcid') { + let nonFontAwesomeIcons = ['orcid', 'ror']; + if (!nonFontAwesomeIcons.includes(props.icon)) { classes.push('fa-' + props.icon); } if (props.inline) { @@ -249,4 +299,14 @@ const classes = computed(() => { fill: #ffffff; } } + +/** + * Ror icon + */ +.pkpIcon--ror { + display: inline-block; + width: 1.5em; + height: 1.5em; + vertical-align: middle; +} diff --git a/src/components/Icon/icons/Ror.vue b/src/components/Icon/icons/Ror.vue new file mode 100644 index 000000000..5bee17284 --- /dev/null +++ b/src/components/Icon/icons/Ror.vue @@ -0,0 +1,45 @@ + diff --git a/src/components/ListPanel/contributors/ContributorsListPanel.vue b/src/components/ListPanel/contributors/ContributorsListPanel.vue index 0ab52503b..9c5849371 100644 --- a/src/components/ListPanel/contributors/ContributorsListPanel.vue +++ b/src/components/ListPanel/contributors/ContributorsListPanel.vue @@ -294,6 +294,13 @@ export default { let activeForm = cloneDeep(this.form); activeForm.action = this.contributorsApiUrl; activeForm.method = 'POST'; + activeForm.fields = activeForm.fields.map((field) => { + if (field.name === 'affiliations') { + field.primaryLocale = activeForm.primaryLocale; + field.supportedFormLocales = activeForm.supportedFormLocales; + } + return field; + }); this.activeForm = activeForm; this.activeFormTitle = this.t('grid.action.addContributor'); const {openSideModal} = useModal(); @@ -395,6 +402,11 @@ export default { field.isVerified = author['orcidIsVerified'] ?? false; field.orcidVerificationRequested = author['orcidVerificationRequested']; + } else if (field.name === 'affiliations') { + field.authorId = author['id']; + field.primaryLocale = activeForm.primaryLocale; + field.supportedFormLocales = activeForm.supportedFormLocales; + field.value = author[field.name]; } else if (Object.keys(author).includes(field.name)) { field.value = author[field.name]; }