Skip to content

Refactor main listener into modular handler files and remove jQuery global#533

Merged
baimard merged 1 commit into
masterfrom
codex/refactor-src/js/main_listener.js
Jun 30, 2026
Merged

Refactor main listener into modular handler files and remove jQuery global#533
baimard merged 1 commit into
masterfrom
codex/refactor-src/js/main_listener.js

Conversation

@baimard

@baimard baimard commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Improve maintainability by splitting the large main_listener.js into focused handler modules for configuration, editable elements, products, selects and table actions.
  • Remove the implicit global jQuery injection to reduce dependency surface and avoid relying on provided globals from webpack.

Description

  • Added new handler modules: src/js/listener/handlers/configuration_handlers.js, editable_handlers.js, product_handlers.js, select_handlers.js, and table_handlers.js implementing focused event handling logic and utility functions such as openFolderPicker, saveEditableElement, duplicateItem, and updateLinkedListSelection.
  • Rewrote src/js/listener/main_listener.js to import and wire the new handlers, register granular event listeners (click, dblclick, change, keydown, focusout, mouseover) and consolidate logic into small functions like handleBodyClick, handleBodyChange, and handleBodyKeydown.
  • Removed jquery from devDependencies in package.json and eliminated the webpack.ProvidePlugin that injected jQuery globals from webpack.js to stop using implicit global jQuery.

Testing

  • Ran a webpack build using the existing config (webpack --config webpack.js) and the build completed without errors.
  • No automated unit tests were added or run as part of this change.

Codex Task

@baimard baimard merged commit 1a5cb89 into master Jun 30, 2026
2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e41c6e1f2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread webpack.js
"window.jQuery": "jquery",
jquery: 'jquery'
}),
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore jquery provisioning for $ usages

Removing the webpack ProvidePlugin leaves existing bundled code with unresolved $ references: globalConfiguration() is used by the app entry points and still reaches $ in src/js/modules/mainFunction.js (for example configureDT, path, and checkSelect), and the show pages call Client.getClientByIdDevis($("#devisid")...) directly. In a Nextcloud page that does not provide a global jQuery, those paths will now throw ReferenceError: $ is not defined at runtime, so keep the provider or replace the remaining $ calls with explicit imports/plain DOM APIs before removing it.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant