active_scaffold 4.1.6 → 4.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/CHANGELOG.rdoc +27 -0
- data/README.md +6 -5
- data/app/assets/javascripts/jquery/active_scaffold.js +98 -47
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +15 -2
- data/app/assets/stylesheets/active_scaffold_images.scss +6 -0
- data/app/assets/stylesheets/{active_scaffold_layout.css → active_scaffold_layout.scss} +104 -4
- data/app/assets/stylesheets/tiny_mce_bridge.scss +11 -0
- data/app/views/active_scaffold_overrides/_base_form.html.erb +3 -2
- data/app/views/active_scaffold_overrides/_field_search.html.erb +2 -2
- data/app/views/active_scaffold_overrides/_form.html.erb +14 -4
- data/app/views/active_scaffold_overrides/_form_association.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +5 -11
- data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb +1 -3
- data/app/views/active_scaffold_overrides/_new_record.js.erb +3 -1
- data/app/views/active_scaffold_overrides/_refresh_list.js.erb +1 -1
- data/app/views/active_scaffold_overrides/_render_field.js.erb +67 -36
- data/app/views/active_scaffold_overrides/_update_field_on_create.js.erb +41 -6
- data/app/views/active_scaffold_overrides/action_links_menu.js.erb +1 -0
- data/config/locales/de.yml +9 -0
- data/config/locales/en.yml +11 -0
- data/config/locales/es.yml +8 -0
- data/config/locales/fr.yml +8 -0
- data/config/locales/hu.yml +8 -0
- data/config/locales/ja.yml +8 -0
- data/config/locales/ru.yml +8 -0
- data/lib/active_scaffold/actions/common_search.rb +2 -0
- data/lib/active_scaffold/actions/core.rb +47 -23
- data/lib/active_scaffold/actions/create.rb +2 -0
- data/lib/active_scaffold/actions/delete.rb +6 -0
- data/lib/active_scaffold/actions/field_search.rb +36 -11
- data/lib/active_scaffold/actions/list.rb +26 -8
- data/lib/active_scaffold/actions/mark.rb +6 -0
- data/lib/active_scaffold/actions/nested.rb +2 -0
- data/lib/active_scaffold/actions/search.rb +7 -0
- data/lib/active_scaffold/actions/show.rb +6 -0
- data/lib/active_scaffold/actions/subform.rb +2 -0
- data/lib/active_scaffold/actions/update.rb +8 -1
- data/lib/active_scaffold/active_record_permissions.rb +3 -3
- data/lib/active_scaffold/attribute_params.rb +35 -17
- data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +10 -9
- data/lib/active_scaffold/bridges/active_storage/form_ui.rb +10 -3
- data/lib/active_scaffold/bridges/active_storage/list_ui.rb +2 -0
- data/lib/active_scaffold/bridges/active_storage.rb +2 -0
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/ancestry.rb +2 -0
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/bitfields/list_ui.rb +2 -0
- data/lib/active_scaffold/bridges/bitfields.rb +2 -0
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +9 -6
- data/lib/active_scaffold/bridges/cancan.rb +2 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +2 -0
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +3 -1
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -0
- data/lib/active_scaffold/bridges/carrierwave.rb +2 -0
- data/lib/active_scaffold/bridges/chosen/helpers.rb +13 -4
- data/lib/active_scaffold/bridges/chosen.rb +2 -0
- data/lib/active_scaffold/bridges/country_select/country_select_bridge_helper.rb +2 -0
- data/lib/active_scaffold/bridges/country_select.rb +2 -0
- data/lib/active_scaffold/bridges/date_picker/ext.rb +6 -0
- data/lib/active_scaffold/bridges/date_picker/helper.rb +7 -3
- data/lib/active_scaffold/bridges/date_picker.rb +2 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +2 -0
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +3 -1
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +2 -0
- data/lib/active_scaffold/bridges/dragonfly.rb +2 -0
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +10 -9
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +2 -0
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +2 -0
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +2 -0
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +2 -0
- data/lib/active_scaffold/bridges/file_column.rb +2 -0
- data/lib/active_scaffold/bridges/logical_query_parser/tokens_grammar.rb +65 -0
- data/lib/active_scaffold/bridges/logical_query_parser/tokens_grammar.treetop +31 -0
- data/lib/active_scaffold/bridges/logical_query_parser.rb +9 -0
- data/lib/active_scaffold/bridges/paper_trail/actions.rb +2 -0
- data/lib/active_scaffold/bridges/paper_trail/config.rb +2 -0
- data/lib/active_scaffold/bridges/paper_trail/helper.rb +2 -0
- data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/paper_trail.rb +2 -0
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +3 -1
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +2 -0
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +2 -0
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +12 -12
- data/lib/active_scaffold/bridges/paperclip.rb +2 -0
- data/lib/active_scaffold/bridges/record_select/helpers.rb +19 -11
- data/lib/active_scaffold/bridges/record_select.rb +2 -0
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +2 -0
- data/lib/active_scaffold/bridges/semantic_attributes.rb +2 -0
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
- data/lib/active_scaffold/bridges/tiny_mce.rb +6 -0
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +2 -0
- data/lib/active_scaffold/bridges/usa_state_select.rb +2 -0
- data/lib/active_scaffold/bridges.rb +2 -0
- data/lib/active_scaffold/config/base.rb +12 -7
- data/lib/active_scaffold/config/core.rb +26 -23
- data/lib/active_scaffold/config/create.rb +2 -0
- data/lib/active_scaffold/config/delete.rb +2 -0
- data/lib/active_scaffold/config/field_search.rb +2 -0
- data/lib/active_scaffold/config/form.rb +11 -1
- data/lib/active_scaffold/config/list.rb +7 -7
- data/lib/active_scaffold/config/mark.rb +2 -0
- data/lib/active_scaffold/config/nested.rb +28 -0
- data/lib/active_scaffold/config/search.rb +2 -0
- data/lib/active_scaffold/config/show.rb +2 -0
- data/lib/active_scaffold/config/subform.rb +2 -0
- data/lib/active_scaffold/config/update.rb +3 -1
- data/lib/active_scaffold/configurable.rb +4 -2
- data/lib/active_scaffold/constraints.rb +2 -0
- data/lib/active_scaffold/core.rb +14 -4
- data/lib/active_scaffold/data_structures/action_columns.rb +3 -1
- data/lib/active_scaffold/data_structures/action_link.rb +10 -0
- data/lib/active_scaffold/data_structures/action_link_separator.rb +2 -0
- data/lib/active_scaffold/data_structures/action_links.rb +32 -21
- data/lib/active_scaffold/data_structures/actions.rb +4 -2
- data/lib/active_scaffold/data_structures/association/abstract.rb +4 -2
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +4 -2
- data/lib/active_scaffold/data_structures/association/active_record.rb +3 -9
- data/lib/active_scaffold/data_structures/association/mongoid.rb +4 -2
- data/lib/active_scaffold/data_structures/association.rb +2 -0
- data/lib/active_scaffold/data_structures/bridge.rb +3 -1
- data/lib/active_scaffold/data_structures/column.rb +37 -3
- data/lib/active_scaffold/data_structures/columns.rb +4 -2
- data/lib/active_scaffold/data_structures/filter.rb +3 -3
- data/lib/active_scaffold/data_structures/filter_option.rb +2 -0
- data/lib/active_scaffold/data_structures/filters.rb +3 -3
- data/lib/active_scaffold/data_structures/nested_info.rb +4 -2
- data/lib/active_scaffold/data_structures/set.rb +8 -10
- data/lib/active_scaffold/data_structures/sorting.rb +5 -7
- data/lib/active_scaffold/engine.rb +3 -4
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -0
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +2 -0
- data/lib/active_scaffold/extensions/action_view_rendering.rb +2 -0
- data/lib/active_scaffold/extensions/connection_adapter.rb +2 -0
- data/lib/active_scaffold/extensions/ice_nine.rb +2 -0
- data/lib/active_scaffold/extensions/localize.rb +2 -0
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +2 -0
- data/lib/active_scaffold/extensions/paginator_extensions.rb +3 -1
- data/lib/active_scaffold/extensions/routing_mapper.rb +2 -0
- data/lib/active_scaffold/extensions/to_label.rb +2 -0
- data/lib/active_scaffold/extensions/unsaved_associated.rb +10 -8
- data/lib/active_scaffold/extensions/unsaved_record.rb +2 -0
- data/lib/active_scaffold/finder.rb +57 -18
- data/lib/active_scaffold/helpers/action_link_helpers.rb +112 -37
- data/lib/active_scaffold/helpers/association_helpers.rb +4 -2
- data/lib/active_scaffold/helpers/controller_helpers.rb +2 -0
- data/lib/active_scaffold/helpers/filter_helpers.rb +11 -3
- data/lib/active_scaffold/helpers/form_column_helpers.rb +98 -71
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +2 -0
- data/lib/active_scaffold/helpers/id_helpers.rb +2 -0
- data/lib/active_scaffold/helpers/list_column_helpers.rb +9 -5
- data/lib/active_scaffold/helpers/pagination_helpers.rb +3 -1
- data/lib/active_scaffold/helpers/search_column_helpers.rb +19 -9
- data/lib/active_scaffold/helpers/show_column_helpers.rb +4 -2
- data/lib/active_scaffold/helpers/tabs_helpers.rb +5 -3
- data/lib/active_scaffold/helpers/view_helpers.rb +3 -3
- data/lib/active_scaffold/marked_model.rb +6 -5
- data/lib/active_scaffold/orm_checks.rb +2 -0
- data/lib/active_scaffold/paginator.rb +4 -1
- data/lib/active_scaffold/registry.rb +2 -0
- data/lib/active_scaffold/responds_to_parent.rb +2 -0
- data/lib/active_scaffold/tableless.rb +23 -13
- data/lib/active_scaffold/version.rb +4 -2
- data/lib/active_scaffold.rb +10 -2
- data/lib/generators/active_scaffold/controller/USAGE +19 -0
- data/lib/generators/active_scaffold/controller/controller_generator.rb +29 -0
- data/lib/generators/active_scaffold/install/USAGE +2 -0
- data/lib/generators/active_scaffold/{install_generator.rb → install/install_generator.rb} +10 -6
- data/lib/generators/active_scaffold/resource/USAGE +29 -0
- data/lib/generators/active_scaffold/resource/resource_generator.rb +30 -0
- data/lib/tasks/brakeman.rake +2 -0
- data/shoulda_macros/macros.rb +2 -0
- metadata +19 -11
- data/lib/generators/active_scaffold/controller_generator.rb +0 -49
- data/lib/generators/active_scaffold/resource_generator.rb +0 -56
- /data/lib/generators/{templates → active_scaffold/controller/templates}/controller.rb +0 -0
- /data/lib/generators/{templates → active_scaffold/controller/templates}/helper.rb +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
module Helpers
|
|
3
5
|
# Helpers that assist with the rendering of a List Column
|
|
@@ -22,8 +24,9 @@ module ActiveScaffold
|
|
|
22
24
|
value = ' '.html_safe if value.nil? || value.blank? # fix for IE 6
|
|
23
25
|
value
|
|
24
26
|
rescue StandardError => e
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
message = "on the ActiveScaffold column = :#{column.name} in #{controller.class}, record: #{record.inspect}"
|
|
28
|
+
ActiveScaffold.log_exception(e, message)
|
|
29
|
+
raise e.class, "#{e.message} -- #{message}", e.backtrace
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
def get_column_method(record, column)
|
|
@@ -62,8 +65,9 @@ module ActiveScaffold
|
|
|
62
65
|
text
|
|
63
66
|
end
|
|
64
67
|
rescue StandardError => e
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
message = "on the ActiveScaffold column = :#{column.name} in #{controller.class}"
|
|
69
|
+
ActiveScaffold.log_exception(e, message)
|
|
70
|
+
raise e.class, "#{e.message} -- #{message}", e.backtrace
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
def column_wrap_tag
|
|
@@ -303,7 +307,7 @@ module ActiveScaffold
|
|
|
303
307
|
empty_field_text(column)
|
|
304
308
|
elsif column_value.is_a?(Time) || column_value.is_a?(Date)
|
|
305
309
|
l(column_value, format: options&.dig(:format) || :default)
|
|
306
|
-
elsif !!column_value == column_value # rubocop:disable Style/DoubleNegation fast check for boolean
|
|
310
|
+
elsif !!column_value == column_value # rubocop:disable Style/DoubleNegation -- fast check for boolean
|
|
307
311
|
as_(column_value.to_s.to_sym)
|
|
308
312
|
else
|
|
309
313
|
column_value.to_s
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
module Helpers
|
|
3
5
|
module PaginationHelpers
|
|
@@ -27,7 +29,7 @@ module ActiveScaffold
|
|
|
27
29
|
|
|
28
30
|
html = []
|
|
29
31
|
if current_page.number == 1
|
|
30
|
-
last_page = 0
|
|
32
|
+
last_page = 0
|
|
31
33
|
else
|
|
32
34
|
last_page = 1
|
|
33
35
|
last_page.upto([last_page + outer_window, current_page.number - 1].min) do |num|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
module Helpers
|
|
3
5
|
# Helpers that assist with the rendering of a Form Column
|
|
@@ -43,8 +45,9 @@ module ActiveScaffold
|
|
|
43
45
|
text_field(:record, column.name, options.merge(column.options))
|
|
44
46
|
end
|
|
45
47
|
rescue StandardError => e
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
message = "on the ActiveScaffold column = :#{column.name} in #{controller.class}"
|
|
49
|
+
ActiveScaffold.log_exception(e, message)
|
|
50
|
+
raise e.class, "#{e.message} -- #{message}", e.backtrace
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
# the standard active scaffold options used for class, name and scope
|
|
@@ -205,13 +208,20 @@ module ActiveScaffold
|
|
|
205
208
|
end
|
|
206
209
|
|
|
207
210
|
def active_scaffold_search_range_comparator_options(column, ui_options: column.options)
|
|
208
|
-
select_options =
|
|
211
|
+
select_options = []
|
|
209
212
|
if active_scaffold_search_range_string?(column)
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
if column.search_sql.present?
|
|
214
|
+
select_options.concat(ActiveScaffold::Finder::STRING_COMPARATORS.collect { |title, comp| [as_(title), comp] })
|
|
215
|
+
end
|
|
216
|
+
if ActiveScaffold::Finder::LOGICAL_COMPARATORS.present? && column.logical_search.present?
|
|
217
|
+
select_options.concat(ActiveScaffold::Finder::LOGICAL_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] })
|
|
218
|
+
end
|
|
212
219
|
end
|
|
213
|
-
if
|
|
214
|
-
select_options.concat(ActiveScaffold::Finder::
|
|
220
|
+
if column.search_sql.present?
|
|
221
|
+
select_options.concat(ActiveScaffold::Finder::NUMERIC_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] })
|
|
222
|
+
if include_null_comparators? column, ui_options: ui_options
|
|
223
|
+
select_options.concat(ActiveScaffold::Finder::NULL_COMPARATORS.collect { |comp| [as_(comp), comp] })
|
|
224
|
+
end
|
|
215
225
|
end
|
|
216
226
|
select_options
|
|
217
227
|
end
|
|
@@ -338,7 +348,7 @@ module ActiveScaffold
|
|
|
338
348
|
options_for_select(active_scaffold_search_datetime_trend_units(column), current_search['unit']),
|
|
339
349
|
class: 'text-input')
|
|
340
350
|
]
|
|
341
|
-
show = current_search.key?(:show) ? current_search[:show] :
|
|
351
|
+
show = current_search.key?(:show) ? current_search[:show] : %w[PAST FUTURE].include?(current_search['opt'])
|
|
342
352
|
content_tag('span', safe_join(trend_controls, ' '),
|
|
343
353
|
id: "#{options[:id]}_trend", class: 'search-date-trend',
|
|
344
354
|
style: ('display: none' unless show))
|
|
@@ -407,7 +417,7 @@ module ActiveScaffold
|
|
|
407
417
|
visibles = []
|
|
408
418
|
hiddens = []
|
|
409
419
|
columns.each_column do |column|
|
|
410
|
-
next unless column.respond_to?(:each_column) || column.
|
|
420
|
+
next unless column.respond_to?(:each_column) || column.searchable?
|
|
411
421
|
|
|
412
422
|
if search_config.optional_columns.include?(column.name) && !searched_by?(column)
|
|
413
423
|
hiddens << column
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
module Helpers
|
|
3
5
|
# Helpers that assist with the rendering of a List Column
|
|
@@ -27,14 +29,14 @@ module ActiveScaffold
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def active_scaffold_show_horizontal(record, column, ui_options: column.options)
|
|
30
|
-
raise ':horizontal show_ui must be used on association column' unless column.association
|
|
32
|
+
raise ArgumentError, ':horizontal show_ui must be used on association column' unless column.association
|
|
31
33
|
|
|
32
34
|
vars = {column: column, parent_record: record, show_partial: :horizontal}
|
|
33
35
|
render partial: 'show_association', locals: vars.merge(ui_options.slice(:tabbed_by, :tab_value, :tab_id))
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
def active_scaffold_show_vertical(record, column, ui_options: column.options)
|
|
37
|
-
raise ':vertical show_ui must be used on association column' unless column.association
|
|
39
|
+
raise ArgumentError, ':vertical show_ui must be used on association column' unless column.association
|
|
38
40
|
|
|
39
41
|
render partial: 'show_association', locals: {column: column, parent_record: record, show_partial: :vertical}
|
|
40
42
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
module Helpers
|
|
3
5
|
# Helpers that assist with rendering of tabs in forms
|
|
@@ -59,13 +61,13 @@ module ActiveScaffold
|
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
def active_scaffold_tab(label, tab_id, active)
|
|
62
|
-
content_tag :li, class:
|
|
63
|
-
link_to(label, "##{tab_id}", class:
|
|
64
|
+
content_tag :li, class: 'nav-item' do
|
|
65
|
+
link_to(label, "##{tab_id}", class: "nav-link #{:active if active}", data: {bs_toggle: :tab})
|
|
64
66
|
end
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
def active_scaffold_tab_content(tab_id, active, content)
|
|
68
|
-
content_tag(:div, content, class: "tab-pane fade#{'
|
|
70
|
+
content_tag(:div, content, class: "tab-pane fade#{' active show' if active}", id: tab_id)
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
def active_scaffold_tabs_for(column, record, subsection_id, tab_options, used_tabs)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
module Helpers
|
|
3
5
|
# All extra helpers that should be included in the View.
|
|
@@ -20,9 +22,7 @@ module ActiveScaffold
|
|
|
20
22
|
##
|
|
21
23
|
|
|
22
24
|
def active_scaffold_controller_for(klass)
|
|
23
|
-
|
|
24
|
-
controller.class.active_scaffold_controller_for(klass)
|
|
25
|
-
end
|
|
25
|
+
controller.class.active_scaffold_controller_for(klass)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
##
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
module MarkedModel
|
|
3
5
|
# This is a module aimed at making the make session_stored marked_records available to ActiveRecord models
|
|
@@ -5,11 +7,12 @@ module ActiveScaffold
|
|
|
5
7
|
def self.included(base)
|
|
6
8
|
base.class_eval do
|
|
7
9
|
extend ClassMethods
|
|
10
|
+
|
|
8
11
|
scope :as_marked, -> { where(primary_key => marked_record_ids) }
|
|
9
12
|
end
|
|
10
13
|
end
|
|
11
14
|
|
|
12
|
-
def as_marked
|
|
15
|
+
def as_marked # rubocop:disable Naming/PredicateMethod
|
|
13
16
|
marked_records.include?(id.to_s)
|
|
14
17
|
end
|
|
15
18
|
|
|
@@ -26,7 +29,7 @@ module ActiveScaffold
|
|
|
26
29
|
ActiveScaffold::Registry.marked_records ||= {}
|
|
27
30
|
end
|
|
28
31
|
|
|
29
|
-
def marked_records=(marked)
|
|
32
|
+
def marked_records=(marked) # rubocop:disable Rails/Delegate
|
|
30
33
|
ActiveScaffold::Registry.marked_records = marked
|
|
31
34
|
end
|
|
32
35
|
|
|
@@ -36,8 +39,6 @@ module ActiveScaffold
|
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
# Instance-level access to the marked_records
|
|
39
|
-
|
|
40
|
-
self.class.marked_records
|
|
41
|
-
end
|
|
42
|
+
delegate :marked_records, to: :class
|
|
42
43
|
end
|
|
43
44
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'forwardable'
|
|
2
4
|
|
|
3
5
|
class Paginator
|
|
4
|
-
VERSION = '1.0.9'
|
|
6
|
+
VERSION = '1.0.9'
|
|
5
7
|
|
|
6
8
|
class ArgumentError < ::ArgumentError; end
|
|
7
9
|
class MissingCountError < ArgumentError; end
|
|
@@ -72,6 +74,7 @@ class Paginator
|
|
|
72
74
|
# of the page in the paginator
|
|
73
75
|
class Page
|
|
74
76
|
extend Forwardable
|
|
77
|
+
|
|
75
78
|
def_delegator :@pager, :first, :first
|
|
76
79
|
def_delegator :@pager, :last, :last
|
|
77
80
|
def_delegator :items, :each
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
|
|
2
4
|
class Connection < ActiveRecord::ConnectionAdapters::AbstractAdapter
|
|
3
5
|
attr_reader :klass
|
|
4
6
|
|
|
5
|
-
def initialize(klass, *
|
|
6
|
-
super(nil, *
|
|
7
|
+
def initialize(klass, *)
|
|
8
|
+
super(nil, *)
|
|
7
9
|
@klass = klass
|
|
8
10
|
end
|
|
9
11
|
|
|
@@ -21,9 +23,19 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
class Column < ActiveRecord::ConnectionAdapters::Column
|
|
24
|
-
def initialize(name, default,
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
def initialize(name, default, type, null = true, *, **) # rubocop:disable Style/OptionalBooleanParameter,Metrics/ParameterLists
|
|
27
|
+
if Rails.version >= '8.1'
|
|
28
|
+
if type.is_a?(Symbol)
|
|
29
|
+
cast_type = ActiveRecord::Type.lookup(type)
|
|
30
|
+
else
|
|
31
|
+
metadata = ActiveRecord::Base.connection.send :fetch_type_metadata, type
|
|
32
|
+
cast_type = ActiveRecord::Type.lookup(metadata.type)
|
|
33
|
+
end
|
|
34
|
+
super(name, cast_type, default, metadata, null, *, **)
|
|
35
|
+
else
|
|
36
|
+
metadata = ActiveRecord::Base.connection.send :fetch_type_metadata, type.to_s
|
|
37
|
+
super(name, default, metadata, null, *, **)
|
|
38
|
+
end
|
|
27
39
|
end
|
|
28
40
|
end
|
|
29
41
|
|
|
@@ -121,16 +133,14 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
|
121
133
|
end
|
|
122
134
|
|
|
123
135
|
def find_one(id)
|
|
124
|
-
|
|
136
|
+
model.find_one(id, self) || raise(ActiveRecord::RecordNotFound)
|
|
125
137
|
end
|
|
126
138
|
|
|
127
139
|
def execute_simple_calculation(operation, column_name, distinct)
|
|
128
|
-
|
|
140
|
+
model.execute_simple_calculation(self, operation, column_name, distinct)
|
|
129
141
|
end
|
|
130
142
|
|
|
131
|
-
|
|
132
|
-
@klass.implicit_order_column
|
|
133
|
-
end
|
|
143
|
+
delegate :implicit_order_column, to: :model
|
|
134
144
|
|
|
135
145
|
def exists?
|
|
136
146
|
size.positive?
|
|
@@ -139,7 +149,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
|
139
149
|
private
|
|
140
150
|
|
|
141
151
|
def exec_queries
|
|
142
|
-
@records =
|
|
152
|
+
@records = model.find_all(self)
|
|
143
153
|
@loaded = true
|
|
144
154
|
@records
|
|
145
155
|
end
|
|
@@ -195,8 +205,8 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
|
195
205
|
@connection ||= Connection.new(self)
|
|
196
206
|
end
|
|
197
207
|
|
|
198
|
-
def self.column(name, sql_type
|
|
199
|
-
column = Column.new(name.to_s, options[:default], sql_type
|
|
208
|
+
def self.column(name, sql_type, options = {})
|
|
209
|
+
column = Column.new(name.to_s, options[:default], sql_type, options.key?(:null) ? options[:null] : true)
|
|
200
210
|
column.tap { columns << column }
|
|
201
211
|
end
|
|
202
212
|
|
data/lib/active_scaffold.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ActiveScaffold
|
|
2
4
|
autoload :ActiveRecordPermissions, 'active_scaffold/active_record_permissions'
|
|
3
5
|
autoload :AttributeParams, 'active_scaffold/attribute_params'
|
|
@@ -77,7 +79,7 @@ module ActiveScaffold
|
|
|
77
79
|
mattr_accessor :nested_subforms, instance_writer: false
|
|
78
80
|
|
|
79
81
|
def self.root
|
|
80
|
-
|
|
82
|
+
File.expand_path '..', __dir__
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
def self.defaults(&)
|
|
@@ -85,7 +87,13 @@ module ActiveScaffold
|
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
def self.deprecator
|
|
88
|
-
@deprecator ||= ActiveSupport::Deprecation.new('4.
|
|
90
|
+
@deprecator ||= ActiveSupport::Deprecation.new('4.3', 'ActiveScaffold')
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.log_exception(exception, message)
|
|
94
|
+
line = exception.backtrace.find { |l| l.start_with? Rails.root.to_s }
|
|
95
|
+
line ||= exception.backtrace.find { |l| l.start_with? ActiveScaffold.root }
|
|
96
|
+
Rails.logger.error "#{exception.class.name}: #{exception.message} -- #{message}\n#{Rails.backtrace_cleaner.clean_frame(line) || line}"
|
|
89
97
|
end
|
|
90
98
|
end
|
|
91
99
|
require 'active_scaffold/engine'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Stubs out a active_scaffolded controller. Pass the model name,
|
|
3
|
+
either CamelCased or under_scored.
|
|
4
|
+
The controller name is retrieved as a pluralized version of the model
|
|
5
|
+
name.
|
|
6
|
+
|
|
7
|
+
To create a controller within a module, specify the model name as a
|
|
8
|
+
path like 'parent_module/controller_name'.
|
|
9
|
+
|
|
10
|
+
This generates a controller class in app/controllers and invokes helper,
|
|
11
|
+
template engine and test framework generators.
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
`rails generate active_scaffold:controller CreditCard`
|
|
15
|
+
|
|
16
|
+
Credit card controller with URLs like /credit_card/debit.
|
|
17
|
+
Controller: app/controllers/credit_cards_controller.rb
|
|
18
|
+
Functional Test: test/functional/credit_cards_controller_test.rb
|
|
19
|
+
Helper: app/helpers/credit_cards_helper.rb
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
|
|
4
|
+
|
|
5
|
+
module ActiveScaffold
|
|
6
|
+
module Generators
|
|
7
|
+
class ControllerGenerator < Rails::Generators::NamedBase
|
|
8
|
+
include Rails::Generators::ResourceHelpers
|
|
9
|
+
|
|
10
|
+
source_root File.expand_path('templates', __dir__)
|
|
11
|
+
|
|
12
|
+
check_class_collision suffix: 'Controller'
|
|
13
|
+
|
|
14
|
+
class_option :orm, banner: 'NAME', type: :string, required: true,
|
|
15
|
+
desc: 'ORM to generate the controller for'
|
|
16
|
+
|
|
17
|
+
def create_controller_files
|
|
18
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
|
|
19
|
+
template 'helper.rb', File.join('app/helpers', class_path, "#{controller_file_name}_helper.rb")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
hook_for :test_framework, as: :scaffold
|
|
23
|
+
|
|
24
|
+
def create_view_root_folder
|
|
25
|
+
empty_directory File.join('app/views', controller_file_path)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rails/generators/base'
|
|
2
4
|
# require 'generators/active_scaffold_controller/active_scaffold_controller_generator'
|
|
3
5
|
|
|
4
6
|
module ActiveScaffold
|
|
5
7
|
module Generators
|
|
6
8
|
class InstallGenerator < Rails::Generators::Base
|
|
7
|
-
|
|
9
|
+
def self.base_root
|
|
10
|
+
File.expand_path '../..', __dir__
|
|
11
|
+
end
|
|
8
12
|
|
|
9
13
|
def add_concern_routes
|
|
10
14
|
route 'concern :active_scaffold, ActiveScaffold::Routing::Basic.new(association: true)'
|
|
11
15
|
route 'concern :active_scaffold_association, ActiveScaffold::Routing::Association.new'
|
|
12
16
|
end
|
|
13
17
|
|
|
14
|
-
IMPORTMAP = 'config/importmap.rb'
|
|
15
|
-
JS_ASSET = 'app/assets/javascripts/application.js'
|
|
16
|
-
JS_APP = 'app/javascript/application.js'
|
|
17
|
-
MANIFEST = 'app/assets/config/manifest.js'
|
|
18
|
+
IMPORTMAP = 'config/importmap.rb'
|
|
19
|
+
JS_ASSET = 'app/assets/javascripts/application.js'
|
|
20
|
+
JS_APP = 'app/javascript/application.js'
|
|
21
|
+
MANIFEST = 'app/assets/config/manifest.js'
|
|
18
22
|
|
|
19
23
|
def add_javascript
|
|
20
24
|
if File.exist?(IMPORTMAP)
|
|
@@ -44,7 +48,7 @@ module ActiveScaffold
|
|
|
44
48
|
if original_css.match?(/require active_scaffold$/)
|
|
45
49
|
say_status('skipped', 'insert into app/assets/stylesheets/application.css', :yellow)
|
|
46
50
|
else
|
|
47
|
-
insert_into_file 'app/assets/stylesheets/application.css', before: %r{
|
|
51
|
+
insert_into_file 'app/assets/stylesheets/application.css', before: %r{ *\*/} do
|
|
48
52
|
" *= require active_scaffold\n"
|
|
49
53
|
end
|
|
50
54
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Scaffolds an entire resource, from model and migration to controller,
|
|
3
|
+
along with a full test suite and configured to use active_scaffold.
|
|
4
|
+
The resource is ready to use as a starting point for your RESTful,
|
|
5
|
+
resource-oriented application.
|
|
6
|
+
|
|
7
|
+
Pass the name of the model (in singular form), either CamelCased or
|
|
8
|
+
under_scored, as the first argument, and an optional list of attribute
|
|
9
|
+
pairs.
|
|
10
|
+
|
|
11
|
+
Attribute pairs are field:type arguments specifying the
|
|
12
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
|
13
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
|
14
|
+
|
|
15
|
+
You don't have to think up every attribute up front, but it helps to
|
|
16
|
+
sketch out a few so you can start working with the resource immediately.
|
|
17
|
+
|
|
18
|
+
For example, 'active_scaffold post title:string body:text published:boolean'
|
|
19
|
+
gives you a model with those three attributes, a controller configured to use active_scaffold,
|
|
20
|
+
as well as a resources :posts with additional active_scaffold routes
|
|
21
|
+
declaration in config/routes.rb.
|
|
22
|
+
|
|
23
|
+
If you want to remove all the generated files, run
|
|
24
|
+
'rails destroy active_scaffold ModelName'.
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
`rails generate active_scaffold:resource post`
|
|
28
|
+
`rails generate active_scaffold:resource post title:string body:text published:boolean`
|
|
29
|
+
`rails generate active_scaffold:resource purchase order_id:integer amount:decimal`
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/generators/rails/resource/resource_generator'
|
|
4
|
+
# require 'generators/active_scaffold_controller/active_scaffold_controller_generator'
|
|
5
|
+
|
|
6
|
+
module ActiveScaffold
|
|
7
|
+
module Generators
|
|
8
|
+
class ResourceGenerator < Rails::Generators::ResourceGenerator
|
|
9
|
+
def self.base_root
|
|
10
|
+
File.expand_path '../..', __dir__
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
remove_hook_for :resource_controller
|
|
14
|
+
remove_hook_for :resource_route
|
|
15
|
+
remove_class_option :actions
|
|
16
|
+
|
|
17
|
+
def add_resource_route
|
|
18
|
+
routing_code = class_path.collect { |namespace| "namespace :#{namespace} do " }.join(' ')
|
|
19
|
+
routing_code << "resources :#{file_name.pluralize}, concerns: :active_scaffold"
|
|
20
|
+
routing_code << (' end' * class_path.size)
|
|
21
|
+
log :route, routing_code
|
|
22
|
+
in_root do
|
|
23
|
+
inject_into_file 'config/routes.rb', " #{routing_code}\n", after: /^ *concern :active_scaffold,.*\n/, verbose: false, force: true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
invoke 'active_scaffold:controller'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/tasks/brakeman.rake
CHANGED
data/shoulda_macros/macros.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_scaffold
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Many, see README
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dartsass-sprockets
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 7.
|
|
47
|
+
version: 7.2.0
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 7.
|
|
54
|
+
version: 7.2.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: request_store
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -106,8 +106,9 @@ files:
|
|
|
106
106
|
- app/assets/stylesheets/active_scaffold_extensions.css.erb
|
|
107
107
|
- app/assets/stylesheets/active_scaffold_images.scss
|
|
108
108
|
- app/assets/stylesheets/active_scaffold_jquery_ui.css.erb
|
|
109
|
-
- app/assets/stylesheets/active_scaffold_layout.
|
|
109
|
+
- app/assets/stylesheets/active_scaffold_layout.scss
|
|
110
110
|
- app/assets/stylesheets/blue-theme.css
|
|
111
|
+
- app/assets/stylesheets/tiny_mce_bridge.scss
|
|
111
112
|
- app/views/active_scaffold_overrides/_add_existing_form.html.erb
|
|
112
113
|
- app/views/active_scaffold_overrides/_base_form.html.erb
|
|
113
114
|
- app/views/active_scaffold_overrides/_create_form.html.erb
|
|
@@ -158,6 +159,7 @@ files:
|
|
|
158
159
|
- app/views/active_scaffold_overrides/_update_messages.js.erb
|
|
159
160
|
- app/views/active_scaffold_overrides/_vertical_subform.html.erb
|
|
160
161
|
- app/views/active_scaffold_overrides/action_confirmation.html.erb
|
|
162
|
+
- app/views/active_scaffold_overrides/action_links_menu.js.erb
|
|
161
163
|
- app/views/active_scaffold_overrides/add_existing.js.erb
|
|
162
164
|
- app/views/active_scaffold_overrides/add_existing_form.html.erb
|
|
163
165
|
- app/views/active_scaffold_overrides/add_tab.js.erb
|
|
@@ -239,6 +241,9 @@ files:
|
|
|
239
241
|
- lib/active_scaffold/bridges/file_column/list_ui.rb
|
|
240
242
|
- lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb
|
|
241
243
|
- lib/active_scaffold/bridges/file_column/test/mock_model.rb
|
|
244
|
+
- lib/active_scaffold/bridges/logical_query_parser.rb
|
|
245
|
+
- lib/active_scaffold/bridges/logical_query_parser/tokens_grammar.rb
|
|
246
|
+
- lib/active_scaffold/bridges/logical_query_parser/tokens_grammar.treetop
|
|
242
247
|
- lib/active_scaffold/bridges/paper_trail.rb
|
|
243
248
|
- lib/active_scaffold/bridges/paper_trail/actions.rb
|
|
244
249
|
- lib/active_scaffold/bridges/paper_trail/config.rb
|
|
@@ -327,11 +332,14 @@ files:
|
|
|
327
332
|
- lib/active_scaffold/responds_to_parent.rb
|
|
328
333
|
- lib/active_scaffold/tableless.rb
|
|
329
334
|
- lib/active_scaffold/version.rb
|
|
330
|
-
- lib/generators/active_scaffold/
|
|
331
|
-
- lib/generators/active_scaffold/
|
|
332
|
-
- lib/generators/active_scaffold/
|
|
333
|
-
- lib/generators/templates/
|
|
334
|
-
- lib/generators/
|
|
335
|
+
- lib/generators/active_scaffold/controller/USAGE
|
|
336
|
+
- lib/generators/active_scaffold/controller/controller_generator.rb
|
|
337
|
+
- lib/generators/active_scaffold/controller/templates/controller.rb
|
|
338
|
+
- lib/generators/active_scaffold/controller/templates/helper.rb
|
|
339
|
+
- lib/generators/active_scaffold/install/USAGE
|
|
340
|
+
- lib/generators/active_scaffold/install/install_generator.rb
|
|
341
|
+
- lib/generators/active_scaffold/resource/USAGE
|
|
342
|
+
- lib/generators/active_scaffold/resource/resource_generator.rb
|
|
335
343
|
- lib/tasks/brakeman.rake
|
|
336
344
|
- public/blank.html
|
|
337
345
|
- shoulda_macros/macros.rb
|
|
@@ -368,7 +376,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
368
376
|
requirements:
|
|
369
377
|
- - ">="
|
|
370
378
|
- !ruby/object:Gem::Version
|
|
371
|
-
version: '3.
|
|
379
|
+
version: '3.2'
|
|
372
380
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
373
381
|
requirements:
|
|
374
382
|
- - ">="
|