[JS] Replace jquery-ujs with @rails/ujs

jquery-ujs has been deprecated in favor of @rails/ujs.
I wouldn't call the new one supported anymore, the rails team has already
invented a new way of doing things, but it's better that the older one.
Plus it's one dependency on jquery down.
This commit is contained in:
Earlopain 2022-12-20 20:04:01 +01:00
parent 1671c3bbc6
commit f1234653e2
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 10 additions and 8 deletions

View File

@ -5,7 +5,8 @@ function importAll(r) {
r.keys().forEach(r);
}
require('jquery-ujs');
import Rails from "@rails/ujs";
Rails.start();
// should start looking for nodejs replacements
importAll(require.context('../vendor', true, /\.js$/));

View File

@ -5,6 +5,7 @@ import Favorite from './favorites'
import PostSet from './post_sets'
import TagScript from './tag_script'
import { SendQueue } from './send_queue'
import Rails from '@rails/ujs'
let PostModeMenu = {};
@ -79,7 +80,7 @@ PostModeMenu.initialize_edit_form = function() {
}
},
complete: function() {
$.rails.enableFormElements($("#quick-edit-form"));
Rails.enableElement(document.getElementById("quick-edit-form"));
},
success: function(data) {
Post.update_data(data);

View File

@ -3,13 +3,13 @@
"packageManager": "yarn@1.22.19",
"private": true,
"dependencies": {
"@rails/ujs": "^7.0.4",
"@rails/webpacker": "^6.0.0-rc.5",
"babel-plugin-macros": "^3.1.0",
"core-js": "3.8",
"css-loader": "^6.3.0",
"css-minimizer-webpack-plugin": "^3.0.2",
"jquery-ui": "^1.12.1",
"jquery-ujs": "^1.2.2",
"mini-css-extract-plugin": "^2.3.0",
"rails-erb-loader": "^5.5.2",
"sass": "^1.42.1",

View File

@ -970,6 +970,11 @@
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==
"@rails/ujs@^7.0.4":
version "7.0.4"
resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.0.4.tgz#7fe5387d2d82b0547fdfc6667b424ec119c86b1e"
integrity sha512-UY9yQxBvtqXzXScslgPwZoQd16T0+z3P6BQS4lZDJFg5xVuMIgHkHQI6dhyWEt5l/qwbGaYX+YiZu6J+oxWPOw==
"@rails/webpacker@^6.0.0-rc.5":
version "6.0.0-rc.6"
resolved "https://registry.yarnpkg.com/@rails/webpacker/-/webpacker-6.0.0-rc.6.tgz#04af15dc33697e09aa492da54d2093cdd15573ff"
@ -2635,11 +2640,6 @@ jquery-ui@^1.12.1:
dependencies:
jquery ">=1.8.0 <4.0.0"
jquery-ujs@^1.2.2:
version "1.2.3"
resolved "https://registry.yarnpkg.com/jquery-ujs/-/jquery-ujs-1.2.3.tgz#dcac6026ab7268e5ee41faf9d31c997cd4ddd603"
integrity sha512-59wvfx5vcCTHMeQT1/OwFiAj+UffLIwjRIoXdpO7Z7BCFGepzq9T9oLVeoItjTqjoXfUrHJvV7QU6pUR+UzOoA==
"jquery@>=1.8.0 <4.0.0":
version "3.6.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.1.tgz#fab0408f8b45fc19f956205773b62b292c147a16"