Skip to content

Convert FormBuilder.js to module#8

Open
ViolanteCodes wants to merge 2 commits into
opensensor:mainfrom
ViolanteCodes:convert_form_builder_to_es_module
Open

Convert FormBuilder.js to module#8
ViolanteCodes wants to merge 2 commits into
opensensor:mainfrom
ViolanteCodes:convert_form_builder_to_es_module

Conversation

@ViolanteCodes

Copy link
Copy Markdown
Contributor

Converts FormBuilder.js to module that is then imported by the necessary templates, in preparation for splitting the file later. Removes the now unnecessary helper class from the FE test runner.

@matteius
matteius requested a review from Copilot July 24, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Not ready to approve

The template currently uses deferred module scripts to define FormBuilder but then references it from a classic script that executes before the module runs, causing a runtime FormBuilder is undefined error.

Pull request overview

This PR converts the Form Builder frontend script into an ES module so it can be imported directly (including by Vitest), removing the previous “evaluate source to extract class” helper.

Changes:

  • Export FormBuilder from form-builder.js as an ES module.
  • Update Vitest tests to import FormBuilder directly and delete the old loader helper.
  • Update the admin template to load form-builder.js as a module (but the current script ordering introduces a runtime error; see comment).
File summaries
File Description
tests_js/form-builder/setupCanvas.test.js Switches tests from helper-based class loading to direct ES module import.
tests_js/form-builder/initializePropertyFormTabs.test.js Switches tests from helper-based class loading to direct ES module import.
tests_js/form-builder/addFieldAtPosition.test.js Switches tests from helper-based class loading to direct ES module import.
tests_js/form-builder/helpers/loadFormBuilderClass.js Removes the no-longer-needed helper that evaluated the source to extract the class.
django_forms_workflows/templates/admin/django_forms_workflows/form_builder.html Updates script tags to load the Form Builder JS as a module (currently with a timing/ordering issue).
django_forms_workflows/static/django_forms_workflows/js/form-builder.js Exports FormBuilder as a named ES module export.

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread django_forms_workflows/templates/admin/django_forms_workflows/form_builder.html Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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