elaine_crud 0.1.1 → 0.1.3
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/app/assets/stylesheets/elaine_crud.source.css +9 -0
- data/app/controllers/elaine_crud/base_controller.rb +12 -1
- data/app/views/elaine_crud/base/_view_row.html.erb +6 -4
- data/lib/elaine_crud/dsl_methods.rb +23 -5
- data/lib/elaine_crud/engine.rb +5 -0
- data/lib/elaine_crud/version.rb +1 -1
- data/vendor/assets/stylesheets/elaine_crud.css +1411 -13
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b331198ebb4dcf4ce1e5d3718d65fb36e2fac98ef24c219f46206fc9cb450309
|
|
4
|
+
data.tar.gz: 690b1dd2f306cf3a6156dd35095471c283dd9674fe35f3895effec18d48cc047
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40b0b2d357e3bd0b87360fe7f0ea59613fb7dab409534b7843181caa15e726681ff2d1fd0d42161765be50b79bb8ac1ba7aeab03d19eaf89288e858865abacdf
|
|
7
|
+
data.tar.gz: dbd100c7c1dcea367e12522c14fabb94f68b6ca7a19c6f42945da72752f475c0e2e6a8684611c33253ad1edcbb31d8e20bf31ff233b3cc912c1105bf08df3fc1
|
|
@@ -4,3 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
@import "tailwindcss";
|
|
6
6
|
@config "../../../tailwind.config.js";
|
|
7
|
+
|
|
8
|
+
@theme {
|
|
9
|
+
--animate-highlight-fade: highlight-fade 2s ease-out;
|
|
10
|
+
|
|
11
|
+
@keyframes highlight-fade {
|
|
12
|
+
0% { background-color: var(--color-yellow-200); }
|
|
13
|
+
100% { background-color: transparent; }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -30,6 +30,10 @@ module ElaineCrud
|
|
|
30
30
|
protect_from_forgery with: :exception
|
|
31
31
|
# No layout specified - host app controllers should set their own layout
|
|
32
32
|
|
|
33
|
+
# Run deferred auto-configuration on first request
|
|
34
|
+
# This defers database access until runtime, allowing asset precompilation without a database
|
|
35
|
+
before_action :ensure_auto_configuration
|
|
36
|
+
|
|
33
37
|
# Handle record not found errors with custom 404 page
|
|
34
38
|
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
|
|
35
39
|
|
|
@@ -160,7 +164,8 @@ module ElaineCrud
|
|
|
160
164
|
# For Turbo Frame requests, return the view row partial
|
|
161
165
|
if turbo_frame_request?
|
|
162
166
|
# Use bg-white for consistency when returning from edit (alternating colors handled by full page refresh)
|
|
163
|
-
|
|
167
|
+
# Pass just_saved: true to trigger highlight animation
|
|
168
|
+
render partial: 'elaine_crud/base/view_row', locals: { record: @record, columns: @columns, row_bg_class: 'bg-white', is_last_record: false, just_saved: true }
|
|
164
169
|
else
|
|
165
170
|
redirect_to polymorphic_path(@record), notice: "#{crud_model.name} was successfully updated.", status: :see_other
|
|
166
171
|
end
|
|
@@ -207,6 +212,12 @@ module ElaineCrud
|
|
|
207
212
|
|
|
208
213
|
private
|
|
209
214
|
|
|
215
|
+
# Run deferred auto-configuration if needed
|
|
216
|
+
# This allows the controller to be loaded without database access during asset precompilation
|
|
217
|
+
def ensure_auto_configuration
|
|
218
|
+
self.class.run_deferred_auto_configuration
|
|
219
|
+
end
|
|
220
|
+
|
|
210
221
|
# Check if the request is coming from a Turbo Frame
|
|
211
222
|
def turbo_frame_request?
|
|
212
223
|
request.headers['Turbo-Frame'].present?
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
<% has_multiple_rows = record_layout.length > 1 %>
|
|
5
5
|
<% is_last_record = defined?(is_last_record) ? is_last_record : false %>
|
|
6
6
|
<% show_actions = local_assigns.fetch(:show_actions, true) %>
|
|
7
|
+
<% just_saved = local_assigns.fetch(:just_saved, false) %>
|
|
8
|
+
<% highlight_class = just_saved ? 'animate-highlight-fade' : '' %>
|
|
7
9
|
|
|
8
10
|
<%# Wrap entire row in turbo-frame for row-level inline editing %>
|
|
9
11
|
<% if controller.respond_to?(:turbo_disabled?) && controller.turbo_disabled? %>
|
|
@@ -16,7 +18,7 @@
|
|
|
16
18
|
<% rowspan = column_config[:rowspan] || 1 %>
|
|
17
19
|
<% cell_border_bottom = (has_multiple_rows && !is_last_row) || !is_last_record ? 'border-b' : '' %>
|
|
18
20
|
|
|
19
|
-
<div class="px-3 py-3 text-sm text-gray-900 border-r border-gray-200 <%= cell_border_bottom %> break-words <%= row_bg_class %> hover:bg-blue-50 <%= 'col-span-' + colspan.to_s if colspan > 1 %> <%= 'row-span-' + rowspan.to_s if rowspan > 1 %>">
|
|
21
|
+
<div class="px-3 py-3 text-sm text-gray-900 border-r border-gray-200 <%= cell_border_bottom %> break-words <%= row_bg_class %> hover:bg-blue-50 <%= highlight_class %> <%= 'col-span-' + colspan.to_s if colspan > 1 %> <%= 'row-span-' + rowspan.to_s if rowspan > 1 %>">
|
|
20
22
|
<%= display_field_value(record, field_name) %>
|
|
21
23
|
</div>
|
|
22
24
|
<% end %>
|
|
@@ -24,7 +26,7 @@
|
|
|
24
26
|
<%# Actions column (only on first row) %>
|
|
25
27
|
<% if show_actions && row_index == 0 %>
|
|
26
28
|
<% actions_border_bottom = has_multiple_rows ? '' : (is_last_record ? '' : 'border-b') %>
|
|
27
|
-
<div class="px-3 py-3 text-sm text-gray-500 border-gray-200 <%= row_bg_class %> hover:bg-blue-50 <%= actions_border_bottom %> <%= 'row-span-' + record_layout.length.to_s if record_layout.length > 1 %>">
|
|
29
|
+
<div class="px-3 py-3 text-sm text-gray-500 border-gray-200 <%= row_bg_class %> hover:bg-blue-50 <%= highlight_class %> <%= actions_border_bottom %> <%= 'row-span-' + record_layout.length.to_s if record_layout.length > 1 %>">
|
|
28
30
|
<div class="flex space-x-2">
|
|
29
31
|
<% if controller.class.show_view_action_button %>
|
|
30
32
|
<%= link_to "View",
|
|
@@ -60,7 +62,7 @@
|
|
|
60
62
|
<% rowspan = column_config[:rowspan] || 1 %>
|
|
61
63
|
<% cell_border_bottom = (has_multiple_rows && !is_last_row) || !is_last_record ? 'border-b' : '' %>
|
|
62
64
|
|
|
63
|
-
<div class="px-3 py-3 text-sm text-gray-900 border-r border-gray-200 <%= cell_border_bottom %> break-words <%= row_bg_class %> hover:bg-blue-50 <%= 'col-span-' + colspan.to_s if colspan > 1 %> <%= 'row-span-' + rowspan.to_s if rowspan > 1 %>">
|
|
65
|
+
<div class="px-3 py-3 text-sm text-gray-900 border-r border-gray-200 <%= cell_border_bottom %> break-words <%= row_bg_class %> hover:bg-blue-50 <%= highlight_class %> <%= 'col-span-' + colspan.to_s if colspan > 1 %> <%= 'row-span-' + rowspan.to_s if rowspan > 1 %>">
|
|
64
66
|
<%= display_field_value(record, field_name) %>
|
|
65
67
|
</div>
|
|
66
68
|
<% end %>
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
<%# Actions column (only on first row) %>
|
|
69
71
|
<% if show_actions && row_index == 0 %>
|
|
70
72
|
<% actions_border_bottom = has_multiple_rows ? '' : (is_last_record ? '' : 'border-b') %>
|
|
71
|
-
<div class="px-3 py-3 text-sm text-gray-500 border-gray-200 <%= row_bg_class %> hover:bg-blue-50 <%= actions_border_bottom %> <%= 'row-span-' + record_layout.length.to_s if record_layout.length > 1 %>">
|
|
73
|
+
<div class="px-3 py-3 text-sm text-gray-500 border-gray-200 <%= row_bg_class %> hover:bg-blue-50 <%= highlight_class %> <%= actions_border_bottom %> <%= 'row-span-' + record_layout.length.to_s if record_layout.length > 1 %>">
|
|
72
74
|
<div class="flex space-x-2">
|
|
73
75
|
<% if controller.class.show_view_action_button %>
|
|
74
76
|
<%= link_to "View",
|
|
@@ -9,13 +9,17 @@ module ElaineCrud
|
|
|
9
9
|
included do
|
|
10
10
|
class_attribute :crud_model, :permitted_attributes, :column_configurations,
|
|
11
11
|
:field_configurations, :default_sort_column, :default_sort_direction,
|
|
12
|
-
:disable_turbo_frames, :show_view_action_button, :max_export_records
|
|
12
|
+
:disable_turbo_frames, :show_view_action_button, :max_export_records,
|
|
13
|
+
:needs_auto_configuration
|
|
13
14
|
|
|
14
15
|
# Default: View button is disabled
|
|
15
16
|
self.show_view_action_button = false
|
|
16
17
|
|
|
17
18
|
# Default: Max 10,000 records for export
|
|
18
19
|
self.max_export_records = 10_000
|
|
20
|
+
|
|
21
|
+
# Default: No auto-configuration pending
|
|
22
|
+
self.needs_auto_configuration = false
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
class_methods do
|
|
@@ -23,16 +27,30 @@ module ElaineCrud
|
|
|
23
27
|
# @param model_class [Class] The ActiveRecord model class
|
|
24
28
|
def model(model_class)
|
|
25
29
|
self.crud_model = model_class
|
|
30
|
+
# Mark that auto-configuration needs to run at request time
|
|
31
|
+
# This defers database access until runtime, avoiding issues during asset precompilation
|
|
32
|
+
self.needs_auto_configuration = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Run deferred auto-configuration (called at request time, not class load time)
|
|
36
|
+
# This allows asset precompilation to work without database access
|
|
37
|
+
def run_deferred_auto_configuration
|
|
38
|
+
return unless needs_auto_configuration
|
|
39
|
+
return unless crud_model
|
|
40
|
+
|
|
26
41
|
# Auto-configure foreign key fields after setting the model
|
|
27
|
-
auto_configure_foreign_keys
|
|
42
|
+
auto_configure_foreign_keys
|
|
28
43
|
# Auto-configure has_many relationships
|
|
29
|
-
auto_configure_has_many_relationships
|
|
44
|
+
auto_configure_has_many_relationships
|
|
30
45
|
# Auto-configure has_one relationships
|
|
31
|
-
auto_configure_has_one_relationships
|
|
46
|
+
auto_configure_has_one_relationships
|
|
32
47
|
# Auto-configure has_and_belongs_to_many relationships
|
|
33
|
-
auto_configure_habtm_relationships
|
|
48
|
+
auto_configure_habtm_relationships
|
|
34
49
|
# Re-run permit_params to include foreign keys if it was called before model was set
|
|
35
50
|
refresh_permitted_attributes
|
|
51
|
+
|
|
52
|
+
# Mark as configured so we don't run again
|
|
53
|
+
self.needs_auto_configuration = false
|
|
36
54
|
end
|
|
37
55
|
|
|
38
56
|
# Specify permitted parameters for strong params
|
data/lib/elaine_crud/engine.rb
CHANGED
|
@@ -12,6 +12,11 @@ module ElaineCrud
|
|
|
12
12
|
config.autoload_paths << File.expand_path('../../app/helpers', __dir__)
|
|
13
13
|
config.autoload_paths << File.expand_path('..', __dir__)
|
|
14
14
|
|
|
15
|
+
# Register XLSX MIME type for Excel exports
|
|
16
|
+
initializer 'elaine_crud.mime_types', before: :load_config_initializers do
|
|
17
|
+
Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
# Add vendor/assets to asset paths for precompiled CSS
|
|
16
21
|
initializer 'elaine_crud.assets' do |app|
|
|
17
22
|
app.config.assets.paths << File.expand_path('../../vendor/assets/stylesheets', __dir__) if app.config.respond_to?(:assets)
|
data/lib/elaine_crud/version.rb
CHANGED