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

NGSTACK-922 remove jquery #37

Merged
merged 4 commits into from
Nov 7, 2024
Merged

NGSTACK-922 remove jquery #37

merged 4 commits into from
Nov 7, 2024

Conversation

amalija-ramljak
Copy link
Member

Changes

  • removed all usages of jquery
  • functions exposed globally in window
  • kept the possibility of calling a method on all instances, but through a different function for clarity
  • cleaned up some code like the ternaries removing and adding classes
  • keeping track of existing instances based on instanceId passed during creation (last index of instances array)
    • old way was setting jquery data on jquery elements
  • creating new elements by creating a template element and setting its innerHTML to the trimmed template string, then reading content.firstChild
    • requires the string to have a single root element, but the code in general relies on there being a single wrapper for each item anyway
    • old way was just passing a string to jquery and letting it handle that
  • events are now CustomEvents, still dispatched from body and the element triggering them
    • I am not sure if this makes some difference compared to the events sent out by jquery, not sure where these are listened to and used

Note

  • I am uncertain how options work because the init file does not contain any options to initialise the elements with (nothing was passed even before to the jquery function)
  • if there is a limit, the add button is not really disabled from what I can see, the disabled behaviour is handled through code (was that way before), just has a class for the visuals I suppose

Testing

  • have a media-site (ibexa) project with the bundle installed
  • if tags bundle is installed
    • from vendor/netgen/tagsbundle/bundle/Resources/config/ibexa/admin/services.yaml remove netgen_tags.ibexa.admin.component.javascripts config
  • clone this repo in place of vendor/netgen/enhanced-selection-bundle
  • checkout NGSTACK-922-remove-jquery
  • clear cache
  • if possible or needed, test some options through data-* parameters (the names are like data-error_message, see the underscore in the name after the usual data- prefix)
  • in the admin, try to edit ng_category
    • should have no enhanced-selection related errors in the console, esp not jquery
    • add/remove items from a sckenhancedselection field
    • add new sckenhancedselection fields
    • save with empty fields to trigger errors
    • collapse with empty fields and save - should uncollapse

@emodric
Copy link
Member

emodric commented Oct 29, 2024

@Ljudevit @pspanja Please review.

@emodric emodric requested review from pspanja and Ljudevit October 29, 2024 12:30
Copy link
Member

@hknezevic hknezevic left a comment

Choose a reason for hiding this comment

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

I have tested and compared behaviour of the edit interface between the jquery-based implementation and the new one. Everything looks good and works as expected.

@emodric emodric merged commit 7af6c05 into master Nov 7, 2024
5 checks passed
@emodric
Copy link
Member

emodric commented Nov 7, 2024

Thanks @amalija-ramljak @hknezevic !

@emodric emodric deleted the NGSTACK-922-remove-jquery branch November 7, 2024 11:31
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