hotsheet 0.1.0 → 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 +32 -35
- 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 -11
- metadata +17 -89
- data/CHANGELOG.md +0 -17
- 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 -6
- data/app/assets/javascripts/hotsheet/controllers/editable_attribute_controller.js +0 -51
- data/app/assets/stylesheets/hotsheet/application.css +0 -86
- 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 -24
- data/app/views/hotsheet/pages/index.html.erb +0 -27
- data/app/views/layouts/hotsheet/_flash.html.erb +0 -7
- data/app/views/layouts/hotsheet/_sidebar.html.erb +0 -11
- data/config/initializers/hotsheet/content_security_policy.rb +0 -14
- data/config/initializers/hotsheet/editable_attributes.rb +0 -43
- data/config/initializers/hotsheet/pagy.rb +0 -7
- data/config/locales/en.yml +0 -5
- data/lib/hotsheet/configuration.rb +0 -19
- data/vendor/assets/stylesheets/hotsheet/pagy.css +0 -37
@@ -1,24 +0,0 @@
|
|
1
|
-
<%# locals: (attribute:, model:, record:) %>
|
2
|
-
|
3
|
-
<%= turbo_frame_tag "#{dom_id record}-#{attribute}" do %>
|
4
|
-
<div data-controller="editable-attribute"
|
5
|
-
data-editable-attribute-broadcast-url-value="<%= broadcast_edit_intent_path %>"
|
6
|
-
data-editable-attribute-resource-name-value="<%= model.table_name %>"
|
7
|
-
data-editable-attribute-resource-id-value="<%= record.id %>">
|
8
|
-
<div class="readonly-attribute"
|
9
|
-
data-editable-attribute-target="readonlyAttribute"
|
10
|
-
data-action="click->editable-attribute#displayInputField"
|
11
|
-
role="button">
|
12
|
-
<%= record.public_send attribute %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div data-editable-attribute-target="attributeForm" style="display:none">
|
16
|
-
<%= form_for record, url: "#{root_path}#{model.table_name}/#{record.id}" do |f| %>
|
17
|
-
<%= f.text_field attribute, class: "editable-input", data: {
|
18
|
-
editable_attribute_target: "attributeFormInput",
|
19
|
-
action: "keydown.enter->editable-attribute#submitForm blur->editable-attribute#submitForm"
|
20
|
-
} %>
|
21
|
-
<% end %>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
<% end %>
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<% if @model.nil? %>
|
2
|
-
<h1>Hotsheet</h1>
|
3
|
-
<p>Welcome to the hottest sheet around. Select a model from the sidebar to view the spreadsheet.</p>
|
4
|
-
<% else %>
|
5
|
-
<h1><%= @model.model_name.human %></h1>
|
6
|
-
<table>
|
7
|
-
<thead>
|
8
|
-
<tr>
|
9
|
-
<% @model.editable_attributes.each do |attribute| %>
|
10
|
-
<th><%= attribute %></th>
|
11
|
-
<% end %>
|
12
|
-
</tr>
|
13
|
-
</thead>
|
14
|
-
<tbody>
|
15
|
-
<% @records.each do |record| %>
|
16
|
-
<tr>
|
17
|
-
<% @model.editable_attributes.each do |attribute| %>
|
18
|
-
<td>
|
19
|
-
<%= render "editable_attribute", model: @model, record: record, attribute: attribute %>
|
20
|
-
</td>
|
21
|
-
<% end %>
|
22
|
-
</tr>
|
23
|
-
<% end %>
|
24
|
-
</tbody>
|
25
|
-
</table>
|
26
|
-
<%== pagy_nav @pagy %>
|
27
|
-
<% end %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Rails.application.configure do
|
4
|
-
config.content_security_policy do |csp|
|
5
|
-
csp.default_src :none
|
6
|
-
csp.connect_src :self
|
7
|
-
csp.img_src :self
|
8
|
-
csp.script_src :strict_dynamic
|
9
|
-
csp.style_src :self, :unsafe_inline
|
10
|
-
end
|
11
|
-
|
12
|
-
config.content_security_policy_nonce_directives = %w[script-src]
|
13
|
-
config.content_security_policy_nonce_generator = ->(_) { SecureRandom.base64 18 }
|
14
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Rails.application.config.after_initialize do # rubocop:disable Metrics/BlockLength
|
4
|
-
# Only run this initializer when running the Rails server
|
5
|
-
next unless Rails.env.test? || defined? Rails::Server
|
6
|
-
|
7
|
-
Hotsheet.configuration.models.each_key do |model| # rubocop:disable Metrics/BlockLength
|
8
|
-
model.constantize.class_eval do
|
9
|
-
class << self
|
10
|
-
def editable_attributes
|
11
|
-
@editable_attributes ||= fetch_editable_attributes
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def fetch_editable_attributes
|
17
|
-
config = Hotsheet.configuration.models[name]
|
18
|
-
excluded_attributes = config.excluded_attributes
|
19
|
-
|
20
|
-
if config.included_attributes.present?
|
21
|
-
raise "Can only specify either included or excluded attributes" if excluded_attributes.present?
|
22
|
-
|
23
|
-
attrs_to_s(config.included_attributes)
|
24
|
-
elsif excluded_attributes.present?
|
25
|
-
column_names - attrs_to_s(excluded_attributes)
|
26
|
-
else
|
27
|
-
column_names
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def attrs_to_s(attrs)
|
32
|
-
attrs.map do |attr|
|
33
|
-
raise "Attribute '#{attr}' doesn't exist on model '#{name}'" if column_names.exclude? attr.to_s
|
34
|
-
|
35
|
-
attr.to_s
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
model.constantize.editable_attributes
|
42
|
-
end
|
43
|
-
end
|
data/config/locales/en.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Hotsheet
|
4
|
-
class Configuration
|
5
|
-
include ActiveSupport::Configurable
|
6
|
-
|
7
|
-
config_accessor(:models) { {} }
|
8
|
-
|
9
|
-
def model(name, &block)
|
10
|
-
model_config = ModelConfig.new
|
11
|
-
yield model_config if block
|
12
|
-
models[name.to_s] = model_config
|
13
|
-
end
|
14
|
-
|
15
|
-
class ModelConfig
|
16
|
-
attr_accessor :included_attributes, :excluded_attributes
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
/* https://ddnexus.github.io/pagy/docs/api/stylesheets */
|
2
|
-
|
3
|
-
.pagy {
|
4
|
-
color: #6b7280;
|
5
|
-
display: flex;
|
6
|
-
font-size: .875rem;
|
7
|
-
font-weight: 600;
|
8
|
-
margin-top: 1rem;
|
9
|
-
|
10
|
-
a ~ a {
|
11
|
-
margin-left: .25rem;
|
12
|
-
}
|
13
|
-
|
14
|
-
a:not(.gap) {
|
15
|
-
background-color: #e5e7eb;
|
16
|
-
border-radius: .5rem;
|
17
|
-
color: inherit;
|
18
|
-
display: block;
|
19
|
-
padding: .25rem .75rem;
|
20
|
-
text-decoration: none;
|
21
|
-
|
22
|
-
&:hover {
|
23
|
-
background-color: #d1d5db;
|
24
|
-
}
|
25
|
-
|
26
|
-
&:not([href]) {
|
27
|
-
background-color: #f3f4f6;
|
28
|
-
color: #d1d5db;
|
29
|
-
cursor: default;
|
30
|
-
}
|
31
|
-
|
32
|
-
&.current {
|
33
|
-
background-color: #9ca3af;
|
34
|
-
color: white;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|