brick 1.0.102 → 1.0.103
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/lib/brick/extensions.rb +10 -10
- data/lib/brick/frameworks/rails/engine.rb +130 -82
- data/lib/brick/version_number.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74743982216a9827513b4aaa68fe0887c9ba3e7b78c45ff52f0a2f2b99dc7b88
|
4
|
+
data.tar.gz: 3857a95e891e7561d285dd3ecbdeb6c4c16cc9a8205e7b733b55867ed7a69f64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b71aa5b1d4da8c4aa1ce88af6d0767c12bdf72b2457594575795d4b9b3f36d1bfb2adef82413a3bc80e041813e7bc6c05768016c5e4cfc197e3bbb730113934
|
7
|
+
data.tar.gz: 6399e040cb4b54eac4d7a09b907cfba11037a4b3391dd3a86b4845e79bd0c4d4e169586c095fdaaaa8506f346628072c9c4c9b6d2ed60c3306a58866e6f9d030
|
data/lib/brick/extensions.rb
CHANGED
@@ -77,14 +77,13 @@ module ActiveRecord
|
|
77
77
|
def self.brick_get_dsl
|
78
78
|
# If there's no DSL yet specified, just try to find the first usable column on this model
|
79
79
|
unless (dsl = ::Brick.config.model_descrips[name])
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
80
|
+
skip_columns = _brick_get_fks + (::Brick.config.metadata_columns || []) + [primary_key]
|
81
|
+
dsl = if (descrip_col = columns.find { |c| [:boolean, :binary, :xml].exclude?(c.type) && skip_columns.exclude?(c.name) })
|
82
|
+
"[#{descrip_col.name}]"
|
83
|
+
elsif (pk_parts = self.primary_key.is_a?(Array) ? self.primary_key : [self.primary_key])
|
84
|
+
"#{name} ##{pk_parts.map { |pk_part| "[#{pk_part}]" }.join(', ')}"
|
85
|
+
end
|
86
|
+
::Brick.config.model_descrips[name] = dsl
|
88
87
|
end
|
89
88
|
dsl
|
90
89
|
end
|
@@ -129,7 +128,7 @@ module ActiveRecord
|
|
129
128
|
translations[parts[0..-2].join('.')] = klass
|
130
129
|
end
|
131
130
|
if klass&.column_names.exclude?(parts.last) &&
|
132
|
-
|
131
|
+
(klass = (orig_class = klass).reflect_on_association(possible_dsl = parts.pop.to_sym)&.klass)
|
133
132
|
if prefix.empty? # Custom columns start with an empty prefix
|
134
133
|
prefix << parts.shift until parts.empty?
|
135
134
|
end
|
@@ -805,7 +804,8 @@ JOIN (SELECT #{hm_selects.map { |s| "#{'br_t0.' if from_clause}#{s}" }.join(', '
|
|
805
804
|
alias _brick_find_sti_class find_sti_class
|
806
805
|
def find_sti_class(type_name)
|
807
806
|
if ::Brick.sti_models.key?(type_name ||= name)
|
808
|
-
::Brick.sti_models[type_name].fetch(:base, nil) || _brick_find_sti_class(type_name)
|
807
|
+
# Used to be: ::Brick.sti_models[type_name].fetch(:base, nil) || _brick_find_sti_class(type_name)
|
808
|
+
_brick_find_sti_class(type_name)
|
809
809
|
else
|
810
810
|
# This auto-STI is more of a brute-force approach, building modules where needed
|
811
811
|
# The more graceful alternative is the overload of ActiveSupport::Dependencies#autoload_module! found below
|
@@ -29,6 +29,54 @@ module Brick
|
|
29
29
|
var finalParams = Object.keys(params).reduce(function (s, v) { if (params[v]) s.push(v + \"=\" + params[v]); return s; }, []).join(\"&\");
|
30
30
|
return hrefParts[0] + (finalParams.length > 0 ? \"?\" + finalParams : \"\");
|
31
31
|
}
|
32
|
+
|
33
|
+
// This PageTransitionEvent fires when the page first loads, as well as after any other history
|
34
|
+
// transition such as when using the browser's Back and Forward buttons.
|
35
|
+
window.addEventListener(\"pageshow\", linkSchemas);
|
36
|
+
var brickSchema;
|
37
|
+
function linkSchemas() {
|
38
|
+
var schemaSelect = document.getElementById(\"schema\");
|
39
|
+
var tblSelect = document.getElementById(\"tbl\");
|
40
|
+
if (tblSelect) { // Always present
|
41
|
+
// Used to be: var i = # {::Brick.config.path_prefix ? '0' : 'schemaSelect ? 1 : 0'},
|
42
|
+
var changeoutList = changeout(location.href);
|
43
|
+
for (var i = 0; i < changeoutList.length; ++i) {
|
44
|
+
tblSelect.value = changeoutList[i];
|
45
|
+
if (tblSelect.value !== \"\") break;
|
46
|
+
}
|
47
|
+
|
48
|
+
tblSelect.addEventListener(\"change\", function () {
|
49
|
+
var lhr = changeout(location.href, null, this.value);
|
50
|
+
if (brickSchema) lhr = changeout(lhr, \"_brick_schema\", schemaSelect.value);
|
51
|
+
location.href = lhr;
|
52
|
+
});
|
53
|
+
}
|
54
|
+
|
55
|
+
if (schemaSelect) { // First drop-down is only present if multitenant
|
56
|
+
if (brickSchema = changeout(location.href, \"_brick_schema\")) {
|
57
|
+
[... document.getElementsByTagName(\"A\")].forEach(function (a) { a.href = changeout(a.href, \"_brick_schema\", brickSchema); });
|
58
|
+
}
|
59
|
+
if (schemaSelect.options.length > 1) {
|
60
|
+
schemaSelect.value = brickSchema || \"public\";
|
61
|
+
schemaSelect.addEventListener(\"change\", function () {
|
62
|
+
// If there's an ID then remove it (trim after selected table)
|
63
|
+
location.href = changeout(location.href, \"_brick_schema\", this.value, tblSelect.value);
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
tblSelect.focus();
|
68
|
+
|
69
|
+
[... document.getElementsByTagName(\"FORM\")].forEach(function (form) {
|
70
|
+
if (brickSchema)
|
71
|
+
form.action = changeout(form.action, \"_brick_schema\", brickSchema);
|
72
|
+
form.addEventListener('submit', function (ev) {
|
73
|
+
[... ev.target.getElementsByTagName(\"SELECT\")].forEach(function (select) {
|
74
|
+
if (select.value === \"^^^brick_NULL^^^\") select.value = null;
|
75
|
+
});
|
76
|
+
return true;
|
77
|
+
});
|
78
|
+
});
|
79
|
+
};
|
32
80
|
"
|
33
81
|
|
34
82
|
# paths['app/models'] << 'lib/brick/frameworks/active_record/models'
|
@@ -168,17 +216,9 @@ module Brick
|
|
168
216
|
end
|
169
217
|
"<script>
|
170
218
|
#{JS_CHANGEOUT}
|
171
|
-
window.addEventListener(\"load\", linkSchemas);
|
172
219
|
document.addEventListener(\"turbo:render\", linkSchemas);
|
173
220
|
window.addEventListener(\"popstate\", linkSchemas);
|
174
221
|
// [... document.getElementsByTagName('turbo-frame')].forEach(function (a) { a.addEventListener(\"turbo:frame-render\", linkSchemas); });
|
175
|
-
function linkSchemas() {
|
176
|
-
brickSchema = changeout(location.href, \"_brick_schema\");
|
177
|
-
if (brickSchema) {
|
178
|
-
[... document.getElementsByTagName(\"A\")].forEach(function (a) { a.href = changeout(a.href, \"_brick_schema\", brickSchema); });
|
179
|
-
[... document.getElementsByTagName(\"FORM\")].forEach(function (form) { form.action = changeout(form.action, \"_brick_schema\", brickSchema); });
|
180
|
-
}
|
181
|
-
}
|
182
222
|
</script>
|
183
223
|
#{_brick_content}".html_safe
|
184
224
|
end
|
@@ -288,7 +328,14 @@ function linkSchemas() {
|
|
288
328
|
else
|
289
329
|
[[fk_name, pk.length == 1 ? pk.first : pk.inspect]]
|
290
330
|
end
|
291
|
-
|
331
|
+
if hm_assoc.options.key?(:as)
|
332
|
+
poly_type = if hm_assoc.active_record.column_names.include?(hm_assoc.active_record.inheritance_column)
|
333
|
+
'[sti_type]'
|
334
|
+
else
|
335
|
+
hm_assoc.active_record.name
|
336
|
+
end
|
337
|
+
keys << [hm_assoc.inverse_of.foreign_type, poly_type]
|
338
|
+
end
|
292
339
|
keys.to_h
|
293
340
|
end
|
294
341
|
|
@@ -362,9 +409,14 @@ function linkSchemas() {
|
|
362
409
|
end
|
363
410
|
when 'show', 'new', 'update'
|
364
411
|
hm_stuff << if hm_fk_name
|
365
|
-
if hm_assoc.klass.column_names.include?(hm_fk_name)
|
412
|
+
if hm_assoc.klass.column_names.include?(hm_fk_name) ||
|
413
|
+
(hm_fk_name.is_a?(String) && hm_fk_name.include?('.')) # HMT? (Could do a better check for this)
|
366
414
|
predicates = path_keys(hm_assoc, hm_fk_name, pk).map do |k, v|
|
367
|
-
v
|
415
|
+
if v == '[sti_type]'
|
416
|
+
"'#{k}': @#{obj_name}.#{hm_assoc.active_record.inheritance_column}"
|
417
|
+
else
|
418
|
+
v.is_a?(String) ? "'#{k}': '#{v}'" : "'#{k}': @#{obj_name}.#{v}"
|
419
|
+
end
|
368
420
|
end.join(', ')
|
369
421
|
"<%= link_to '#{assoc_name}', #{hm_assoc.klass._brick_index}_path({ #{predicates} }) %>\n"
|
370
422
|
else
|
@@ -622,13 +674,24 @@ def hide_bcrypt(val, max_len = 200)
|
|
622
674
|
end
|
623
675
|
end
|
624
676
|
def display_value(col_type, val)
|
677
|
+
is_mssql_geography = nil
|
678
|
+
# Some binary thing that really looks like a Microsoft-encoded WGS84 point? (With the first two bytes, E6 10, indicating an EPSG code of 4326)
|
679
|
+
if col_type == :binary && val && val.length < 31 && (val.length - 6) % 8 == 0 && val[0..5].bytes == [230, 16, 0, 0, 1, 12]
|
680
|
+
col_type = 'geography'
|
681
|
+
is_mssql_geography = true
|
682
|
+
end
|
625
683
|
case col_type
|
626
684
|
when 'geometry', 'geography'
|
627
685
|
if Object.const_defined?('RGeo')
|
628
686
|
@is_mysql = ['Mysql2', 'Trilogy'].include?(ActiveRecord::Base.connection.adapter_name) if @is_mysql.nil?
|
629
687
|
@is_mssql = ActiveRecord::Base.connection.adapter_name == 'SQLServer' if @is_mssql.nil?
|
630
688
|
val_err = nil
|
631
|
-
|
689
|
+
|
690
|
+
if @is_mysql || (is_mssql_geography ||=
|
691
|
+
(@is_mssql ||
|
692
|
+
(val && val.length < 31 && (val.length - 6) % 8 == 0 && val[0..5].bytes == [230, 16, 0, 0, 1, 12])
|
693
|
+
)
|
694
|
+
)
|
632
695
|
# MySQL's \"Internal Geometry Format\" and MSSQL's Geography are like WKB, but with an initial 4 bytes that indicates the SRID.
|
633
696
|
if (srid = val&.[](0..3)&.unpack('I'))
|
634
697
|
val = val.dup.force_encoding('BINARY')[4..-1].bytes
|
@@ -642,20 +705,25 @@ def display_value(col_type, val)
|
|
642
705
|
# xx1x xxxx = IsWholeGlobe
|
643
706
|
# Convert Microsoft's unique geography binary to standard WKB
|
644
707
|
# (MSSQL point usually has two doubles, lng / lat, and can also have Z)
|
645
|
-
if
|
708
|
+
if is_mssql_geography
|
646
709
|
if val[0] == 1 && (val[1] & 8 > 0) && # Single point?
|
647
|
-
|
648
|
-
|
649
|
-
new_val = [0, 0, 0, 0, 1]
|
650
|
-
new_val.concat(val[idx - 8...idx].reverse) while (idx += 8) <= val.length
|
651
|
-
val = new_val
|
710
|
+
(val.length - 2) % 8 == 0 && val.length < 27 # And containing up to three 8-byte values?
|
711
|
+
val = [0, 0, 0, 0, 1] + val[2..-1].reverse
|
652
712
|
else
|
653
713
|
val_err = '(Microsoft internal SQL geography type)'
|
654
714
|
end
|
655
715
|
end
|
656
716
|
end
|
657
717
|
end
|
658
|
-
val_err ||
|
718
|
+
unless val_err || val.nil?
|
719
|
+
if (geometry = RGeo::WKRep::WKBParser.new.parse(val.pack('c*'))).is_a?(RGeo::Cartesian::PointImpl) &&
|
720
|
+
!(geometry.y == 0.0 && geometry.x == 0.0)
|
721
|
+
# Create a POINT link to this style of Google maps URL: https://www.google.com/maps/place/38.7071296+-121.2810649/@38.7071296,-121.2810649,12z
|
722
|
+
geometry = \"<a href=\\\"https://www.google.com/maps/place/#\{geometry.y}+#\{geometry.x}/@#\{geometry.y},#\{geometry.x},12z\\\" target=\\\"blank\\\">#\{geometry.to_s}</a>\"
|
723
|
+
end
|
724
|
+
val = geometry
|
725
|
+
end
|
726
|
+
val_err || val
|
659
727
|
else
|
660
728
|
'(Add RGeo gem to parse geometry detail)'
|
661
729
|
end
|
@@ -671,13 +739,13 @@ def display_value(col_type, val)
|
|
671
739
|
end
|
672
740
|
|
673
741
|
def image_signatures
|
674
|
-
@image_signatures ||= { \"\\xFF\\xD8\\xFF\\xEE\" => 'jpeg',
|
675
|
-
\"\\xFF\\xD8\\xFF\\xE0\\x00\\x10\\x4A\\x46\\x49\\x46\\x00\\x01\" => 'jpeg',
|
676
|
-
\"\\x89PNG\\r\\n\\x1A\\n\" => 'png',
|
742
|
+
@image_signatures ||= { \"\\xFF\\xD8\\xFF\\xEE\".force_encoding('ASCII-8BIT') => 'jpeg',
|
743
|
+
\"\\xFF\\xD8\\xFF\\xE0\\x00\\x10\\x4A\\x46\\x49\\x46\\x00\\x01\".force_encoding('ASCII-8BIT') => 'jpeg',
|
744
|
+
\"\\x89PNG\\r\\n\\x1A\\n\".force_encoding('ASCII-8BIT') => 'png',
|
677
745
|
'<svg' => 'svg+xml', # %%% Not yet very good detection for SVG
|
678
|
-
'BM' => 'bmp',
|
679
|
-
'GIF87a' => 'gif',
|
680
|
-
'GIF89a' => 'gif' }
|
746
|
+
'BM'.force_encoding('ASCII-8BIT') => 'bmp',
|
747
|
+
'GIF87a'.force_encoding('ASCII-8BIT') => 'gif',
|
748
|
+
'GIF89a'.force_encoding('ASCII-8BIT') => 'gif' }
|
681
749
|
end
|
682
750
|
def display_binary(val)
|
683
751
|
if val[0..1] == \"\\x15\\x1C\" # One of those goofy Microsoft OLE containers?
|
@@ -741,56 +809,8 @@ callbacks = {} %>
|
|
741
809
|
|
742
810
|
# %%% When doing schema select, if we're on a new page go to index
|
743
811
|
script = "<script>
|
744
|
-
var schemaSelect = document.getElementById(\"schema\");
|
745
|
-
var tblSelect = document.getElementById(\"tbl\");
|
746
|
-
var brickSchema;
|
747
812
|
var #{table_name}HtColumns;
|
748
813
|
|
749
|
-
// This PageTransitionEvent fires when the page first loads, as well as after any other history
|
750
|
-
// transition such as when using the browser's Back and Forward buttons.
|
751
|
-
window.addEventListener(\"pageshow\", function() {
|
752
|
-
if (tblSelect) { // Always present
|
753
|
-
var i = #{::Brick.config.path_prefix ? '0' : 'schemaSelect ? 1 : 0'},
|
754
|
-
changeoutList = changeout(location.href);
|
755
|
-
for (; i < changeoutList.length; ++i) {
|
756
|
-
tblSelect.value = changeoutList[i];
|
757
|
-
if (tblSelect.value !== \"\") break;
|
758
|
-
}
|
759
|
-
|
760
|
-
tblSelect.addEventListener(\"change\", function () {
|
761
|
-
var lhr = changeout(location.href, null, this.value);
|
762
|
-
if (brickSchema)
|
763
|
-
lhr = changeout(lhr, \"_brick_schema\", schemaSelect.value);
|
764
|
-
location.href = lhr;
|
765
|
-
});
|
766
|
-
}
|
767
|
-
|
768
|
-
if (schemaSelect && schemaSelect.options.length > 1) { // First drop-down is only present if multitenant
|
769
|
-
brickSchema = changeout(location.href, \"_brick_schema\");
|
770
|
-
if (brickSchema) {
|
771
|
-
[... document.getElementsByTagName(\"A\")].forEach(function (a) { a.href = changeout(a.href, \"_brick_schema\", brickSchema); });
|
772
|
-
}
|
773
|
-
schemaSelect.value = brickSchema || \"public\";
|
774
|
-
schemaSelect.focus();
|
775
|
-
schemaSelect.addEventListener(\"change\", function () {
|
776
|
-
// If there's an ID then remove it (trim after selected table)
|
777
|
-
location.href = changeout(location.href, \"_brick_schema\", this.value, tblSelect.value);
|
778
|
-
});
|
779
|
-
}
|
780
|
-
|
781
|
-
[... document.getElementsByTagName(\"FORM\")].forEach(function (form) {
|
782
|
-
if (brickSchema)
|
783
|
-
form.action = changeout(form.action, \"_brick_schema\", brickSchema);
|
784
|
-
form.addEventListener('submit', function (ev) {
|
785
|
-
[... ev.target.getElementsByTagName(\"SELECT\")].forEach(function (select) {
|
786
|
-
if (select.value === \"^^^brick_NULL^^^\")
|
787
|
-
select.value = null;
|
788
|
-
});
|
789
|
-
return true;
|
790
|
-
});
|
791
|
-
});
|
792
|
-
});
|
793
|
-
|
794
814
|
// Add \"Are you sure?\" behaviour to any data-confirm buttons out there
|
795
815
|
document.querySelectorAll(\"input[type=submit][data-confirm]\").forEach(function (btn) {
|
796
816
|
btn.addEventListener(\"click\", function (evt) {
|
@@ -1118,8 +1138,11 @@ erDiagram
|
|
1118
1138
|
id = id.first if id.is_a?(Array) && id.length == 1
|
1119
1139
|
origin = (key_parts = k.split('.')).length == 1 ? model : model.reflect_on_association(key_parts.first).klass
|
1120
1140
|
if (destination_fk = Brick.relations[origin.table_name][:fks].values.find { |fk| fk[:fk] == key_parts.last }) &&
|
1121
|
-
(
|
1122
|
-
|
1141
|
+
(objs = (destination = origin.reflect_on_association(destination_fk[:assoc_name])&.klass)&.find(id))
|
1142
|
+
objs = [objs] unless objs.is_a?(Array) %>
|
1143
|
+
<h3>for <% objs.each do |obj| %><%=
|
1144
|
+
link_to \"#{"#\{obj.brick_descrip\} (#\{destination.name\})\""}, send(\"#\{destination._brick_index(:singular)\}_path\".to_sym, id)
|
1145
|
+
%><% end %></h3><%
|
1123
1146
|
end
|
1124
1147
|
end %>
|
1125
1148
|
(<%= link_to \"See all #\{model.base_class.name.split('::').last.pluralize}\", #{@_brick_model._brick_index}_path %>)
|
@@ -1263,7 +1286,9 @@ erDiagram
|
|
1263
1286
|
<head>
|
1264
1287
|
#{css}
|
1265
1288
|
<title><%=
|
1266
|
-
|
1289
|
+
model = (obj = @#{obj_name})&.class
|
1290
|
+
model_name = @#{obj_name}.#{inh_col = @_brick_model.inheritance_column} if obj.respond_to?(:#{inh_col})
|
1291
|
+
page_title = (\"#\{model_name ||= model.name}: #\{obj&.brick_descrip || controller_name}\")
|
1267
1292
|
%></title>
|
1268
1293
|
</head>
|
1269
1294
|
<body>
|
@@ -1297,7 +1322,7 @@ end
|
|
1297
1322
|
<% if obj
|
1298
1323
|
# path_options = [obj.#{pk}]
|
1299
1324
|
# path_options << { '_brick_schema': } if
|
1300
|
-
# url = send(:#\{
|
1325
|
+
# url = send(:#\{model._brick_index(:singular)}_path, obj.#{pk})
|
1301
1326
|
options = {}
|
1302
1327
|
options[:url] = send(\"#\{#{model_name}._brick_index(:singular)}_path\".to_sym, obj) if ::Brick.config.path_prefix
|
1303
1328
|
%>
|
@@ -1393,7 +1418,17 @@ end
|
|
1393
1418
|
# In Postgres labels of data stored in a hierarchical tree-like structure
|
1394
1419
|
# If it's not yet enabled then: create extension ltree;
|
1395
1420
|
val %>
|
1396
|
-
<% when :binary
|
1421
|
+
<% when :binary %>
|
1422
|
+
<%= is_revert = false
|
1423
|
+
if val
|
1424
|
+
# %%% This same kind of geography check is done two other times above ... would be great to DRY it up.
|
1425
|
+
if val.length < 31 && (val.length - 6) % 8 == 0 && val[0..5].bytes == [230, 16, 0, 0, 1, 12]
|
1426
|
+
display_value('geography', val)
|
1427
|
+
else
|
1428
|
+
display_binary(val)
|
1429
|
+
end.html_safe
|
1430
|
+
end %>
|
1431
|
+
<% when :primary_key
|
1397
1432
|
is_revert = false %>
|
1398
1433
|
<% else %>
|
1399
1434
|
<%= is_revert = false
|
@@ -1417,8 +1452,8 @@ end
|
|
1417
1452
|
<% end %>
|
1418
1453
|
|
1419
1454
|
#{unless args.first == 'new'
|
1420
|
-
# Was: confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: 'Delete
|
1421
|
-
confirm_are_you_sure = "data: { confirm: 'Delete
|
1455
|
+
# Was: confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: 'Delete #\{model_name} -- Are you sure?' }" : "form: { data: { turbo_confirm: 'Delete #\{model_name} -- Are you sure?' } }"
|
1456
|
+
confirm_are_you_sure = "data: { confirm: 'Delete #\{model_name} -- Are you sure?' }"
|
1422
1457
|
hms_headers.each_with_object(+'') do |hm, s|
|
1423
1458
|
# %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
|
1424
1459
|
next if hm.first.options[:through] && !hm.first.through_reflection
|
@@ -1426,11 +1461,24 @@ end
|
|
1426
1461
|
if (pk = hm.first.klass.primary_key)
|
1427
1462
|
hm_singular_name = (hm_name = hm.first.name.to_s).singularize.underscore
|
1428
1463
|
obj_pk = (pk.is_a?(Array) ? pk : [pk]).each_with_object([]) { |pk_part, s| s << "#{hm_singular_name}.#{pk_part}" }.join(', ')
|
1464
|
+
poly_fix = if (poly_type = (hm.first.options[:as] && hm.first.type))
|
1465
|
+
"
|
1466
|
+
# Let's fix an unexpected \"feature\" of AR -- when going through a polymorphic has_many
|
1467
|
+
# association that points to an STI model then filtering for the __able_type column is done
|
1468
|
+
# with a .where(). And the polymorphic class name it points to is the base class name of
|
1469
|
+
# the STI model instead of its subclass.
|
1470
|
+
if (poly_type = #{poly_type.inspect}) &&
|
1471
|
+
@#{obj_name}.respond_to?(:#{@_brick_model.inheritance_column}) &&
|
1472
|
+
(base_type = collection.where_values_hash[poly_type])
|
1473
|
+
collection = collection.rewhere(poly_type => [base_type, @#{obj_name}.#{@_brick_model.inheritance_column}])
|
1474
|
+
end"
|
1475
|
+
end
|
1429
1476
|
s << "<table id=\"#{hm_name}\" class=\"shadow\">
|
1430
|
-
<tr><th>#{hm[3]}</th></tr>
|
1477
|
+
<tr><th>#{hm[1]}#{' poly' if hm[0].options[:as]} #{hm[3]}</th></tr>
|
1431
1478
|
<% collection = @#{obj_name}.#{hm_name}
|
1432
1479
|
collection = case collection
|
1433
|
-
when ActiveRecord::Associations::CollectionProxy
|
1480
|
+
when ActiveRecord::Associations::CollectionProxy#{
|
1481
|
+
poly_fix}
|
1434
1482
|
collection.order(#{pk.inspect})
|
1435
1483
|
when ActiveRecord::Base # Object from a has_one
|
1436
1484
|
[collection]
|
data/lib/brick/version_number.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.103
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorin Thwaits
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|