brick 1.0.179 → 1.0.181

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54b14ce2c9b998599c3fd529f0a718a85365c49f7405a97e698155e2b9cf22be
4
- data.tar.gz: e1337a86afb957dc8a5545090dc667534bbf792266e82f4654a55611b92b7e18
3
+ metadata.gz: 322ed139c5ec7c48572ab2ea87830998fe742c32ac56e91d2eed97084f7d8c42
4
+ data.tar.gz: 836c21610811fb2322bdfd572d2b1ccce0a23464bf54512ae160149a6bfdb972
5
5
  SHA512:
6
- metadata.gz: c0bee060354c43c662e41e247957f896d7680af9b11cd4109e4ad32ef4b5b8bf907f64d2ed66d32bb59522addb540d1dc3a9e4812f2fdfc1dd6eb6a4da6e516a
7
- data.tar.gz: a44dc906d317e74100463a1ffb18935e91ee7a818727131fa4813f5329cbc0db07f7995d08246d32052239d4a6bae15db8db4de51cfcdb0c3d250b08e341d4ee
6
+ metadata.gz: 034b252fc08bc09216a33d8cd34a97c4afa81a86943d319e0bccd26a387060d69a3d1e0b80de2ba29e9f57c06e7eff3b41cbdfa92354f8a754e350b0ab8daacf
7
+ data.tar.gz: 0ba1422cb56af76c4e0eb89de5fd940a90dcfb93fd90016852cb9631d71542825dea0187fd44ac66fa65a79905583b9dec92b3615b67db1f16d4ad5e5357f1ac
@@ -115,14 +115,30 @@ if Object.const_defined?('ActionPack') && !ActionPack.respond_to?(:version)
115
115
  end
116
116
  end
117
117
  end
118
- if Bundler.locked_gems&.dependencies.key?('action_view')
118
+ if Object.const_defined?('Bundler') && Bundler.locked_gems&.dependencies.key?('action_view')
119
119
  require 'action_view' # Needed for Rails <= 4.0
120
- if Object.const_defined?('ActionView') && !ActionView.respond_to?(:version)
121
- module ActionView
120
+ module ::ActionView
121
+ if Object.const_defined?('ActionView') && !ActionView.respond_to?(:version)
122
122
  def self.version
123
123
  ActionPack.version
124
124
  end
125
125
  end
126
+ if self.version < ::Gem::Version.new('5.2')
127
+ module Helpers
128
+ module TextHelper
129
+ # Older versions of #pluralize lack the all-important .to_s
130
+ def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)
131
+ word = if (count == 1 || count.to_s =~ /^1(\.0+)?$/)
132
+ singular
133
+ else
134
+ plural || singular.pluralize(locale)
135
+ end
136
+
137
+ "#{count || 0} #{word}"
138
+ end
139
+ end
140
+ end
141
+ end
126
142
  end
127
143
  end
128
144
 
@@ -1189,7 +1189,7 @@ if Object.const_defined?('ActionView')
1189
1189
  # not let Brick have any fun. So just call this right before any wildcard routes, and
1190
1190
  # you'll be in business!
1191
1191
  def mount_brick_routes
1192
- add_brick_routes unless ::Brick.routes_done
1192
+ add_brick_routes if !::Brick.routes_done && respond_to?(:add_brick_routes)
1193
1193
  end
1194
1194
  end
1195
1195
  end
@@ -1404,12 +1404,6 @@ end
1404
1404
  #{erd_markup}
1405
1405
 
1406
1406
  <%= # Consider getting the name from the association -- hm.first.name -- if a more \"friendly\" alias should be used for a screwy table name
1407
- cols = {#{hms_keys = []
1408
- hms_headers.map do |hm|
1409
- hms_keys << (assoc_name = (assoc = hm.first).name.to_s)
1410
- "#{assoc_name.inspect} => [#{(assoc.options[:through] && !assoc.through_reflection).inspect}, #{assoc.klass.name}, #{hm[1].inspect}, #{hm[2].inspect}]"
1411
- end.join(', ')}}
1412
-
1413
1407
  # If the resource is missing, has the user simply created an inappropriately pluralised name for a table?
