Feature #42510 » 0001-WIP-Stimulus-demo.patch
| 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' |
|
| 20 |
gem "importmap-rails" |
|
| 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 << |
| ... | ... | |
| 1934 | 1934 | |
| 1935 | 1935 |
def copy_object_url_link(url) |
| 1936 | 1936 |
link_to_function( |
| 1937 |
sprite_icon('copy-link', l(:button_copy_link)), 'copyTextToClipboard(this);',
|
|
| 1937 |
sprite_icon('copy-link', l(:button_copy_link)), {},
|
|
| 1938 | 1938 |
class: 'icon icon-copy-link', |
| 1939 |
data: {'clipboard-text' => url}
|
|
| 1939 |
data: {
|
|
| 1940 |
'clipboard-value': url, |
|
| 1941 |
controller: "clipboard", |
|
| 1942 |
action: "clipboard#copy", |
|
| 1943 |
'clipboard-target': "source", |
|
| 1944 |
} |
|
| 1940 | 1945 |
) |
| 1941 | 1946 |
end |
| 1942 | 1947 | |
| 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 |
// Configure Stimulus development experience |
|
| 6 |
application.debug = false |
|
| 7 |
window.Stimulus = application |
|
| 8 | ||
| 9 |
export { application }
|
|
| app/javascript/controllers/clipboard_controller.js | ||
|---|---|---|
| 1 |
import { Controller } from "@hotwired/stimulus"
|
|
| 2 | ||
| 3 |
export default class extends Controller {
|
|
| 4 |
static targets = [ "source" ] |
|
| 5 |
copy() {
|
|
| 6 |
navigator.clipboard.writeText(this.sourceTarget.dataset.clipboardValue).then(() => this.close()) |
|
| 7 |
} |
|
| 8 |
close() {
|
|
| 9 |
const drdn = this.sourceTarget.closest('.drdn.expanded')
|
|
| 10 |
if (drdn) {
|
|
| 11 |
drdn.classList.remove("expanded");
|
|
| 12 |
} |
|
| 13 |
} |
|
| 14 |
} |
|
| app/javascript/controllers/index.js | ||
|---|---|---|
| 1 |
// Import and register all your controllers from the importmap under controllers/* |
|
| 2 | ||
| 3 |
import { application } from "controllers/application"
|
|
| 4 | ||
| 5 |
// Eager load all controllers defined in the import map under controllers/**/*_controller |
|
| 6 |
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
|
| 7 |
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", preload: true |
|
| 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" |
|