brick 1.0.113 → 1.0.114

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: f6cede45ed1fd983a2199fb279dffad0ecd02e51c7ed31cec6d46fccbc799e7c
4
- data.tar.gz: 65eb5df73a7869b1bbe3ac128a69b4fda257e9dc098e77dc65c75d8f593756d7
3
+ metadata.gz: 5006a6dabf5c9e86965e57a40ae344f9d67c2fc5e76caec8a00e978117089062
4
+ data.tar.gz: 5bd0fef75e305514b4ef22e4930660cdbf9385c22b07ee92d6eb77a626a13943
5
5
  SHA512:
6
- metadata.gz: 0e506c2b4d00a1402e232f48c9eb95fc1edfb201a4b2d46ce8fd2a29d0f6a62e5d954ba84dfad4ccab2ff2c5c972d32478873e1f5c7ddf19bdfcca24894b0d1e
7
- data.tar.gz: ee7dd85c423043b10efb60075716e3464db2645ac642fa43f457cf1b05c98a52cb7645e58e3a8208be8fd94b3a4b74f6b7d5e3102d890d087542a04b7e8cc7ec
6
+ metadata.gz: b0621761d15baec575a9cd16fdb1b22e9a1d4784308c071d9878121ac841f6cf7419cb6fbcc210afad2ce98a69814c27279dc951a5d84750e7573e203d2f806a
7
+ data.tar.gz: ed4b5c992076b4f28c85ab8af48bab847ab80105f2999371475529219cc6b0053444dc722a700d686fc7ed7ea39d3d939cb448c43d798bde18a0b5cfd80be23e
data/lib/brick/config.rb CHANGED
@@ -213,6 +213,14 @@ module Brick
213
213
  @mutex.synchronize { @polymorphics = polys }
214
214
  end
215
215
 
216
+ def json_columns
217
+ @mutex.synchronize { @json_columns ||= {} }
218
+ end
219
+
220
+ def json_columns=(cols)
221
+ @mutex.synchronize { @json_columns = cols }
222
+ end
223
+
216
224
  def model_descrips
217
225
  @mutex.synchronize { @model_descrips ||= {} }
218
226
  end
@@ -274,7 +274,7 @@ module ActiveRecord
274
274
  tbl_parts.unshift(::Brick.config.path_prefix) if ::Brick.config.path_prefix
275
275
  index = tbl_parts.map(&:underscore).join(separator)
276
276
  # Rails applies an _index suffix to that route when the resource name is singular
277
- index << '_index' if mode != :singular && index == index.singularize
277
+ index << '_index' if mode != :singular && separator == '_' && index == index.singularize
278
278
  index
279
279
  end
280
280
 