1414
1408
  @#{table_name} ||= if (dym_list = instance_variables.reject do |entry|
1415
1409
  entry.to_s.start_with?('@_') ||
@@ -1429,6 +1423,13 @@ end
1429
1423
  end
1430
1424
  end
1431
1425
 
1426
+ # Starts as being just has_many columns, and will be augmented later with all the other columns
1427
+ cols = {#{hms_keys = []
1428
+ hms_headers.map do |hm|
1429
+ hms_keys << (assoc_name = (assoc = hm.first).name.to_s)
1430
+ "#{assoc_name.inspect} => [#{(assoc.options[:through] && !assoc.through_reflection).inspect}, #{assoc.klass.name}, #{hm[1].inspect}, #{hm[2].inspect}]"
1431
+ end.join(', ')}}
1432
+
1432
1433
  # %%% Why in the Canvas LMS app does ActionView::Helpers get cleared / reloaded, or otherwise lose access to #brick_grid ???
1433
1434
  # Possible fix if somewhere we can implement the #include with:
1434
1435
  # (ActiveSupport.const_defined?('Reloader') ? ActiveSupport : ActionDispatch)::Reloader.to_prepare do ... end
@@ -1436,8 +1437,8 @@ end
1436
1437
  # Rails.application.reloader.to_prepare do ... end
1437
1438
  self.class.class_exec { include ::Brick::Rails::FormTags } unless respond_to?(:brick_grid)
1438
1439
  # Write out the mega-grid
1439
- brick_grid(@#{table_name}, @_brick_bt_descrip, @_brick_sequence, @_brick_incl, @_brick_excl,
1440
- cols, poly_cols, bts, #{hms_keys.inspect}, {#{hms_columns.join(', ')}}) %>
1440
+ brick_grid(@#{table_name}, @_brick_sequence, @_brick_incl, @_brick_excl,
1441
+ cols, bt_descrip: @_brick_bt_descrip, poly_cols: poly_cols, bts: bts, hms_keys: #{hms_keys.inspect}, hms_cols: {#{hms_columns.join(', ')}}) %>
1441
1442
 
1442
1443
  #{"<hr><%= link_to(\"New #{new_path_name = "new_#{path_obj_name}_path"
1443
1444
  obj_name}\", #{new_path_name}, { class: '__brick' }) if respond_to?(:#{new_path_name}) %>" unless @_brick_model.is_view?}
@@ -1803,7 +1804,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
1803
1804
  gErd.addEventListener(\"click\",
1804
1805
  function (evt) {
1805
1806
  location.href = changeout(changeout(
1806
- changeout(location.href, '_brick_order', null), // Remove any ordering
1807
+ changeout(location.href, \"_brick_order\", null), // Remove any ordering
1807
1808
  -1, cbs[this.id].replace(/^[\/]+/, \"\")), \"_brick_erd\", \"1\");
1808
1809
  }
1809
1810
  );
@@ -1811,6 +1812,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
1811
1812
  }}
1812
1813
  });
1813
1814
  mermaid.contentLoaded();
1815
+ window.history.replaceState({}, \"\", changeout(location.href, \"_brick_erd\", \"1\"));
1814
1816
  // Add <span> at the end
1815
1817
  var span = document.createElement(\"SPAN\");
1816
1818
  span.className = \"exclude\";
@@ -1819,7 +1821,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
1819
1821
  e.stopPropagation();
1820
1822
  imgErd.style.display = \"table-cell\";
1821
1823
  mermaidErd.style.display = \"none\";
1822
- window.history.pushState({}, '', changeout(location.href, '_brick_erd', null));
1824
+ window.history.replaceState({}, \"\", changeout(location.href, \"_brick_erd\", null));
1823
1825
  });
1824
1826
  mermaidErd.appendChild(span);
1825
1827
  }
@@ -1,7 +1,7 @@
1
1
  module Brick::Rails::FormTags
2
2
  # Our super speedy grid
3
- def brick_grid(relation = nil, bt_descrip = nil, sequence = nil, inclusions = nil, exclusions = nil,
4
- cols = {}, poly_cols = nil, bts = {}, hms_keys = [], hms_cols = {},
3
+ def brick_grid(relation = nil, sequence = nil, inclusions = nil, exclusions = nil,
4
+ cols = {}, bt_descrip: nil, poly_cols: nil, bts: {}, hms_keys: [], hms_cols: {},
5
5
  show_header: nil, show_row_count: nil, show_erd_button: nil, show_new_button: nil, show_avo_button: nil, show_aa_button: nil)
6
6
  # When a relation is not provided, first see if one exists which matches the controller name
7
7
  unless (relation ||= instance_variable_get("@#{controller_name}".to_sym))
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 179
8
+ TINY = 181
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
data/lib/brick.rb CHANGED
@@ -910,7 +910,7 @@ In config/initializers/brick.rb appropriate entries would look something like:
910
910
 
911
911
  object_name = k.split('.').last # Take off any first schema part
912
912
 
913
- full_schema_prefix = if (aps = v.fetch(:auto_prefixed_schema, nil))
913
+ full_schema_prefix = if (full_aps = aps = v.fetch(:auto_prefixed_schema, nil))
914
914
  aps = aps[0..-2] if aps[-1] == '_'
915
915
  (schema_prefix&.dup || +'') << "#{aps}."
916
916
  else
@@ -925,7 +925,7 @@ In config/initializers/brick.rb appropriate entries would look something like:
925
925
  else
926
926
  table_class_length = class_name.length if class_name.length > table_class_length
927
927
  tables
928
- end << [class_name, aps, k.tr('.', '/')]
928
+ end << [class_name, aps, k.tr('.', '/')[full_aps&.length || 0 .. -1]]
929
929
  end
930
930
 
931
931
  options = {}
@@ -1544,7 +1544,7 @@ ActiveSupport.on_load(:active_record) do
1544
1544
  else
1545
1545
  {}
1546
1546
  end
1547
- _original_initialize(klass, **kwargs)
1547
+ _original_initialize(klass, *args, **kwargs)
1548
1548
  end
1549
1549
  end
1550
1550
  end
@@ -2036,11 +2036,13 @@ if ActiveRecord.version < ::Gem::Version.new('6.0') && ruby_version >= ::Gem::Ve
2036
2036
  end
2037
2037
 
2038
2038
  # AR >= 5.0 on Ruby >= 3.0
2039
- ::ActiveRecord::Type::AdapterSpecificRegistry.class_exec do
2040
- alias :_brick_add_modifier :add_modifier
2041
- def add_modifier(*args, **kwargs)
2042
- kwargs.merge!(args.pop) if args.length > 2 && args.last.is_a?(Hash)
2043
- _brick_add_modifier(*args, **kwargs)
2039
+ if ActiveRecord.version >= ::Gem::Version.new('5.0')
2040
+ ::ActiveRecord::Type::AdapterSpecificRegistry.class_exec do
2041
+ alias :_brick_add_modifier :add_modifier
2042
+ def add_modifier(*args, **kwargs)
2043
+ kwargs.merge!(args.pop) if args.length > 2 && args.last.is_a?(Hash)
2044
+ _brick_add_modifier(*args, **kwargs)
2045
+ end
2044
2046
  end
2045
2047
  end
2046
2048
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'brick'
3
4
  require 'rails/generators'
4
5
  # require 'rails/generators/active_record'
5
6
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'brick'
3
4
  require 'rails/generators'
4
5
  require 'rails/generators/active_record'
5
6
  require 'fancy_gets'
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'brick'
3
4
  require 'rails/generators'
4
5
  require 'rails/generators/active_record'
5
6
  require 'fancy_gets'
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'brick'
3
4
  require 'rails/generators'
4
5
  require 'fancy_gets'
5
6
 
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.179
4
+ version: 1.0.181
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-10-07 00:00:00.000000000 Z
11
+ date: 2023-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord