brick 1.0.135 → 1.0.137
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 +7 -6
- data/lib/brick/frameworks/rails/engine.rb +7 -1
- data/lib/brick/frameworks/rails/form_tags.rb +26 -26
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +2 -0
- 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: f25abe6f88b55efadd50c9deb65e7d9aabac31482a77f0f911f84157d4394079
|
4
|
+
data.tar.gz: a437b8efd9116a7c1e5a81fa6d67a66755b15a275db56717ecb7abe76bbbb50a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21ea85675d6e711261c8873c12187d78ecfdb53961a8ba795d35210b2a7cd00940d3522def3f3c8f10d37e3f7a8409f68efefc923798847b602f8d8afe24316f
|
7
|
+
data.tar.gz: b34c4d0396aea262f73e34bc25d4f0e2d9e2d3bddb36aa1293d7e7293edfed9f930318724c8471f11344822b6faa4afa942018148ed59cfa27d50eef6bca0eea
|
data/lib/brick/extensions.rb
CHANGED
@@ -989,7 +989,7 @@ end
|
|
989
989
|
if Object.const_defined?('ActionView')
|
990
990
|
require 'brick/frameworks/rails/form_tags'
|
991
991
|
require 'brick/frameworks/rails/form_builder'
|
992
|
-
module ActionView::Helpers
|
992
|
+
module ::ActionView::Helpers
|
993
993
|
module FormTagHelper
|
994
994
|
include ::Brick::Rails::FormTags
|
995
995
|
end
|
@@ -999,8 +999,8 @@ if Object.const_defined?('ActionView')
|
|
999
999
|
end
|
1000
1000
|
|
1001
1001
|
# FormBuilder#field_id isn't available in Rails < 7.0. This is a rudimentary version with no `index`.
|
1002
|
-
unless ActionView::Helpers::FormBuilder.methods.include?(:field_id)
|
1003
|
-
ActionView::Helpers::FormBuilder.class_exec do
|
1002
|
+
unless ::ActionView::Helpers::FormBuilder.methods.include?(:field_id)
|
1003
|
+
::ActionView::Helpers::FormBuilder.class_exec do
|
1004
1004
|
def field_id(method)
|
1005
1005
|
[object_name, method.to_s].join('_')
|
1006
1006
|
end
|
@@ -1149,7 +1149,7 @@ Module.class_exec do
|
|
1149
1149
|
::Brick.is_oracle ? class_name.upcase : class_name,
|
1150
1150
|
(plural_class_name = class_name.pluralize)].find { |s| Brick.db_schemas&.include?(s) }&.camelize ||
|
1151
1151
|
(::Brick.config.sti_namespace_prefixes&.key?("::#{class_name}::") && class_name) ||
|
1152
|
-
(::Brick.config.table_name_prefixes
|
1152
|
+
(::Brick.config.table_name_prefixes&.values&.include?(class_name) && class_name))
|
1153
1153
|
return self.const_get(schema_name) if !is_tnp_module && self.const_defined?(schema_name)
|
1154
1154
|
|
1155
1155
|
# Build out a module for the schema if it's namespaced
|
@@ -1942,8 +1942,9 @@ class Object
|
|
1942
1942
|
end
|
1943
1943
|
render json: { result: ::Brick.unexclude_column(table_name, col) }
|
1944
1944
|
else
|
1945
|
-
instance_variable_set("@#{singular_table_name}".to_sym,
|
1946
|
-
|
1945
|
+
@_lookup_context.instance_variable_set("@#{singular_table_name}".to_sym,
|
1946
|
+
model.send(:create, send(params_name_sym)))
|
1947
|
+
@_lookup_context.instance_variable_set(:@_brick_model, model)
|
1947
1948
|
index
|
1948
1949
|
render :index
|
1949
1950
|
end
|
@@ -1430,6 +1430,12 @@ end
|
|
1430
1430
|
end
|
1431
1431
|
end
|
1432
1432
|
|
1433
|
+
# %%% Why in the Canvas LMS app does ActionView::Helpers get cleared / reloaded, or otherwise lose access to #brick_grid ???
|
1434
|
+
# Possible fix if somewhere we can implement the #include with:
|
1435
|
+
# (ActiveSupport.const_defined?('Reloader') ? ActiveSupport : ActionDispatch)::Reloader.to_prepare do ... end
|
1436
|
+
# or
|
1437
|
+
# Rails.application.reloader.to_prepare do ... end
|
1438
|
+
self.class.class_exec { include ::Brick::Rails::FormTags } unless respond_to?(:brick_grid)
|
1433
1439
|
# Write out the mega-grid
|
1434
1440
|
brick_grid(@#{table_name}, @_brick_bt_descrip, @_brick_sequence, @_brick_incl, @_brick_excl,
|
1435
1441
|
cols, poly_cols, bts, #{hms_keys.inspect}, {#{hms_columns.join(', ')}}) %>
|
@@ -1625,7 +1631,7 @@ end
|
|
1625
1631
|
if bt.length < 4
|
1626
1632
|
bt << (option_detail = [[\"(No #\{bt_name\} chosen)\", '^^^brick_NULL^^^']])
|
1627
1633
|
# %%% Accommodate composite keys for obj.pk at the end here
|
1628
|
-
collection, descrip_cols = bt_class&.order(obj_pk = bt_class.primary_key)
|
1634
|
+
collection, descrip_cols = bt_class&.order(obj_pk = bt_class.primary_key)&.brick_list
|
1629
1635
|
collection&.each do |obj|
|
1630
1636
|
option_detail << [
|
1631
1637
|
obj.brick_descrip(
|
@@ -36,9 +36,9 @@ module Brick::Rails::FormTags
|
|
36
36
|
end
|
37
37
|
sequence.reject! { |nm| exclusions.include?(nm) } if exclusions
|
38
38
|
out << sequence.each_with_object(+'') do |col_name, s|
|
39
|
+
s << '<th '
|
39
40
|
if (col = cols[col_name]).is_a?(ActiveRecord::ConnectionAdapters::Column)
|
40
|
-
s <<
|
41
|
-
s << "title=\"#{col.comment}\"" if col.respond_to?(:comment) && !col.comment.blank?
|
41
|
+
s << "title=\"#{col.comment}\" " if col.respond_to?(:comment) && !col.comment.blank?
|
42
42
|
s << if (bt = bts[col_name])
|
43
43
|
# Allow sorting for any BT except polymorphics
|
44
44
|
"x-order=\"#{bt.first.to_s + '"' unless bt[2]}>BT " +
|
@@ -49,18 +49,18 @@ module Brick::Rails::FormTags
|
|
49
49
|
elsif col # HM column
|
50
50
|
options = {}
|
51
51
|
options[col[1].inheritance_column] = col[1].name unless col[1] == col[1].base_class
|
52
|
-
s << "
|
52
|
+
s << "x-order=\"#{col_name + '"' if true}>#{col[2]} "
|
53
53
|
s << (col.first ? "#{col[3]}" : "#{link_to(col[3], send("#{col[1]._brick_index}_path", options))}")
|
54
54
|
elsif cust_cols.key?(col_name) # Custom column
|
55
|
-
s << "
|
55
|
+
s << "x-order=\"#{col_name}\">#{col_name}"
|
56
56
|
elsif col_name.is_a?(Symbol) && (hot = bts[col_name]) # has_one :through
|
57
|
-
s << "
|
57
|
+
s << "x-order=\"#{hot.first.to_s}\">HOT " +
|
58
58
|
hot[1].map { |hot_pair| hot_pair.first.bt_link(col_name) }.join(' ')
|
59
59
|
elsif (bt = composite_bt_names[col_name])
|
60
|
-
s << "
|
60
|
+
s << "x-order=\"#{bt.first.to_s + '"' unless bt[2]}>BT comp " +
|
61
61
|
bt[1].map { |bt_pair| bt_pair.first.bt_link(bt.first) }.join(' ')
|
62
62
|
else # Bad column name!
|
63
|
-
s << "
|
63
|
+
s << "title=\"<< Unknown column >>\">#{col_name}"
|
64
64
|
end
|
65
65
|
s << '</th>'
|
66
66
|
end
|
@@ -93,18 +93,20 @@ module Brick::Rails::FormTags
|
|
93
93
|
end
|
94
94
|
else # BT or HOT
|
95
95
|
bt_class = bt[1].first.first
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
96
|
+
if bt_descrip
|
97
|
+
descrips = bt_descrip[bt.first][bt_class]
|
98
|
+
bt_id_col = if descrips.nil?
|
99
|
+
puts "Caught it in the act for obj / #{col_name}!"
|
100
|
+
elsif descrips.length == 1
|
101
|
+
[obj.class.reflect_on_association(bt.first)&.foreign_key]
|
102
|
+
else
|
103
|
+
descrips.last
|
104
|
+
end
|
105
|
+
end
|
106
|
+
br_descrip_args = [obj]
|
107
|
+
# 0..62 because Postgres column names are limited to 63 characters
|
108
|
+
br_descrip_args += [descrips[0..-2].map { |id| obj.send(id.last[0..62]) }, bt_id_col] if descrips
|
109
|
+
bt_txt = bt_class.brick_descrip(*br_descrip_args)
|
108
110
|
bt_txt = ::Brick::Rails.display_binary(bt_txt).html_safe if bt_txt&.encoding&.name == 'ASCII-8BIT'
|
109
111
|
bt_txt ||= "<span class=\"orphan\"><< Orphaned ID: #{val} >></span>" if val
|
110
112
|
bt_id = bt_id_col&.map { |id_col| obj.respond_to?(id_sym = id_col.to_sym) ? obj.send(id_sym) : id_col }
|
@@ -128,13 +130,11 @@ module Brick::Rails::FormTags
|
|
128
130
|
end
|
129
131
|
out << link_to(ho_txt, send("#{hm_klass.base_class._brick_index(:singular)}_path".to_sym, ho_id))
|
130
132
|
end
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
send("#{hm_klass._brick_index}_path".to_sym, predicates))}\n"
|
137
|
-
end
|
133
|
+
elsif obj.respond_to?(ct_col = hms_col[1].to_sym) && (ct = obj.send(ct_col)&.to_i)&.positive?
|
134
|
+
predicates = hms_col[2].each_with_object({}) { |v, s| s[v.first] = v.last.is_a?(String) ? v.last : obj.send(v.last) }
|
135
|
+
predicates.each { |k, v| predicates[k] = obj.class.name if v == '[sti_type]' }
|
136
|
+
out << "#{link_to("#{ct || 'View'} #{hms_col.first}",
|
137
|
+
send("#{hm_klass._brick_index}_path".to_sym, predicates))}\n"
|
138
138
|
end
|
139
139
|
end
|
140
140
|
elsif (col = cols[col_name]).is_a?(ActiveRecord::ConnectionAdapters::Column)
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
@@ -163,6 +163,8 @@ module Brick
|
|
163
163
|
|
164
164
|
# All tables and views (what Postgres calls "relations" including column and foreign key info)
|
165
165
|
def relations
|
166
|
+
return {} if ::ActiveRecord::Base.connection_handler.connection_pool_list.blank?
|
167
|
+
|
166
168
|
# Key our list of relations for this connection off of the connection pool's object_id
|
167
169
|
(@relations ||= {})[ActiveRecord::Base.connection_pool.object_id] ||= Hash.new { |h, k| h[k] = Hash.new { |h, k| h[k] = {} } }
|
168
170
|
end
|
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.137
|
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-
|
11
|
+
date: 2023-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|