From 34f6545405ef3cf8b2d33cd2965c8dab769184a3 Mon Sep 17 00:00:00 2001 From: GaziYucel Date: Sun, 17 Nov 2024 21:28:00 +0100 Subject: [PATCH 1/4] Resolve PR conflicts --- 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 | 2 + src/components/Icon/icons/Ror.vue | 45 ++ .../contributors/ContributorsListPanel.vue | 12 + 11 files changed, 1095 insertions(+), 1 deletion(-) 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 580f440c3..006374b55 100644 --- a/src/components/Icon/Icon.stories.js +++ b/src/components/Icon/Icon.stories.js @@ -149,6 +149,7 @@ export const IconGallery = { 'ReviewAssignments', 'ReviewRequestDeclined', 'ReviewSent', + 'Ror', 'Search', 'Settings', 'Sitemap', diff --git a/src/components/Icon/Icon.vue b/src/components/Icon/Icon.vue index d7f658560..b2df35a7e 100644 --- a/src/components/Icon/Icon.vue +++ b/src/components/Icon/Icon.vue @@ -97,6 +97,7 @@ import ReinstateReviewer from './icons/ReinstateReviewer.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 Sitemap from './icons/Sitemap.vue'; @@ -207,6 +208,7 @@ const svgIcons = { ReviewAssignments, ReviewRequestDeclined, ReviewSent, + Ror, Search, Settings, Sitemap, 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 ec832a321..af83b1f48 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]; } From db537dc587a4d4ad85214f5c8f9f3ac9444065d2 Mon Sep 17 00:00:00 2001 From: GaziYucel Date: Mon, 18 Nov 2024 11:14:39 +0100 Subject: [PATCH 2/4] Do not copy ror to author_affiliation_settings; --- public/globals.js | 3 +- .../Form/fields/FieldAffiliations.vue | 130 +++-- .../Form/mocks/field-affiliations.js | 543 ++++++++++-------- 3 files changed, 362 insertions(+), 314 deletions(-) diff --git a/public/globals.js b/public/globals.js index f3308d31a..3c1d364a3 100644 --- a/public/globals.js +++ b/public/globals.js @@ -761,7 +761,8 @@ window.pkp = { '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' + 'user.affiliations.searchPhraseNothingFound': 'Your search phrase could not be found', + 'user.affiliations.primaryLocaleRequired': 'The primary language {$primaryLocale} is required', }, tinyMCE: { diff --git a/src/components/Form/fields/FieldAffiliations.vue b/src/components/Form/fields/FieldAffiliations.vue index 32e5fbbd8..51b4fc3d8 100644 --- a/src/components/Form/fields/FieldAffiliations.vue +++ b/src/components/Form/fields/FieldAffiliations.vue @@ -22,11 +22,21 @@ - + + {{ row.name[primaryLocale] }} + + + {{ - row.name[primaryLocale] - ? row.name[primaryLocale] - : getAlternativeDisplayName(row.name) + t('user.affiliations.primaryLocaleRequired', { + primaryLocale: getLocaleDisplayName(primaryLocale), + }) }} @@ -50,7 +60,7 @@ >
@@ -106,13 +106,13 @@ :class="'dropDownActions border-transparent'" @action="rowActionsHandler" /> - +
@@ -208,7 +208,7 @@ ? t( 'user.affiliations.typeTranslationNameInLanguageLabel', {language: getLocaleDisplayName(localeAddMode)}, - ) + ) : getLocaleDisplayName(localeAddMode) }} @@ -234,20 +234,20 @@
- +
- +
@@ -573,6 +573,11 @@ function sortNamesPrimaryFirst(names) { .dropDownActions svg { width: 1.5em; } + + .link-disabled { + opacity: 0.5; + pointer-events: none; + } } .pkpFormField--affiliations__control .searchPhraseResults { From bcb04a52de08b99cb8b07c4643b05d81ec0080ee Mon Sep 17 00:00:00 2001 From: GaziYucel Date: Wed, 20 Nov 2024 10:36:37 +0100 Subject: [PATCH 4/4] currentValue getter/setter refactoring for better understanding documentation properties, variables, functions --- public/globals.js | 5 +- .../Form/fields/FieldAffiliations.stories.js | 8 +- .../Form/fields/FieldAffiliations.vue | 393 ++++++++++++------ .../Form/mocks/field-affiliations.js | 6 +- .../contributors/ContributorsListPanel.vue | 4 +- 5 files changed, 271 insertions(+), 145 deletions(-) diff --git a/public/globals.js b/public/globals.js index 3c1d364a3..fadb8fd60 100644 --- a/public/globals.js +++ b/public/globals.js @@ -125,6 +125,7 @@ window.pkp = { 'article.metadata': 'Metadata', 'author.users.contributor.principalContact': 'Primary Contact', 'author.users.contributor.setPrincipalContact': 'Set Primary Contact', + 'common.add': 'Add', 'common.addCCBCC': 'Add CC/BCC', 'common.assign': 'Assign', 'common.attachFiles': 'Attach Files', @@ -755,11 +756,11 @@ window.pkp = { '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.translationsSomeAvailable': '{$count} 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.deleteModal.message': 'The affiliation {$affiliation} will be deleted.', 'user.affiliations.searchPhraseLabel': 'Type the institute name in {$language}', 'user.affiliations.searchPhraseNothingFound': 'Your search phrase could not be found', 'user.affiliations.primaryLocaleRequired': 'The primary language {$primaryLocale} is required', diff --git a/src/components/Form/fields/FieldAffiliations.stories.js b/src/components/Form/fields/FieldAffiliations.stories.js index 967f7ef95..b7f7e87ad 100644 --- a/src/components/Form/fields/FieldAffiliations.stories.js +++ b/src/components/Form/fields/FieldAffiliations.stories.js @@ -1,6 +1,6 @@ import FieldAffiliations from './FieldAffiliations.vue'; import FieldAffiliationsMock from '@/components/Form/mocks/field-affiliations'; -import {http, HttpResponse} from "msw"; +import {http, HttpResponse} from 'msw'; const args = {...FieldAffiliationsMock}; @@ -14,7 +14,7 @@ export default { http.get( 'https://mock/index.php/publicknowledge/api/v1/rors/?searchPhrase=Simon+Fraser+University', async () => { - return HttpResponse.json(args.apiResponse); + return HttpResponse.json(args.searchResults); }, ), ], @@ -23,10 +23,10 @@ export default { render: (args) => ({ components: {FieldAffiliations}, setup() { - return {args} + return {args}; }, template: ` - ` + `, }), decorators: [ () => ({ diff --git a/src/components/Form/fields/FieldAffiliations.vue b/src/components/Form/fields/FieldAffiliations.vue index b7eb4706c..2c283768a 100644 --- a/src/components/Form/fields/FieldAffiliations.vue +++ b/src/components/Form/fields/FieldAffiliations.vue @@ -20,17 +20,23 @@   - + - - {{ row.name[primaryLocale] }} + + {{ affiliation.name[primaryLocale] }} {{ @@ -39,7 +45,7 @@ }) }} - +   @@ -48,48 +54,65 @@ -
+
- {{ t('common.close', {}) }} - + @@ -155,8 +178,8 @@
  • -
    +
    {{ - newAffiliationPending.ror + newAffiliation.ror ? t( 'user.affiliations.typeTranslationNameInLanguageLabel', - {language: getLocaleDisplayName(localeAddMode)}, - ) - : getLocaleDisplayName(localeAddMode) + { + language: getLocaleDisplayName( + newAffiliationNameLocale, + ), + }, + ) + : getLocaleDisplayName(newAffiliationNameLocale) }}
    - @@ -258,10 +300,11 @@ @@ -573,11 +703,6 @@ function sortNamesPrimaryFirst(names) { .dropDownActions svg { width: 1.5em; } - - .link-disabled { - opacity: 0.5; - pointer-events: none; - } } .pkpFormField--affiliations__control .searchPhraseResults { diff --git a/src/components/Form/mocks/field-affiliations.js b/src/components/Form/mocks/field-affiliations.js index 664aae1b0..86be1b039 100644 --- a/src/components/Form/mocks/field-affiliations.js +++ b/src/components/Form/mocks/field-affiliations.js @@ -3,7 +3,7 @@ export default { component: 'author-affiliations', authorId: 1, primaryLocale: 'en', - supportedFormLocales: [ + locales: [ {key: 'en', label: 'English'}, {key: 'fr_CA', label: 'French (Canada)'}, {key: 'de', label: 'German'}, @@ -41,7 +41,7 @@ export default { }, }, ], - apiResponse: { + searchResults: { itemsMax: 110723, items: [ { @@ -376,7 +376,7 @@ export default { }, ], }, - newAffiliationPending: { + newAffiliation: { id: null, authorId: 1, ror: null, diff --git a/src/components/ListPanel/contributors/ContributorsListPanel.vue b/src/components/ListPanel/contributors/ContributorsListPanel.vue index af83b1f48..ab901f5f0 100644 --- a/src/components/ListPanel/contributors/ContributorsListPanel.vue +++ b/src/components/ListPanel/contributors/ContributorsListPanel.vue @@ -297,7 +297,7 @@ export default { activeForm.fields = activeForm.fields.map((field) => { if (field.name === 'affiliations') { field.primaryLocale = activeForm.primaryLocale; - field.supportedFormLocales = activeForm.supportedFormLocales; + field.locales = activeForm.supportedFormLocales; } return field; }); @@ -405,7 +405,7 @@ export default { } else if (field.name === 'affiliations') { field.authorId = author['id']; field.primaryLocale = activeForm.primaryLocale; - field.supportedFormLocales = activeForm.supportedFormLocales; + field.locales = activeForm.supportedFormLocales; field.value = author[field.name]; } else if (Object.keys(author).includes(field.name)) { field.value = author[field.name];