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

WIP: Enable and use import maps #3209

Merged
merged 27 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
33d8492
WIP: Enable and use import maps
heyapricot Oct 25, 2022
e0e2e78
Fix issue sidenav with nested options not opening
edwinthinks Oct 27, 2022
f09e678
Fix issue in which line items UI supported by cocoon was not working
edwinthinks Oct 28, 2022
fa0582e
Migrate turbo from webpack to importmaps
edwinthinks Oct 28, 2022
cf854ca
Fix dropdown not working
edwinthinks Oct 29, 2022
13fe042
Enabled Stimulus controllers via importmaps
heyapricot Oct 30, 2022
61fb082
Merge branch 'main' into implement-import-maps
edwinthinks Nov 15, 2022
aa197d9
Remove all webpacker steps in favor of importmaps
edwinthinks Nov 15, 2022
e9acb69
Merge branch 'main' into implement-import-maps
edwinthinks Dec 18, 2022
5ca5af3
Remove adding controller that does not exist
edwinthinks Dec 18, 2022
86f0b7e
Update to load stimulus controllers
edwinthinks Dec 18, 2022
16f681d
Fixes for fontawesome, select2, litepicker
Dec 29, 2022
14ed05d
Fixes for modals etc.
Dec 29, 2022
e1f458e
Update other layouts
Dec 29, 2022
24c0cdc
Fix precompile / remove JS
Dec 29, 2022
d541c86
More fixes!
Dec 30, 2022
166dfd4
Fix barcodes!
Dec 30, 2022
312abdc
Add filterrific
Dec 30, 2022
fc0ba8d
Add tab navigation
Dec 30, 2022
d2b60a0
Fix lint
Dec 31, 2022
f594a06
Merge branch 'main' into implement-import-maps
Jan 23, 2023
e68559b
Merge remote-tracking branch 'origin/main' into implement-import-maps
awwaiid Feb 12, 2023
12db666
Fix Gemfile.lock
Feb 13, 2023
7f726bc
Merge branch 'main' into implement-import-maps
Feb 19, 2023
87a8abc
Fix spec
Feb 19, 2023
a43f355
Hack to fix the close button not working.
Feb 21, 2023
28d2de5
add comments
Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ gem "jquery-rails"
gem "jquery-ui-rails"
# SASS CSS framework (nested selectors, variables, etc.)
gem "sass-rails"
# JavaScript bundler.
gem 'webpacker', '~> 5.0'
# Used to verify that the user is a human.
gem "recaptcha"
# Hotwire for SPA like without much JS
Expand Down Expand Up @@ -112,7 +110,7 @@ gem "clockwork"
gem "mini_racer", "~> 0.6.3"
gem "nokogiri", ">= 1.10.4"
gem "image_processing"
gem "sprockets", "~> 4.2.0"
gem "sprockets", "~> 4.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Had to downgrade this due to rails/sprockets#749 .

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like the system didn't like this downgrade very much :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

In what way?


group :production do
# Reduce the noise of logs and include custom fields to it for easier access
Expand Down Expand Up @@ -218,3 +216,5 @@ end

# Use Redis for Action Cable
gem "redis", "~> 5.0"

gem "importmap-rails", "~> 1.1"
21 changes: 8 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ GEM
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
importmap-rails (1.1.5)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -404,8 +407,6 @@ GEM
rack (2.2.6.2)
rack-protection (2.1.0)
rack
rack-proxy (0.7.0)
rack
rack-test (2.0.2)
rack (>= 1.3)
rails (7.0.4.2)
Expand Down Expand Up @@ -528,7 +529,6 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_range (3.0.0)
shellany (0.0.1)
shoulda-matchers (5.3.0)
activesupport (>= 5.2.0)
Expand All @@ -552,9 +552,9 @@ GEM
snaky_hash (2.0.0)
hashie
version_gem (~> 1.1)
sprockets (4.2.0)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
rack (> 1, < 3)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand Down Expand Up @@ -596,11 +596,6 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webpacker (5.4.3)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.7.0)
websocket (1.2.9)
websocket-driver (0.7.5)
Expand Down Expand Up @@ -654,6 +649,7 @@ DEPENDENCIES
httparty
icalendar
image_processing
importmap-rails (~> 1.1)
jbuilder
jquery-rails
jquery-ui-rails
Expand Down Expand Up @@ -695,7 +691,7 @@ DEPENDENCIES
simple_form
simplecov
skylight
sprockets (~> 4.2.0)
sprockets (~> 4.0.0)
standard (~> 1.0)
stimulus-rails
strong_migrations (= 1.4.2)
Expand All @@ -704,10 +700,9 @@ DEPENDENCIES
web-console
webdrivers (~> 5.2)
webmock (~> 3.18)
webpacker (~> 5.0)

RUBY VERSION
ruby 3.1.2p20

