hotsheet 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +45 -38
- data/app/assets/hotsheet.css +1 -0
- data/app/assets/hotsheet.js +33 -0
- data/app/controllers/hotsheet/application_controller.rb +7 -3
- data/app/controllers/hotsheet/home_controller.rb +9 -0
- data/app/controllers/hotsheet/sheets_controller.rb +45 -0
- data/app/views/hotsheet/home/error.html.erb +1 -0
- data/app/views/hotsheet/home/show.html.erb +1 -0
- data/app/views/hotsheet/shared/_nav.html.erb +14 -0
- data/app/views/hotsheet/sheets/index.html.erb +20 -0
- data/app/views/layouts/hotsheet/application.html.erb +7 -7
- data/config/locales/en.yml +3 -3
- data/config/routes.rb +5 -5
- data/lib/generators/templates/hotsheet.rb +14 -4
- data/lib/hotsheet/column.rb +31 -0
- data/lib/hotsheet/config.rb +29 -0
- data/lib/hotsheet/engine.rb +5 -4
- data/lib/hotsheet/sheet.rb +44 -0
- data/lib/hotsheet/version.rb +1 -1
- data/lib/hotsheet.rb +38 -12
- metadata +18 -90
- data/CHANGELOG.md +0 -22
- data/app/assets/config/hotsheet.js +0 -2
- data/app/assets/javascripts/hotsheet/application.js +0 -1
- data/app/assets/javascripts/hotsheet/channels/consumer.js +0 -3
- data/app/assets/javascripts/hotsheet/channels/inline_edit_channel.js +0 -3
- data/app/assets/javascripts/hotsheet/controllers/application.js +0 -8
- data/app/assets/javascripts/hotsheet/controllers/editable_attribute_controller.js +0 -39
- data/app/assets/javascripts/hotsheet/controllers/flash_controller.js +0 -8
- data/app/assets/stylesheets/hotsheet/application.css +0 -153
- data/app/channels/application_cable/channel.rb +0 -6
- data/app/channels/application_cable/connection.rb +0 -6
- data/app/channels/inline_edit_channel.rb +0 -9
- data/app/controllers/hotsheet/pages_controller.rb +0 -43
- data/app/helpers/hotsheet/application_helper.rb +0 -7
- data/app/views/hotsheet/pages/_editable_attribute.html.erb +0 -15
- data/app/views/hotsheet/pages/index.html.erb +0 -27
- data/app/views/layouts/hotsheet/_flash.html.erb +0 -10
- data/app/views/layouts/hotsheet/_sidebar.html.erb +0 -11
- data/config/initializers/hotsheet/content_security_policy.rb +0 -14
- data/config/initializers/hotsheet/pagy.rb +0 -7
- data/lib/hotsheet/configuration.rb +0 -59
- data/lib/hotsheet/editable_attributes.rb +0 -24
- data/vendor/assets/stylesheets/hotsheet/pagy.css +0 -37
@@ -0,0 +1,14 @@
|
|
1
|
+
<nav class="nav" data-controller="nav">
|
2
|
+
<ul>
|
3
|
+
<li><%= link_to Hotsheet.t("title"), root_path, class: "title" %></li>
|
4
|
+
</ul>
|
5
|
+
<ul class="sheets">
|
6
|
+
<% Hotsheet.sheets.each_with_index do |entry, index| %>
|
7
|
+
<li>
|
8
|
+
<% sheet_name, sheet = entry %>
|
9
|
+
<%= link_to sheet.model.model_name.human(count: 2), sheets_path(sheet_name),
|
10
|
+
class: ("active" if params[:sheet_name] == sheet_name), data: { x: index } %>
|
11
|
+
</li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</nav>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="table" spellcheck="false" data-controller="sheets">
|
2
|
+
<% @columns.each_with_index do |entry, x_index| %>
|
3
|
+
<% column_name, column = entry %>
|
4
|
+
<% editable = column.editable? %>
|
5
|
+
|
6
|
+
<div class="column">
|
7
|
+
<span class="cell header" data-name="<%= column_name %>">
|
8
|
+
<%= @sheet.model.human_attribute_name column_name %>
|
9
|
+
</span>
|
10
|
+
|
11
|
+
<% @cells[x_index]&.each_with_index do |value, y_index| %>
|
12
|
+
<% if editable %>
|
13
|
+
<span class="cell" tabindex="0" data-xy="<%= "#{x_index},#{y_index}" %>"><%= value %></span>
|
14
|
+
<% else %>
|
15
|
+
<span class="cell readonly"><%= value %></span>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
@@ -1,21 +1,21 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html lang="<%= I18n.locale %>">
|
3
3
|
<head>
|
4
|
-
<title
|
4
|
+
<title><%= Hotsheet.t "title" %></title>
|
5
5
|
<meta charset="utf-8">
|
6
6
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
7
7
|
<meta name="robots" content="noindex,nofollow">
|
8
8
|
<meta name="turbo-prefetch" content="false">
|
9
|
+
<meta name="turbo-refresh-method" content="morph">
|
10
|
+
<meta name="turbo-refresh-scroll" content="preserve">
|
9
11
|
<%= csrf_meta_tags %>
|
10
|
-
<%=
|
11
|
-
<%=
|
12
|
-
<%= javascript_include_tag "hotsheet/application", "data-turbolinks-track": :reload,
|
13
|
-
type: :module, nonce: content_security_policy_nonce, defer: true %>
|
12
|
+
<%= stylesheet_link_tag "hotsheet", nonce: true %>
|
13
|
+
<%= javascript_include_tag "hotsheet", nonce: true, defer: true %>
|
14
14
|
</head>
|
15
15
|
<body>
|
16
|
-
<%= render "
|
16
|
+
<%= render "hotsheet/shared/nav" %>
|
17
17
|
<main>
|
18
|
-
|
18
|
+
<div class="flash"></div>
|
19
19
|
<%= yield %>
|
20
20
|
</main>
|
21
21
|
</body>
|
data/config/locales/en.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Hotsheet::Engine.routes.draw do
|
4
|
-
root
|
4
|
+
root "home#show"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
Hotsheet.models.each do |model|
|
9
|
-
resources model.table_name, controller: :pages, only: %i[index update], model: model.name
|
6
|
+
scope ":sheet_name" do
|
7
|
+
resources controller: :sheets, only: %i[index update], as: :sheets
|
10
8
|
end
|
9
|
+
|
10
|
+
match "*path", to: "home#error", via: :all
|
11
11
|
end
|
@@ -1,9 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
Hotsheet.
|
4
|
-
|
3
|
+
# Configure the models to be used by Hotsheet.
|
4
|
+
# See https://github.com/renuo/hotsheet/blob/main/README.md#usage.
|
5
5
|
|
6
|
-
|
7
|
-
#
|
6
|
+
Hotsheet.configure do
|
7
|
+
# Configure the visible and editable columns for each model.
|
8
|
+
# The ID is included as the first column by default.
|
9
|
+
|
10
|
+
# sheet :User do
|
11
|
+
# column :name
|
12
|
+
# column :email, editable: false
|
13
|
+
# column :birthdate, editable: -> { rand > 0.5 }
|
8
14
|
# end
|
15
|
+
|
16
|
+
# Leave the block out to include all database columns.
|
17
|
+
|
18
|
+
# sheet :Post
|
9
19
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Hotsheet::Column
|
4
|
+
include Hotsheet::Config
|
5
|
+
|
6
|
+
attr_reader :config
|
7
|
+
|
8
|
+
CONFIG = {
|
9
|
+
editable: { allowed_classes: [FalseClass, Proc], default: true },
|
10
|
+
visible: { allowed_classes: [FalseClass, Proc], default: true }
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
def initialize(config)
|
14
|
+
@config = merge_config! CONFIG, config
|
15
|
+
end
|
16
|
+
|
17
|
+
def editable?
|
18
|
+
is? :editable
|
19
|
+
end
|
20
|
+
|
21
|
+
def visible?
|
22
|
+
is? :visible
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def is?(permission)
|
28
|
+
perm = @config[permission]
|
29
|
+
perm.is_a?(Proc) ? perm.call : perm
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hotsheet::Config
|
4
|
+
def merge_config!(default, custom)
|
5
|
+
config = default.transform_values { |value| value[:default] }
|
6
|
+
|
7
|
+
custom.each do |key, value|
|
8
|
+
unless default.key? key
|
9
|
+
raise Hotsheet::Error, "Config must be one of #{default.keys}, got '#{key}'"
|
10
|
+
end
|
11
|
+
|
12
|
+
ensure_allowed_value! key, value, default[key]
|
13
|
+
config[key] = value
|
14
|
+
end
|
15
|
+
|
16
|
+
config
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def ensure_allowed_value!(key, value, config)
|
22
|
+
allowed = config[:allowed_classes]
|
23
|
+
value = value.class
|
24
|
+
|
25
|
+
return if allowed.include? value
|
26
|
+
|
27
|
+
raise Hotsheet::Error, "Config '#{key}' must be one of #{allowed}, got '#{value}'"
|
28
|
+
end
|
29
|
+
end
|
data/lib/hotsheet/engine.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
isolate_namespace Hotsheet
|
3
|
+
class Hotsheet::Engine < Rails::Engine
|
4
|
+
isolate_namespace Hotsheet
|
6
5
|
|
7
|
-
|
6
|
+
if config.respond_to? :assets
|
7
|
+
config.assets.paths << Hotsheet::Engine.root.join("app/assets")
|
8
|
+
config.assets.precompile << %w[hotsheet.css hotsheet.js]
|
8
9
|
end
|
9
10
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Hotsheet::Sheet
|
4
|
+
include Hotsheet::Config
|
5
|
+
|
6
|
+
CONFIG = {}.freeze
|
7
|
+
|
8
|
+
attr_reader :config, :model
|
9
|
+
|
10
|
+
def initialize(name, config, &columns)
|
11
|
+
@config = merge_config! CONFIG, config
|
12
|
+
@model = name.to_s.constantize
|
13
|
+
@columns = {}
|
14
|
+
|
15
|
+
column :id, editable: false
|
16
|
+
columns ? instance_eval(&columns) : use_default_configuration
|
17
|
+
end
|
18
|
+
|
19
|
+
def columns
|
20
|
+
@columns.select { |_name, column| column.visible? }
|
21
|
+
end
|
22
|
+
|
23
|
+
def cells_for(columns)
|
24
|
+
@model.pluck(*columns.keys).transpose
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def use_default_configuration
|
30
|
+
@model.column_names[1..].each { |name| column name }
|
31
|
+
end
|
32
|
+
|
33
|
+
def column(name, config = {})
|
34
|
+
ensure_column_exists! name
|
35
|
+
|
36
|
+
@columns[name.to_s] = Hotsheet::Column.new config
|
37
|
+
end
|
38
|
+
|
39
|
+
def ensure_column_exists!(name)
|
40
|
+
return if @model.column_names.include? name.to_s
|
41
|
+
|
42
|
+
raise Hotsheet::Error, "Column must be one of #{@model.column_names}, got '#{name}'"
|
43
|
+
end
|
44
|
+
end
|
data/lib/hotsheet/version.rb
CHANGED
data/lib/hotsheet.rb
CHANGED
@@ -1,27 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "sprockets/railtie"
|
4
|
-
require "turbo-rails"
|
5
|
-
|
6
|
-
require "hotsheet/engine"
|
7
3
|
require "hotsheet/version"
|
8
|
-
require "hotsheet/
|
9
|
-
require "hotsheet/
|
4
|
+
require "hotsheet/engine"
|
5
|
+
require "hotsheet/config"
|
6
|
+
require "hotsheet/sheet"
|
7
|
+
require "hotsheet/column"
|
10
8
|
|
11
9
|
module Hotsheet
|
12
10
|
class Error < StandardError; end
|
13
11
|
|
14
12
|
class << self
|
15
|
-
|
16
|
-
|
13
|
+
include Config
|
14
|
+
|
15
|
+
attr_reader :config
|
16
|
+
|
17
|
+
CONFIG = {}.freeze
|
18
|
+
|
19
|
+
def configure(config = {}, &sheets)
|
20
|
+
@config = [merge_config!(CONFIG, config), sheets]
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def sheets
|
25
|
+
@sheets ||= begin
|
26
|
+
@sheets = {}
|
27
|
+
instance_eval(&@config.pop)
|
28
|
+
@sheets
|
29
|
+
end
|
17
30
|
end
|
18
31
|
|
19
|
-
|
20
|
-
|
32
|
+
I18N = Psych.load_file(Hotsheet::Engine.root.join("config/locales/en.yml"))["en"]["hotsheet"].freeze
|
33
|
+
|
34
|
+
def t(key)
|
35
|
+
I18n.t "hotsheet.#{key}", default: I18N[key]
|
21
36
|
end
|
22
37
|
|
23
|
-
|
24
|
-
|
38
|
+
private
|
39
|
+
|
40
|
+
def sheet(name, config = {}, &)
|
41
|
+
ensure_sheet_exists! name
|
42
|
+
|
43
|
+
sheet = Sheet.new(name, config, &)
|
44
|
+
@sheets[sheet.model.table_name] = sheet
|
45
|
+
end
|
46
|
+
|
47
|
+
def ensure_sheet_exists!(name)
|
48
|
+
return if Object.const_defined? name
|
49
|
+
|
50
|
+
raise Hotsheet::Error, "Unknown model '#{name}'"
|
25
51
|
end
|
26
52
|
end
|
27
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -24,64 +23,7 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: 6.1.0
|
27
|
-
-
|
28
|
-
name: pagy
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sprockets-rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: stimulus-rails
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: turbo-rails
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
description: This gem allows you to mount a view to manage your database using a table
|
84
|
-
view where you can edit DB records inline.
|
26
|
+
description: Manage your Rails database through a spreadsheet-like interface.
|
85
27
|
email:
|
86
28
|
- ignacio.sfeir@renuo.ch
|
87
29
|
- simon.isler@renuo.ch
|
@@ -91,50 +33,37 @@ executables: []
|
|
91
33
|
extensions: []
|
92
34
|
extra_rdoc_files: []
|
93
35
|
files:
|
94
|
-
- CHANGELOG.md
|
95
36
|
- LICENSE
|
96
37
|
- README.md
|
97
|
-
- app/assets/
|
98
|
-
- app/assets/
|
99
|
-
- app/assets/javascripts/hotsheet/channels/consumer.js
|
100
|
-
- app/assets/javascripts/hotsheet/channels/inline_edit_channel.js
|
101
|
-
- app/assets/javascripts/hotsheet/controllers/application.js
|
102
|
-
- app/assets/javascripts/hotsheet/controllers/editable_attribute_controller.js
|
103
|
-
- app/assets/javascripts/hotsheet/controllers/flash_controller.js
|
104
|
-
- app/assets/stylesheets/hotsheet/application.css
|
105
|
-
- app/channels/application_cable/channel.rb
|
106
|
-
- app/channels/application_cable/connection.rb
|
107
|
-
- app/channels/inline_edit_channel.rb
|
38
|
+
- app/assets/hotsheet.css
|
39
|
+
- app/assets/hotsheet.js
|
108
40
|
- app/controllers/hotsheet/application_controller.rb
|
109
|
-
- app/controllers/hotsheet/
|
110
|
-
- app/
|
111
|
-
- app/views/hotsheet/
|
112
|
-
- app/views/hotsheet/
|
113
|
-
- app/views/
|
114
|
-
- app/views/
|
41
|
+
- app/controllers/hotsheet/home_controller.rb
|
42
|
+
- app/controllers/hotsheet/sheets_controller.rb
|
43
|
+
- app/views/hotsheet/home/error.html.erb
|
44
|
+
- app/views/hotsheet/home/show.html.erb
|
45
|
+
- app/views/hotsheet/shared/_nav.html.erb
|
46
|
+
- app/views/hotsheet/sheets/index.html.erb
|
115
47
|
- app/views/layouts/hotsheet/application.html.erb
|
116
|
-
- config/initializers/hotsheet/content_security_policy.rb
|
117
|
-
- config/initializers/hotsheet/pagy.rb
|
118
48
|
- config/locales/en.yml
|
119
49
|
- config/routes.rb
|
120
50
|
- lib/generators/hotsheet/install_generator.rb
|
121
51
|
- lib/generators/templates/hotsheet.rb
|
122
52
|
- lib/hotsheet.rb
|
123
|
-
- lib/hotsheet/
|
124
|
-
- lib/hotsheet/
|
53
|
+
- lib/hotsheet/column.rb
|
54
|
+
- lib/hotsheet/config.rb
|
125
55
|
- lib/hotsheet/engine.rb
|
56
|
+
- lib/hotsheet/sheet.rb
|
126
57
|
- lib/hotsheet/version.rb
|
127
|
-
- vendor/assets/stylesheets/hotsheet/pagy.css
|
128
58
|
homepage: https://github.com/renuo/hotsheet
|
129
59
|
licenses:
|
130
60
|
- MIT
|
131
61
|
metadata:
|
132
|
-
homepage_uri: https://github.com/renuo/hotsheet
|
133
62
|
source_code_uri: https://github.com/renuo/hotsheet
|
63
|
+
bug_tracker_uri: https://github.com/renuo/hotsheet/issues
|
134
64
|
changelog_uri: https://github.com/renuo/hotsheet/blob/main/CHANGELOG.md
|
135
65
|
documentation_uri: https://github.com/renuo/hotsheet/blob/main/README.md
|
136
66
|
rubygems_mfa_required: 'true'
|
137
|
-
post_install_message:
|
138
67
|
rdoc_options: []
|
139
68
|
require_paths:
|
140
69
|
- lib
|
@@ -142,15 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
71
|
requirements:
|
143
72
|
- - ">="
|
144
73
|
- !ruby/object:Gem::Version
|
145
|
-
version: 3.
|
74
|
+
version: 3.1.0
|
146
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
76
|
requirements:
|
148
77
|
- - ">="
|
149
78
|
- !ruby/object:Gem::Version
|
150
79
|
version: '0'
|
151
80
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
153
|
-
signing_key:
|
81
|
+
rubygems_version: 3.6.9
|
154
82
|
specification_version: 4
|
155
|
-
summary:
|
83
|
+
summary: Database GUI for Rails.
|
156
84
|
test_files: []
|
data/CHANGELOG.md
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
<!-- ## [Unreleased](https://github.com/renuo/hotsheet/compare/v0.1.0..HEAD) -->
|
2
|
-
|
3
|
-
## [0.1.1](https://github.com/renuo/hotsheet/releases/tag/v0.1.1) (2025-02-03)
|
4
|
-
|
5
|
-
- Improve configuration file usage and logic ([@simon-isler])
|
6
|
-
- Configure compatible Ruby/Rails versions for testing ([@ignaciosy])
|
7
|
-
- Improve flash messages layout ([@ignaciosy])
|
8
|
-
- Form inputs are now always visible for usage simplicity ([@ignaciosy])
|
9
|
-
|
10
|
-
## [0.1.0](https://github.com/renuo/hotsheet/releases/tag/v0.1.0) (2024-11-05)
|
11
|
-
|
12
|
-
- Gem structure and initial configuration ([@ignaciosy])
|
13
|
-
- Inline editing table (([@simon-isler]) and ([@edmunteanu]))
|
14
|
-
- Dummy app for development and test ([@hunchr])
|
15
|
-
- Configuration for initializer, CI, lint, tests ([@hunchr])
|
16
|
-
- Generator `bin/rails g hotsheet:install` for copying initializer and mounting engine in routes ([@hunchr])
|
17
|
-
- Pagination for data tables ([@hunchr])
|
18
|
-
|
19
|
-
[@ignaciosy]: https://github.com/ignaciosy
|
20
|
-
[@hunchr]: https://github.com/hunchr
|
21
|
-
[@simon-isler]: https://github.com/simon-isler
|
22
|
-
[@edmunteanu]: https://github.com/edmunteanu
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require ./controllers/application
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { Application } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js"
|
2
|
-
import EditableAttributeController from "./controllers/editable_attribute_controller"
|
3
|
-
import FlashController from "./controllers/flash_controller"
|
4
|
-
|
5
|
-
window.Stimulus = Application.start()
|
6
|
-
|
7
|
-
Stimulus.register("editable-attribute", EditableAttributeController)
|
8
|
-
Stimulus.register("flash", FlashController)
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import { Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js"
|
2
|
-
|
3
|
-
export default class extends Controller {
|
4
|
-
static values = {
|
5
|
-
broadcastUrl: String,
|
6
|
-
resourceName: String,
|
7
|
-
resourceId: Number,
|
8
|
-
resourceInitialValue: String
|
9
|
-
}
|
10
|
-
|
11
|
-
static targets = ["attributeFormInput"]
|
12
|
-
|
13
|
-
broadcastEditIntent() { // TODO: trigger on input focus
|
14
|
-
const headers = {
|
15
|
-
"Content-Type": "application/json",
|
16
|
-
"X-CSRF-Token": document.querySelector("meta[name=csrf-token]").content,
|
17
|
-
}
|
18
|
-
const body = JSON.stringify({
|
19
|
-
broadcast: {
|
20
|
-
resource_name: this.resourceNameValue,
|
21
|
-
resource_id: this.resourceIdValue,
|
22
|
-
},
|
23
|
-
})
|
24
|
-
|
25
|
-
fetch(this.broadcastUrlValue, { method: "POST", headers, body })
|
26
|
-
}
|
27
|
-
|
28
|
-
submitForm(event) {
|
29
|
-
// Prevent standard submission triggered by Enter press
|
30
|
-
event.preventDefault()
|
31
|
-
|
32
|
-
const newValue = this.attributeFormInputTarget.value
|
33
|
-
if (this.resourceInitialValueValue === newValue) return;
|
34
|
-
|
35
|
-
// It's important to use requestSubmit() instead of simply submit() as the latter will circumvent the
|
36
|
-
// Turbo mechanism, causing the PATCH request to be submitted as HTML instead of TURBO_STREAM
|
37
|
-
this.attributeFormInputTarget.form.requestSubmit()
|
38
|
-
}
|
39
|
-
}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js"
|
2
|
-
|
3
|
-
export default class extends Controller {
|
4
|
-
close() {
|
5
|
-
this.element.addEventListener("animationend", () => { this.element.remove(); });
|
6
|
-
this.element.classList.add("closing");
|
7
|
-
}
|
8
|
-
}
|