brick 1.0.41 → 1.0.44
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 +29 -18
- data/lib/brick/frameworks/rails/engine.rb +140 -32
- data/lib/brick/version_number.rb +1 -1
- data/lib/generators/brick/install_generator.rb +2 -2
- 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: 0d43e8d88203f6496d0e86f57a3de2638f254a74da070d6a0f0ae107bf596a87
|
4
|
+
data.tar.gz: d5ce2e3814f36fa758762e3c4774032c70ce18a101cdd1e30622dd86c757ab1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b8bf590c1d980655b8c465e52659fdbcdf3e13b7050e46dcb41c2b3fba44ebc9ff14db823afddbb49b3e6b736a33fa1ef794ed6062aba4e35ade3cd95c5bbd
|
7
|
+
data.tar.gz: d1bd0954d0400068aaf8f7c83cc599f283fbe9c75e347fd4193d1fa3973c0d2bd3198f3265990cd3d24f406cd3b55f3174518bd6a991801c75a06d1c749cc157
|
data/lib/brick/extensions.rb
CHANGED
@@ -354,6 +354,7 @@ module ActiveRecord
|
|
354
354
|
next if bt[2] # Polymorphic?
|
355
355
|
|
356
356
|
# join_array will receive this relation name when calling #brick_parse_dsl
|
357
|
+
# binding.pry if bt.length > 2
|
357
358
|
bt_descrip[bt.first] = if bt[1].is_a?(Array)
|
358
359
|
bt[1].each_with_object({}) { |bt_class, s| s[bt_class] = bt_class.brick_parse_dsl(join_array, bt.first, translations, true) }
|
359
360
|
else
|
@@ -364,7 +365,12 @@ module ActiveRecord
|
|
364
365
|
hms.each do |k, hm|
|
365
366
|
next if skip_klass_hms.key?(k)
|
366
367
|
|
367
|
-
|
368
|
+
if hm.macro == :has_one
|
369
|
+
# For our purposes a :has_one is similar enough to a :belongs_to that we can just join forces
|
370
|
+
bt_descrip[k] = { hm.klass => hm.klass.brick_parse_dsl(join_array, k, translations) }
|
371
|
+
else # Standard :has_many
|
372
|
+
hm_counts[k] = hm
|
373
|
+
end
|
368
374
|
end
|
369
375
|
end
|
370
376
|
|
@@ -650,10 +656,11 @@ class Object
|
|
650
656
|
private
|
651
657
|
|
652
658
|
def build_model(schema_name, inheritable_name, model_name, singular_table_name, table_name, relations, matching)
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
659
|
+
if ::Brick.config.schema_behavior[:multitenant] && Object.const_defined?('Apartment') &&
|
660
|
+
schema_name == Apartment.default_schema
|
661
|
+
relation = relations["#{schema_name}.#{matching}"]
|
662
|
+
end
|
663
|
+
full_name = if relation || schema_name.blank?
|
657
664
|
inheritable_name || model_name
|
658
665
|
else # Prefix the schema to the table name + prefix the schema namespace to the class name
|
659
666
|
schema_module = if schema_name.instance_of?(Module) # from an auto-STI namespace?
|
@@ -749,10 +756,10 @@ class Object
|
|
749
756
|
if assoc[:is_bt]
|
750
757
|
invs = invs.first # Just do the first one of what would be multiple identical polymorphic belongs_to
|
751
758
|
else
|
752
|
-
invs.each { |inv| build_bt_or_hm(
|
759
|
+
invs.each { |inv| build_bt_or_hm(full_name, relations, relation, hmts, assoc, inverse_assoc_name, inv, code) }
|
753
760
|
end
|
754
761
|
end
|
755
|
-
build_bt_or_hm(
|
762
|
+
build_bt_or_hm(full_name, relations, relation, hmts, assoc, inverse_assoc_name, invs, code) unless invs.is_a?(Array)
|
756
763
|
hmts
|
757
764
|
end
|
758
765
|
# # Not NULLables
|
@@ -804,7 +811,7 @@ class Object
|
|
804
811
|
[built_model, code]
|
805
812
|
end
|
806
813
|
|
807
|
-
def build_bt_or_hm(
|
814
|
+
def build_bt_or_hm(full_name, relations, relation, hmts, assoc, inverse_assoc_name, inverse_table, code)
|
808
815
|
singular_table_name = inverse_table&.singularize
|
809
816
|
options = {}
|
810
817
|
macro = if assoc[:is_bt]
|
@@ -826,8 +833,14 @@ class Object
|
|
826
833
|
end
|
827
834
|
if (inverse = assoc[:inverse])
|
828
835
|
inverse_assoc_name, _x = _brick_get_hm_assoc_name(relations[inverse_table], inverse)
|
829
|
-
|
830
|
-
if
|
836
|
+
# If it's multitenant with something like: public.____ ...
|
837
|
+
if (it_parts = inverse_table.split('.')).length > 1 &&
|
838
|
+
::Brick.config.schema_behavior[:multitenant] && Object.const_defined?('Apartment') &&
|
839
|
+
it_parts.first == Apartment.default_schema
|
840
|
+
it_parts.shift # ... then ditch the generic schema name
|
841
|
+
end
|
842
|
+
has_ones = ::Brick.config.has_ones&.fetch(it_parts.join('/').singularize.camelize, nil)
|
843
|
+
if has_ones&.key?(singular_inv_assoc_name = ActiveSupport::Inflector.singularize(inverse_assoc_name.tr('.', '_')))
|
831
844
|
inverse_assoc_name = if has_ones[singular_inv_assoc_name]
|
832
845
|
need_inverse_of = true
|
833
846
|
has_ones[singular_inv_assoc_name]
|
@@ -838,7 +851,6 @@ class Object
|
|
838
851
|
end
|
839
852
|
:belongs_to
|
840
853
|
else
|
841
|
-
# need_class_name = ActiveSupport::Inflector.singularize(assoc_name) == ActiveSupport::Inflector.singularize(table_name.underscore)
|
842
854
|
# Are there multiple foreign keys out to the same table?
|
843
855
|
assoc_name, need_class_name = _brick_get_hm_assoc_name(relation, assoc)
|
844
856
|
if assoc.key?(:polymorphic)
|
@@ -846,8 +858,8 @@ class Object
|
|
846
858
|
else
|
847
859
|
need_fk = "#{ActiveSupport::Inflector.singularize(assoc[:inverse][:inverse_table].split('.').last)}_id" != assoc[:fk]
|
848
860
|
end
|
849
|
-
|
850
|
-
if
|
861
|
+
has_ones = ::Brick.config.has_ones&.fetch(full_name, nil)
|
862
|
+
if has_ones&.key?(singular_assoc_name = ActiveSupport::Inflector.singularize(assoc_name.tr('.', '_')))
|
851
863
|
assoc_name = if (custom_assoc_name = has_ones[singular_assoc_name])
|
852
864
|
need_class_name = custom_assoc_name != singular_assoc_name
|
853
865
|
custom_assoc_name
|
@@ -905,10 +917,8 @@ class Object
|
|
905
917
|
if plural_class_name == 'BrickGem'
|
906
918
|
self.define_method :orphans do
|
907
919
|
instance_variable_set(:@orphans, ::Brick.find_orphans(::Brick.set_db_schema(params)))
|
908
|
-
puts "BrickGemController #{action_name} #{params.inspect}"
|
909
|
-
# render inline: 'Brick gem!'
|
910
920
|
end
|
911
|
-
return [new_controller_class, code + ' # BrickGem controller
|
921
|
+
return [new_controller_class, code + ' # BrickGem controller']
|
912
922
|
end
|
913
923
|
|
914
924
|
unless (is_swagger = plural_class_name == 'BrickSwagger') # && request.format == :json)
|
@@ -1061,10 +1071,11 @@ class Object
|
|
1061
1071
|
if is_need_params
|
1062
1072
|
code << "private\n"
|
1063
1073
|
code << " def #{params_name}\n"
|
1064
|
-
code << " params.require(:#{
|
1074
|
+
code << " params.require(:#{require_name = model.name.underscore.tr('/', '_')
|
1075
|
+
}).permit(#{model.columns_hash.keys.map { |c| c.to_sym.inspect }.join(', ')})\n"
|
1065
1076
|
code << " end\n"
|
1066
1077
|
self.define_method(params_name) do
|
1067
|
-
params.require(
|
1078
|
+
params.require(require_name.to_sym).permit(model.columns_hash.keys)
|
1068
1079
|
end
|
1069
1080
|
private params_name
|
1070
1081
|
# Get column names for params from relations[model.table_name][:cols].keys
|
@@ -112,7 +112,8 @@ module Brick
|
|
112
112
|
else
|
113
113
|
hm_assoc.foreign_key
|
114
114
|
end
|
115
|
-
|
115
|
+
case args.first
|
116
|
+
when 'index'
|
116
117
|
hms_columns << if hm_assoc.macro == :has_many
|
117
118
|
set_ct = if skip_klass_hms.key?(assoc_name.to_sym)
|
118
119
|
'nil'
|
@@ -124,16 +125,20 @@ module Brick
|
|
124
125
|
if hm_fk_name
|
125
126
|
"<%= ct = #{set_ct}
|
126
127
|
link_to \"#\{ct || 'View'\} #{assoc_name}\", #{hm_assoc.klass.name.underscore.tr('/', '_').pluralize}_path({ #{path_keys(hm_assoc, hm_fk_name, obj_name, pk)} }) unless ct&.zero? %>\n"
|
127
|
-
else
|
128
|
+
else # %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
|
128
129
|
"#{assoc_name}\n"
|
129
130
|
end
|
130
131
|
else # has_one
|
131
|
-
|
132
|
+
# 0..62 because Postgres column names are limited to 63 characters
|
133
|
+
"<%= descrips = @_brick_bt_descrip[#{hm.first.inspect}][ho_class = #{hm[1].klass.name}]
|
134
|
+
ho_txt = ho_class.brick_descrip(#{obj_name}, descrips[0..-2].map { |id| #{obj_name}.send(id.last[0..62]) }, (ho_id_col = descrips.last))
|
135
|
+
ho_id = ho_id_col.map { |id_col| #{obj_name}.send(id_col.to_sym) }
|
136
|
+
ho_id&.first ? link_to(ho_txt, send(\"#\{ho_class.base_class.name.underscore.tr('/', '_')\}_path\".to_sym, ho_id)) : ho_txt %>\n"
|
132
137
|
end
|
133
|
-
|
138
|
+
when 'show', 'update'
|
134
139
|
hm_stuff << if hm_fk_name
|
135
140
|
"<%= link_to '#{assoc_name}', #{hm_assoc.klass.name.underscore.tr('/', '_').pluralize}_path({ #{path_keys(hm_assoc, hm_fk_name, "@#{obj_name}", pk)} }) %>\n"
|
136
|
-
else
|
141
|
+
else # %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
|
137
142
|
assoc_name
|
138
143
|
end
|
139
144
|
end
|
@@ -213,6 +218,9 @@ table tbody tr.active-row {
|
|
213
218
|
color: #009879;
|
214
219
|
}
|
215
220
|
|
221
|
+
td.val {
|
222
|
+
display: block;
|
223
|
+
}
|
216
224
|
a.show-arrow {
|
217
225
|
font-size: 1.5em;
|
218
226
|
text-decoration: none;
|
@@ -226,11 +234,27 @@ a.big-arrow {
|
|
226
234
|
overflow: hidden;
|
227
235
|
}
|
228
236
|
.wide-input input[type=text] {
|
229
|
-
|
237
|
+
display: inline-block;
|
238
|
+
width: 90%;
|
230
239
|
}
|
231
240
|
.dimmed {
|
232
241
|
background-color: #C0C0C0;
|
233
242
|
}
|
243
|
+
|
244
|
+
#revertTemplate {
|
245
|
+
display: none;
|
246
|
+
}
|
247
|
+
svg.revert {
|
248
|
+
display: none;
|
249
|
+
margin-left: 0.25em;
|
250
|
+
}
|
251
|
+
.wide-input > svg.revert {
|
252
|
+
float: right;
|
253
|
+
}
|
254
|
+
input+svg.revert {
|
255
|
+
top: 0.5em;
|
256
|
+
}
|
257
|
+
|
234
258
|
input[type=submit] {
|
235
259
|
background-color: #004998;
|
236
260
|
color: #FFF;
|
@@ -239,7 +263,9 @@ input[type=submit] {
|
|
239
263
|
text-align: right;
|
240
264
|
}
|
241
265
|
</style>
|
242
|
-
<%
|
266
|
+
<% is_includes_dates = nil
|
267
|
+
|
268
|
+
def is_bcrypt?(val)
|
243
269
|
val.is_a?(String) && val.length == 60 && val.start_with?('$2a$')
|
244
270
|
end
|
245
271
|
def hide_bcrypt(val, max_len = 200)
|
@@ -311,7 +337,13 @@ window.addEventListener(\"pageshow\", function() {
|
|
311
337
|
});
|
312
338
|
|
313
339
|
if (tblSelect) { // Always present
|
314
|
-
|
340
|
+
var i = schemaSelect ? 1 : 0,
|
341
|
+
changeoutList = changeout(location.href);
|
342
|
+
for (; i < changeoutList.length; ++i) {
|
343
|
+
tblSelect.value = changeoutList[i];
|
344
|
+
if (tblSelect.value !== \"\") break;
|
345
|
+
}
|
346
|
+
|
315
347
|
tblSelect.addEventListener(\"change\", function () {
|
316
348
|
var lhr = changeout(location.href, null, this.value);
|
317
349
|
if (brickSchema)
|
@@ -328,13 +360,13 @@ function changeout(href, param, value, trimAfter) {
|
|
328
360
|
var pathParts = hrefParts[hrefParts.length - 1].split(\"/\");
|
329
361
|
if (value === undefined)
|
330
362
|
// A couple possibilities if it's namespaced, starting with two parts in the path -- and then try just one
|
331
|
-
return [pathParts.slice(1, 3).join('/'), pathParts.slice(1, 2)];
|
363
|
+
return [pathParts.slice(1, 3).join('/'), pathParts.slice(1, 2)[0]];
|
332
364
|
else
|
333
365
|
return hrefParts[0] + \"://\" + pathParts[0] + \"/\" + value;
|
334
366
|
}
|
335
367
|
if (trimAfter) {
|
336
368
|
var pathParts = hrefParts[0].split(\"/\");
|
337
|
-
while (pathParts.lastIndexOf(trimAfter)
|
369
|
+
while (pathParts.lastIndexOf(trimAfter) !== pathParts.length - 1) pathParts.pop();
|
338
370
|
hrefParts[0] = pathParts.join(\"/\");
|
339
371
|
}
|
340
372
|
var params = hrefParts.length > 1 ? hrefParts[1].split(\"&\") : [];
|
@@ -478,7 +510,7 @@ if (headerTop) {
|
|
478
510
|
end
|
479
511
|
# %%% Instead of our current "for Janet Leverling (Employee)" kind of link we previously had this code that did a "where x = 123" thing:
|
480
512
|
# (where <%= @_brick_params.each_with_object([]) { |v, s| s << \"#\{v.first\} = #\{v.last.inspect\}\" }.join(', ') %>)
|
481
|
-
"#{css}
|
513
|
+
+"#{css}
|
482
514
|
<p style=\"color: green\"><%= notice %></p>#{"
|
483
515
|
<select id=\"schema\">#{schema_options}</select>" if ::Brick.config.schema_behavior[:multitenant] && ::Brick.db_schemas.length > 1}
|
484
516
|
<select id=\"tbl\">#{table_options}</select>
|
@@ -504,8 +536,7 @@ if (headerTop) {
|
|
504
536
|
<thead><tr>#{'<th></th>' if pk.present?}<%
|
505
537
|
col_order = []
|
506
538
|
@#{table_name}.columns.each do |col|
|
507
|
-
col_name = col.name
|
508
|
-
next if (#{(pk || []).inspect}.include?(col_name) && col.type == :integer && !bts.key?(col_name)) ||
|
539
|
+
next if (#{(pk || []).inspect}.include?(col_name = col.name) && col.type == :integer && !bts.key?(col_name)) ||
|
509
540
|
::Brick.config.metadata_columns.include?(col_name) || poly_cols.include?(col_name)
|
510
541
|
|
511
542
|
col_order << col_name
|
@@ -518,12 +549,12 @@ if (headerTop) {
|
|
518
549
|
else %><%=
|
519
550
|
col_name %><%
|
520
551
|
end
|
521
|
-
|
552
|
+
%></th><%
|
522
553
|
end
|
523
554
|
# Consider getting the name from the association -- h.first.name -- if a more \"friendly\" alias should be used for a screwy table name
|
524
555
|
%>#{hms_headers.map do |h|
|
525
556
|
if h.first.options[:through] && !h.first.through_reflection
|
526
|
-
"<th>#{h[1]} #{h[2]} %></th>"
|
557
|
+
"<th>#{h[1]} #{h[2]} %></th>" # %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
|
527
558
|
else
|
528
559
|
"<th>#{h[1]} <%= link_to('#{h[2]}', #{h.first.klass.name.underscore.tr('/', '_').pluralize}_path) %></th>"
|
529
560
|
end
|
@@ -547,11 +578,11 @@ if (headerTop) {
|
|
547
578
|
else
|
548
579
|
bt_txt = (bt_class = bt[1].first.first).brick_descrip(
|
549
580
|
# 0..62 because Postgres column names are limited to 63 characters
|
550
|
-
#{obj_name}, (descrips = @_brick_bt_descrip[bt.first][bt_class])[0..-2].map { |
|
581
|
+
#{obj_name}, (descrips = @_brick_bt_descrip[bt.first][bt_class])[0..-2].map { |id| #{obj_name}.send(id.last[0..62]) }, (bt_id_col = descrips.last)
|
551
582
|
)
|
552
583
|
bt_txt ||= \"<< Orphaned ID: #\{val} >>\" if val
|
553
|
-
bt_id = #{obj_name}.send(
|
554
|
-
<%= bt_id ? link_to(bt_txt, send(\"#\{bt_class.base_class.name.underscore.tr('/', '_')\}_path\".to_sym, bt_id)) : bt_txt %>
|
584
|
+
bt_id = bt_id_col.map { |id_col| #{obj_name}.send(id_col.to_sym) } if bt_id_col&.present? %>
|
585
|
+
<%= bt_id&.first ? link_to(bt_txt, send(\"#\{bt_class.base_class.name.underscore.tr('/', '_')\}_path\".to_sym, bt_id)) : bt_txt %>
|
555
586
|
<%#= Previously was: bt_obj = bt[1].first.first.find_by(bt[2] => val); link_to(bt_obj.brick_descrip, send(\"#\{bt[1].first.first.name.underscore\}_path\".to_sym, bt_obj.send(bt[1].first.first.primary_key.to_sym))) if bt_obj %>
|
556
587
|
<% end %>
|
557
588
|
<% else %>
|
@@ -569,7 +600,7 @@ if (headerTop) {
|
|
569
600
|
#{script}"
|
570
601
|
when 'orphans'
|
571
602
|
if is_orphans
|
572
|
-
"#{css}
|
603
|
+
+"#{css}
|
573
604
|
<p style=\"color: green\"><%= notice %></p>#{"
|
574
605
|
<select id=\"schema\">#{schema_options}</select>" if ::Brick.config.schema_behavior[:multitenant] && ::Brick.db_schemas.length > 1}
|
575
606
|
<select id=\"tbl\">#{table_options}</select>
|
@@ -584,7 +615,14 @@ if (headerTop) {
|
|
584
615
|
end
|
585
616
|
|
586
617
|
when 'show', 'update'
|
587
|
-
"#{css}
|
618
|
+
+"#{css}
|
619
|
+
|
620
|
+
<svg id=\"revertTemplate\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"
|
621
|
+
width=\"32px\" height=\"32px\" viewBox=\"0 0 512 512\" xml:space=\"preserve\">
|
622
|
+
<path id=\"revertPath\" fill=\"#2020A0\" d=\"M271.844,119.641c-78.531,0-148.031,37.875-191.813,96.188l-80.172-80.188v256h256l-87.094-87.094
|
623
|
+
c23.141-70.188,89.141-120.906,167.063-120.906c97.25,0,176,78.813,176,176C511.828,227.078,404.391,119.641,271.844,119.641z\" />
|
624
|
+
</svg>
|
625
|
+
|
588
626
|
<p style=\"color: green\"><%= notice %></p>#{"
|
589
627
|
<select id=\"schema\">#{schema_options}</select>" if ::Brick.config.schema_behavior[:multitenant] && ::Brick.db_schemas.length > 1}
|
590
628
|
<select id=\"tbl\">#{table_options}</select>
|
@@ -642,30 +680,39 @@ end
|
|
642
680
|
<%= k %>
|
643
681
|
<% end %>
|
644
682
|
</th>
|
645
|
-
<td>
|
646
|
-
<%
|
683
|
+
<td class=\"val\">
|
684
|
+
<% dt_pickers = { datetime: 'datetimepicker', timestamp: 'datetimepicker', time: 'timepicker', date: 'datepicker' }
|
685
|
+
if bt
|
647
686
|
html_options = { prompt: \"Select #\{bt_name\}\" }
|
648
687
|
html_options[:class] = 'dimmed' unless val %>
|
649
688
|
<%= f.select k.to_sym, bt[3], { value: val || '^^^brick_NULL^^^' }, html_options %>
|
650
689
|
<%= if (bt_obj = bt_class&.find_by(bt_pair[1] => val))
|
651
690
|
link_to('⇛', send(\"#\{bt_class.base_class.name.underscore.tr('/', '_')\}_path\".to_sym, bt_obj.send(bt_class.primary_key.to_sym)), { class: 'show-arrow' })
|
652
691
|
elsif val
|
653
|
-
\"Orphaned ID: #\{val}
|
654
|
-
end
|
655
|
-
<% else case #{model_name}.column_for_attribute(k).type
|
692
|
+
\"<span>Orphaned ID: #\{val}</span>\".html_safe
|
693
|
+
end %><svg class=\"revert\" width=\"1.5em\" viewBox=\"0 0 512 512\"><use xlink:href=\"#revertPath\" /></svg>
|
694
|
+
<% else case (col_type = #{model_name}.column_for_attribute(k).type)
|
656
695
|
when :string, :text %>
|
657
696
|
<% if is_bcrypt?(val) # || .readonly? %>
|
658
697
|
<%= hide_bcrypt(val, 1000) %>
|
659
698
|
<% else %>
|
660
|
-
<div class=\"wide-input\"><%= f.text_field k.to_sym
|
699
|
+
<div class=\"wide-input\"><%= f.text_field k.to_sym %><svg class=\"revert\" width=\"1.5em\" viewBox=\"0 0 512 512\"><use xlink:href=\"#revertPath\" /></svg></div>
|
661
700
|
<% end %>
|
662
701
|
<% when :boolean %>
|
663
|
-
<%= f.check_box k.to_sym
|
664
|
-
<% when :integer, :decimal, :float
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
702
|
+
<%= f.check_box k.to_sym %><svg class=\"revert\" width=\"1.5em\" viewBox=\"0 0 512 512\"><use xlink:href=\"#revertPath\" /></svg>
|
703
|
+
<% when :integer, :decimal, :float
|
704
|
+
<%= if col_type == :integer
|
705
|
+
f.text_field k.to_sym, { pattern: '\\d*', class: 'check-validity' }
|
706
|
+
else
|
707
|
+
f.number_field k.to_sym
|
708
|
+
end %><svg class=\"revert\" width=\"1.5em\" viewBox=\"0 0 512 512\"><use xlink:href=\"#revertPath\" /></svg>
|
709
|
+
<% when *dt_pickers.keys
|
710
|
+
is_includes_dates = true %>
|
711
|
+
<%= f.text_field k.to_sym, { class: dt_pickers[col_type] } %><svg class=\"revert\" width=\"1.5em\" viewBox=\"0 0 512 512\"><use xlink:href=\"#revertPath\" /></svg>
|
712
|
+
<% when :uuid %>
|
713
|
+
# Postgres naturally uses the +uuid_generate_v4()+ function from the uuid-ossp extension
|
714
|
+
# If it's not yet enabled then: enable_extension 'uuid-ossp'
|
715
|
+
# ActiveUUID gem created a new :uuid type %>
|
669
716
|
<%= val %>
|
670
717
|
<% when :binary, :primary_key %>
|
671
718
|
<% end %>
|
@@ -682,6 +729,7 @@ end
|
|
682
729
|
<% end %>
|
683
730
|
|
684
731
|
#{hms_headers.each_with_object(+'') do |hm, s|
|
732
|
+
# %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
|
685
733
|
next if hm.first.options[:through] && !hm.first.through_reflection
|
686
734
|
|
687
735
|
if (pk = hm.first.klass.primary_key)
|
@@ -707,6 +755,66 @@ end
|
|
707
755
|
#{script}"
|
708
756
|
|
709
757
|
end
|
758
|
+
inline << "
|
759
|
+
<% if is_includes_dates %>
|
760
|
+
<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css\">
|
761
|
+
<style>
|
762
|
+
.flatpickr-calendar {
|
763
|
+
background: #A0FFA0;
|
764
|
+
}
|
765
|
+
</style>
|
766
|
+
<script src=\"https://cdn.jsdelivr.net/npm/flatpickr\"></script>
|
767
|
+
<script>
|
768
|
+
flatpickr(\".datepicker\");
|
769
|
+
flatpickr(\".datetimepicker\", {enableTime: true});
|
770
|
+
flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
771
|
+
</script>
|
772
|
+
<% end %>
|
773
|
+
<script>
|
774
|
+
document.querySelectorAll(\"input, select\").forEach(function (inp) {
|
775
|
+
var origVal = getInpVal(),
|
776
|
+
prevVal = origVal;
|
777
|
+
var revert;
|
778
|
+
if ((revert = ((inp.tagName === \"SELECT\" && inp.nextElementSibling.nextElementSibling) ||
|
779
|
+
inp.nextElementSibling ||
|
780
|
+
inp.parentElement.nextElementSibling)) && revert.tagName.toLowerCase() === \"svg\")
|
781
|
+
revert.addEventListener(\"click\", function (e) {
|
782
|
+
if (inp.type === \"checkbox\")
|
783
|
+
inp.checked = origVal;
|
784
|
+
else
|
785
|
+
inp.value = origVal;
|
786
|
+
revert.style.display = \"none\";
|
787
|
+
if (inp._flatpickr)
|
788
|
+
inp._flatpickr.setDate(origVal);
|
789
|
+
else
|
790
|
+
inp.focus();
|
791
|
+
});
|
792
|
+
inp.addEventListener(inp.type === \"checkbox\" ? \"change\" : \"input\", function (e) {
|
793
|
+
if(inp.className.split(\" \").indexOf(\"check-validity\") > 0) {
|
794
|
+
if (inp.checkValidity()) {
|
795
|
+
prevVal = getInpVal();
|
796
|
+
} else {
|
797
|
+
inp.value = prevVal;
|
798
|
+
}
|
799
|
+
} else {
|
800
|
+
// If this is the result of changing an hour or minute, keep the calendar open.
|
801
|
+
// And if it was the result of selecting a date, the calendar can now close.
|
802
|
+
if (inp._flatpickr &&
|
803
|
+
// Test only for changes in the date portion of a date or datetime
|
804
|
+
((giv = getInpVal()) && (giv1 = giv.split(' ')[0])) !== (prevVal && prevVal.split(' ')[0]) &&
|
805
|
+
giv1.indexOf(\":\") < 0 // (definitely not any part of a time thing)
|
806
|
+
)
|
807
|
+
inp._flatpickr.close();
|
808
|
+
prevVal = getInpVal();
|
809
|
+
}
|
810
|
+
// Show or hide the revert button
|
811
|
+
if (revert) revert.style.display = getInpVal() === origVal ? \"none\" : \"inline-block\";
|
812
|
+
});
|
813
|
+
function getInpVal() {
|
814
|
+
return inp.type === \"checkbox\" ? inp.checked : inp.value;
|
815
|
+
}
|
816
|
+
});
|
817
|
+
</script>"
|
710
818
|
# As if it were an inline template (see #determine_template in actionview-5.2.6.2/lib/action_view/renderer/template_renderer.rb)
|
711
819
|
keys = options.has_key?(:locals) ? options[:locals].keys : []
|
712
820
|
handler = ActionView::Template.handler_for_extension(options[:type] || 'erb')
|
data/lib/brick/version_number.rb
CHANGED
@@ -224,8 +224,8 @@ module Brick
|
|
224
224
|
# # Database schema to use when analysing existing data, such as deriving a list of polymorphic classes in the case that
|
225
225
|
# # it wasn't originally specified.
|
226
226
|
# Brick.schema_behavior = :namespaced
|
227
|
-
#{Brick.config.schema_behavior ? "Brick.schema_behavior = { multitenant: { schema_to_analyse: #{
|
228
|
-
Brick.config.schema_behavior[:multitenant]
|
227
|
+
#{Brick.config.schema_behavior.present? ? "Brick.schema_behavior = { multitenant: { schema_to_analyse: #{
|
228
|
+
Brick.config.schema_behavior[:multitenant]&.fetch(:schema_to_analyse, nil).inspect}" :
|
229
229
|
"# Brick.schema_behavior = { multitenant: { schema_to_analyse: 'engineering'"
|
230
230
|
} } }
|
231
231
|
|
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.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorin Thwaits
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|