active_scaffold 4.0.13 → 4.1.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +19 -0
  3. data/README.md +11 -5
  4. data/app/assets/javascripts/active_scaffold.js.erb +1 -1
  5. data/app/assets/javascripts/jquery/active_scaffold.js +67 -20
  6. data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +1 -1
  7. data/app/assets/javascripts/jquery/draggable_lists.js +1 -1
  8. data/app/assets/javascripts/jquery/tiny_mce_bridge.js +1 -0
  9. data/app/assets/stylesheets/active_scaffold.scss +415 -6
  10. data/app/assets/stylesheets/active_scaffold_layout.css +11 -1
  11. data/app/views/active_scaffold_overrides/_form.html.erb +1 -1
  12. data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +2 -1
  13. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +1 -1
  14. data/app/views/active_scaffold_overrides/_human_filters.html.erb +1 -0
  15. data/app/views/active_scaffold_overrides/_list_header.html.erb +2 -0
  16. data/app/views/active_scaffold_overrides/_list_messages.html.erb +11 -0
  17. data/app/views/active_scaffold_overrides/_render_field.js.erb +1 -1
  18. data/app/views/active_scaffold_overrides/_show_association.html.erb +1 -0
  19. data/app/views/active_scaffold_overrides/_show_columns.html.erb +17 -2
  20. data/app/views/active_scaffold_overrides/_update_field_on_create.js.erb +20 -0
  21. data/app/views/active_scaffold_overrides/add_tab.js.erb +3 -3
  22. data/app/views/active_scaffold_overrides/edit_associated.js.erb +1 -1
  23. data/app/views/active_scaffold_overrides/on_create.js.erb +21 -17
  24. data/app/views/active_scaffold_overrides/on_update.js.erb +1 -1
  25. data/lib/active_scaffold/actions/core.rb +34 -16
  26. data/lib/active_scaffold/actions/field_search.rb +21 -8
  27. data/lib/active_scaffold/actions/list.rb +40 -5
  28. data/lib/active_scaffold/actions/nested.rb +1 -1
  29. data/lib/active_scaffold/actions/subform.rb +2 -1
  30. data/lib/active_scaffold/attribute_params.rb +12 -2
  31. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +1 -1
  32. data/lib/active_scaffold/bridges/paper_trail/helper.rb +1 -1
  33. data/lib/active_scaffold/bridges/record_select/helpers.rb +1 -1
  34. data/lib/active_scaffold/config/core.rb +5 -1
  35. data/lib/active_scaffold/config/list.rb +35 -1
  36. data/lib/active_scaffold/constraints.rb +4 -2
  37. data/lib/active_scaffold/data_structures/action_columns.rb +2 -2
  38. data/lib/active_scaffold/data_structures/action_link.rb +16 -11
  39. data/lib/active_scaffold/data_structures/action_links.rb +3 -3
  40. data/lib/active_scaffold/data_structures/actions.rb +2 -2
  41. data/lib/active_scaffold/data_structures/column.rb +21 -0
  42. data/lib/active_scaffold/data_structures/columns.rb +2 -2
  43. data/lib/active_scaffold/data_structures/filter.rb +85 -0
  44. data/lib/active_scaffold/data_structures/filter_option.rb +32 -0
  45. data/lib/active_scaffold/data_structures/filters.rb +51 -0
  46. data/lib/active_scaffold/data_structures/set.rb +2 -2
  47. data/lib/active_scaffold/data_structures/sorting.rb +2 -2
  48. data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
  49. data/lib/active_scaffold/extensions/action_view_rendering.rb +3 -3
  50. data/lib/active_scaffold/finder.rb +16 -6
  51. data/lib/active_scaffold/helpers/action_link_helpers.rb +21 -17
  52. data/lib/active_scaffold/helpers/filter_helpers.rb +36 -0
  53. data/lib/active_scaffold/helpers/form_column_helpers.rb +116 -26
  54. data/lib/active_scaffold/helpers/human_condition_helpers.rb +4 -0
  55. data/lib/active_scaffold/helpers/list_column_helpers.rb +26 -12
  56. data/lib/active_scaffold/helpers/search_column_helpers.rb +4 -2
  57. data/lib/active_scaffold/helpers/show_column_helpers.rb +4 -3
  58. data/lib/active_scaffold/helpers/tabs_helpers.rb +4 -3
  59. data/lib/active_scaffold/helpers/view_helpers.rb +7 -1
  60. data/lib/active_scaffold/registry.rb +1 -1
  61. data/lib/active_scaffold/responds_to_parent.rb +3 -3
  62. data/lib/active_scaffold/tableless.rb +2 -2
  63. data/lib/active_scaffold/version.rb +2 -2
  64. data/lib/active_scaffold.rb +3 -7
  65. metadata +22 -17
  66. data/app/assets/stylesheets/active_scaffold_colors.scss +0 -414
