Skip to content
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

set projectURl and baseUrl on pre-request #56

Merged
merged 1 commit into from
May 20, 2022

Conversation

devonpis
Copy link
Contributor

this will fix the URL construction of data resource request from a select doesn't contain the projectId
eg.
before:
api.forms.platforms.qld.gov.au/form/627dd82559d38c6f610de8c7/submission?limit=10000&skip=0&data.label__regex=s&sort=data.submissionOrderBy
after:
api.forms.platforms.qld.gov.au/dev-zmuchxwdmdytntr/form/627dd82559d38c6f610de8c7/submission?limit=10000&skip=0&sort=data.submissionOrderBy

@devonpis devonpis requested a review from a team May 20, 2022 05:21
@devonpis devonpis merged commit c5508a4 into main May 20, 2022
@@ -15,6 +15,8 @@ const requestPluginHandler = (requestArgs, opts) => {
requestArgs.opts.base = requestArgs.formio.options.base;
requestArgs.opts.project = requestArgs.formio.options.project;
requestArgs.opts.namespace = requestArgs.formio.options.namespace;
Formio.setProjectUrl(requestArgs.formio.options.project);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm global, that is strange. how many of these 'gotchas' have we come accross.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actual did fix in few places, as in formio.js, there are few ocassions using Formio.getProjectUrl to contruct URL for internal request, such as PDF, nested Form, Select (using data resource). (not every component using this method to construct URL tho, eg. ReCaptcha)

by adding Formio.setProjectUrl in pre-request hook, hence update the global Formio just before the request, luckily we still can support multiple forms with this patch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the discovery, could you raise and issue on the formio js upstream project with examples where they missed local variable instead of global with the proviso to doing multi form on one page with different 'stages/projects'

@duttonw duttonw deleted the select-component-data-resource-hotfix branch November 20, 2022 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants