super 0.20.0 → 0.22.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -48
  3. data/app/assets/javascripts/super/application.js +1201 -2092
  4. data/app/assets/stylesheets/super/application.css +54 -6569
  5. data/app/controllers/super/application_controller.rb +52 -47
  6. data/app/controllers/super/foundation_controller.rb +30 -0
  7. data/app/controllers/super/sitewide_controller.rb +36 -0
  8. data/app/controllers/super/substructure_controller.rb +40 -92
  9. data/app/controllers/super/view_controller.rb +59 -0
  10. data/app/views/layouts/super/application.html.erb +3 -3
  11. data/app/views/super/application/_batch_checkbox.csv.erb +1 -1
  12. data/app/views/super/application/_batch_checkbox.html.erb +1 -1
  13. data/app/views/super/application/_collection_header.html.erb +1 -1
  14. data/app/views/super/application/_csv_button.html.erb +1 -1
  15. data/app/views/super/application/_display_actions.html.erb +1 -1
  16. data/app/views/super/application/_display_index.html.erb +8 -2
  17. data/app/views/super/application/_display_rich_text.html.erb +1 -1
  18. data/app/views/super/application/_display_show.html.erb +10 -2
  19. data/app/views/super/application/_filter.html.erb +63 -59
  20. data/app/views/super/application/_form.html.erb +1 -1
  21. data/app/views/super/application/_form_fieldset.html.erb +1 -1
  22. data/app/views/super/application/_form_has_many.html.erb +2 -2
  23. data/app/views/super/application/_form_has_one.html.erb +1 -1
  24. data/app/views/super/application/_layout.html.erb +6 -8
  25. data/app/views/super/application/_link.html.erb +1 -6
  26. data/app/views/super/application/_member_header.html.erb +1 -1
  27. data/app/views/super/application/_panel.html.erb +1 -1
  28. data/app/views/super/application/_query.html.erb +13 -12
  29. data/app/views/super/application/_site_header.html.erb +2 -2
  30. data/app/views/super/application/_sort.html.erb +18 -14
  31. data/app/views/super/application/_sort_expression.html.erb +1 -1
  32. data/app/views/super/application/_view_chain.html.erb +1 -5
  33. data/app/views/super/application/edit.html.erb +1 -1
  34. data/app/views/super/application/index.html.erb +1 -1
  35. data/app/views/super/application/new.html.erb +1 -1
  36. data/app/views/super/application/show.html.erb +1 -1
  37. data/config/locales/en.yml +3 -0
  38. data/frontend/super-frontend/dist/application.css +54 -6569
  39. data/frontend/super-frontend/dist/application.js +1201 -2092
  40. data/lib/super/action_inquirer.rb +28 -8
  41. data/lib/super/assets.rb +2 -2
  42. data/lib/super/badge.rb +8 -23
  43. data/lib/super/cheat.rb +11 -5
  44. data/lib/super/client_error.rb +4 -0
  45. data/lib/super/compatibility.rb +4 -0
  46. data/lib/super/configuration.rb +3 -0
  47. data/lib/super/display/schema_types.rb +50 -71
  48. data/lib/super/display.rb +16 -15
  49. data/lib/super/error.rb +16 -2
  50. data/lib/super/filter/form_object.rb +2 -2
  51. data/lib/super/filter/operator.rb +1 -1
  52. data/lib/super/filter/schema_types.rb +1 -1
  53. data/lib/super/form/field_transcript.rb +4 -0
  54. data/lib/super/form/schema_types.rb +2 -2
  55. data/lib/super/form/strong_params.rb +1 -1
  56. data/lib/super/form_builder/base_methods.rb +3 -9
  57. data/lib/super/form_builder/flatpickr_methods.rb +3 -3
  58. data/lib/super/form_builder.rb +19 -21
  59. data/{app/helpers → lib}/super/form_builder_helper.rb +13 -2
  60. data/lib/super/link.rb +15 -6
  61. data/lib/super/link_builder.rb +4 -4
  62. data/lib/super/navigation.rb +49 -45
  63. data/lib/super/partial.rb +0 -12
  64. data/lib/super/plugin.rb +2 -2
  65. data/lib/super/query.rb +61 -0
  66. data/lib/super/{engine.rb → railtie.rb} +8 -1
  67. data/lib/super/render_helper.rb +31 -0
  68. data/lib/super/reset.rb +7 -5
  69. data/lib/super/schema/guesser.rb +5 -5
  70. data/lib/super/schema.rb +10 -4
  71. data/lib/super/sort.rb +2 -4
  72. data/lib/super/useful/deprecations.rb +16 -0
  73. data/lib/super/useful/enum.rb +1 -1
  74. data/lib/super/useful/i19.rb +1 -1
  75. data/lib/super/version.rb +1 -1
  76. data/lib/super/view_chain.rb +33 -4
  77. data/lib/super.rb +9 -2
  78. metadata +11 -49
  79. data/config/routes.rb +0 -4
  80. data/lib/super/query/form_object.rb +0 -48
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Super
4
4
  # Provides a default implementation for each of the resourceful actions
5
- class ApplicationController < SubstructureController
5
+ class ApplicationController < ViewController
6
6
  include ClientError::Handling
7
7
 
8
8
  before_action do
@@ -12,6 +12,8 @@ module Super
12
12
  end
13
13
 
14
14
  # Displays a list of records to the user
15
+ #
16
+ # @return [void]
15
17
  def index
16
18
  if request.format.ref == :csv && !csv_enabled?
17
19
  params_for_rebuilding_url = params.to_unsafe_hash
@@ -22,13 +24,14 @@ module Super
22
24
  @records = load_records
23
25
  @display = display_schema.apply(action: current_action, format: request.format)
24
26
  @view = index_view
25
- @query_form = initialize_query_form
26
27
  initialize_filter_form
27
28
  initialize_sort_form
28
29
  @records = apply_queries
29
30
  end
30
31
 
31
32
  # Displays a specific record to the user
33
+ #
34
+ # @return [void]
32
35
  def show
33
36
  @record = load_record
34
37
  @display = display_schema.apply(action: current_action, format: request.format)
@@ -36,6 +39,8 @@ module Super
36
39
  end
37
40
 
38
41
  # Displays a form to allow the user to create a new record
42
+ #
43
+ # @return [void]
39
44
  def new
40
45
  @record = build_record
41
46
  @form = form_schema
@@ -43,21 +48,22 @@ module Super
43
48
  end
44
49
 
45
50
  # Creates a record, or shows the validation errors
51
+ #
52
+ # @return [void]
46
53
  def create
47
54
  @record = build_record
48
55
  set_record_attributes
49
56
 
50
57
  if save_record
51
- redirect_to polymorphic_path(Super::Link.polymorphic_parts(@record))
58
+ redirect_to_record
52
59
  else
53
- @current_action = ActionInquirer.new!
54
- @form = form_schema
55
- @view = new_view
56
- render :new, status: :bad_request
60
+ render_new_as_bad_request
57
61
  end
58
62
  end
59
63
 
60
64
  # Displays a form to allow the user to update an existing record
65
+ #
66
+ # @return [void]
61
67
  def edit
62
68
  @record = load_record
63
69
  @form = form_schema
@@ -65,74 +71,73 @@ module Super
65
71
  end
66
72
 
67
73
  # Updates a record, or shows validation errors
74
+ #
75
+ # @return [void]
68
76
  def update
69
77
  @record = load_record
70
78
  set_record_attributes
71
79
 
72
80
  if save_record
73
- redirect_to polymorphic_path(Super::Link.polymorphic_parts(@record))
81
+ redirect_to_record
74
82
  else
75
- @current_action = ActionInquirer.edit!
76
- @form = form_schema
77
- @view = edit_view
78
- render :edit, status: :bad_request
83
+ render_edit_as_bad_request
79
84
  end
80
85
  end
81
86
 
82
87
  # Deletes a record, or shows validation errors
88
+ #
89
+ # @return [void]
83
90
  def destroy
84
91
  @record = load_record
85
92
 
86
93
  if destroy_record
87
- redirect_to polymorphic_path(Super::Link.polymorphic_parts(@record))
94
+ redirect_to_records
88
95
  else
89
- flash.alert = "Couldn't delete record"
90
- redirect_to polymorphic_path(Super::Link.polymorphic_parts(@record))
96
+ redirect_to_record_with_destroy_failure_message
91
97
  end
92
- rescue ActiveRecord::InvalidForeignKey => e
93
- flash.alert = "Couldn't delete record: #{e.class}"
94
- redirect_to polymorphic_path(Super::Link.polymorphic_parts(@record))
98
+ rescue ActiveRecord::ActiveRecordError => e
99
+ redirect_to_record_with_destroy_failure_message(e)
95
100
  end
96
101
 
97
102
  private
98
103
 
99
- helper_method def current_action
100
- @current_action ||=
101
- ActionInquirer.new(
102
- ActionInquirer.default_for_resources,
103
- params[:action]
104
- )
104
+ # @return [void]
105
+ def redirect_to_record
106
+ redirect_to polymorphic_path(Super::Link.polymorphic_parts(@record))
105
107
  end
106
108
 
107
- def with_current_action(action)
108
- original = @current_action
109
- @current_action = ActionInquirer.new(
110
- ActionInquirer.default_for_resources,
111
- action
112
- )
113
- yield
114
- ensure
115
- @current_action = original
109
+ # @return [void]
110
+ def redirect_to_records
111
+ redirect_to polymorphic_path(Super::Link.polymorphic_parts(model))
116
112
  end
117
113
 
118
- helper_method def resolved_member_actions(record)
119
- member_actions(record).map do |action|
120
- if action.respond_to?(:resolve)
121
- resolve_member_action(action, record)
114
+ # @return [void]
115
+ def redirect_to_record_with_destroy_failure_message(error = nil)
116
+ flash.alert =
117
+ case error
118
+ when ActiveRecord::InvalidForeignKey
119
+ I18n.t("super.destroy_error.invalid_foreign_key")
122
120
  else
123
- action
121
+ I18n.t("super.destroy_error.generic")
124
122
  end
125
- end
123
+
124
+ redirect_to polymorphic_path(Super::Link.polymorphic_parts(@record))
126
125
  end
127
126
 
128
- helper_method def resolved_collection_actions
129
- collection_actions.map do |action|
130
- if action.respond_to?(:resolve)
131
- resolve_collection_action(action)
132
- else
133
- action
134
- end
135
- end
127
+ # @return [void]
128
+ def render_new_as_bad_request
129
+ @current_action = ActionInquirer.new!
130
+ @form = form_schema
131
+ @view = new_view
132
+ render :new, status: :bad_request
133
+ end
134
+
135
+ # @return [void]
136
+ def render_edit_as_bad_request
137
+ @current_action = ActionInquirer.edit!
138
+ @form = form_schema
139
+ @view = edit_view
140
+ render :edit, status: :bad_request
136
141
  end
137
142
  end
138
143
  end
@@ -0,0 +1,30 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Super
5
+ # These methods could be useful for any Super controller, resourceful or not.
6
+ class FoundationController < ActionController::Base
7
+ private
8
+
9
+ # @return [Super::ActionInquirer]
10
+ helper_method def current_action
11
+ @current_action ||=
12
+ ActionInquirer.new(
13
+ ActionInquirer.default_for_resources,
14
+ params[:action]
15
+ )
16
+ end
17
+
18
+ # @return [void]
19
+ def with_current_action(action)
20
+ original = @current_action
21
+ @current_action = ActionInquirer.new(
22
+ ActionInquirer.default_for_resources,
23
+ action
24
+ )
25
+ yield
26
+ ensure
27
+ @current_action = original
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Super
4
+ # These methods could be useful for any Super controller, resourceful or not.
5
+ class SitewideController < SubstructureController
6
+ private
7
+
8
+ # @return [String]
9
+ helper_method def site_title
10
+ Super.configuration.title
11
+ end
12
+
13
+ # @return [Super::Navigation]
14
+ helper_method def site_navigation
15
+ Super::Navigation.new(&:all)
16
+ end
17
+
18
+ # @return [String]
19
+ helper_method def document_title
20
+ if instance_variable_defined?(:@document_title)
21
+ return @document_title
22
+ end
23
+
24
+ document_title_segments.map(&:presence).compact.join(document_title_separator)
25
+ end
26
+
27
+ def document_title_segments
28
+ @document_title_segments ||= [page_title, site_title]
29
+ end
30
+
31
+ # @return [String]
32
+ def document_title_separator
33
+ @document_title_separator ||= " - "
34
+ end
35
+ end
36
+ end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Super
4
- # Various methods that determine the behavior of your controllers. These
5
- # methods can and should be overridden.
6
- class SubstructureController < ActionController::Base
4
+ # These methods determine the behavior of your resourceful Super controllers.
5
+ # These methods can and should be overridden.
6
+ class SubstructureController < FoundationController
7
7
  def self.batch(action_name)
8
8
  mod = Module.new do
9
9
  define_method(action_name) do
@@ -42,7 +42,7 @@ module Super
42
42
  helper_method def page_title
43
43
  model.name.pluralize
44
44
  rescue Error::NotImplementedError, NameError
45
- return nil
45
+ nil
46
46
  end
47
47
 
48
48
  # Configures what database records are visible on load. This is an optional
@@ -143,25 +143,24 @@ module Super
143
143
  action.resolve(params: params, record: record)
144
144
  end
145
145
 
146
+ # @return [Boolean]
146
147
  helper_method def filters_enabled?
147
148
  true
148
149
  end
149
150
 
151
+ # @return [Super::Filter]
150
152
  helper_method def filter_schema
151
153
  Super::Filter.new do |fields, type|
152
154
  Super::Filter::Guesser.new(model: model, fields: fields, type: type).call
153
155
  end
154
156
  end
155
157
 
158
+ # @return [Boolean]
156
159
  helper_method def sort_enabled?
157
160
  true
158
161
  end
159
162
 
160
163
  helper_method def sortable_columns
161
- action = ActionInquirer.new(
162
- ActionInquirer.default_for_resources,
163
- "index"
164
- )
165
164
  attribute_names =
166
165
  display_schema.each_attribute.map do |key, val|
167
166
  val = val.build if val.respond_to?(:build)
@@ -172,23 +171,23 @@ module Super
172
171
  end
173
172
 
174
173
  helper_method def default_sort
175
- { id: :desc }
174
+ {id: :desc}
176
175
  end
177
176
 
178
177
  # Specifies how many records to show per page
179
178
  #
180
- # @return [ActiveRecord::Relation]
179
+ # @return [Integer]
181
180
  helper_method def records_per_page
182
181
  Super.configuration.index_records_per_page
183
182
  end
184
183
 
184
+ # @return [Boolean]
185
185
  helper_method def batch_actions_enabled?
186
186
  true
187
187
  end
188
188
 
189
189
  helper_method def batch_actions
190
- [
191
- ]
190
+ []
192
191
  end
193
192
 
194
193
  def load_records
@@ -203,6 +202,7 @@ module Super
203
202
  base_scope.build
204
203
  end
205
204
 
205
+ # @return [void]
206
206
  def set_record_attributes
207
207
  @record.attributes = permitted_params
208
208
  end
@@ -215,22 +215,24 @@ module Super
215
215
  @record.destroy
216
216
  end
217
217
 