@@ -5,11 +5,420 @@
5
5
  ActiveScaffold is freely distributable under the terms of an MIT-style license.
6
6
 
7
7
  For details, see the ActiveScaffold web site: https://github.com/activescaffold/active_scaffold
8
- *= require_self
9
- *= require "active_scaffold_jquery_ui"
10
- *= require "active_scaffold_extensions"
11
8
  */
12
9
 
13
- @import 'active_scaffold_layout';
14
- @import 'active_scaffold_images';
15
- @import 'active_scaffold_colors';
10
+ @use 'active_scaffold_layout';
11
+ @use 'active_scaffold_images';
12
+ @use 'active_scaffold_jquery_ui';
13
+ @use 'active_scaffold_extensions';
14
+
15
+ $disabled_color: #999 !default;
16
+ $actions_disabled_color: #666 !default;
17
+ $link_color: #06c !default;
18
+ $hover_bg: #ff8 !default;
19
+ $header_color: #555 !default;
20
+
21
+ $column_header_bg: $header_color !default;
22
+ $column_header_link_color: #fff !default;
23
+ $column_header_link_hover_bg: #000 !default;
24
+ $column_header_link_hover_color: #ff8 !default;
25
+ $column_header_color: #eee !default;
26
+ $column_header_sorted_bg: #333 !default;
27
+
28
+ $column_bg: #E6F2FF !default;
29
+ $column_even_bg: #fff !default;
30
+ $column_color: #333 !default;
31
+ $column_empty_color: #999 !default;
32
+ $column_border_color: #C5DBF7 !default;
33
+ $column_even_border_color: #ddd !default;
34
+ $column_actions_border_color: #ccc !default;
35
+ $vertical_sub_form_border_color: $column_actions_border_color !default;
36
+
37
+ $column_sorted_bg: #B9DCFF !default;
38
+ $column_sorted_border_color: #AFD0F5 !default;
39
+ $column_even_sorted_bg: #E6F2FF !default;
40
+ $column_even_sorted_border_color: #AFD0F5 !default;
41
+
42
+ $calculations_bg: #eee !default;
43
+ $calculations_border_color: #005CB8 !default;
44
+
45
+ $action_group_color: #0066CC !default;
46
+ $action_group_hover_bg: #ff8 !default;
47
+ $action_group_border_color: #005CB8 !default;
48
+ $action_group_items_bg: #EEE !default;
49
+ $action_group_items_border_color: #222 !default;
50
+ $action_group_link_color: $column_color !default;
51
+ $active_filter: $link_color !default;
52
+
53
+ $nested_bg: #DAFFCD !default;
54
+ $nested_border_color: #7FCF00 !default;
55
+ $nested_footer_color: #444 !default;
56
+ $nested_column_bg: #ECFFE7 !default;
57
+ $nested_column_even_bg: #fff !default;
58
+ $nested_column_border_color: $column_border_color !default;
59
+
60
+ $second_nested_bg: #FFFFBB !default;
61
+ $second_nested_border_color: #DDDF37 !default;
62
+
63
+ $third_nested_bg: $nested_bg !default;
64
+ $third_nested_border_color: $nested_border_color !default;
65
+
66
+ $pagination_border_color: #ccc !default;
67
+ $msg_color: #333 !default;
68
+ $msg_error_bg: #fbb !default;
69
+ $msg_error_border_color: #f66 !default;
70
+ $msg_warning_bg: #ffb !default;
71
+ $msg_warning_border_color: #ff6 !default;
72
+ $msg_info_bg: #bbf !default;
73
+ $msg_info_border_color: #66f !default;
74
+ $msg_filtered_bg: #e8e8e8 !default;
75
+ $msg_filtered_color: #666 !default;
76
+
77
+ $form_title_color: #1F7F00 !default;
78
+ $label_color: $header_color !default;
79
+ $description_color: #999 !default;
80
+ $placeholder_color: #aaa !default;
81
+ $input_border_color: $form_title_color !default;
82
+ $input_error_border_color: #f00 !default;
83
+ $input_focus_bg: #ffc !default;
84
+
85
+ $draggable_list_bg: #FFFF88 !default;
86
+ $draggable_list_selected_bg: #7FCF00 !default;
87
+ $draggable_list_disabled_bg: $disabled_color !default;
88
+ $checkbox_list_bg: #fff !default;
89
+
90
+ $subform_color: #999 !default;
91
+ $subform_header_color: $header_color !default;
92
+ $subform_footer_color: $subform_color !default;
93
+
94
+ .active-scaffold a, .active-scaffold a:visited {
95
+ color: $link_color;
96
+ }
97
+
98
+ .active-scaffold a.disabled {
99
+ color: $disabled_color;
100
+ }
101
+
102
+ .active-scaffold a:hover, .active-scaffold div.hover, .active-scaffold td span.hover {
103
+ background-color: $hover_bg;
104
+ }
105
+
106
+ noscript.active-scaffold {
107
+ border-color: $msg_error_border_color;
108
+ background-color: $msg_error_bg;
109
+ color: $column_color;
110
+ }
111
+
112
+ /* Header
113
+ ======================== */
114
+
115
+ .active-scaffold-header h2 {
116
+ color: $header_color;
117
+ }
118
+
119
+ .active-scaffold div.actions a.separator {
120
+ border-color: $action_group_border_color;
121
+ }
122
+ .active-scaffold-header div.actions a.disabled {
123
+ color: $actions_disabled_color;
124
+ }
125
+ .active-scaffold .actions .filters .active {
126
+ color: $active_filter;
127
+ }
128
+
129
+ /* Table :: Column Headers
130
+ ============================= */
131
+
132
+ .active-scaffold th {
133
+ background-color: $column_header_bg;
134
+ }
135
+
136
+ .active-scaffold th a,
137
+ .active-scaffold th p {
138
+ background-color: $column_header_bg;
139
+ }
140
+
141
+ .active-scaffold th a, .active-scaffold th a:visited {
142
+ color: $column_header_link_color;
143
+ }
144
+
145
+ .active-scaffold th p,
146
+ .active-scaffold .show-view th {
147
+ color: $column_header_color;
148
+ }
149
+
150
+ .active-scaffold th a:hover {
151
+ background-color: $column_header_link_hover_bg;
152
+ color: $column_header_link_hover_color;
153
+ }
154
+
155
+ .active-scaffold th.sorted {
156
+ background-color: $column_header_sorted_bg;
157
+ }
158
+
159
+ .active-scaffold th.asc a,
160
+ .active-scaffold th.asc a:hover,
161
+ .active-scaffold th.desc a,
162
+ .active-scaffold th.desc a:hover,
163
+ .active-scaffold th.loading a,
164
+ .active-scaffold th.loading a:hover {
165
+ background-color: $column_header_sorted_bg;
166
+ }
167
+
168
+ /* Table :: Record Rows
169
+ ============================= */
170
+
171
+ .active-scaffold tr.record {
172
+ background-color: $column_bg;
173
+ }
174
+ .active-scaffold tr.record td {
175
+ color: $column_color;
176
+ border-color: $column_border_color;
177
+ }
178
+
179
+ .active-scaffold tr.even-record {
180
+ background-color: $column_even_bg;
181
+ }
182
+ .active-scaffold tr.even-record td {
183
+ border-left-color: $column_even_border_color;
184
+ }
185
+
186
+ .active-scaffold tr.record td.sorted {
187
+ background-color: $column_sorted_bg;
188
+ border-bottom-color: $column_sorted_border_color;
189
+ }
190
+
191
+ .active-scaffold tr.even-record td.sorted {
192
+ background-color: $column_even_sorted_bg;
193
+ border-bottom-color: $column_even_sorted_border_color;
194
+ }
195
+
196
+ .active-scaffold tbody.records td.empty {
197
+ color: $column_empty_color;
198
+ }
199
+
200
+ /* Table :: Actions (Edit, Delete)
201
+ ============================= */
202
+ .active-scaffold tr.record td.actions {
203
+ border-color: $column_actions_border_color;
204
+ }
205
+
206
+ .active-scaffold tr.record td.actions table td.separator {
207
+ border-color: $column_actions_border_color;
208
+ }
209
+
210
+ .active-scaffold tr.record td.actions a.disabled {
211
+ color: $actions_disabled_color;
212
+ }
213
+
214
+ .active-scaffold .actions .action_group div:hover {
215
+ background-color: $action_group_hover_bg;
216
+ }
217
+
218
+ .active-scaffold .actions .action_group {
219
+ color: $action_group_color;
220
+ }
221
+
222
+ .active-scaffold .actions .action_group ul {
223
+ border-color: $action_group_border_color;
224
+ }
225
+
226
+ .active-scaffold .actions .action_group ul li {
227
+ background-color: $action_group_items_bg;
228
+ border-color: $action_group_items_border_color;
229
+ }
230
+
231
+ .active-scaffold .actions .action_group ul li a {
232
+ color: $action_group_link_color;
233
+ }
234
+
235
+ /* Table :: Inline Adapter
236
+ ============================= */
237
+
238
+ .active-scaffold .view {
239
+ background-color: $nested_bg;
240
+ border-color: $nested_border_color;
241
+ }
242
+
243
+ /* Nested
244
+ ======================== */
245
+
246
+ .active-scaffold .active-scaffold .active-scaffold-footer {
247
+ color: $nested_footer_color;
248
+ }
249
+
250
+ .active-scaffold .active-scaffold tr.record {
251
+ background-color: $nested_column_bg;
252
+ border-color: $nested_column_border_color;
253
+ }
254
+ .active-scaffold .active-scaffold tr.even-record {
255
+ background-color: $nested_column_even_bg;
256
+ }
257
+
258
+ .active-scaffold .active-scaffold td.inline-adapter-cell {
259
+ background-color: $second_nested_bg;
260
+ border-color: $second_nested_border_color;
261
+ }
262
+
263
+ .active-scaffold .active-scaffold .active-scaffold td.inline-adapter-cell {
264
+ background-color: $third_nested_bg;
265
+ border-color: $third_nested_border_color;
266
+ }
267
+
268
+ /* Footer
269
+ ========================== */
270
+
271
+ .active-scaffold-calculations td {
272
+ background-color: $calculations_bg;
273
+ border-color: $calculations_border_color;
274
+ }
275
+
276
+ .active-scaffold-footer .next {
277
+ border-color: $pagination_border_color;
278
+ }
279
+
280
+ .active-scaffold-footer .previous {
281
+ border-color: $pagination_border_color;
282
+ }
283
+
284
+ /* Messages
285
+ ========================= */
286
+
287
+
288
+ .active-scaffold .empty-message, .active-scaffold .filtered-message {
289
+ background-color: $msg_filtered_bg;
290
+ color: $msg_filtered_color;
291
+ }
292
+
293
+ .active-scaffold .message {
294
+ color: $msg_color;
295
+ }
296
+
297
+ .active-scaffold .error-message, .active-scaffold-component .error-message {
298
+ border-color: $msg_error_border_color;
299
+ background-color: $msg_error_bg;
300
+ }
301
+
302
+ .active-scaffold .warning-message {
303
+ border-color: $msg_warning_border_color;
304
+ background-color: $msg_warning_bg;
305
+ }
306
+
307
+ .active-scaffold .info-message {
308
+ border-color: $msg_info_border_color;
309
+ background-color: $msg_info_bg;
310
+ }
311
+
312
+ /* Error Styling
313
+ ========================== */
314
+
315
+ .active-scaffold .errorExplanation {
316
+ background-color: $msg_error_bg;
317
+ border-color: $msg_error_border_color;
318
+ }
319
+
320
+ .active-scaffold .errorExplanation h2 {
321
+ color: $msg_color;
322
+ background-color: $msg_error_border_color;
323
+ }
324
+
325
+ /* Show
326
+ ============================= */
327
+
328
+ .active-scaffold .show-view dt {
329
+ color: $label_color;
330
+ }
331
+
332
+ /* Form
333
+ ============================== */
334
+
335
+ .active-scaffold h4,
336
+ .active-scaffold h5 {
337
+ color: $form_title_color;
338
+ }
339
+
340
+ /* Form :: Fields
341
+ ============================== */
342
+
343
+ .active-scaffold label {
344
+ color: $label_color;
345
+ }
346
+
347
+ .active-scaffold .description {
348
+ color: $description_color;
349
+ }
350
+
351
+ .active-scaffold label.example {
352
+ color: $placeholder_color;
353
+ }
354
+
355
+ .active-scaffold input.text-input,
356
+ .active-scaffold select {
357
+ border-color: $input_border_color;
358
+ }
359
+
360
+ .active-scaffold input:invalid,
361
+ .active-scaffold textarea:invalid,
362
+ .active-scaffold select:invalid,
363
+ .active-scaffold .fieldWithErrors input,
364
+ .active-scaffold .field_with_errors input,
365
+ .active-scaffold .fieldWithErrors textarea,
366
+ .active-scaffold .field_with_errors textarea,
367
+ .active-scaffold .fieldWithErrors select,
368
+ .active-scaffold .field_with_errors select {
369
+ border-color: $input_error_border_color;
370
+ }
371
+
372
+ .active-scaffold input.example {
373
+ color: $placeholder_color;
374
+ }
375
+
376
+ .active-scaffold select:focus,
377
+ .active-scaffold input.text-input:focus {
378
+ background-color: $input_focus_bg;
379
+ }
380
+
381
+ .active-scaffold textarea {
382
+ border-color: $input_border_color;
383
+ }
384
+
385
+ .active-scaffold form .checkbox-list.draggable-list {
386
+ background-color: $draggable_list_bg;
387
+ }
388
+
389
+ .active-scaffold form .checkbox-list.draggable-list.selected {
390
+ background-color: $draggable_list_selected_bg;
391
+ }
392
+ .active-scaffold .ui-droppable-disabled, .active-scaffold .ui-droppable-disabled.selected {
393
+ background-color: $draggable_list_disabled_bg;
394
+ }
395
+
396
+
397
+ /* Form :: Association Sub-Forms
398
+ ============================== */
399
+
400
+ .active-scaffold .sub-form table th {
401
+ color: $subform_header_color;
402
+ }
403
+
404
+ .active-scaffold .sub-form .checkbox-list {
405
+ background-color: $checkbox_list_bg;
406
+ border-color: $input_border_color;
407
+ }
408
+
409
+ .active-scaffold .vertical-sub-form .sub-form-record + .sub-form-record {
410
+ border-color: $vertical_sub_form_border_color;
411
+ }
412
+
413
+ .active-scaffold .sub-form table td {
414
+ color: $subform_color;
415
+ }
416
+
417
+ .active-scaffold .sub-form .footer {
418
+ color: $subform_footer_color;
419
+ }
420
+
421
+ .as_touch th a, .as_touch th a:visited {
422
+ color: $column_header_link_color;
423
+ }
424
+
@@ -86,7 +86,7 @@ margin-left: 0px;
86
86
  padding: 1px 5px;
