Project

General

Profile

Feature #42510 » 0001-Introduce-Stimulus-to-facilitate-JavaScript-moderniz.patch

Marius BĂLTEANU, 2025-04-06 20:19

View differences:

Gemfile
16 16
gem 'rubyzip', '~> 2.4.0'
17 17
gem 'propshaft', '~> 1.1.0'
18 18
gem 'rack', '>= 3.1.3'
19
gem "stimulus-rails", "~> 1.3"
20
gem "importmap-rails", "~> 2.0"
19 21

  
20 22
#  Ruby Standard Gems
21 23
gem 'csv', '~> 3.2.8'
app/helpers/application_helper.rb
1805 1805
    if Setting.wiki_tablesort_enabled?
1806 1806
      tags << javascript_include_tag('tablesort-5.2.1.min.js', 'tablesort-5.2.1.number.min.js')
1807 1807
    end
1808
    tags << javascript_include_tag('application', 'responsive')
1808
    tags << javascript_include_tag('application-legacy', 'responsive')
1809 1809
    unless User.current.pref.warn_on_leaving_unsaved == '0'
1810 1810
      warn_text = escape_javascript(l(:text_warn_on_leaving_unsaved))
1811 1811
      tags <<
app/javascript/application.js
1
import "controllers"
app/javascript/controllers/application.js
1
import { Application } from '@hotwired/stimulus'
2

  
3
const application = Application.start()
4

  
5
application.debug = false
6
window.Stimulus   = application
7

  
8
export { application }
app/javascript/controllers/index.js
1
import { application } from "controllers/application"
2
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
3
eagerLoadControllersFrom("controllers", application)
app/views/layouts/base.html.erb
10 10
<%= favicon %>
11 11
<%= stylesheet_link_tag 'jquery/jquery-ui-1.13.2', 'tribute-5.1.3', 'application', 'responsive', :media => 'all' %>
12 12
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
13
<%= javascript_importmap_tags %>
13 14
<%= javascript_heads %>
14 15
<%= heads_for_theme %>
15 16
<%= heads_for_auto_complete(@project) %>
bin/importmap
1
#!/usr/bin/env ruby
2

  
3
require_relative "../config/application"
4
require "importmap/commands"
config/importmap.rb
1
# Pin npm packages by running ./bin/importmap
2

  
3
pin "application"
4
pin "@hotwired/stimulus", to: "stimulus.min.js"
5
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
6
pin_all_from "app/javascript/controllers", under: "controllers"
(2-2/2)