Skip to content

Commit d21e845

Browse files
jardakotesovecGaziYucel
authored andcommitted
pkp/pkp-lib#7135 Multiple author affiliations (Ror) - changes and fixes
1 parent 18a2510 commit d21e845

File tree

3 files changed

+62
-44
lines changed

3 files changed

+62
-44
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

+49-43
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,38 +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-
'-' +
101-
affiliationNameLocale
102-
"
103-
v-model="affiliation.name[affiliationNameLocale]"
104-
:name="
105-
'contributors-affiliations-' +
106-
affiliationIndex +
107-
'-' +
92+
<FieldText
93+
:label="getTextFieldLabel(affiliationNameLocale)"
94+
:value="affiliation.name[affiliationNameLocale]"
95+
name="name"
96+
:all-errors="{
97+
name: errors?.[affiliationIndex]?.name?.[
10898
affiliationNameLocale
109-
"
110-
class="pkpFormField__input pkpFormField--text__input"
111-
type="text"
112-
:aria-invalid="false"
113-
/>
114-
</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+
/>
115113
</div>
116114
</div>
117115
</div>
@@ -121,7 +119,6 @@
121119
<DropdownActions
122120
v-if="!(affiliationIndex === indexEditMode)"
123121
v-bind="rowActionsArgs(affiliationIndex)"
124-
:class="'dropDownActions border-transparent'"
125122
@action="rowActionsHandler"
126123
/>
127124
</TableCell>
@@ -312,17 +309,11 @@ const {fetch: postRorObject} = useFetch(apiUrl.value, {
312309
body: rorObjectToBeUpdated,
313310
});
314311
315-
computed(() => {
312+
const errors = computed(() => {
316313
if (!Object.keys(props.allErrors).includes(props.name)) {
317314
return [];
318315
}
319-
let errors = props.allErrors[props.name];
320-
if (props.isMultilingual && Object.keys(errors).includes(props.localeKey)) {
321-
return errors[props.localeKey];
322-
} else if (!props.isMultilingual) {
323-
return errors;
324-
}
325-
return [];
316+
return props.allErrors[props.name];
326317
});
327318
328319
// new affiliation form
@@ -417,7 +408,7 @@ const rowActionsArgs = function (index) {
417408
label: t('user.affiliations.translationActionsAriaLabel', {}),
418409
ariaLabel: t('user.affiliations.translationActionsAriaLabel', {}),
419410
direction: 'left',
420-
displayAsEllipsis: true,
411+
buttonVariant: 'ellipsis',
421412
};
422413
};
423414
@@ -476,6 +467,21 @@ function deleteRow(index) {
476467
});
477468
}
478469
470+
function updateAffiliationName(affiliationIndex, locale, value) {
471+
currentValue.value = currentValue.value.map((affiliation, index) => {
472+
if (index !== affiliationIndex) {
473+
return affiliation;
474+
}
475+
return {
476+
...affiliation,
477+
name: {
478+
...affiliation.name,
479+
[locale]: value,
480+
},
481+
};
482+
});
483+
}
484+
479485
// helper methods
480486
481487
function getLocaleDisplayName(locale) {

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)