87
87
  }
88
88
 
89
- .active-scaffold div.actions div.action_group {
89
+ .active-scaffold div.actions div.action_group, .active-scaffold div.actions div.filters {
90
90
  display: inline;
91
91
  float: right;
92
92
  }
@@ -928,6 +928,15 @@ float: left;
928
928
  margin-right: 5px;
929
929
  }
930
930
 
931
+ .active-scaffold .vertical-sub-form .sub-form-record + .sub-form-record {
932
+ border-top: 1px solid;
933
+ padding-top: 10px;
934
+ }
935
+
936
+ .active-scaffold .vertical-sub-form .sub-form-record .association-record-new:not(.locked) {
937
+ padding-bottom: 10px;
938
+ }
939
+
931
940
  .active-scaffold .sub-form .checkbox-list {
932
941
  padding: 0 2px 2px 2px;
933
942
  border: solid 1px;
@@ -958,6 +967,7 @@ padding: 0;
958
967
  width: 16px;
959
968
  text-indent: -4000px;
960
969
  background: 0 0 no-repeat;
970
+ overflow: hidden;
961
971
  }
962
972
 
963
973
  .active-scaffold .sub-form .locked a.destroy {
@@ -11,7 +11,7 @@
11
11
  <% column_css_class = column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc) %>