@@ -245,7 +245,7 @@ window.addEventListener(\"popstate\", linkSchemas);
245
245
  @_name = name || ''
246
246
  end
247
247
  def to_s
248
- @_name.html_safe + @vc.instance_variable_get(:@__vc_helpers)&.link_to_brick(nil,
248
+ @_name.to_s.html_safe + @vc.instance_variable_get(:@__vc_helpers)&.link_to_brick(nil,
249
249
  "<svg version=\"1.1\" style=\"display: inline; padding-left: 0.5em;\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"
250
250
  viewBox=\"0 0 58 58\" height=\"1.4em\" xml:space=\"preserve\">
251
251
  <g>
@@ -304,6 +304,26 @@ window.addEventListener(\"popstate\", linkSchemas);
304
304
  end
305
305
  end # Avo compatibility
306
306
 
307
+ # ActiveAdmin compatibility
308
+ if Object.const_defined?('ActiveAdmin') && ::ActiveAdmin.application&.site_title.present?
309
+ ::ActiveAdmin.class_exec do
310
+ class << self
311
+ ActiveAdmin.load!
312
+ alias _brick_routes routes
313
+ def routes(*args)
314
+ ::Brick.relations.each do |k, v|
315
+ next if k == 'active_admin_comments'
316
+
317
+ if (class_name = Object.const_get(v.fetch(:class_name, nil)))
318
+ ::ActiveAdmin.register(class_name) { config.clear_batch_actions! }
319
+ end
320
+ end
321
+ _brick_routes(*args)
322
+ end
323
+ end
324
+ end
325
+ end
326
+
307
327
  # ====================================
308
328
  # Dynamically create generic templates
309
329
  # ====================================
@@ -1365,7 +1385,7 @@ erDiagram
1365
1385
  <% end %>
1366
1386
  </table>
1367
1387
  <%
1368
- if (description = (relation = Brick.relations[#{model_name}.table_name])&.fetch(:description, nil)) %><%=
1388
+ if (description = (relation = Brick.relations[tbl_name = #{model_name}.table_name])&.fetch(:description, nil)) %><%=
1369
1389
  description %><br><%
1370
1390
  end
1371
1391
  %><%= link_to '(See all #{obj_name.pluralize})', #{@_brick_model._brick_index}_path %>
@@ -1437,7 +1457,13 @@ end
1437
1457
  \"<span class=\\\"orphan\\\">Orphaned ID: #\{val}</span>\".html_safe
1438
1458
  end %>
1439
1459
  <% else
1440
- col_type = col&.sql_type == 'geography' ? col.sql_type : col&.type
1460
+ col_type = if ::Brick.config.json_columns[tbl_name]&.include?(k)
1461
+ :json
1462
+ elsif col&.sql_type == 'geography'
1463
+ col.sql_type
1464
+ else
1465
+ col&.type
1466
+ end
1441
1467
  case (col_type ||= col&.sql_type)
1442
1468
  when :string, :text %>
1443
1469
  <% if is_bcrypt?(val) # || .readonly?
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 113
8
+ TINY = 114
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
@@ -458,6 +458,11 @@ module Brick
458
458
  Brick.config.polymorphics = polys || {}
459
459
  end
460
460
 
461
+ # @api public
462
+ def json_columns=(cols)
463
+ Brick.config.json_columns = cols
464
+ end
465
+
461
466
  # DSL templates for individual models to provide prettier descriptions of objects
462
467
  # @api public
463
468
  def model_descrips=(descrips)
@@ -529,7 +534,7 @@ module Brick
529
534
  You might be missing an STI namespace prefix entry for these tables: #{missing_stis.keys.join(', ')}.
530
535
  In config/initializers/brick.rb appropriate entries would look something like:
531
536
  Brick.sti_namespace_prefixes = {"
532
- puts missing_stis.map { |_k, missing_sti| "\n '::#{missing_sti}' => 'SomeParentModel'" }.join(',')
537
+ puts missing_stis.map { |_k, missing_sti| "\n '#{missing_sti}' => 'SomeParentModel'" }.join(',')
533
538
  puts " }
534
539
  (Just trade out SomeParentModel with some more appropriate one.)"
535
540
  end
@@ -859,6 +864,14 @@ In config/initializers/brick.rb appropriate entries would look something like:
859
864
  end
860
865
  end
861
866
  end
867
+
868
+ # Trestle compatibility
869
+ if Object.const_defined?('Trestle') && ::Trestle.config.options&.key?(:site_title) &&
870
+ !Object.const_defined?("#{resource_name.camelize}Admin")
871
+ ::Trestle.resource(res_sym = k.to_sym) do
872
+ menu { item res_sym, icon: "fa fa-star" }
873
+ end
874
+ end
862
875
  end
863
876
 
864
877
  if ::Brick.config.add_status && instance_variable_get(:@set).named_routes.names.exclude?(:brick_status)
@@ -261,6 +261,10 @@ if ActiveRecord::Base.respond_to?(:brick_select) && !::Brick.initializer_loaded
261
261
  # # Designated by <table name>.<column name>
262
262
  # Brick.not_nullables = ['users.name']
263
263
 
264
+ # # String or text columns which for editing purposes should be treated as JSON. Format for the hash is:
265
+ # # { table_name => [column names] }
266
+ # Brick.json_columns = { 'users' => ['info'] }
267
+
264
268
  # # FRIENDLY DSL
265
269
 
266
270
  # # A simple DSL is available to allow more user-friendly display of objects. Normally a user object might be shown
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.113
4
+ version: 1.0.114
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-02-17 00:00:00.000000000 Z
11
+ date: 2023-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord