Skip to content

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 Ljudevit and pspanja 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.

4 participants