12
12
  <% renders_as = column_renders_as(column) %>
13
13
  <% authorized = show_unauthorized_columns || renders_as == :subsection ? @record.authorized_for?(crud_type: form_action, column: column.name) : true %>
14
- <% if renders_as == :subsection || renders_as == :tabbed -%>
14
+ <% if renders_as == :subsection -%>
15
15
  <% next unless authorized %>
16
16
  <li class="sub-section <%= column_css_class %>">
17
17
  <%= render_subsection(column, @record, scope, form_action) %>
@@ -47,7 +47,8 @@ end
47
47
  <% if remote_controller.respond_to?(:uses_record_select?) && remote_controller.uses_record_select? -%>
48
48
  <%= link_to_record_select as_(:add_existing), remote_controller.controller_path, record_select_params_for_add_existing(column.association, edit_associated_url, parent_record) -%>
49
49
  <% else -%>
50
- <% select_options = options_from_collection_for_select(sorted_association_options_find(column.association, nil, parent_record), :to_param, :to_label)
50
+ <% helper_method = association_helper_method(column.association, :sorted_association_options_find)
51
+ select_options = options_from_collection_for_select(send(helper_method, column.association, nil, parent_record), :to_param, :to_label)
51
52
  add_existing_id = "#{subform_div_id}-add-existing"
52
53
  add_existing_label = column.association.collection? ? :add_existing : :replace_existing %>
53
54
  <%= select_tag 'associated_id', content_tag(:option, as_(:_select_), value: '') + select_options %>
@@ -9,7 +9,7 @@
9
9
  scope = column_scope(record_column, scope, record)
10
10
  options = active_scaffold_input_options(config.columns[record.class.primary_key], scope, object: record)
11
11
  tr_id = "association-#{options[:id]}"
12
- layout ||= config.subform.layout
12
+ layout ||= column.options[:layout] || config.subform.layout
13
13
 
14
14
  if layout == :vertical
15
15
  record_tag ||= :div
@@ -0,0 +1 @@
1
+ <%= filters.map { |filter| active_scaffold_human_filter_for filter }.to_sentence %>
@@ -1,5 +1,7 @@
1
1
  <% action_links = active_scaffold_config.action_links.collection -%>
2
+ <% filters = active_scaffold_config.list.filters %>
2
3
  <div class="actions">
4
+ <%= display_filters(filters) %>
3
5
  <%= display_action_links(action_links, nil, skip_unauthorized: true) unless action_links.empty? %>
4
6
  <%= loading_indicator_tag(action: :table) %>
5
7
  </div>
@@ -14,6 +14,17 @@
14
14
  </div>
15
15
  <% end -%>
16
16
  <% end %>
17
+ <%= content_tag :div, class: 'filtered-message applied-filters',
18
+ style: ('display:none;' unless active_scaffold_config.list.filter_human_message && @applied_filters.present?),
19
+ data: ({search: search_params || ''} if active_scaffold_config.store_user_settings && respond_to?(:search_params)) do %>
20
+ <div><%= render('human_filters', filters: @applied_filters) if active_scaffold_config.list.filter_human_message && @applied_filters.present? %></div>
21
+ <% if active_scaffold_config.list.show_filter_reset && @applied_filters.present? -%>
22
+ <div class="reset">
23
+ <%= loading_indicator_tag(action: :record, id: nil) %>
24
+ <%= render_action_link(active_scaffold_config.list.reset_filter_link) %>
25
+ </div>
26
+ <% end -%>
27
+ <% end %>
17
28
  <p id="<%= empty_message_id %>" class="empty-message" <%= ' style="display:none;" '.html_safe unless @page.empty? %>>
18
29
  <%= as_(active_scaffold_config.list.no_entries_message) %>
19
30
  </p>
@@ -28,7 +28,7 @@
28
28
  html =
29
29
  if scope
30
30
  readonly = @record.readonly? || !@record.authorized_for?(crud_type: :update)
31
- crud_type = @record.new_record? ? :create : (readonly ? :read : :update)
31
+ crud_type = @record.id.nil? ? :create : (readonly ? :read : :update) # don't use new_record?, it's always true in render_field action
32
32
  # subform.columns.to_a.include? so it doesn't check inside subgroups
33
33
  active_scaffold_render_subform_column(column, scope, crud_type, readonly, active_scaffold_config.subform.columns.to_a.exclude?(column.name), @record)
34
34
  elsif @form_action == :field_search
@@ -1,2 +1,3 @@
1
1
  <% associated = column.association.singular? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a -%>
2
+ <% associated = associated.select { |record| record.send(tabbed_by) == tab_value } if local_assigns[:tabbed_by] %>
2
3
  <%= render "show_association_#{show_partial}", column: column, parent_record: parent_record, associated: associated if associated.present? %>
@@ -3,12 +3,27 @@
3
3
  <dt><%= show_label(column) -%></dt>
4
4
  <% if column.respond_to? :each_column -%>
5
5
  <dd>
6
- <%= render 'show_columns', columns: column, record: record %>
6
+ <% locals = {columns: column, record: record} %>
7
+ <% if column.tabbed_by %>
8
+ <div>
9
+ <%=
10
+ locals[:tabbed_by] = column.tabbed_by
11
+ subsection_id = sub_section_id(sub_section: column.label)
12
+ tab_options = send(override_helper_per_model(:active_scaffold_tab_options, record.class), column, record)
13
+ used_tabs = send(override_helper_per_model(:active_scaffold_current_tabs, record.class), column, record, tab_options)
14
+ active_scaffold_tabs_for(column, record, subsection_id, tab_options, used_tabs) do |tab_value, tab_id|
15
+ render 'show_columns', locals.merge(tab_id: tab_id, tab_value: tab_value)
16
+ end
17
+ %>
18
+ </div>
19
+ <% else %>
20
+ <%= render 'show_columns', locals %>
21
+ <% end %>
7
22
  <% else -%>
8
23
  <% css_class = "#{column.name}-view"
9
24
  css_class.concat(" #{column.css_class}") unless column.css_class.nil? %>
10
25
  <dd class="<%= css_class.strip %>">
11
- <%= show_column_value(record, column) -%>
26
+ <%= show_column_value(record, column, **local_assigns.slice(:tabbed_by, :tab_id, :tab_value)) -%>
12
27
  <% end -%>
13
28
  </dd>
14
29
  <% end -%>
@@ -0,0 +1,20 @@
1
+ var field = jQuery('#<%= params[:from_field] %>');
2
+ <%
3
+ label, id = new_option_from_record(@record)
4
+ config = active_scaffold_config_for(params[:parent_model])
5
+ column = config.columns[params[:parent_column]] if config
6
+ field_options = active_scaffold_input_options(column, params[:parent_scope], {object: @record}.merge(params[:radio_data]&.to_unsafe_h || {})) if column
7
+ field_options[:class] = "#{field_options[:class]} update_form" if field_options&.dig('data-update_url')
8
+ %>
9
+ if (field.is('select')) {
10
+ field.append('<%= j content_tag(:option, label, value: id) %>');
11
+ field.val(<%= id %>);
12
+ } else if (field.is('input.recordselect')) {
13
+ field.val('<%= j label %>').addClass('selected');
14
+ field.next().val(<%= id %>);
15
+ } else if (field.is('.new-radio-container')) {
16
+ field.append('<%= j active_scaffold_radio_option(@record, id, column, field_options, ui_options: column.form_ui_options || column.options) if column %>');
17
+ }
18
+ field.trigger('change');
19
+ var action_link = ActiveScaffold.ActionLink.get(field.parent().find('a.as_action'));
20
+ if (action_link) action_link.close();
@@ -8,8 +8,8 @@
8
8
  tab_content = render('form', columns: @column, subsection_id: "#{subsection_id}-#{tab_id_suffix}", form_action: @form_action, scope: @scope, tab_value: tab_record || tab_value, tab_id: tab_id_suffix, tabbed_by: @column.tabbed_by)
9
9
  tab = active_scaffold_tab_content(tab_id, true, tab_content)
