-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose publication forms via API #10336
Comments
Hey @jardakotesovec, I've done some initial testing with this and this approach seems good. With the endpoint returning the JSON from |
@ewhanson This issue is just expose via API. I will use that on ui-library side of things. Workflow handlers eventually will be removed completely. Once we have all apps moved to the side modal workflow. |
Perfect, thanks @jardakotesovec. |
Implementation overviewCopy over existing form creation to an API endpoint and return as JSON the results of I did some initial exploring with the Example
Route::get('{submissionId}/publications/{publicationId}/_components/titleAbstract', $this->getTitleAbstractComponent(...))
->name('submission.publication.components.titleAbstract')
->whereNumber(['submissionId', 'publicationId']);
public function getTitleAbstractComponent(Request $illuminateRequest): JsonResponse
{
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION);
$context = $this->getRequest()->getContext();
if ($submission->getData('contextId') !== $context->getId()) {
$context = app()->get('context')->get($submission->getData('contextId'));
}
$publication = Repo::publication()->get((int) $illuminateRequest->route('publicationId'));
$locales = collect($context->getSupportedSubmissionMetadataLocaleNames() + $submission->getPublicationLanguageNames())
->map(fn (string $name, string $locale) => ['key' => $locale, 'label' => $name])
->sortBy('key')
->values()
->toArray();
$latestPublicationApiUrl = $this->getRequest()->getDispatcher()->url($this->getRequest(), Application::ROUTE_API, $context->getData('urlPath'), 'submissions/' . $submission->getId() . '/publications/' . $publication->getId());
$section = Repo::section()->get($publication->getData('sectionId'), $context->getId());
$titleAbstractForm = new TitleAbstractForm(
$latestPublicationApiUrl,
$locales,
$publication,
(int) $section->getData('wordCount'),
!$section->getData('abstractsNotRequired')
);
return response()->json($titleAbstractForm->getConfig(), Response::HTTP_OK);
}
|
Hey @taslangraham, could you have a look at this issue? I've tried to capture all the relevant details above, but if anything is unclear, please let me know. Thanks! |
@ewhanson Thank you! |
@ewhanson sure thing! |
…ssueEntryForm) via API
…to utility method
…tleAbstractForm, & IssueEntryForm) via API
…tleAbstractForm, & IssueEntryForm) via API
…tleAbstractForm, & IssueEntryForm) via API
…to utility method
…tleAbstractForm, & IssueEntryForm) via API
…to utility method
…to utility method
…to utility method
Ready for review @ewhanson PRs
|
Looks really good @taslangraham! Just a few comments, but otherwise ready to go! |
…to utility method
…tleAbstractForm, & IssueEntryForm) via API
Thanks for the review @ewhanson! I've made the changes you suggested. If there are no objections, I'll go ahead and merge |
Looks good @taslangraham. Feel free to merge! |
@taslangraham @ewhanson Thanks guys! Great work.. will connect it with the UI once its merged and let you know if there are any issues, but looking promising! :-) |
All merged @jardakotesovec @ewhanson |
Just notice that if I hit this endpoint I get following PHP warnings.. but no idea whether its concern or not..
|
Actually this seems to be present for almost any request.. Therefore not related to this one. Sorry for noise.. |
Describe the issue
There are challenges when the forms are both manipulated client and server side. In future we might shift to client side form building. But for current efforts with new submission listing and workflow, it will be best to just expose the forms as private API. More detail discussion is available here - #10331
Proposed solution
This is based on the discussion linked above. I am ok with details being different (different url, multiple forms together or individual, etc) as long as I can get to them via API.
I propose example following url, that would expose individual forms
GET
/submissions/{submissionId}/publications/{publicationId}/_components/titleAbstract
Which would return json from
titleAbstractForm->getConfig()
.Publicaton forms
Following forms needs to be exposed
In terms of implementation its mostly about cherry-picking from PKPWorkflowHandler.php for common forms, and WorkflowHandler.php for ojs specific forms + this handler might modify some of the pkp-lib forms.
Considerations
In terms of the permissions - publications forms are presented to editors and authors, not reviewers. But in general following permissions that are in place for given /publications/{$publicationId} should be good starting point.
What application are you using?
OJS version 3.5
The text was updated successfully, but these errors were encountered: