brick 1.0.251 → 1.0.253

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f3523afa6d066b034bb48321fee476541b520db03a6414a6bbb3ce7eb6fef68
4
- data.tar.gz: 2a7db114267da1de863e4d225c09983585e04674a92c4d3c7d21c2eadf9ce1d8
3
+ metadata.gz: 23f8352ed61f4850362135926a1a1e407297021aefeef6eca84caa3cabe4b649
4
+ data.tar.gz: 5dc89b848cc8f7607d043d7ee5e7e4f2e320abfe1f0f7e046ca129f9458ba869
5
5
  SHA512:
6
- metadata.gz: ca9c7a8a90956bbfce0af44e21bace777bc988653173c854e59b783c05d7016ab0407015367ea7e5b075f6ab88416e3caf8825653f208d781c3ff86e82baf610
7
- data.tar.gz: c93ba7596bfe01d8850178a2334d952fff29e2e4b76e0d5db22a081a8d05151cd64287caa81769a6401fd8f31c3bd9fad6bd50ca4c2081fa245376ef0c591254
6
+ metadata.gz: 73220fc9aed649d42514715e8be0085a1e04639f33007e7b142adbed985c2b54bb4f99a232a26b9659d53702c957a7cf704af57c951d7a761d74033df9d2a89f
7
+ data.tar.gz: d794342f7836f29fdd0a1a8f79eb9f5c7cac40a252c7d3654fd712723a1a8fc3df08bb25864377d35755cc65a9b1d777eb86f1312f63a121314cf62033df8f85
@@ -490,7 +490,7 @@ module ActiveRecord
490
490
  end
491
491
 
492
492
  def _brick_find_permits(current_permits, is_for_expects = nil, done_models = [])
493
- return current_permits if done_models.any? { |dp| self <= dp }
493
+ return current_permits if done_models.include?(self)
494
494
 
495
495
  done_models << self
496
496
  self.reflect_on_all_associations.select { |assoc| !assoc.belongs_to? }.each do |assoc|
@@ -2817,7 +2817,7 @@ class Object
2817
2817
  # %%% does this work with STI?
2818
2818
  all_params = params[real_singular_table_name]
2819
2819
  hma.each do |hma_field|
2820
- if upd_hash.fetch(hma_field) == [''] && # No new attachments...
2820
+ if upd_hash.fetch(hma_field, nil) == [''] && # No new attachments...
2821
2821
  all_params&.fetch("_brick_attached_#{hma_field}", nil) # ...and there is something existing
2822
2822
  upd_hash.delete(hma_field)
2823
2823
  end
@@ -1041,7 +1041,7 @@ if (window.brickFontFamily) {
1041
1041
  });
1042
1042
  }
1043
1043
  </script>
1044
- <script src=\"https://apis.google.com/js/api.js\"></script>
1044
+ <script async defer src=\"https://apis.google.com/js/api.js\"></script>
1045
1045
  <script async defer src=\"https://accounts.google.com/gsi/client\" id=\"gapiScript\"></script>
1046
1046
  <script<%= @_request.env['_brick_nonce'] %>>
