Skip to content

Commit 61effaf

Browse files
committed
pkp/pkp-lib#9295 better implementation of composable
1 parent f31d818 commit 61effaf

File tree

7 files changed

+156
-291
lines changed

7 files changed

+156
-291
lines changed

src/components/Form/Form.vue

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -493,29 +493,18 @@ export default {
493493
* @param {String} localeKey Optional locale key for multilingual props
494494
*/
495495
fieldChanged: function (name, prop, value, localeKey) {
496-
// Check if this is a hidden field or normal field
497-
const isHiddenField = this.hiddenFields && name in this.hiddenFields;
498-
499-
if (isHiddenField) {
500-
const newHiddenFields = {...this.hiddenFields};
501-
newHiddenFields[name] = value;
502-
this.$emit('set', this.id, {hiddenFields: newHiddenFields});
503-
} else {
504-
const newFields = this.fields.map((field) => {
505-
if (field.name === name) {
506-
if (localeKey) {
507-
field[prop][localeKey] = value;
508-
} else {
509-
field[prop] = value;
510-
}
496+
const newFields = this.fields.map((field) => {
497+
if (field.name === name) {
498+
if (localeKey) {
499+
field[prop][localeKey] = value;
500+
} else {
501+
field[prop] = value;
511502
}
512-
return field;
513-
});
514-
this.$emit('set', this.id, {fields: newFields});
515-
516-
// Remove any errors for this field
517-
this.removeError(name, localeKey);
518-
}
503+
}
504+
return field;
505+
});
506+
this.$emit('set', this.id, {fields: newFields});
507+
this.removeError(name, localeKey);
519508
},
520509
521510
/**
@@ -645,13 +634,6 @@ export default {
645634
setErrors: function (errors) {
646635
this.$emit('set', this.id, {errors: errors});
647636
},
648-
649-
/**
650-
* Set the required state for a specific field
651-
*/
652-
setFieldRequired(fieldName, isRequired) {
653-
this.fieldRequiredStates[fieldName] = isRequired;
654-
},
655637
},
656638
};
657639
</script>

src/pages/workflow/WorkflowPageOJS.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import WorkflowNotificationDisplay from './components/primary/WorkflowNotificati
2323
import WorkflowListingEmails from './components/primary/WorkflowListingEmails.vue';
2424
import WorkflowPaymentDropdown from './components/header/WorkflowPaymentDropdown.vue';
2525
import WorkflowPublicationForm from './components/publication/WorkflowPublicationForm.vue';
26-
import WorkflowPublicationFormIssue from './components/publication/WorkflowPublicationFormIssue.vue';
2726
import WorkflowPublicationJats from './components/publication/WorkflowPublicationJats.vue';
2827
import WorkflowPublicationVersionControl from './components/publication/WorkflowPublicationVersionControl.vue';
2928
import WorkflowChangeSubmissionLanguage from './components/publication/WorkflowChangeSubmissionLanguage.vue';
@@ -62,7 +61,6 @@ const Components = markRaw({
6261
WorkflowPaymentDropdown,
6362
WorkflowPrimaryBasicMetadata,
6463
WorkflowPublicationForm,
65-
WorkflowPublicationFormIssue,
6664
WorkflowPublicationJats,
6765
WorkflowPublicationVersionControl,
6866
WorkflowChangeSubmissionLanguage,

src/pages/workflow/components/publication/WorkflowPublicationForm.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {useFetch} from '@/composables/useFetch';
1919
import {useForm} from '@/composables/useForm';
2020
import {useUrl} from '@/composables/useUrl';
2121
import {useDataChanged} from '@/composables/useDataChanged';
22+
import {useApp} from '@/composables/useApp';
23+
import {useWorkflowPublicationFormIssue} from '../../composables/useWorkflowPublicationFormIssue';
2224
2325
const props = defineProps({
2426
canEdit: {type: Boolean, required: true},
@@ -28,6 +30,8 @@ const props = defineProps({
2830
publication: {type: Object, required: true},
2931
});
3032
33+
const {isOJS} = useApp();
34+
3135
const relativeUrl = computed(() => {
3236
return `submissions/${props.submission.id}/publications/${props.publication.id}/_components/${props.formName}`;
3337
});
@@ -55,16 +59,31 @@ const displayNoFieldsEnabled = computed(() => {
5559
return false;
5660
});
5761
62+
const {set, form} = useForm(publicationForm);
63+
5864
const customFns = {
5965
metadata: metadataDataChange,
66+
issue: issueDataChange,
6067
};
6168
6269
const {triggerDataChange} = useDataChanged(customFns[props.formName]);
6370
64-
const {set, form} = useForm(publicationForm);
65-
6671
async function metadataDataChange() {
6772
// Some metadata fields need extra data from db not in publication object
6873
await fetchForm();
6974
}
75+
76+
async function issueDataChange() {
77+
await fetchForm();
78+
}
79+
80+
watch(
81+
form,
82+
async (newForm) => {
83+
if (newForm && props.formName === 'issue' && isOJS()) {
84+
await useWorkflowPublicationFormIssue(newForm);
85+
}
86+
},
87+
{immediate: true},
88+
);
7089
</script>

src/pages/workflow/components/publication/WorkflowPublicationFormIssue.vue

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/pages/workflow/composables/useWorkflowActions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import WorkflowVersionSideModal from '@/pages/workflow/components/publication/Wo
1212

1313
export const Actions = {
1414
WORKFLOW_VIEW_PUBLISHED_SUBMISSION: 'workflowViewPublishedSubmission',
15-
WORKFLOW_ASSIGN_TO_ISSUE: 'workflowAssignToIssue',
1615
WORKFLOW_VIEW_ACTIVITY_LOG: 'workflowViewActivityLog',
1716
WORKFLOW_VIEW_LIBRARY: 'workflowViewLibrary',
1817
WORKFLOW_ASSIGN_TO_ISSUE_AND_SCHEDULE_FOR_PUBLICATION:

src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOJS.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,7 @@ export const PublicationConfig = {
10041004
}) => {
10051005
return [
10061006
{
1007-
// component: 'WorkflowPublicationForm',
1008-
component: 'WorkflowPublicationFormIssue',
1007+
component: 'WorkflowPublicationForm',
10091008
props: {
10101009
formName: 'issue',
10111010
submission,

0 commit comments

Comments
 (0)