brick 1.0.198 → 1.0.200
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brick/extensions.rb +115 -605
- data/lib/brick/frameworks/rails/engine.rb +2 -37
- data/lib/brick/frameworks/rails/form_tags.rb +3 -3
- data/lib/brick/reflect_tables.rb +582 -0
- data/lib/brick/route_mapper.rb +20 -4
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +2 -1
- data/lib/generators/brick/migration_builder.rb +8 -5
- metadata +3 -2
@@ -788,20 +788,13 @@ window.addEventListener(\"popstate\", linkSchemas);
|
|
788
788
|
next if rel.first.blank? || rel.last[:cols].empty? ||
|
789
789
|
::Brick.config.exclude_tables.include?(rel.first)
|
790
790
|
|
791
|
-
tbl_parts = rel.first.split('.')
|
792
|
-
if (aps = rel.last.fetch(:auto_prefixed_schema, nil))
|
793
|
-
tbl_parts << tbl_parts.last[aps.length..-1]
|
794
|
-
aps = aps[0..-2] if aps[-1] == '_'
|
795
|
-
tbl_parts[-2] = aps
|
796
|
-
end
|
797
|
-
tbl_parts.shift if tbl_parts.first == apartment_default_schema
|
798
791
|
# %%% When table_name_prefixes are use then during rendering empty non-TNP
|
799
792
|
# entries get added at some point when an attempt is made to find the table.
|
800
793
|
# Will have to hunt that down at some point.
|
801
794
|
if (rowcount = rel.last.fetch(:rowcount, nil))
|
802
795
|
rowcount = rowcount > 0 ? " (#{rowcount})" : nil
|
803
796
|
end
|
804
|
-
s << "<option value=\"#{::Brick._brick_index(rel.first, nil, '/')}\">#{rel.first}#{rowcount}</option>"
|
797
|
+
s << "<option value=\"#{::Brick._brick_index(rel.first, nil, '/', nil, true)}\">#{rel.first}#{rowcount}</option>"
|
805
798
|
end.html_safe
|
806
799
|
prefix = "#{::Brick.config.path_prefix}/" if ::Brick.config.path_prefix
|
807
800
|
table_options << "<option value=\"#{prefix}brick_status\">(Status)</option>".html_safe if ::Brick.config.add_status
|
@@ -1623,7 +1616,7 @@ end %>#{"
|
|
1623
1616
|
<td><%= link_to_brick(
|
1624
1617
|
::Brick::Rails::AA_PNG.html_safe,
|
1625
1618
|
{ show_proc: Proc.new do |aa_model, relation|
|
1626
|
-
path_helper = \"#\{ns}_#\{relation.fetch(:auto_prefixed_schema, nil)}#\{
|
1619
|
+
path_helper = \"#\{ns}_#\{relation.fetch(:auto_prefixed_schema, nil)}#\{aa_model.model_name.singular_route_key}_path\".to_sym
|
1627
1620
|
send(path_helper, obj) if respond_to?(path_helper)
|
1628
1621
|
end,
|
1629
1622
|
title: \"#\{page_title} in ActiveAdmin\" }
|
@@ -1962,34 +1955,6 @@ document.querySelectorAll(\"input, select\").forEach(function (inp) {
|
|
1962
1955
|
end # TemplateRenderer
|
1963
1956
|
end
|
1964
1957
|
|
1965
|
-
if ::Brick.enable_routes?
|
1966
|
-
require 'brick/route_mapper'
|
1967
|
-
ActionDispatch::Routing::RouteSet.class_exec do
|
1968
|
-
# In order to defer auto-creation of any routes that already exist, calculate Brick routes only after having loaded all others
|
1969
|
-
prepend ::Brick::RouteSet
|
1970
|
-
end
|
1971
|
-
ActionDispatch::Routing::Mapper.class_exec do
|
1972
|
-
include ::Brick::RouteMapper
|
1973
|
-
end
|
1974
|
-
|
1975
|
-
# Do the root route before the Rails Welcome one would otherwise take precedence
|
1976
|
-
if (route = ::Brick.config.default_route_fallback).present?
|
1977
|
-
action = "#{route}#{'#index' unless route.index('#')}"
|
1978
|
-
if ::Brick.config.path_prefix
|
1979
|
-
::Rails.application.routes.append do
|
1980
|
-
send(:namespace, ::Brick.config.path_prefix) do
|
1981
|
-
send(:root, action)
|
1982
|
-
end
|
1983
|
-
end
|
1984
|
-
elsif ::Rails.application.routes.named_routes.send(:routes)[:root].nil?
|
1985
|
-
::Rails.application.routes.append do
|
1986
|
-
send(:root, action)
|
1987
|
-
end
|
1988
|
-
end
|
1989
|
-
::Brick.established_drf = "/#{::Brick.config.path_prefix}#{action[action.index('#')..-1]}"
|
1990
|
-
end
|
1991
|
-
end
|
1992
|
-
|
1993
1958
|
# Just in case it hadn't been done previously when we tried to load the brick initialiser,
|
1994
1959
|
# go make sure we've loaded additional references (virtual foreign keys and polymorphic associations).
|
1995
1960
|
# (This should only happen if for whatever reason the initializer file was not exactly config/initializers/brick.rb.)
|
@@ -73,7 +73,7 @@ module Brick::Rails::FormTags
|
|
73
73
|
<td>#{link_to_brick(
|
74
74
|
::Brick::Rails::AA_PNG.html_safe,
|
75
75
|
{ index_proc: Proc.new do |aa_model, relation|
|
76
|
-
path_helper = "#{ns}_#{relation.fetch(:auto_prefixed_schema, nil)}#{
|
76
|
+
path_helper = "#{ns}_#{relation.fetch(:auto_prefixed_schema, nil)}#{aa_model.model_name.route_key}_path".to_sym
|
77
77
|
send(path_helper) if respond_to?(path_helper)
|
78
78
|
end,
|
79
79
|
title: "#{klass.name} in ActiveAdmin" }
|
@@ -137,7 +137,7 @@ module Brick::Rails::FormTags
|
|
137
137
|
options[col[1].inheritance_column] = col[1].name unless col[1] == col[1].base_class
|
138
138
|
x_order = " x-order=\"#{col_name}\"" if true
|
139
139
|
s << "#{x_order}>#{col[2]} "
|
140
|
-
s << (col.first ?
|
140
|
+
s << (col.first ? col[3].to_s : "#{link_to(col[3], send("#{col[1]._brick_index}_path", options))}")
|
141
141
|
elsif cust_cols.key?(col_name) # Custom column
|
142
142
|
x_order = " x-order=\"#{col_name}\"" if true
|
143
143
|
s << "#{x_order}>#{col_name}"
|
@@ -222,7 +222,7 @@ module Brick::Rails::FormTags
|
|
222
222
|
out << link_to(ho_txt, send("#{hm_klass.base_class._brick_index(:singular)}_path".to_sym, ho_id))
|
223
223
|
end
|
224
224
|
elsif obj.respond_to?(ct_col = hms_col[1].to_sym) && (ct = obj.send(ct_col)&.to_i)&.positive?
|
225
|
-
predicates = hms_col[2].each_with_object({}) { |v, s| s["__#{v.first}"] = v.last.is_a?(String) ? v.last : obj.send(v.last) }
|
225
|
+
predicates = hms_col[2].each_with_object({}) { |v, s| s["__#{v.first}"] = v.last.is_a?(String) ? v.last : obj.send(v.last) if v.last }
|
226
226
|
predicates.each { |k, v| predicates[k] = klass.name if v == '[sti_type]' }
|
227
227
|
out << "#{link_to("#{ct || 'View'} #{hms_col.first}",
|
228
228
|
send("#{hm_klass._brick_index}_path".to_sym, predicates))}\n"
|