mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 00:36:14 +02:00
Introduces Stimulus as a Javascript framework (#42510):
* old @application.js@ from @app/assets/javascripts@ become @application-legacy.js@ in favour of @application.js@ provided by Stimulus * adds @importmap@ gem to handle JavaScript modules using logical names that map to versioned/digested files Stimulus will be used for new functionality and, over time, to migrate existing features from JQuery / JQuery UI. git-svn-id: https://svn.redmine.org/redmine/trunk@23697 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -16,6 +16,8 @@ gem 'addressable'
|
|||||||
gem 'rubyzip', '~> 2.4.0'
|
gem 'rubyzip', '~> 2.4.0'
|
||||||
gem 'propshaft', '~> 1.1.0'
|
gem 'propshaft', '~> 1.1.0'
|
||||||
gem 'rack', '>= 3.1.3'
|
gem 'rack', '>= 3.1.3'
|
||||||
|
gem "stimulus-rails", "~> 1.3"
|
||||||
|
gem "importmap-rails", "~> 2.0"
|
||||||
|
|
||||||
# Ruby Standard Gems
|
# Ruby Standard Gems
|
||||||
gem 'csv', '~> 3.3.2'
|
gem 'csv', '~> 3.3.2'
|
||||||
|
|||||||
@@ -1805,7 +1805,7 @@ module ApplicationHelper
|
|||||||
if Setting.wiki_tablesort_enabled?
|
if Setting.wiki_tablesort_enabled?
|
||||||
tags << javascript_include_tag('tablesort-5.2.1.min.js', 'tablesort-5.2.1.number.min.js')
|
tags << javascript_include_tag('tablesort-5.2.1.min.js', 'tablesort-5.2.1.number.min.js')
|
||||||
end
|
end
|
||||||
tags << javascript_include_tag('application', 'responsive')
|
tags << javascript_include_tag('application-legacy', 'responsive')
|
||||||
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
||||||
warn_text = escape_javascript(l(:text_warn_on_leaving_unsaved))
|
warn_text = escape_javascript(l(:text_warn_on_leaving_unsaved))
|
||||||
tags <<
|
tags <<
|
||||||
|
|||||||
1
app/javascript/application.js
Normal file
1
app/javascript/application.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import "controllers"
|
||||||
8
app/javascript/controllers/application.js
Normal file
8
app/javascript/controllers/application.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { Application } from '@hotwired/stimulus'
|
||||||
|
|
||||||
|
const application = Application.start()
|
||||||
|
|
||||||
|
application.debug = false
|
||||||
|
window.Stimulus = application
|
||||||
|
|
||||||
|
export { application }
|
||||||
3
app/javascript/controllers/index.js
Normal file
3
app/javascript/controllers/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { application } from "controllers/application"
|
||||||
|
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||||
|
eagerLoadControllersFrom("controllers", application)
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
<%= favicon %>
|
<%= favicon %>
|
||||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.13.2', 'tribute-5.1.3', 'application', 'responsive', :media => 'all' %>
|
<%= stylesheet_link_tag 'jquery/jquery-ui-1.13.2', 'tribute-5.1.3', 'application', 'responsive', :media => 'all' %>
|
||||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||||
|
<%= javascript_importmap_tags %>
|
||||||
<%= javascript_heads %>
|
<%= javascript_heads %>
|
||||||
<%= heads_for_theme %>
|
<%= heads_for_theme %>
|
||||||
<%= heads_for_i18n %>
|
<%= heads_for_i18n %>
|
||||||
|
|||||||
4
bin/importmap
Normal file
4
bin/importmap
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require_relative "../config/application"
|
||||||
|
require "importmap/commands"
|
||||||
6
config/importmap.rb
Normal file
6
config/importmap.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Pin npm packages by running ./bin/importmap
|
||||||
|
|
||||||
|
pin "application"
|
||||||
|
pin "@hotwired/stimulus", to: "stimulus.min.js"
|
||||||
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
||||||
|
pin_all_from "app/javascript/controllers", under: "controllers"
|
||||||
Reference in New Issue
Block a user