1047
1047
  document.getElementById(\"gapiScript\").addEventListener(\"onload\",
@@ -1103,6 +1103,59 @@ if (window.brickFontFamily) {
1103
1103
  end
1104
1104
  \"<tr><td colspan=\\\"#\{td_count}\\\">Parent: #\{parent_links.join(' ')}</tr>\".html_safe
1105
1105
  end
1106
+ %><%
1107
+ # Consider getting the name from the association -- hm.first.name -- if a more \"friendly\" alias should be used for a screwy table name
1108
+ # If the resource is missing, has the user simply created an inappropriately pluralised name for a table?
1109
+ @#{res_name} ||= if (dym_list = instance_variables.reject do |entry|
1110
+ entry.to_s.start_with?('@_') ||
1111
+ ['@cache_hit', '@marked_for_same_origin_verification', '@view_renderer', '@view_flow', '@output_buffer', '@virtual_path'].include?(entry.to_s)
1112
+ end).present?
1113
+ msg = +\"Can't find resource \\\"#{res_name}\\\".\"
1114
+ # Can't be sure otherwise of what is up, so check DidYouMean and offer a suggestion.
1115
+ if (dym = DidYouMean::SpellChecker.new(dictionary: dym_list).correct('@#{res_name}')).present?
1116
+ msg << \"\nIf you meant \\\"#\{found_dym = dym.first[1..-1]}\\\" then to avoid this message add this entry into inflections.rb:\n\"
1117
+ msg << \" inflect.irregular '#{obj_name}', '#\{found_dym}'\"
1118
+ puts
1119
+ puts \"WARNING: #\{msg}\"
1120
+ puts
1121
+ @#{res_name} = instance_variable_get(dym.first.to_sym)
1122
+ else
1123
+ raise ActiveRecord::RecordNotFound.new(msg)
1124
+ end
1125
+ end
1126
+
1127
+ # Starts as being just has_many columns, and will be augmented later with all the other columns
1128
+ cols = {#{hms_keys = []
1129
+ hms_headers.map do |hm|
1130
+ hms_keys << (assoc_name = (assoc = hm.first).name.to_s)
1131
+ "#{assoc_name.inspect} => [#{(assoc.options[:through] && !assoc.through_reflection).inspect}, #{assoc.klass.name}, #{hm[1].inspect}, #{hm[2].inspect}]"
1132
+ end.join(', ')}}
1133
+
1134
+ # %%% Why in the Canvas LMS app does ActionView::Helpers get cleared / reloaded, or otherwise lose access to #brick_grid ???
1135
+ # Possible fix if somewhere we can implement the #include with:
1136
+ # (ActiveSupport.const_defined?('Reloader') ? ActiveSupport : ActionDispatch)::Reloader.to_prepare do ... end
1137
+ # or
1138
+ # Rails.application.reloader.to_prepare do ... end
1139
+ self.class.class_exec { include ::Brick::Rails::FormTags } unless respond_to?(:brick_grid)
1140
+
1141
+ # Prepare the main content now so that we have a chance to become aware of any STI child classes represented in the rows returned.
1142
+ main_content = #{
1143
+ # Determine if we should render an N:M representation or the standard "mega_grid"
1144
+ taa = ::Brick.config.treat_as_associative&.fetch(table_name, nil)
1145
+ options = {}
1146
+ options[:prefix] = prefix unless prefix.blank?
1147
+ if taa.is_a?(String) || # Write out a constellation
1148
+ (taa.is_a?(Array) && (options[:axes] = taa[0..-2]) && (options[:dsl] = taa.last))
1149
+ representation = :constellation
1150
+ "brick_constellation(@#{res_name}, #{options.inspect}, bt_descrip: @_brick_bt_descrip, bts: bts)"
1151
+ elsif taa.is_a?(Symbol) # Write out a bezier representation
1152
+ "brick_bezier(@#{res_name}, #{options.inspect}, bt_descrip: @_brick_bt_descrip, bts: bts)"
1153
+ else # Write out the mega-grid
1154
+ representation = :grid
1155
+ "brick_grid(@#{res_name}, @_brick_sequence, @_brick_incl, @_brick_excl,
1156
+ cols, bt_descrip: @_brick_bt_descrip,
1157
+ poly_cols: poly_cols, bts: bts, hms_keys: #{hms_keys.inspect}, hms_cols: {#{hms_columns.join(', ')}})"
1158
+ end}
1106
1159
  %><%= if (children = model.descendants).present?
1107
1160
  child_links = children.map do |child|
1108
1161
  path = send(\"#\{child._brick_index}_path\") + \"?__#\{base_model.inheritance_column}=#\{child.name}\"
@@ -1214,60 +1267,7 @@ end
1214
1267
  </div></div>
1215
1268
  #{::Brick::Rails.erd_markup(@_brick_model, prefix) if @_brick_model}
1216
1269
 
1217
- <%=# Consider getting the name from the association -- hm.first.name -- if a more \"friendly\" alias should be used for a screwy table name
1218
- # If the resource is missing, has the user simply created an inappropriately pluralised name for a table?
1219
- @#{res_name} ||= if (dym_list = instance_variables.reject do |entry|
1220
- entry.to_s.start_with?('@_') ||
1221
- ['@cache_hit', '@marked_for_same_origin_verification', '@view_renderer', '@view_flow', '@output_buffer', '@virtual_path'].include?(entry.to_s)
1222
- end).present?
1223
- msg = +\"Can't find resource \\\"#{res_name}\\\".\"
1224
- # Can't be sure otherwise of what is up, so check DidYouMean and offer a suggestion.
1225
- if (dym = DidYouMean::SpellChecker.new(dictionary: dym_list).correct('@#{res_name}')).present?
1226
- msg << \"\nIf you meant \\\"#\{found_dym = dym.first[1..-1]}\\\" then to avoid this message add this entry into inflections.rb:\n\"
1227
- msg << \" inflect.irregular '#{obj_name}', '#\{found_dym}'\"
1228
- puts
1229
- puts \"WARNING: #\{msg}\"
1230
- puts
1231
- @#{res_name} = instance_variable_get(dym.first.to_sym)
1232
- else
1233
- raise ActiveRecord::RecordNotFound.new(msg)
1234
- end
1235
- end
1236
-
1237
- # Starts as being just has_many columns, and will be augmented later with all the other columns
1238
- cols = {#{hms_keys = []
1239
- hms_headers.map do |hm|
1240
- hms_keys << (assoc_name = (assoc = hm.first).name.to_s)
1241
- "#{assoc_name.inspect} => [#{(assoc.options[:through] && !assoc.through_reflection).inspect}, #{assoc.klass.name}, #{hm[1].inspect}, #{hm[2].inspect}]"
1242
- end.join(', ')}}
1243
-
1244
- # %%% Why in the Canvas LMS app does ActionView::Helpers get cleared / reloaded, or otherwise lose access to #brick_grid ???
1245
- # Possible fix if somewhere we can implement the #include with:
1246
- # (ActiveSupport.const_defined?('Reloader') ? ActiveSupport : ActionDispatch)::Reloader.to_prepare do ... end
1247
- # or
1248
- # Rails.application.reloader.to_prepare do ... end
1249
- self.class.class_exec { include ::Brick::Rails::FormTags } unless respond_to?(:brick_grid)
1250
-
1251
- #{# Determine if we should render an N:M representation or the standard "mega_grid"
1252
- taa = ::Brick.config.treat_as_associative&.fetch(table_name, nil)
1253
- options = {}
1254
- options[:prefix] = prefix unless prefix.blank?
1255
- if taa.is_a?(String) || # Write out a constellation
1256
- (taa.is_a?(Array) && (options[:axes] = taa[0..-2]) && (options[:dsl] = taa.last))
1257
- representation = :constellation
1258
- "
1259
- brick_constellation(@#{res_name}, #{options.inspect}, bt_descrip: @_brick_bt_descrip, bts: bts)"
1260
- elsif taa.is_a?(Symbol) # Write out a bezier representation
1261
- "
1262
- brick_bezier(@#{res_name}, #{options.inspect}, bt_descrip: @_brick_bt_descrip, bts: bts)"
1263
- else # Write out the mega-grid
1264
- representation = :grid
1265
- "
1266
- brick_grid(@#{res_name}, @_brick_sequence, @_brick_incl, @_brick_excl,
1267
- cols, bt_descrip: @_brick_bt_descrip,
1268
- poly_cols: poly_cols, bts: bts, hms_keys: #{hms_keys.inspect}, hms_cols: {#{hms_columns.join(', ')}})"
1269
- end}
1270
- %>
1270
+ <%= main_content %>
1271
1271
 
1272
1272
  #{"<hr><%= link_to_brick(model, new: true, class: '__brick') %>" unless @_brick_model.is_view?}
1273
1273
  #{script}
@@ -1397,6 +1397,7 @@ s << \"\\n <br>\\n\"
1397
1397
  end
1398
1398
 
1399
1399
  when 'show', 'new', 'update'
1400
+ representation = :show
1400
1401
  +"<html>
1401
1402
  <head>
1402
1403
  #{css}
@@ -1709,7 +1710,8 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
1709
1710
  <% end %>
1710
1711
  "
1711
1712
  end
1712
- if representation == :grid
1713
+ case representation
1714
+ when :grid
1713
1715
  inline << "<script<%= @_request.env['_brick_nonce'] %>>
1714
1716
  <%# Make column headers sort when clicked
1715
1717
  # %%% Create a smart javascript routine which can do this client-side %>
@@ -1724,6 +1726,9 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
1724
1726
  }
1725
1727
  });
1726
1728
  });
1729
+ </script>"
1730
+ when :show
1731
+ inline << "<script<%= @_request.env['_brick_nonce'] %>>
1727
1732
  document.querySelectorAll(\"input, select\").forEach(function (inp) {
1728
1733
  var origVal = getInpVal(),
1729
1734
  prevVal = origVal;
@@ -58,6 +58,7 @@ module Brick::Rails::FormTags
58
58
  s << if (bt = bts[col_name])
59
59
  # Allow sorting for any BT except polymorphics
60
60
  x_order = " x-order=\"#{bt.first}\"" unless bt[2]
61
+ # binding.pry
61
62
  "#{x_order}>BT #{bt[1].map { |bt_pair| bt_pair.first.bt_link(bt.first) }.join(' ')}"
62
63
  else # Normal column
63
64
  col_name_humanised = klass.human_attribute_name(col_name, { default: col_name })
data/lib/brick/rails.rb CHANGED
@@ -27,7 +27,7 @@ module ::Brick::Rails
27
27
  (val && ::Brick.is_geography?(val))
28
28
  )
29
29
  )
30
- # MySQL's \"Internal Geometry Format\" and MSSQL's Geography are like WKB, but with an initial 4 bytes that indicates the SRID.
30
+ # MySQL's "Internal Geometry Format" and MSSQL's Geography are like WKB, but with an initial 4 bytes that indicates the SRID.
31
31
  if (srid = val&.[](0..3)&.unpack('I'))
32
32
  val = val.dup.force_encoding('BINARY')[4..-1].bytes
33
33
 
@@ -109,7 +109,7 @@ module ::Brick::Rails
109
109
  if ((signature = @image_signatures.find { |k, _v| val[0...k.length] == k }&.last) ||
110
110
  (val[0..3] == 'RIFF' && val[8..11] == 'WEBP' && binding.local_variable_set(:signature, 'webp'))) &&
111
111
  val.length < max_size
112
- "<img src=\"data:image/#{signature.last};base64,#{Base64.encode64(val)}\">"
112
+ "<img src=\"data:image/#{signature};base64,#{Base64.encode64(val)}\">"
113
113
  else
114
114
  descrip = "#{signature ? "#{signature} image" : 'Binary'}, #{val.length} bytes"
115
115
  no_escaped_html ? "< #{descrip} >" : "&lt;&nbsp;#{descrip}&nbsp;>"
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 251
8
+ TINY = 253
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.251
4
+ version: 1.0.253
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits