How to generate/control forms on Workflow/Publications #10331
Replies: 2 comments 3 replies
-
Thanks for walking me through this, @jardakotesovec! I agree with your proposal to add an endpoint that exposes form state, potentially with a new e.g. submission, which can be used from the UI to update the VueJS state on a pre-existing form. I'd suggest prefixing the endpoint with a Down the road I think we're likely to reduce our server-side form generation, eventually doing all of that in VueJS. But that's too big for 3.5, so we're looking probably at an interim solution for 3.5 that's subject to change in 3.6 or 3.7 (when we have a good pattern to replace it fully on the client side and have the time to reduce tech debt). So re-using the existing PHP form classes as proposed makes sense as a limited intervention. We talked a little about whether to code this up as a one-by-one exposure of form state at different API URLs, vs. allowing several to be fetched at once in a batch, and my intuition is that a batched fetch of several forms might be harder to maintain. But coding this up as a proof of concept might reveal what's easier/harder. |
Beta Was this translation helpful? Give feedback.
-
I'll do a bit more thinking about this, but some initial first thoughts: I think taking approach number 2 of creating dedicated API endpoints is probably the best solution for our needs at the moment. I also like the idea of keeping them to a To @asmecher point of whether these should be coded on a one-by-one basis or grouping them, I would favour having one API endpoint per thing we're trying to fetch. If we find we need things in batches, I suspect we could come up with some pattern to collect these nicely in JS, but as these things grow in complexity, having one endpoint do only one thing seems like a good approach. |
Beta Was this translation helpful? Give feedback.
-
Issue description
There is long tradition on OJS creating Form configurations on backend PHP side. This will provide configuration for form and individual fields and than its rendered by Vue.js Form component. We are always passing these configurations on the page load as part of the page state.
This mostly works fine, but want to explore scenario where this approach is causing some tricky duplicated coding.
In 3.4, if you go to Workflow page as part of that page load it also generates all forms that are related for Publication (abstractTitle, metadata, citations, identifiers, issue, license). And these forms are generated in context of current publication and ready to be displayed with data and everything.
Where it gets problematic is once you have multiple publication versions and you switch between these. To update the forms with the different publication object, it unfortunately needs to do more than just update form values. But also handle things like maxLimit for abstract, or correct description for licenses base on given publication. These special cases are handled here and here. Thats not ideal.
And for 3.5 I would make it even worse. Because we have page load only for submission listing - so that opportunity for me to pass the form configurations to the client side. But these have even more thing missing (metadataLocales, other tricky fields description that require publication data), because at that point dashboard controller don't know what submission user will open.
Ideas how to make it better
I can think of only two options how to get around it:
Generate some forms client side - we might want to consider this approach in future. But this would be significant decision, which would require significant work to provide helpers on JS side, similarly like we have FormComponent and all related classes.
Create dedicated API endpoint to return form configuration in context of given publication. That should be quite quick and easy addition to the API and could look like
GET
/submissions/{$submissionId}/publications/${publicationId}/form/titleAbstract
And it would simply return form configuration for given publication.
Implementation of such endpoint would roughly be something like:
I think the logic can be literally cherry-picked from the WorkflowHander.php.
Additional considerations
/submissions/{$submissionId}/publications/${publicationId}/component/titleAndAbstract
, so its more flexible.Beta Was this translation helpful? Give feedback.
All reactions