brick 1.0.35 → 1.0.36
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 +5 -1
- data/lib/brick/frameworks/rails/engine.rb +31 -21
- 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: 6ef930474d4e1496812af0a626f57a2db1b05396c2dc46eb8f117c6fbf2f4df5
|
4
|
+
data.tar.gz: 8847971321e1a6178b340ef6929298d2d33edb1a1918584c43d67edc5b844a39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cba480c932d00067c122b99d22f2633d8b26795295a4039a4c6ac014893ed0e4313ac33571cad06a880d9cbf426627e766c2b13514e7bf7b81093acc723aa425
|
7
|
+
data.tar.gz: 75aa1e29cd0619bf9654df74a4f36625b1b703bd307b9f72439e4ce9e25f0b80bd9fb10b4fe6f2eadf70effcf28849e1a513c1745d48b31000d33e8948ab555c
|
data/lib/brick/extensions.rb
CHANGED
@@ -1108,9 +1108,11 @@ module ActiveRecord::ConnectionHandling
|
|
1108
1108
|
# Only for Postgres? (Doesn't work in sqlite3)
|
1109
1109
|
# puts ActiveRecord::Base.execute_sql("SELECT current_setting('SEARCH_PATH')").to_a.inspect
|
1110
1110
|
|
1111
|
+
is_postgres = nil
|
1111
1112
|
schema_sql = 'SELECT NULL AS table_schema;'
|
1112
1113
|
case ActiveRecord::Base.connection.adapter_name
|
1113
1114
|
when 'PostgreSQL'
|
1115
|
+
is_postgres = true
|
1114
1116
|
if (is_multitenant = (multitenancy = ::Brick.config.schema_behavior[:multitenant]) &&
|
1115
1117
|
(sta = multitenancy[:schema_to_analyse]) != 'public')
|
1116
1118
|
::Brick.default_schema = schema = sta
|
@@ -1158,7 +1160,8 @@ module ActiveRecord::ConnectionHandling
|
|
1158
1160
|
# %%% Retrieve internal ActiveRecord table names like this:
|
1159
1161
|
# ActiveRecord::Base.internal_metadata_table_name, ActiveRecord::Base.schema_migrations_table_name
|
1160
1162
|
# For if it's not SQLite -- so this is the Postgres and MySQL version
|
1161
|
-
sql ||= "SELECT t.table_schema AS schema, t.table_name AS relation_name, t.table_type
|
1163
|
+
sql ||= "SELECT t.table_schema AS schema, t.table_name AS relation_name, t.table_type,#{"
|
1164
|
+
pg_catalog.obj_description((t.table_schema || '.' || t.table_name)::regclass, 'pg_class') AS table_description," if is_postgres}
|
1162
1165
|
c.column_name, c.data_type,
|
1163
1166
|
COALESCE(c.character_maximum_length, c.numeric_precision) AS max_length,
|
1164
1167
|
tc.constraint_type AS const, kcu.constraint_name AS \"key\",
|
@@ -1197,6 +1200,7 @@ module ActiveRecord::ConnectionHandling
|
|
1197
1200
|
relation_name = schema_name ? "#{schema_name}.#{r['relation_name']}" : r['relation_name']
|
1198
1201
|
relation = relations[relation_name]
|
1199
1202
|
relation[:isView] = true if r['table_type'] == 'VIEW'
|
1203
|
+
relation[:description] = r['table_description'] if r['table_description']
|
1200
1204
|
col_name = r['column_name']
|
1201
1205
|
key = case r['const']
|
1202
1206
|
when 'PRIMARY KEY'
|
@@ -415,18 +415,19 @@ function changeout(href, param, value, trimAfter) {
|
|
415
415
|
end
|
416
416
|
# %%% Instead of our current "for Janet Leverling (Employee)" kind of link we previously had this code that did a "where x = 123" thing:
|
417
417
|
# (where <%= @_brick_params.each_with_object([]) { |v, s| s << \"#\{v.first\} = #\{v.last.inspect\}\" }.join(', ') %>)
|
418
|
-
"#{css}
|
418
|
+
x = "#{css}
|
419
419
|
<p style=\"color: green\"><%= notice %></p>#{"
|
420
420
|
<select id=\"schema\">#{schema_options}</select>" if ::Brick.config.schema_behavior[:multitenant] && ::Brick.db_schemas.length > 1}
|
421
421
|
<select id=\"tbl\">#{table_options}</select>
|
422
|
-
<h1>#{model_plural = model_name.pluralize}</h1>#{template_link}
|
423
|
-
|
424
|
-
|
422
|
+
<h1>#{model_plural = model_name.pluralize}</h1>#{template_link}<%
|
423
|
+
if (relation = Brick.relations[#{model_name}.table_name])[:description] %><%=
|
424
|
+
relation.fetch(:description, nil) %><br><%
|
425
|
+
end
|
426
|
+
if @_brick_params&.present? %>
|
425
427
|
<% if @_brick_params.length == 1 # %%% Does not yet work with composite keys
|
426
428
|
k, id = @_brick_params.first
|
427
429
|
id = id.first if id.is_a?(Array) && id.length == 1
|
428
430
|
origin = (key_parts = k.split('.')).length == 1 ? #{model_name} : #{model_name}.reflect_on_association(key_parts.first).klass
|
429
|
-
# binding.pry
|
430
431
|
if (destination_fk = Brick.relations[origin.table_name][:fks].values.find { |fk| puts fk.inspect; fk[:fk] == key_parts.last }) &&
|
431
432
|
(obj = (destination = origin.reflect_on_association(destination_fk[:assoc_name])&.klass)&.find(id)) %>
|
432
433
|
<h3>for <%= link_to \"#{"#\{obj.brick_descrip\} (#\{destination.name\})\""}, send(\"#\{destination.name.underscore.tr('/', '_')\}_path\".to_sym, id) %></h3><%
|
@@ -436,19 +437,23 @@ function changeout(href, param, value, trimAfter) {
|
|
436
437
|
<% end %>
|
437
438
|
<table id=\"#{table_name}\">
|
438
439
|
<thead><tr>#{'<th></th>' if pk.present?}
|
439
|
-
<%
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
440
|
+
<% col_order = []
|
441
|
+
@#{table_name}.columns.each do |col|
|
442
|
+
col_name = col.name
|
443
|
+
next if (#{(pk || []).inspect}.include?(col_name) && col.type == :integer && !bts.key?(col_name)) ||
|
444
|
+
::Brick.config.metadata_columns.include?(col_name) || poly_cols.include?(col_name)
|
445
|
+
|
446
|
+
col_order << col_name %>
|
447
|
+
<th<%= \" title = \\\"#\{col.comment}\\\"\".html_safe unless col.comment.blank? %>><%
|
448
|
+
if (bt = bts[col_name]) %>
|
444
449
|
BT <%
|
445
450
|
bt[1].each do |bt_pair| %><%=
|
446
451
|
bt_pair.first.bt_link(bt.first) %> <%
|
447
452
|
end %><%
|
448
453
|
else %><%=
|
449
|
-
|
450
|
-
end
|
451
|
-
|
454
|
+
col_name %><%
|
455
|
+
end
|
456
|
+
%></th>
|
452
457
|
<% end %>
|
453
458
|
<%# Consider getting the name from the association -- h.first.name -- if a more \"friendly\" alias should be used for a screwy table name %>
|
454
459
|
#{hms_headers.map { |h| "<th>#{h[1]} <%= link_to('#{h[2]}', #{h.first.klass.name.underscore.tr('/', '_').pluralize}_path) %></th>\n" }.join}
|
@@ -458,11 +463,10 @@ function changeout(href, param, value, trimAfter) {
|
|
458
463
|
<% @#{table_name}.each do |#{obj_name}| %>
|
459
464
|
<tr>#{"
|
460
465
|
<td><%= link_to '⇛', #{path_obj_name}_path(#{obj_pk}), { class: 'big-arrow' } %></td>" if obj_pk}
|
461
|
-
<%
|
462
|
-
|
463
|
-
::Brick.config.metadata_columns.include?(k) || poly_cols.include?(k) || k.start_with?('_brfk_') || (k.start_with?('_br_') && (k.length == 63 || k.end_with?('_ct'))) %>
|
466
|
+
<% col_order.each do |col_name|
|
467
|
+
val = #{obj_name}.attributes[col_name] %>
|
464
468
|
<td>
|
465
|
-
<% if (bt = bts[
|
469
|
+
<% if (bt = bts[col_name]) %>
|
466
470
|
<% if bt[2] # Polymorphic?
|
467
471
|
bt_class = #{obj_name}.send(\"#\{bt.first\}_type\")
|
468
472
|
base_class = (::Brick.existing_stis[bt_class] || bt_class).constantize.base_class.name.underscore
|
@@ -491,13 +495,18 @@ function changeout(href, param, value, trimAfter) {
|
|
491
495
|
|
492
496
|
#{"<hr><%= link_to \"New #{obj_name}\", new_#{path_obj_name}_path %>" unless @_brick_model.is_view?}
|
493
497
|
#{script}"
|
498
|
+
puts x
|
499
|
+
x
|
494
500
|
when 'show', 'update'
|
495
501
|
"#{css}
|
496
502
|
<p style=\"color: green\"><%= notice %></p>#{"
|
497
503
|
<select id=\"schema\">#{schema_options}</select>" if ::Brick.config.schema_behavior[:multitenant] && ::Brick.db_schemas.length > 1}
|
498
504
|
<select id=\"tbl\">#{table_options}</select>
|
499
|
-
<h1>#{model_name}: <%= (obj = @#{obj_name})&.brick_descrip || controller_name %></h1
|
500
|
-
|
505
|
+
<h1>#{model_name}: <%= (obj = @#{obj_name})&.brick_descrip || controller_name %></h1><%
|
506
|
+
if (relation = Brick.relations[#{model_name}.table_name])[:description] %><%=
|
507
|
+
relation.fetch(:description, nil) %><br><%
|
508
|
+
end
|
509
|
+
%><%= link_to '(See all #{obj_name.pluralize})', #{path_obj_name.pluralize}_path %>
|
501
510
|
<% if obj %>
|
502
511
|
<%= # path_options = [obj.#{pk}]
|
503
512
|
# path_options << { '_brick_schema': } if
|
@@ -505,11 +514,12 @@ function changeout(href, param, value, trimAfter) {
|
|
505
514
|
form_for(obj.becomes(#{model_name})) do |f| %>
|
506
515
|
<table>
|
507
516
|
<% has_fields = false
|
508
|
-
@#{obj_name}.attributes.each do |k, val|
|
517
|
+
@#{obj_name}.attributes.each do |k, val|
|
518
|
+
col = #{model_name}.columns_hash[k] %>
|
509
519
|
<tr>
|
510
520
|
<% next if (#{(pk || []).inspect}.include?(k) && !bts.key?(k)) ||
|
511
521
|
::Brick.config.metadata_columns.include?(k) %>
|
512
|
-
<th class=\"show-field\"
|
522
|
+
<th class=\"show-field\"<%= \" title = \\\"#\{col.comment}\\\"\".html_safe unless col.comment.blank? %>>
|
513
523
|
<% has_fields = true
|
514
524
|
if (bt = bts[k])
|
515
525
|
# Add a final member in this array with descriptive options to be used in <select> drop-downs
|
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.36
|
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-06-
|
11
|
+
date: 2022-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|