brick 1.0.66 → 1.0.67

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: c7e8235e9e499424e41a8329f9056b4ab801fd7502889dfdafc527522f061ad3
4
- data.tar.gz: 898b3f172cb9eb6594b382087394857d7ff471a833069bfe7e060f404bfd2d4c
3
+ metadata.gz: 60ed6bcfecfc09b579a605a6141e06b958d0e274c010432be8b97980833be6fc
4
+ data.tar.gz: 4ce18cf47d569f61e58cf25d3bd26577fea4932e7171cbcf5cb7756f9d4a8cc5
5
5
  SHA512:
6
- metadata.gz: 0d0b88ac19a60e25ee48074e5ee67037c41d77b80a54ea22ad1813d22d4e3d233d253ed92a39e317f3faa86aac290ee51e0bed7ab178c583ca1d06b075bfaac1
7
- data.tar.gz: a0d8f7683236868789c9262a08a8c615786afdd6ad93b1f330807d5acad5962ea2e2ea645a236e37926b42bfd09db00ec9d00fae15de90da8fe589bfbe493b65
6
+ metadata.gz: 7691f14a41dad2cea3fcc73f60fc88a57e24ecd8ab1d69575be6b716e43f9ae15eddc6e0e1bd089ba8b3daf7cef2e78ecdaf12a0a86e249ec8f609d00b0a473d
7
+ data.tar.gz: 237aa7e873db35c6dad6c89c3641c7b9d81016520ddbbc0d1ddfc94576e067adc162c3e8a5f15c983df624e4e3d185d1e1e695a505f7b3a66bda6dd036d91e8c
@@ -657,9 +657,12 @@ Module.class_exec do
657
657
  full_class_name = +''
658
658
  full_class_name << "::#{self.name}" unless self == Object
659
659
  full_class_name << "::#{plural_class_name.underscore.singularize.camelize}"
660
- if (plural_class_name == 'BrickSwagger' ||
661
- ((::Brick.config.add_status || ::Brick.config.add_orphans) && plural_class_name == 'BrickGem') ||
662
- model = self.const_get(full_class_name))
660
+ if plural_class_name == 'BrickSwagger' ||
661
+ (
662
+ (::Brick.config.add_status || ::Brick.config.add_orphans) &&
663
+ plural_class_name == 'BrickGem'
664
+ ) ||
665
+ model = self.const_get(full_class_name)
663
666
  # if it's a controller and no match or a model doesn't really use the same table name, eager load all models and try to find a model class of the right name.
664
667
  Object.send(:build_controller, self, class_name, plural_class_name, model, relations)
665
668
  end
@@ -1033,7 +1036,7 @@ class Object
1033
1036
  self.define_method :orphans do
1034
1037
  instance_variable_set(:@orphans, ::Brick.find_orphans(::Brick.set_db_schema(params)))
1035
1038
  end
1036
- return [new_controller_class, code + ' # BrickGem controller']
1039
+ return [new_controller_class, code + "end # BrickGem controller\n"]
1037
1040
  when 'BrickSwagger'
1038
1041
  is_swagger = true # if request.format == :json)
1039
1042
  end
@@ -1193,6 +1196,8 @@ class Object
1193
1196
  else
1194
1197
  instance_variable_set("@#{singular_table_name}".to_sym,
1195
1198
  model.send(:create, send(params_name_sym)))
1199
+ index
1200
+ render :index
1196
1201
  end
1197
1202
  end
1198
1203
 
@@ -96,12 +96,13 @@ module Brick
96
96
 
97
97
  alias :_brick_find_template :find_template
98
98
  def find_template(*args, **options)
99
- unless (model_name = (
99
+ unless (is_status = ::Brick.config.add_status && args[0..1] == ['status', ['brick_gem']]) ||
100
+ (is_orphans = ::Brick.config.add_orphans && args[0..1] == ['orphans', ['brick_gem']]) ||
101
+ (model_name = (
100
102
  @_brick_model ||
101
- (ActionView.version < ::Gem::Version.new('5.0') && args[1].is_a?(Array) ? set_brick_model(args) : nil)
102
- )&.name) ||
103
- (is_status = ::Brick.config.add_status && args[0..1] == ['status', ['brick_gem']]) ||
104
- (is_orphans = ::Brick.config.add_orphans && args[0..1] == ['orphans', ['brick_gem']])
103
+ # Used to also have: ActionView.version < ::Gem::Version.new('5.0') &&
104
+ (args[1].is_a?(Array) ? set_brick_model(args) : nil)
105
+ )&.name)
105
106
  return _brick_find_template(*args, **options)
106
107
  end
107
108
 
@@ -156,7 +157,7 @@ module Brick
156
157
  end
157
158
  hm_entry << ']'
158
159
  hms_columns << hm_entry
159
- when 'show', 'update'
160
+ when 'show', 'new', 'update'
160
161
  hm_stuff << if hm_fk_name
161
162
  "<%= link_to '#{assoc_name}', #{hm_assoc.klass.name.underscore.tr('/', '_').pluralize}_path({ #{path_keys(hm_assoc, hm_fk_name, "@#{obj_name}", pk)} }) %>\n"
162
163
  else # %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
@@ -179,6 +180,7 @@ module Brick
179
180
  end.keys.sort.each_with_object(+'') do |v, s|
180
181
  s << "<option value=\"#{v.underscore.gsub('.', '/').pluralize}\">#{v}</option>"
181
182
  end.html_safe
183
+ table_options << '<option value="brick_status">(Status)</option>'.html_safe
182
184
  table_options << '<option value="brick_orphans">(Orphans)</option>'.html_safe if is_orphans
183
185
  css = +"<style>
184
186
  h1, h3 {
@@ -379,9 +381,10 @@ def display_value(col_type, val)
379
381
  '?'
380
382
  end
381
383
  end
382
- end %>"
384
+ end
385
+ callbacks = {} %>"
383
386
 
384
- if ['index', 'show', 'update'].include?(args.first)
387
+ if ['index', 'show', 'new', 'update'].include?(args.first)
385
388
  poly_cols = []
386
389
  css << "<% bts = { #{
387
390
  bt_items = bts.each_with_object([]) do |v, s|
@@ -537,10 +540,10 @@ if (headerTop) {
537
540
  }
538
541
  </script>"
539
542
 
540
- erd_markup = "<div id=\"mermaidErd\" class=\"mermaid\">
543
+ erd_markup = if @_brick_model
544
+ "<div id=\"mermaidErd\" class=\"mermaid\">
541
545
  erDiagram
542
546
  <% model_short_name = #{@_brick_model.name.split('::').last.inspect}
543
- callbacks = {}
544
547
  @_brick_bt_descrip&.each do |bt|
545
548
  bt_class = bt[1].first.first
546
549
  callbacks[bt_name = bt_class.name.split('::').last] = bt_class
@@ -595,6 +598,7 @@ erDiagram
595
598
  %>
596
599
  </div>
597
600
  "
601
+ end
598
602
  inline = case args.first
599
603
  when 'index'
600
604
  obj_pk = if pk&.is_a?(Array) # Composite primary key?
@@ -890,7 +894,7 @@ erDiagram
890
894
  #{script}"
891
895
  end
892
896
 
893
- when 'show', 'update'
897
+ when 'show', 'new', 'update'
894
898
  +"#{css}
895
899
 
896
900
  <svg id=\"revertTemplate\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 66
8
+ TINY = 67
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
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.66
4
+ version: 1.0.67
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-08-29 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord