hotsheet 0.1.1 → 0.2.0
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 +21 -34
- data/app/assets/hotsheet.css +1 -0
- data/app/assets/hotsheet.js +33 -0
- data/app/controllers/hotsheet/application_controller.rb +2 -4
- data/app/controllers/hotsheet/sheets_controller.rb +47 -0
- data/app/helpers/hotsheet/application_helper.rb +3 -3
- data/app/views/hotsheet/shared/_nav.html.erb +14 -0
- data/app/views/hotsheet/sheets/error.html.erb +1 -0
- data/app/views/hotsheet/sheets/index.html.erb +20 -0
- data/app/views/hotsheet/sheets/root.html.erb +1 -0
- data/app/views/layouts/hotsheet/application.html.erb +7 -7
- data/config/routes.rb +6 -5
- data/lib/generators/templates/hotsheet.rb +7 -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 +17 -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/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/config/locales/en.yml +0 -5
- data/lib/hotsheet/configuration.rb +0 -59
- data/lib/hotsheet/editable_attributes.rb +0 -24
- data/vendor/assets/stylesheets/hotsheet/pagy.css +0 -37
@@ -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/routes.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Hotsheet::Engine.routes.draw do
|
4
|
-
|
4
|
+
next unless defined? Rails::Server
|
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
|
+
Hotsheet.sheets.each_key do |sheet_name|
|
7
|
+
resources sheet_name, sheet_name:, controller: :sheets, only: %i[index update]
|
10
8
|
end
|
9
|
+
|
10
|
+
root "sheets#root"
|
11
|
+
match "*path", to: "sheets#error", via: :all
|
11
12
|
end
|
@@ -1,9 +1,12 @@
|
|
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?tab=readme-ov-file#usage.
|
5
|
+
# The ID is included by default. It is always the first column.
|
5
6
|
|
6
|
-
|
7
|
-
#
|
7
|
+
Hotsheet.configure do
|
8
|
+
# sheet :User do
|
9
|
+
# column :name
|
10
|
+
# column :birthdate, editable: false
|
8
11
|
# end
|
9
12
|
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
|
+
CONFIG = {}.freeze
|
16
|
+
|
17
|
+
attr_reader :config
|
18
|
+
|
19
|
+
def configure(config = {}, &sheets)
|
20
|
+
@config = [merge_config!(CONFIG, config), sheets]
|
21
|
+
self
|
17
22
|
end
|
18
23
|
|
19
|
-
def
|
20
|
-
@
|
24
|
+
def sheets
|
25
|
+
@sheets ||= begin
|
26
|
+
@sheets = {}
|
27
|
+
instance_eval(&@config.pop)
|
28
|
+
@sheets
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
|
-
def
|
24
|
-
|
32
|
+
def t(key)
|
33
|
+
I18n.t key, scope: "hotsheet"
|
34
|
+
rescue I18n::MissingTranslationData
|
35
|
+
I18n.with_locale(:en) { I18n.t key, scope: "hotsheet" }
|
36
|
+
end
|
37
|
+
|
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.0
|
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,36 @@ 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/
|
41
|
+
- app/controllers/hotsheet/sheets_controller.rb
|
110
42
|
- app/helpers/hotsheet/application_helper.rb
|
111
|
-
- app/views/hotsheet/
|
112
|
-
- app/views/hotsheet/
|
113
|
-
- app/views/
|
114
|
-
- app/views/
|
43
|
+
- app/views/hotsheet/shared/_nav.html.erb
|
44
|
+
- app/views/hotsheet/sheets/error.html.erb
|
45
|
+
- app/views/hotsheet/sheets/index.html.erb
|
46
|
+
- app/views/hotsheet/sheets/root.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
|
-
- config/locales/en.yml
|
119
48
|
- config/routes.rb
|
120
49
|
- lib/generators/hotsheet/install_generator.rb
|
121
50
|
- lib/generators/templates/hotsheet.rb
|
122
51
|
- lib/hotsheet.rb
|
123
|
-
- lib/hotsheet/
|
124
|
-
- lib/hotsheet/
|
52
|
+
- lib/hotsheet/column.rb
|
53
|
+
- lib/hotsheet/config.rb
|
125
54
|
- lib/hotsheet/engine.rb
|
55
|
+
- lib/hotsheet/sheet.rb
|
126
56
|
- lib/hotsheet/version.rb
|
127
|
-
- vendor/assets/stylesheets/hotsheet/pagy.css
|
128
57
|
homepage: https://github.com/renuo/hotsheet
|
129
58
|
licenses:
|
130
59
|
- MIT
|
131
60
|
metadata:
|
132
|
-
homepage_uri: https://github.com/renuo/hotsheet
|
133
61
|
source_code_uri: https://github.com/renuo/hotsheet
|
62
|
+
bug_tracker_uri: https://github.com/renuo/hotsheet/issues
|
134
63
|
changelog_uri: https://github.com/renuo/hotsheet/blob/main/CHANGELOG.md
|
135
64
|
documentation_uri: https://github.com/renuo/hotsheet/blob/main/README.md
|
136
65
|
rubygems_mfa_required: 'true'
|
137
|
-
post_install_message:
|
138
66
|
rdoc_options: []
|
139
67
|
require_paths:
|
140
68
|
- lib
|
@@ -142,15 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
70
|
requirements:
|
143
71
|
- - ">="
|
144
72
|
- !ruby/object:Gem::Version
|
145
|
-
version: 3.
|
73
|
+
version: 3.1.0
|
146
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
75
|
requirements:
|
148
76
|
- - ">="
|
149
77
|
- !ruby/object:Gem::Version
|
150
78
|
version: '0'
|
151
79
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
153
|
-
signing_key:
|
80
|
+
rubygems_version: 3.6.9
|
154
81
|
specification_version: 4
|
155
|
-
summary:
|
82
|
+
summary: Database GUI for Rails.
|
156
83
|
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
|
-
}
|
@@ -1,153 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
*= require_tree .
|
6
|
-
*= require_self
|
7
|
-
*= require hotsheet/pagy
|
8
|
-
*/
|
9
|
-
|
10
|
-
:root {
|
11
|
-
--sidebar-width: 12rem;
|
12
|
-
--main-padding-x: 2rem;
|
13
|
-
--main-padding-y: 2rem;
|
14
|
-
|
15
|
-
--body-font: 400 16px system-ui, Roboto, Helvetica, Arial, sans-serif;
|
16
|
-
--bg-color: lightgray;
|
17
|
-
--success-color: green;
|
18
|
-
--alert-color: yellow;
|
19
|
-
--notice-color: blue;
|
20
|
-
--error-color: red;
|
21
|
-
|
22
|
-
--td-padding: 0.5rem;
|
23
|
-
}
|
24
|
-
|
25
|
-
body {
|
26
|
-
font: var(--body-font);
|
27
|
-
margin: 0;
|
28
|
-
}
|
29
|
-
|
30
|
-
main {
|
31
|
-
margin-left: var(--sidebar-width);
|
32
|
-
padding: var(--main-padding-y) var(--main-padding-x);
|
33
|
-
}
|
34
|
-
|
35
|
-
aside {
|
36
|
-
background-color: var(--bg-color);
|
37
|
-
border-right: 1px solid gray;
|
38
|
-
height: 100%;
|
39
|
-
left: 0;
|
40
|
-
overflow-y: auto;
|
41
|
-
position: fixed;
|
42
|
-
top: 0;
|
43
|
-
width: var(--sidebar-width);
|
44
|
-
|
45
|
-
ul {
|
46
|
-
display: flex;
|
47
|
-
flex-direction: column;
|
48
|
-
margin: 0;
|
49
|
-
padding: 0.5rem;
|
50
|
-
|
51
|
-
a {
|
52
|
-
border-radius: 0.5rem;
|
53
|
-
color: green;
|
54
|
-
font-weight: 700;
|
55
|
-
overflow: hidden;
|
56
|
-
padding: 0.5rem;
|
57
|
-
text-decoration: none;
|
58
|
-
text-overflow: ellipsis;
|
59
|
-
white-space: nowrap;
|
60
|
-
|
61
|
-
&:hover {
|
62
|
-
background-color: darkgray;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
h1 {
|
69
|
-
margin: 0 0 1rem 0;
|
70
|
-
}
|
71
|
-
|
72
|
-
table {
|
73
|
-
border-collapse: collapse;
|
74
|
-
|
75
|
-
th,
|
76
|
-
td {
|
77
|
-
border: 1px solid var(--bg-color);
|
78
|
-
text-align: left;
|
79
|
-
}
|
80
|
-
|
81
|
-
th {
|
82
|
-
background-color: var(--bg-color);
|
83
|
-
padding: var(--td-padding);
|
84
|
-
}
|
85
|
-
|
86
|
-
.readonly-attribute {
|
87
|
-
min-height: 1rem;
|
88
|
-
min-width: 1rem;
|
89
|
-
}
|
90
|
-
|
91
|
-
.editable-input {
|
92
|
-
background-color: transparent;
|
93
|
-
border: none;
|
94
|
-
font: var(--body-font);
|
95
|
-
padding: var(--td-padding);
|
96
|
-
width: calc(100% - var(--td-padding) * 2);
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
.flash-container {
|
101
|
-
position: fixed;
|
102
|
-
display: flex;
|
103
|
-
flex-direction: column;
|
104
|
-
bottom: 1rem;
|
105
|
-
right: 1rem;
|
106
|
-
gap: 1rem;
|
107
|
-
max-width: calc(100% - var(--sidebar-width) - var(--main-padding-x));
|
108
|
-
|
109
|
-
.flash {
|
110
|
-
border-radius: 0.4rem;
|
111
|
-
padding: 0.75rem 1.25rem;
|
112
|
-
display: flex;
|
113
|
-
justify-content: space-between;
|
114
|
-
align-items: center;
|
115
|
-
gap: 1rem;
|
116
|
-
|
117
|
-
&.success {
|
118
|
-
background-color: rgb(from var(--success-color) r g b / 80%);
|
119
|
-
}
|
120
|
-
|
121
|
-
&.alert {
|
122
|
-
background-color: rgb(from var(--alert-color) r g b / 80%);
|
123
|
-
}
|
124
|
-
|
125
|
-
&.notice {
|
126
|
-
background-color: rgb(from var(--notice-color) r g b / 80%);
|
127
|
-
}
|
128
|
-
|
129
|
-
&.error {
|
130
|
-
background-color: rgb(from var(--error-color) r g b / 80%);
|
131
|
-
}
|
132
|
-
|
133
|
-
.btn-close {
|
134
|
-
background-color: transparent;
|
135
|
-
border: none;
|
136
|
-
cursor: pointer;
|
137
|
-
font-size: 1.5rem;
|
138
|
-
}
|
139
|
-
|
140
|
-
&.closing {
|
141
|
-
animation: fade-out 0.5s ease-in forwards;
|
142
|
-
}
|
143
|
-
}
|
144
|
-
}
|
145
|
-
|
146
|
-
@keyframes fade-out {
|
147
|
-
from {
|
148
|
-
opacity: 1;
|
149
|
-
}
|
150
|
-
to {
|
151
|
-
opacity: 0;
|
152
|
-
}
|
153
|
-
}
|