218
- def initialize_query_form
219
- Super::Query::FormObject.new(
218
+ # @return [Super::Query]
219
+ helper_method def query
220
+ @query ||= Super::Query.new(
220
221
  model: model,
221
- params: params,
222
- namespace: :q,
223
- current_path: request.path,
222
+ params: request.GET,
223
+ current_path: request.path
224
224
  )
225
225
  end
226
226
 
227
+ # @return [ActiveRecord::Relation]
227
228
  def apply_queries
228
- @query_form.apply_changes(@records)
229
+ query.apply_changes(@records)
229
230
  end
230
231
 
232
+ # @return [Super::Filter::FormObject, nil]
231
233
  def initialize_filter_form
232
234
  if filters_enabled?
233
- @query_form.add(
235
+ @filter_form = query.build(
234
236
  Super::Filter::FormObject,
235
237
  namespace: :f,
236
238
  schema: filter_schema
@@ -238,9 +240,10 @@ module Super
238
240
  end
239
241
  end
240
242
 
243
+ # @return [Super::Sort::FormObject, nil]
241
244
  def initialize_sort_form
242
245
  if sort_enabled?
243
- @query_form.add(
246
+ @sort_form = query.build(
244
247
  Super::Sort::FormObject,
245
248
  namespace: :s,
246
249
  default: default_sort,
@@ -249,10 +252,12 @@ module Super
249
252
  end
250
253
  end
251
254
 
255
+ # @return [Symbol, String]
252
256
  helper_method def pagination_disabled_param
253
257
  :_all_pages
254
258
  end
255
259
 
260
+ # @return [Boolean]
256
261
  def pagination_enabled?
257
262
  !params.key?(pagination_disabled_param)
258
263
  end
@@ -287,85 +292,28 @@ module Super
287
292
  )
288
293
  end
289
294
 
295
+ # @return [Boolean]
290
296
  helper_method def csv_enabled?
291
297
  true
292
298
  end
293
299
 
294
- def index_view
295
- Super::Layout.new(
296
- main: Super::ViewChain.new(
297
- main_panel: Super::Panel.new,
298
- batch_form: Super::Partial.new("batch_form"),
299
- main_header: Super::Partial.new("collection_header"),
300
- main: :@display
301
- ),
302
- aside: Super::ViewChain.new(
303
- main: :@query_form
304
- )
305
- )
306
- end
307
-
308
- def show_view
309
- Super::Layout.new(
310
- main: Super::ViewChain.new(
311
- main_panel: Super::Panel.new,
312
- main_header: Super::Partial.new("member_header"),
313
- main: :@display
314
- )
315
- )
316
- end
317
-
318
- def new_view
319
- Super::Layout.new(
320
- main: Super::ViewChain.new(
321
- main_panel: Super::Panel.new,
322
- main_header: Super::Partial.new("collection_header"),
323
- main: :@form
324
- )
325
- )
326
- end
327
-
328
- def edit_view
329
- Super::Layout.new(
330
- main: Super::ViewChain.new(
331
- main_panel: Super::Panel.new,
332
- main_header: Super::Partial.new("member_header"),
333
- main: :@form
334
- )
335
- )
336
- end
337
-
338
- concerning :Sitewide do
339
- included do
340
- helper_method :site_title
341
- helper_method :site_navigation
342
- helper_method :document_title
343
- end
344
-
345
- private
346
-
347
- def site_title
348
- Super.configuration.title
349
- end
350
-
351
- def site_navigation
352
- Super::Navigation.new(&:all)
353
- end
354
-
355
- def document_title
356
- if instance_variable_defined?(:@document_title)
357
- return @document_title
300
+ helper_method def resolved_member_actions(record)
301
+ member_actions(record).map do |action|
302
+ if action.respond_to?(:resolve)
303
+ resolve_member_action(action, record)
304
+ else
305
+ action
358
306
  end
359
-
360
- document_title_segments.map(&:presence).compact.join(document_title_separator)
361
- end
362
-
363
- def document_title_segments
364
- @document_title_segments ||= [page_title, site_title]
365
307
  end
308
+ end
366
309
 
367
- def document_title_separator
368
- @document_title_separator ||= " - "
310
+ helper_method def resolved_collection_actions
311
+ collection_actions.map do |action|
312
+ if action.respond_to?(:resolve)
313
+ resolve_collection_action(action)
314
+ else
315
+ action
316
+ end
369
317
  end
370
318
  end
371
319
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Super
4
+ # These methods define what each resourceful Super admin page looks like.
5
+ # Generally, the return value of each of these methods should be set to
6
+ # `@view`.
7
+ class ViewController < SitewideController
8
+ private
9
+
10
+ # @return [#to_partial_path]
11
+ def index_view
12
+ Super::Layout.new(
13
+ main: Super::ViewChain.new(
14
+ main_panel: Super::Panel.new,
15
+ batch_form: Super::Partial.new("batch_form"),
16
+ main_header: Super::Partial.new("collection_header"),
17
+ main: :@display
18
+ ),
19
+ aside: Super::ViewChain.new(
20
+ query_panel: Super::Panel.new,
21
+ query: query
22
+ )
23
+ )
24
+ end
25
+
26
+ # @return [#to_partial_path]
27
+ def show_view
28
+ Super::Layout.new(
29
+ main: Super::ViewChain.new(
30
+ main_panel: Super::Panel.new,
31
+ main_header: Super::Partial.new("member_header"),
32
+ main: :@display
33
+ )
34
+ )
35
+ end
36
+
37
+ # @return [#to_partial_path]
38
+ def new_view
39
+ Super::Layout.new(
40
+ main: Super::ViewChain.new(
41
+ main_panel: Super::Panel.new,
42
+ main_header: Super::Partial.new("collection_header"),
43
+ main: :@form
44
+ )
45
+ )
46
+ end
47
+
48
+ # @return [#to_partial_path]
49
+ def edit_view
50
+ Super::Layout.new(
51
+ main: Super::ViewChain.new(
52
+ main_panel: Super::Panel.new,
53
+ main_header: Super::Partial.new("member_header"),
54
+ main: :@form
55
+ )
56
+ )
57
+ end
58
+ end
59
+ end
@@ -28,15 +28,15 @@
28
28
 
29
29
  <body class="font-sans pb-4">
30
30
  <div class="px-4">
31
- <%= render "site_header" %>
31
+ <%= super_render "site_header" %>
32
32
 
33
- <%= render "flash" %>
33
+ <%= super_render "flash" %>
34
34
 
35
35
  <div class="pt-4"></div>
36
36
 
37
37
  <%= yield %>
38
38
 
39
- <%= render "site_footer" %>
39
+ <%= super_render "site_footer" %>
40
40
  </div>
41
41
  </body>
42
42
  </html>
@@ -1 +1 @@
1
- <%= value -%>
1
+ <%= batch_checkbox.locals[:value] -%>
@@ -1,7 +1,7 @@
1
1
  <% if current_action.collection? %>
2
2
  <div class="whitespace-nowrap gap-1">
3
3
  <% html_id = "batch-checkbox-#{value.to_s.gsub(/[^a-z0-9]+/, "-")}" %>
4
- <input type="checkbox" name="batch[]" value="<%= value %>" id="<%= html_id %>">
4
+ <input type="checkbox" name="batch[]" value="<%= batch_checkbox.locals[:value] %>" id="<%= html_id %>">
5
5
  <label for="<%= html_id %>"><%= value %></label>
6
6
  </div>
7
7
  <% else %>
@@ -4,7 +4,7 @@
4
4
  </h1>
5
5
  <div class="flex gap-2">
6
6
  <% resolved_collection_actions.each do |link| %>
7
- <%= render(
7
+ <%= super_render(
8
8
  link,
9
9
  default_options: {
10
10
  class: "super-button super-button--border-blue super-button-sm inline-block"
@@ -5,7 +5,7 @@
5
5
  <details-dialog class="bg-white shadow-md px-4 py-4 rounded-lg">
6
6
  <header class="flex items-center">
7
7
  <h1 class="font-semibold border-b-1 flex-1"><%= t("super.csv.modal_header") %></h1>
8
- <button type="button" data-close-dialog class="flex-initial h-4 w-4"><%= render("super/feather/x") %></button>
8
+ <button type="button" data-close-dialog class="flex-initial h-4 w-4"><%= super_render("super/feather/x") %></button>
9
9
  </header>
10
10
  <div class="mt-3">
11
11
  <% linkable_params = params.to_unsafe_hash %>
@@ -1,5 +1,5 @@
1
1
  <div>
2
2
  <% resolved_member_actions(record).each do |link| %>
3
- <span class="pr-2 last:pr-0"><%= render link %></span>
3
+ <span class="pr-2 last:pr-0"><%= super_render link %></span>
4
4
  <% end %>
5
5
  </div>
@@ -2,9 +2,15 @@
2
2
  <table class="w-full border-separate" cellspacing="0" cellpadding="0">
3
3
  <thead class="">
4
4
  <tr class="">
5
- <% display_index.each_attribute_name do |attribute_name| %>
5
+ <% display_index.each_attribute do |attribute_name, attribute_definition| %>
6
6
  <th class="p-2 first:pl-6 border-b border-b-2 border-gray-400 text-gray-600 text-left text-sm font-normal bg-white top-0 z-10">
7
- <%= model.human_attribute_name(attribute_name) %>
7
+ <%=
8
+ if attribute_definition.respond_to?(:attribute_name) && attribute_definition.attribute_name
9
+ attribute_definition.attribute_name
10
+ else
11
+ model.human_attribute_name(attribute_name)
12
+ end
13
+ %>
8
14
  </th>
9
15
  <% end %>
10
16
  </tr>
@@ -1 +1 @@
1
- <%= rich_text %>
1
+ <%= display_rich_text.locals[:rich_text] %>
@@ -1,7 +1,15 @@
1
1
  <table class="max-w-full mt-4">
2
- <% display_show.each_attribute_name do |attribute_name| %>
2
+ <% display_show.each_attribute do |attribute_name, attribute_definition| %>
3
3
  <tr>
4
- <th class="py-1 align-baseline text-right px-4"><%= model.human_attribute_name(attribute_name) %></th>
4
+ <th class="py-1 align-baseline text-right px-4">
5
+ <%=
6
+ if attribute_definition.respond_to?(:attribute_name) && attribute_definition.attribute_name
7
+ attribute_definition.attribute_name
8
+ else
9
+ model.human_attribute_name(attribute_name)
10
+ end
11
+ %>
12
+ </th>
5
13
  <td class="py-1 align-baseline"><%= display_show.render_attribute(template: self, record: @record, column: attribute_name) %></td>
6
14
  </tr>
7
15
  <% end %>