BUNDLED WITH
2.3.22
2.3.25
1 change: 0 additions & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
web: bundle exec rails s -p 3000
worker: bundle exec rails jobs:work
webpack: bin/webpack-dev-server
3 changes: 2 additions & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//= link filterrific/filterrific-spinner.gif
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
7 changes: 0 additions & 7 deletions app/assets/javascripts/adminlte.min.js

This file was deleted.

1 change: 0 additions & 1 deletion app/assets/javascripts/adminlte.min.js.map

This file was deleted.

108 changes: 0 additions & 108 deletions app/assets/javascripts/application.js

This file was deleted.

13 changes: 0 additions & 13 deletions app/assets/javascripts/cable.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails

import { Turbo } from "@hotwired/turbo-rails"

// Disable turbo by default to avoid issues with turbolinks
Turbo.session.drive = false
import jQuery from 'jquery'
window.jQuery = jQuery
window.$ = jQuery

import "../controllers/index"
import 'admin-lte'
Copy link
Collaborator

Choose a reason for hiding this comment

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

@heyapricot i was able to make the sidenav work again by importing it here after pinning it.

import "cocoon-js-vanilla";
import 'filterrific'
import { Turbo } from "@hotwired/turbo-rails"
import "trix"
import "@rails/actiontext"
import "stylesheets/application.scss"
import $ from 'jquery';

import {DateTime} from "luxon";
import Litepicker from 'litepicker';
import 'litepicker';
import { Calendar } from '@fullcalendar/core';
import luxonPlugin from '@fullcalendar/luxon'
import dayGridPlugin from '@fullcalendar/daygrid';
import listPlugin from '@fullcalendar/list';
import toastr from 'toastr';
import 'litepicker/dist/plugins/ranges';
import "@fortawesome/fontawesome-free/css/fontawesome.css";
import "@fortawesome/fontawesome-free/css/solid.css";
import "@fortawesome/fontawesome-free/css/regular.css";
import "@fortawesome/fontawesome-free/css/brands.css";
import "@fortawesome/fontawesome-free/css/v4-shims.css";
import "toastr/build/toastr.css"
import 'litepicker/ranges';

import 'bootstrap'
import 'controllers'

import 'utils/adjustments'
import 'utils/barcode_items'
import 'utils/barcode_scan'
import 'utils/deadline_day_pickers'
import 'utils/distributions_and_transfers'
import 'utils/donations'
import 'utils/purchases'

import Rails from "@rails/ujs"
Rails.start()

// Disable turbo by default to avoid issues with turbolinks
Turbo.session.drive = false

// Global toastr options
window.toastr = toastr;
Expand All @@ -47,7 +51,13 @@ function isShortHeightScreen() {
return $(window).height() < 768 && !isMobileResolution();
}


// es-module-shims calls DOMContentLoaded twice for some reason
document.addEventListener("DOMContentLoaded", function() {
const hash = window.location.hash;
if (hash) {
$('ul.nav a[href="' + hash + '"]').tab('show');
}
const isMobile = isMobileResolution();
const isShortHeight = isShortHeightScreen();

Expand Down Expand Up @@ -96,3 +106,5 @@ document.addEventListener("DOMContentLoaded", function() {
});
picker.setDateRange(startDate, endDate);
}, false);


5 changes: 0 additions & 5 deletions app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { Application } from "@hotwired/stimulus"
import { definitionsFromContext } from "@hotwired/stimulus-webpack-helpers"

const application = Application.start()
window.Stimulus = application;

const context = require.context("/", true, /\.js$/)
Stimulus.load(definitionsFromContext(context))

// Configure Stimulus development experience
application.debug = false
Expand Down
14 changes: 10 additions & 4 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName
// Import and register all your controllers from the importmap under controllers/*

import { application } from "./application"
import { application } from "controllers/application"

// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)

// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
// lazyLoadControllersFrom("controllers", application)
2 changes: 1 addition & 1 deletion app/javascript/controllers/select2_controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from "@hotwired/stimulus"
import Select2 from "select2"
import $ from 'jquery';
import "select2"

export default class extends Controller {
static values = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import $ from 'jquery';

/**
* Likely we can remove this since distribution_and_transfers.js seen to cover this use
*/
Expand Down Expand Up @@ -25,13 +27,12 @@ $(function() {
});

$(document).on("cocoon:after-insert", "form#new_adjustment", function(
e,
insertedItem
) {
e) {
const control = $(control_id);
const insertedItem = $(e.detail[2]);
insertedItem
.find("#_barcode-lookup-new_line_items")
.attr("id", `_barcode-lookup-${$(".nested-fields").size() - 1}`);
.attr("id", `_barcode-lookup-${$(".nested-fields").length - 1}`);
$.ajax({
url: control
.data("storage-location-inventory-path")
Expand Down
Loading