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

Replace postForm() with postFormData() #62

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

mbland
Copy link
Owner

@mbland mbland commented Dec 18, 2023

Because the Calculator module now supports multiple String Calculator implementations, there's no need for the main form to contain an action attribute. The default './add' URL is now defined as calculators.DEFAULT_ENDPOINT, and is referenced in the new calculators.defaultPost(). Calculator now ends up calling defaultPost(), with no need to know the POST URL.

As mentioned in the previous change, this will make it easy to add an implementation that talks to a separately running Tomcat backend eventually.

The core change wasn't very large and invasive, despite the apparent size of the commit. Several of the additional changes were basic housekeeping and refactorings that made sense to include at once.

Some of the additional changes and important details of the core change include:

  • Moves DocumentFragment + form comments from the deleted postForm() test into a new "Notes" section of strcalc/src/main/frontend/README.md.

  • Removes top-level apiUrl parameter, as the POST URL is now encapsulated in the calculator implementation function.

  • Deletes the 'impl' field from the FormData produced by the input form, since it's irrelevant to the implementation. It will actually cause the Tomcat backend to return a server error if it's included.

  • Deletes the now unused resolvedUrl() test helper.

  • Moved test/helpers.js to test/page-loader.js, since that's the only entity left in that module.

  • Moved setupFetchStub() from request.test.js to test/fetch-stub.js to reuse it in the new calculators.test.js.

Because the Calculator module now supports multiple String Calculator
implementations, there's no need for the main form to contain an action
attribute. The default './add' URL is now defined as
calculators.DEFAULT_ENDPOINT, and is referenced in the new
calculators.defaultPost(). Calculator now ends up calling defaultPost(),
with no need to know the POST URL.

As mentioned in the previous change, this will make it easy to add an
implementation that talks to a separately running Tomcat backend
eventually.

The core change wasn't very large and invasive, despite the apparent
size of the commit. Several of the additional changes were basic
housekeeping and refactorings that made sense to include at once.

Some of the additional changes and important details of the core change
include:

- Moves DocumentFragment + form comments from the deleted postForm()
  test into a new "Notes" section of
  strcalc/src/main/frontend/README.md.

- Removes top-level `apiUrl` parameter, as the POST URL is now
  encapsulated in the calculator implementation function.

- Deletes the 'impl' field from the FormData produced by the input form,
  since it's irrelevant to the implementation. It will actually cause
  the Tomcat backend to return a server error if it's included.

- Deletes the now unused resolvedUrl() test helper.

- Moved test/helpers.js to test/page-loader.js, since that's the only
  entity left in that module.

- Moved setupFetchStub() from request.test.js to test/fetch-stub.js to
  reuse it in the new calculators.test.js.
@mbland mbland self-assigned this Dec 18, 2023
@mbland mbland merged commit 9f4faad into main Dec 18, 2023
3 checks passed
@mbland mbland deleted the replace-postform-with-postformdata branch December 18, 2023 21:51
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.

None yet

1 participant