Skip to content

Commit

Permalink
pkp/pkp-lib#10879 Correctly set primary locale for contributor form (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jardakotesovec authored Feb 5, 2025
1 parent 5df6e67 commit 5b694f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/composables/useForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,21 @@ export function useForm(_form, {customSubmit} = {}) {
});
}

function setLocales(_locales) {
if (Array.isArray(_locales)) {
form.value.supportedFormLocales = _locales;
function setLocalesForSubmission(submission) {
const supportedFormLocales = submission.metadataLocales;
if (Array.isArray(supportedFormLocales)) {
form.value.supportedFormLocales = supportedFormLocales;
} else {
form.value.supportedFormLocales = Object.keys(_locales).map(
(localeKey) => ({key: localeKey, label: _locales[localeKey]}),
form.value.supportedFormLocales = Object.keys(supportedFormLocales).map(
(localeKey) => ({
key: localeKey,
label: supportedFormLocales[localeKey],
}),
);
}

form.value.primaryLocale = submission.locale;
form.value.visibleLocales = [submission.locale];
}

function structuredErrors(errors) {
Expand Down Expand Up @@ -188,7 +195,7 @@ export function useForm(_form, {customSubmit} = {}) {
form,
connectWithPayload,
connectWithErrors,
setLocales,
setLocalesForSubmission,
setAction,
structuredErrors,
};
Expand Down
4 changes: 2 additions & 2 deletions src/managers/ContributorManager/contributorManagerStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export const useContributorManagerStore = defineComponentStore(

const dashboardStore = useDashboardPageStore();

const {form, setLocales} = useForm(
const {form, setLocalesForSubmission} = useForm(
dashboardStore.componentForms.contributorForm,
);

setLocales(props.submission.metadataLocales);
setLocalesForSubmission(props.submission);

const {triggerDataChange} = useDataChanged();

Expand Down

0 comments on commit 5b694f8

Please sign in to comment.