10
10
  %>
11
- $('#<%= subsection_id %> .tab-content > .tab-pane.active').removeClass('in active');
11
+ jQuery('#<%= subsection_id %> .tab-content > .tab-pane.active').removeClass('in active');
12
12
  ActiveScaffold.create_associated_record_form('<%= subsection_id %> .tab-content', '<%= j tab %>', {singular: false});
13
- $('#<%= subsection_id %> .nav-tabs').find('.nav-item.active').removeClass('active').end().append('<%= j active_scaffold_tab(tab_label, tab_id, true) %>');
14
- $('#<%= @source_id %> option[value=<%= tab_value %>]').hide().parent().val('');
13
+ jQuery('#<%= subsection_id %> .nav-tabs').find('.nav-item.active').removeClass('active').end().append('<%= j active_scaffold_tab(tab_label, tab_id, true) %>');
14
+ jQuery('#<%= @source_id %> option[value=<%= tab_value %>]').hide().parent().val('');
15
15
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%
2
- subform_id = sub_form_list_id(association: @column.name, tab_id: (params[:value] if params[:tabbed_by]), id: @parent_record.id || generated_id(@parent_record) || 99_999_999_999)
2
+ subform_id = sub_form_list_id(association: @column.name, tab_id: @tab_id, id: @parent_record.id || generated_id(@parent_record) || 99_999_999_999)
3
3
  associated_form = render 'form_association_record', scope: @scope, parent_record: @parent_record, column: @column, record: @record, locked: @record.new_record? && @column.association.singular?
4
4
  options = {singular: false}
5
5
  if @column.association.singular?
@@ -1,21 +1,25 @@
1
1
  try {
2
- var action_link;
3
- <%
4
- form_selector ||= element_form_id(action: :create)
5
- insert_at ||= :top
6
- always_show_create ||= active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
7
- -%>
8
- <% if always_show_create -%>
9
- <%= render 'update_messages' %>
10
- <% else -%>
11
- action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
12
- if (action_link) action_link.update_flash_messages('<%= escape_javascript(render('messages')) %>');
13
- <% end -%>
14
- <% if successful? -%>
15
- <%= render 'new_record', insert_at: insert_at %>
16
- <%= render 'refresh_create_form', always_show_create: always_show_create, form_selector: form_selector unless render_parent? %>
2
+ <% if params[:from_field] && successful? %>
3
+ <%= render 'update_field_on_create' %>
17
4
  <% else %>
18
- ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
19
- ActiveScaffold.scroll_to('<%= form_selector %>', true);
5
+ var action_link;
6
+ <%
7
+ form_selector ||= element_form_id(action: :create)
8
+ insert_at ||= :top
9
+ always_show_create ||= active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
10
+ -%>
11
+ <% if always_show_create -%>
12
+ <%= render 'update_messages' %>
13
+ <% else -%>
14
+ action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
15
+ if (action_link) action_link.update_flash_messages('<%= escape_javascript(render('messages')) %>');
16
+ <% end -%>
17
+ <% if successful? -%>
18
+ <%= render 'new_record', insert_at: insert_at %>
19
+ <%= render 'refresh_create_form', always_show_create: always_show_create, form_selector: form_selector unless render_parent? %>
20
+ <% else %>
21
+ ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
22
+ ActiveScaffold.scroll_to('<%= form_selector %>', true);
23
+ <% end %>
20
24
  <% end %>
21
25
  } catch (e) { alert('RJS error:\n\n' + e.toString());}
@@ -6,7 +6,7 @@ if (action_link) action_link.update_flash_messages('<%= escape_javascript(render
6
6
  <% if params[:dont_close] %>
7
7
  <% row_selector = element_row_id(action: :list, id: @record.id) %>
8
8
  ActiveScaffold.update_row('<%= row_selector %>', '<%= escape_javascript(render(list_record_view, record: @record)) %>');
9
- if (action_link) action_link.target = $('#<%= row_selector %>');
9
+ if (action_link) action_link.target = jQuery('#<%= row_selector %>');
10
10
  <%= render 'update_calculations' %>
11
11
  <% if params[:iframe] == 'true' %>
12
12
  ActiveScaffold.enable_form('<%= form_selector %>');