From ec8fe3bf28af5a90e3d32f22b38914373df22da1 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 14 Sep 2020 16:08:39 +0200 Subject: [PATCH] fixes import of JS dependencies --- Gemfile | 2 - Gemfile.lock | 5 --- app/frontend/packs/application.js | 44 +++++++++---------- app/frontend/packs/application.scss | 1 - .../src/javascript/lib}/devise-modal.js | 0 .../frontend/src/javascript/lib}/dirDisqus.js | 0 .../frontend/src/javascript/lib}/humanize.js | 0 .../frontend/src/javascript/lib}/polyfill.js | 8 ++-- .../javascript/lib}/summernote-ext-nugget.js | 0 .../src/stylesheets/application.scss.erb | 11 ++++- app/frontend/templates/profile/complete.html | 6 +-- app/frontend/templates/shared/_cart.html | 4 +- .../templates/shared/_member_form.html | 10 ++--- .../templates/stripe/payment_modal.html | 6 +-- config/webpack/environment.js | 7 ++- config/webpack/loaders/sass_erb.js | 9 ++++ lib/assets/.keep | 0 package.json | 1 + vendor/assets/components/.keep | 0 vendor/assets/javascripts/.keep | 0 vendor/assets/stylesheets/.keep | 0 yarn.lock | 12 +++++ 22 files changed, 76 insertions(+), 50 deletions(-) rename {vendor/assets/javascripts => app/frontend/src/javascript/lib}/devise-modal.js (100%) rename {vendor/assets/javascripts => app/frontend/src/javascript/lib}/dirDisqus.js (100%) rename {vendor/assets/javascripts => app/frontend/src/javascript/lib}/humanize.js (100%) rename {lib/assets/javascripts => app/frontend/src/javascript/lib}/polyfill.js (83%) rename {vendor/assets/javascripts => app/frontend/src/javascript/lib}/summernote-ext-nugget.js (100%) create mode 100644 config/webpack/loaders/sass_erb.js delete mode 100644 lib/assets/.keep delete mode 100644 vendor/assets/components/.keep delete mode 100644 vendor/assets/javascripts/.keep delete mode 100644 vendor/assets/stylesheets/.keep diff --git a/Gemfile b/Gemfile index e7fc752be..6f21bc9a6 100644 --- a/Gemfile +++ b/Gemfile @@ -10,8 +10,6 @@ gem 'bootsnap' gem 'puma', '3.12.6' gem 'webpacker', '~> 5.x' -# Use jquery as the JavaScript library -gem 'jquery-rails' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' gem 'jbuilder_cache_multi' diff --git a/Gemfile.lock b/Gemfile.lock index df35b479f..74e6b9bff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,10 +170,6 @@ GEM activesupport (>= 5.0.0) jbuilder_cache_multi (0.1.0) jbuilder (>= 1.5.0, < 3) - jquery-rails (4.3.5) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) json (2.3.1) jwt (2.2.1) kaminari (1.2.1) @@ -447,7 +443,6 @@ DEPENDENCIES icalendar jbuilder (~> 2.5) jbuilder_cache_multi - jquery-rails json (>= 2.3.0) kaminari listen (~> 3.0.5) diff --git a/app/frontend/packs/application.js b/app/frontend/packs/application.js index 39f43e015..51140cb08 100644 --- a/app/frontend/packs/application.js +++ b/app/frontend/packs/application.js @@ -2,51 +2,49 @@ import 'core-js/stable'; import 'regenerator-runtime/runtime'; import 'jquery'; -import 'jquery_ujs'; +import {} from 'jquery-ujs'; import 'bootstrap-sass'; -import 'polyfill'; +import '../src/javascript/lib/polyfill'; import 'angular'; import 'angular-cookies'; import 'angular-resource'; import 'angular-sanitize'; import 'angular-touch'; -import '@uirouter/angularjs/release/angular-ui-router'; -import 'angular-ui-bootstrap/dist/ui-bootstrap-tpls'; -import 'ui-select/dist/select'; -import 'moment/moment'; -import 'moment-timezone/builds/moment-timezone-with-data-2012-2022'; -import 'angular-ui-calendar/src/calendar'; -import 'fullcalendar/dist/fullcalendar'; -import 'angular-moment/angular-moment'; -import 'ngUpload/ng-upload'; +import '@uirouter/angularjs'; +import 'angular-ui-bootstrap'; +import 'ui-select'; +import 'moment'; +import 'moment-timezone'; +import 'angular-ui-calendar'; +import 'fullcalendar'; +import 'angular-moment'; +import 'ngUpload'; import 'jasny-bootstrap/js/fileinput'; -import 'holderjs/holder'; -import 'AngularDevise/lib/devise'; -import 'devise-modal'; -import 'angular-growl-v2/build/angular-growl'; -import 'angular-xeditable/dist/js/xeditable'; +import 'holderjs'; +import 'AngularDevise'; +import '../src/javascript/lib/devise-modal'; +import 'angular-growl-v2'; +import 'angular-xeditable'; import 'checklist-model/checklist-model'; import 'angular-unsavedchanges/lib/unsavedChanges'; import 'angular-loading-bar/src/loading-bar'; import 'angular-scroll/angular-scroll'; import 'angular-google-analytics/dist/angular-google-analytics'; -import 'dirDisqus'; -import 'humanize'; +import '../src/javascript/lib/dirDisqus'; +import '../src/javascript/lib/humanize'; import 'underscore/underscore'; import 'elasticsearch-browser/elasticsearch.angular'; import 'd3/d3'; import 'nvd3/build/nv.d3.js'; import 'twitter-fetcher'; -import 'app'; -import 'router'; import 'medium-editor/dist/js/medium-editor'; import 'angular-medium-editor/dist/angular-medium-editor'; import 'bootstrap-switch/dist/js/bootstrap-switch.min'; import 'angular-bootstrap-switch/dist/angular-bootstrap-switch.min'; import 'angular-base64-upload/dist/angular-base64-upload.min'; -import 'summernote/src/js/summernote'; +import 'summernote'; import 'angular-summernote/dist/angular-summernote'; -import 'summernote-ext-nugget'; +import '../src/javascript/lib/summernote-ext-nugget'; import 'jquery-minicolors/jquery.minicolors.js'; import 'angular-minicolors/angular-minicolors.js'; import 'angular-translate/dist/angular-translate'; @@ -66,7 +64,7 @@ import 'angular-hotkeys/build/hotkeys'; import 'hone/dist/hone'; import 'tether/dist/js/tether'; import 'angular-bind-html-compile/angular-bind-html-compile'; -import 'angular-ui-tour/dist/angular-ui-tour'; +import 'angular-ui-tour/app/angular-ui-tour'; import '../src/javascript/app.js'; import '../src/javascript/router.js.erb'; diff --git a/app/frontend/packs/application.scss b/app/frontend/packs/application.scss index 23738d3fc..2b21c586a 100644 --- a/app/frontend/packs/application.scss +++ b/app/frontend/packs/application.scss @@ -1,4 +1,3 @@ - @import '~ui-select/dist/select'; @import '~fullcalendar/dist/fullcalendar'; @import '~jasny-bootstrap/dist/css/jasny-bootstrap'; diff --git a/vendor/assets/javascripts/devise-modal.js b/app/frontend/src/javascript/lib/devise-modal.js similarity index 100% rename from vendor/assets/javascripts/devise-modal.js rename to app/frontend/src/javascript/lib/devise-modal.js diff --git a/vendor/assets/javascripts/dirDisqus.js b/app/frontend/src/javascript/lib/dirDisqus.js similarity index 100% rename from vendor/assets/javascripts/dirDisqus.js rename to app/frontend/src/javascript/lib/dirDisqus.js diff --git a/vendor/assets/javascripts/humanize.js b/app/frontend/src/javascript/lib/humanize.js similarity index 100% rename from vendor/assets/javascripts/humanize.js rename to app/frontend/src/javascript/lib/humanize.js diff --git a/lib/assets/javascripts/polyfill.js b/app/frontend/src/javascript/lib/polyfill.js similarity index 83% rename from lib/assets/javascripts/polyfill.js rename to app/frontend/src/javascript/lib/polyfill.js index 259a3ae15..5425e5460 100644 --- a/lib/assets/javascripts/polyfill.js +++ b/app/frontend/src/javascript/lib/polyfill.js @@ -1,7 +1,7 @@ if (typeof Object.assign !== 'function') { // Must be writable: true, enumerable: false, configurable: true - Object.defineProperty(Object, "assign", { - value: function assign(target, varArgs) { // .length of function is 2 + Object.defineProperty(Object, 'assign', { + value: function assign (target, varArgs) { // .length of function is 2 'use strict'; if (target == null) { // TypeError if undefined or null throw new TypeError('Cannot convert undefined or null to object'); @@ -28,8 +28,8 @@ if (typeof Object.assign !== 'function') { }); } -Number.isInteger = Number.isInteger || function(value) { +Number.isInteger = Number.isInteger || function (value) { return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; -}; \ No newline at end of file +}; diff --git a/vendor/assets/javascripts/summernote-ext-nugget.js b/app/frontend/src/javascript/lib/summernote-ext-nugget.js similarity index 100% rename from vendor/assets/javascripts/summernote-ext-nugget.js rename to app/frontend/src/javascript/lib/summernote-ext-nugget.js diff --git a/app/frontend/src/stylesheets/application.scss.erb b/app/frontend/src/stylesheets/application.scss.erb index cbe642b2a..2ff84d3d2 100644 --- a/app/frontend/src/stylesheets/application.scss.erb +++ b/app/frontend/src/stylesheets/application.scss.erb @@ -11,7 +11,16 @@ @import "app.buttons"; @import "app.components"; @import "app.plugins"; -@import "modules/*"; + +@import "modules/abuses"; +@import "modules/cookies"; +@import "modules/icalendar"; +@import "modules/invoice"; +@import "modules/members"; +@import "modules/settings"; +@import "modules/signup"; +@import "modules/stripe"; +@import "modules/tour"; @import "app.responsive"; diff --git a/app/frontend/templates/profile/complete.html b/app/frontend/templates/profile/complete.html index 30765affb..344e5418c 100644 --- a/app/frontend/templates/profile/complete.html +++ b/app/frontend/templates/profile/complete.html @@ -36,11 +36,11 @@ + clear
diff --git a/app/frontend/templates/shared/_cart.html b/app/frontend/templates/shared/_cart.html index b20de0a08..570128776 100644 --- a/app/frontend/templates/shared/_cart.html +++ b/app/frontend/templates/shared/_cart.html @@ -4,7 +4,7 @@
-

+

{{ 'app.shared.cart.select_one_or_more_slots_in_the_calendar' | translate:{SINGLE:limitToOneSlot} }}

@@ -117,7 +117,7 @@
-

+

{{ 'app.shared.cart.select_a_new_slot_in_the_calendar' | translate }}

diff --git a/app/frontend/templates/shared/_member_form.html b/app/frontend/templates/shared/_member_form.html index 8b37df6df..f277940d4 100644 --- a/app/frontend/templates/shared/_member_form.html +++ b/app/frontend/templates/shared/_member_form.html @@ -10,7 +10,7 @@
- +
@@ -453,7 +453,7 @@
- d + d
- d + d
-
d
+
d
-
E
+
E
diff --git a/app/frontend/templates/stripe/payment_modal.html b/app/frontend/templates/stripe/payment_modal.html index 8ef30a2e1..39a670ae4 100644 --- a/app/frontend/templates/stripe/payment_modal.html +++ b/app/frontend/templates/stripe/payment_modal.html @@ -40,9 +40,9 @@ diff --git a/config/webpack/environment.js b/config/webpack/environment.js index 25f93f891..877feac72 100644 --- a/config/webpack/environment.js +++ b/config/webpack/environment.js @@ -1,16 +1,21 @@ const { environment } = require('@rails/webpacker'); const htmlErb = require('./loaders/html_erb'); const jsErb = require('./loaders/js_erb'); +const sassErb = require('./loaders/sass_erb'); const html = require('./loaders/html'); const webpack = require('webpack'); environment.plugins.prepend('Provide', new webpack.ProvidePlugin({ $: 'jquery', - jQuery: 'jquery' + jQuery: 'jquery', + 'window.jQuery': 'jquery', + Hone: 'hone', + Tether: 'tether' })); environment.loaders.prepend('js.erb', jsErb); environment.loaders.prepend('html.erb', htmlErb); +environment.loaders.prepend('sass-erb', sassErb); environment.loaders.append('html', html); environment.splitChunks(); diff --git a/config/webpack/loaders/sass_erb.js b/config/webpack/loaders/sass_erb.js new file mode 100644 index 000000000..09fec0194 --- /dev/null +++ b/config/webpack/loaders/sass_erb.js @@ -0,0 +1,9 @@ +module.exports = { + test: /\.(scss|sass)\.erb$/, + enforce: 'pre', + exclude: /node_modules/, + loader: [ + 'rails-erb-loader', + 'sass-loader' + ] +}; diff --git a/lib/assets/.keep b/lib/assets/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/package.json b/package.json index fa82ecdc0..031c87faa 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "jasny-bootstrap": "3.1", "jquery": ">=3.5.0", "jquery-minicolors": "^2.1.10", + "jquery-ujs": "^1.2.2", "medium-editor": "4.4.0", "moment": "2.22", "moment-timezone": "0.5", diff --git a/vendor/assets/components/.keep b/vendor/assets/components/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/yarn.lock b/yarn.lock index ce1588007..abaf7663f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4769,11 +4769,23 @@ jquery-minicolors@^2.1.10: dependencies: jquery ">= 1.7.x" +jquery-ujs@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/jquery-ujs/-/jquery-ujs-1.2.2.tgz#6a8ef1020e6b6dda385b90a4bddc128c21c56397" + integrity sha1-ao7xAg5rbdo4W5CkvdwSjCHFY5c= + dependencies: + jquery ">=1.8.0" + "jquery@>= 1.7.x", jquery@>=1.7.1, jquery@>=1.9.0, jquery@>=3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.0.tgz#9980b97d9e4194611c36530e7dc46a58d7340fc9" integrity sha512-Xb7SVYMvygPxbFMpTFQiHh1J7HClEaThguL15N/Gg37Lri/qKyhRGZYzHRyLH8Stq3Aow0LsHO2O2ci86fCrNQ== +jquery@>=1.8.0: + version "3.5.1" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5" + integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg== + js-base64@^2.1.8: version "2.6.4" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4"