Skip to content

Commit 4d0a984

Browse files
jardakotesovecbozana
authored andcommitted
pkp/pkp-lib#7135 Multiple author affiliations (Ror) - changes and fixes
1 parent 3f82f96 commit 4d0a984

File tree

3 files changed

+63
-51
lines changed

3 files changed

+63
-51
lines changed

src/components/Form/Form.vue

+9
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,17 @@ export default {
566566
'[id*="' + this.id + '-' + field.name + '"]',
567567
);
568568
if ($el) {
569+
// Handle scrolling within new side modals
570+
const containers = document.querySelectorAll(
571+
'div.pkp-modal-scroll-container',
572+
);
573+
const lastContainer =
574+
containers.length > 0
575+
? containers[containers.length - 1]
576+
: undefined;
569577
this.$scrollTo($el, 500, {
570578
offset: -50,
579+
container: lastContainer,
571580
});
572581
} else {
573582
this.setCurrentPage(group.pageId);

src/components/Form/fields/FieldAffiliations.vue

+50-50
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<template>
2-
<div class="pkpFormField pkpFormField--affiliations">
2+
<!-- To be able to scroll to this field on error-->
3+
<div
4+
:id="`${props.formId}-${props.name}`"
5+
class="pkpFormField pkpFormField--affiliations"
6+
>
37
<div class="pkpFormField__heading">
48
<label class="pkpFormFieldLabel">
59
{{ t('user.affiliations', {}) }}
@@ -70,7 +74,12 @@
7074
/>
7175
{{ translations(affiliation).label }}
7276
</a>
73-
<div v-if="affiliationIndex === indexEditMode">
77+
<div
78+
v-if="
79+
affiliationIndex === indexEditMode ||
80+
errors?.[affiliationIndex]?.name
81+
"
82+
>
7483
<div
7584
v-for="[affiliationNameLocale] in Object.entries(
7685
affiliation.name,
@@ -80,45 +89,27 @@
8089
<div
8190
v-if="supportedLocales.includes(affiliationNameLocale)"
8291
>
83-
<div>
84-
<span class="text-lg-semibold">
85-
{{ getTextFieldLabel(affiliationNameLocale) }}
86-
</span>
87-
<span
88-
v-if="affiliationNameLocale === primaryLocale"
89-
class="pkpFormFieldLabel__required"
90-
>
91-
<span class="aria-hidden">*</span>
92-
<span class="-screenReader">Required</span>
93-
</span>
94-
</div>
95-
<div class="pkpFormField--sizelarge">
96-
<input
97-
:id="
98-
'contributors-affiliations-' +
99-
affiliationIndex +
100-
'-' +
92+
<FieldText
93+
:label="getTextFieldLabel(affiliationNameLocale)"
94+
:value="affiliation.name[affiliationNameLocale]"
95+
name="name"
96+
:all-errors="{
97+
name: errors?.[affiliationIndex]?.name?.[
10198
affiliationNameLocale
102-
"
103-
v-model="affiliation.name[affiliationNameLocale]"
104-
:name="
105-
'contributors-affiliations-' +
106-
affiliationIndex +
107-
'-' +
108-
affiliationNameLocale
109-
"
110-
class="pkpFormField__input pkpFormField--text__input"
111-
type="text"
112-
:aria-invalid="false"
113-
/>
114-
<FieldError
115-
v-if="
116-
affiliationNameLocale === primaryLocale &&
117-
!affiliation.name[affiliationNameLocale].trim()
118-
"
119-
:messages="[t('validator.required', {})]"
120-
/>
121-
</div>
99+
],
100+
}"
101+
size="large"
102+
:is-required="affiliationNameLocale === primaryLocale"
103+
@change="
104+
(fieldName, _, fieldValue) => {
105+
updateAffiliationName(
106+
affiliationIndex,
107+
affiliationNameLocale,
108+
fieldValue,
109+
);
110+
}
111+
"
112+
/>
122113
</div>
123114
</div>
124115
</div>
@@ -128,7 +119,6 @@
128119
<DropdownActions
129120
v-if="!(affiliationIndex === indexEditMode)"
130121
v-bind="rowActionsArgs(affiliationIndex)"
131-
:class="'dropDownActions border-transparent'"
132122
@action="rowActionsHandler"
133123
/>
134124
</TableCell>
@@ -259,6 +249,7 @@ import {ref, computed, onMounted, watch, onBeforeUnmount} from 'vue';
259249
import {t} from '@/utils/i18n';
260250
import {useModal} from '@/composables/useModal';
261251
import DropdownActions from '@/components/DropdownActions/DropdownActions.vue';
252+
import FieldText from '@/components/Form/fields/FieldText.vue';
262253
import FieldError from '@/components/Form/FieldError.vue';
263254
import FieldAffiliationsRorAutoSuggest from '@/components/Form/fields/FieldAffiliationsRorAutoSuggest.vue';
264255
import Icon from '@/components/Icon/Icon.vue';
@@ -343,17 +334,11 @@ const {fetch: postRorObject} = useFetch(apiUrl.value, {
343334
body: rorObjectToBeUpdated,
344335
});
345336
346-
computed(() => {
337+
const errors = computed(() => {
347338
if (!Object.keys(props.allErrors).includes(props.name)) {
348339
return [];
349340
}
350-
let errors = props.allErrors[props.name];
351-
if (props.isMultilingual && Object.keys(errors).includes(props.localeKey)) {
352-
return errors[props.localeKey];
353-
} else if (!props.isMultilingual) {
354-
return errors;
355-
}
356-
return [];
341+
return props.allErrors[props.name];
357342
});
358343
359344
watch(
@@ -444,7 +429,7 @@ const rowActionsArgs = function (index) {
444429
label: t('user.affiliations.translationActionsAriaLabel', {}),
445430
ariaLabel: t('user.affiliations.translationActionsAriaLabel', {}),
446431
direction: 'left',
447-
displayAsEllipsis: true,
432+
buttonVariant: 'ellipsis',
448433
};
449434
};
450435
@@ -503,6 +488,21 @@ function deleteRow(index) {
503488
});
504489
}
505490
491+
function updateAffiliationName(affiliationIndex, locale, value) {
492+
currentValue.value = currentValue.value.map((affiliation, index) => {
493+
if (index !== affiliationIndex) {
494+
return affiliation;
495+
}
496+
return {
497+
...affiliation,
498+
name: {
499+
...affiliation.name,
500+
[locale]: value,
501+
},
502+
};
503+
});
504+
}
505+
506506
// helper methods
507507
508508
function makeCurrentValueCompatible() {

src/components/Modal/SideModalBody.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
</div>
4747
</div>
4848
</div>
49-
<div class="relative mt-6 flex-1 overflow-y-scroll">
49+
<!-- pkp-modal-scroll-container is important for scrolling within form-->
50+
<div
51+
class="pkp-modal-scroll-container relative mt-6 flex-1 overflow-y-scroll"
52+
>
5053
<!-- @slot Body content -->
5154
<slot :close-modal="closeModal" />
5255
</div>

0 commit comments

Comments
 (0)