brick 1.0.117 → 1.0.119
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 +12 -10
- data/lib/brick/frameworks/rails/engine.rb +103 -30
- data/lib/brick/version_number.rb +1 -1
- 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: 6dfec2ebe501c46c17a7466bd98a9fb510ce6676f74c9b914da52e789e279036
|
4
|
+
data.tar.gz: 803598a5b59f73e81ed94079dd2b7dd55328c5c12de6d6968937b6518b68cef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1618ef1ff14f0198d45aa0aafc5ee9e0272c82a886b0129e14cfe6c47fea1cbb55c76f32cf2a98eb93915c68a62275ad53e5ab32621da45b9a7397e2d1f95f3f
|
7
|
+
data.tar.gz: f34063a9ebc164bf352d96b1149f1ed501a351c3e786219a29593be13359162c9bb140cf822d9ce1494be9ea43b655afb0422008d6fcc64f59ee7050a1e84072
|
data/lib/brick/extensions.rb
CHANGED
@@ -279,7 +279,7 @@ module ActiveRecord
|
|
279
279
|
end
|
280
280
|
|
281
281
|
def self.brick_import_template
|
282
|
-
template = constants.include?(:IMPORT_TEMPLATE) ? self::IMPORT_TEMPLATE : suggest_template(
|
282
|
+
template = constants.include?(:IMPORT_TEMPLATE) ? self::IMPORT_TEMPLATE : suggest_template(0, false, true)
|
283
283
|
# Add the primary key to the template as being unique (unless it's already there)
|
284
284
|
template[:uniques] = [pk = primary_key.to_sym]
|
285
285
|
template[:all].unshift(pk) unless template[:all].include?(pk)
|
@@ -1034,18 +1034,19 @@ Module.class_exec do
|
|
1034
1034
|
|
1035
1035
|
# AVO Resource
|
1036
1036
|
elsif base_module == Object && Object.const_defined?('Avo') && requested.end_with?('Resource') &&
|
1037
|
-
|
1038
|
-
|
1037
|
+
# Expect that anything called MotorResource or SpinaResource could be from those administrative gems
|
1038
|
+
requested.length > 8 && ['MotorResource', 'SpinaResource'].exclude?(requested)
|
1039
|
+
if (model = Object.const_get(requested[0..-9])) && model < ActiveRecord::Base
|
1039
1040
|
require 'generators/avo/resource_generator'
|
1040
1041
|
field_generator = Generators::Avo::ResourceGenerator.new([''])
|
1041
1042
|
field_generator.instance_variable_set(:@model, model)
|
1042
|
-
fields = field_generator.send(:generate_fields)
|
1043
|
-
|
1043
|
+
fields = field_generator.send(:generate_fields)&.split("\n")
|
1044
|
+
&.each_with_object([]) do |f, s|
|
1044
1045
|
if (f = f.strip).start_with?('field ')
|
1045
1046
|
f = f[6..-1].split(',')
|
1046
1047
|
s << [f.first[1..-1].to_sym, [f[1][1..-1].split(': :').map(&:to_sym)].to_h]
|
1047
1048
|
end
|
1048
|
-
end
|
1049
|
+
end || []
|
1049
1050
|
built_resource = Class.new(Avo::BaseResource) do |new_resource_class|
|
1050
1051
|
self.model_class = model
|
1051
1052
|
self.title = :brick_descrip
|
@@ -1845,11 +1846,12 @@ class Object
|
|
1845
1846
|
|
1846
1847
|
instance_variable_set("@#{singular_table_name}".to_sym, (obj = find_obj))
|
1847
1848
|
upd_params = send(params_name_sym)
|
1848
|
-
|
1849
|
+
json_overrides = ::Brick.config.json_columns&.fetch(table_name, nil)
|
1850
|
+
if (json_cols = model.columns.select { |c| c.type == :json || json_overrides&.include?(c.name) }.map(&:name)).present?
|
1849
1851
|
upd_hash = upd_params.to_h
|
1850
1852
|
json_cols.each do |c|
|
1851
1853
|
begin
|
1852
|
-
upd_hash[c] = JSON.parse(upd_hash[c])
|
1854
|
+
upd_hash[c] = JSON.parse(upd_hash[c].tr('`', '"').gsub('^^br_btick__', '`'))
|
1853
1855
|
rescue
|
1854
1856
|
end
|
1855
1857
|
end
|
@@ -2385,11 +2387,11 @@ ORDER BY 1, 2, c.internal_column_id, acc.position"
|
|
2385
2387
|
"NOT IN ('information_schema', 'pg_catalog', 'pg_toast', 'heroku_ext',
|
2386
2388
|
'INFORMATION_SCHEMA', 'sys')"
|
2387
2389
|
:
|
2388
|
-
"= '#{ActiveRecord::Base.connection.current_database
|
2390
|
+
"= '#{ActiveRecord::Base.connection.current_database&.tr("'", "''")}'"}#{"
|
2389
2391
|
AND t.table_schema = COALESCE(current_setting('SEARCH_PATH'), 'public')" if is_postgres && schema }
|
2390
2392
|
-- AND t.table_type IN ('VIEW') -- 'BASE TABLE', 'FOREIGN TABLE'
|
2391
2393
|
AND t.table_name NOT IN ('pg_stat_statements', ?, ?)
|
2392
|
-
ORDER BY 1, t.table_type DESC, 2,
|
2394
|
+
ORDER BY 1, t.table_type DESC, 2, c.ordinal_position"
|
2393
2395
|
ActiveRecord::Base.execute_sql(sql, *ar_tables)
|
2394
2396
|
end
|
2395
2397
|
|
@@ -76,6 +76,11 @@ function linkSchemas() {
|
|
76
76
|
[... ev.target.getElementsByTagName(\"SELECT\")].forEach(function (select) {
|
77
77
|
if (select.value === \"^^^brick_NULL^^^\") select.value = null;
|
78
78
|
});
|
79
|
+
// Take outer <div> tag off the HTML being returned by any Trix editor
|
80
|
+
[... document.getElementsByTagName(\"TRIX-EDITOR\")].forEach(function (trix) {
|
81
|
+
var trixHidden = trix.inputElement;
|
82
|
+
if (trixHidden) trixHidden.value = trixHidden.value.slice(5, -6);
|
83
|
+
});
|
79
84
|
return true;
|
80
85
|
});
|
81
86
|
});
|
@@ -181,6 +186,21 @@ function linkSchemas() {
|
|
181
186
|
end
|
182
187
|
end
|
183
188
|
|
189
|
+
# class Fields::TextField
|
190
|
+
# alias _original_initialize initialize
|
191
|
+
# def initialize(id, **args, &block)
|
192
|
+
# if instance_of?(::Avo::Fields::TextField) || instance_of?(::Avo::Fields::TextareaField)
|
193
|
+
# args[:format_using] ||= ->(value) do
|
194
|
+
# if value.is_a?(String) && value.encoding != Encoding::UTF_8
|
195
|
+
# value = value.encode!("UTF-8", invalid: :replace, undef: :replace, replace: "?")
|
196
|
+
# end
|
197
|
+
# value
|
198
|
+
# end
|
199
|
+
# end
|
200
|
+
# _original_initialize(id, **args, &block)
|
201
|
+
# end
|
202
|
+
# end
|
203
|
+
|
184
204
|
class App
|
185
205
|
class << self
|
186
206
|
alias _brick_eager_load eager_load
|
@@ -215,16 +235,16 @@ function linkSchemas() {
|
|
215
235
|
TurboFrameWrapperComponent.class_exec do
|
216
236
|
alias _brick_content content
|
217
237
|
def content
|
218
|
-
# Avo's logo partial fails if there is not a URL helper called exactly "root_path"
|
219
|
-
# (Finicky line over there is: avo/app/views/avo/partials/_logo.html.erb:1)
|
220
238
|
if ::Brick.instance_variable_get(:@_brick_avo_js) == view_renderer.object_id
|
221
239
|
_brick_content
|
222
240
|
else
|
223
241
|
::Brick.instance_variable_set(:@_brick_avo_js, view_renderer.object_id)
|
242
|
+
# Avo's logo partial fails if there is not a URL helper called exactly "root_path"
|
243
|
+
# (Finicky line over there is: avo/app/views/avo/partials/_logo.html.erb:1)
|
224
244
|
unless ::Rails.application.routes.named_routes.names.include?(:root) || ActionView::Base.respond_to?(:root_path)
|
225
245
|
ActionView::Base.class_exec do
|
226
246
|
def root_path
|
227
|
-
Avo
|
247
|
+
Avo.configuration.root_path
|
228
248
|
end
|
229
249
|
end
|
230
250
|
end
|
@@ -420,6 +440,39 @@ window.addEventListener(\"popstate\", linkSchemas);
|
|
420
440
|
end
|
421
441
|
end
|
422
442
|
|
443
|
+
# Unconfigured Mobility gem?
|
444
|
+
if Object.const_defined?('Mobility') && Mobility.respond_to?(:translations_class)
|
445
|
+
# Find the current defaults
|
446
|
+
defs = if Mobility.instance_variable_defined?(:@translations_class)
|
447
|
+
::Mobility.translations_class.defaults
|
448
|
+
else
|
449
|
+
{}
|
450
|
+
end
|
451
|
+
# Fill in the blanks for any missing defaults
|
452
|
+
::Mobility.configure do |config|
|
453
|
+
config.plugins do
|
454
|
+
# Default initializer would also set these:
|
455
|
+
# :backend_reader=>true
|
456
|
+
# :query=>:i18n
|
457
|
+
# :cache=>true
|
458
|
+
# :presence=>true
|
459
|
+
backend :key_value, type: :string unless defs.key?(:backend)
|
460
|
+
reader unless defs.key?(:reader)
|
461
|
+
writer unless defs.key?(:writer)
|
462
|
+
active_record unless ::Mobility::Plugins.instance_variable_get(:@plugins)&.key?(:active_record)
|
463
|
+
fallbacks false unless defs.key?(:fallbacks)
|
464
|
+
default nil unless defs.key?(:default)
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
# Spina compatibility
|
470
|
+
if Object.const_defined?('Spina')
|
471
|
+
# Add JSON fields
|
472
|
+
(::Brick.config.json_columns['spina_accounts'] ||= []) << 'json_attributes' if ::Spina.const_defined?('Account')
|
473
|
+
(::Brick.config.json_columns['spina_pages'] ||= []) << 'json_attributes' if ::Spina.const_defined?('Page')
|
474
|
+
end
|
475
|
+
|
423
476
|
# ====================================
|
424
477
|
# Dynamically create generic templates
|
425
478
|
# ====================================
|
@@ -765,6 +818,7 @@ input+svg.revert {
|
|
765
818
|
|
766
819
|
<% is_includes_dates = nil
|
767
820
|
is_includes_json = nil
|
821
|
+
is_includes_text = nil
|
768
822
|
def is_bcrypt?(val)
|
769
823
|
val.is_a?(String) && val.length == 60 && val.start_with?('$2a$')
|
770
824
|
end
|
@@ -1519,8 +1573,11 @@ end
|
|
1519
1573
|
# path_options << { '_brick_schema': } if
|
1520
1574
|
# url = send(:#\{model._brick_index(:singular)}_path, obj.#{pk})
|
1521
1575
|
options = {}
|
1522
|
-
|
1523
|
-
|
1576
|
+
if ::Brick.config.path_prefix
|
1577
|
+
path_helper = obj.new_record? ? #{model_name}._brick_index : #{model_name}._brick_index(:singular)
|
1578
|
+
options[:url] = send(\"#\{path_helper}_path\".to_sym, obj)
|
1579
|
+
end
|
1580
|
+
%>
|
1524
1581
|
<br><br>
|
1525
1582
|
<%= form_for(obj.becomes(#{model_name}), options) do |f| %>
|
1526
1583
|
<table class=\"shadow\">
|
@@ -1569,32 +1626,36 @@ end
|
|
1569
1626
|
<td>
|
1570
1627
|
<table><tr><td>
|
1571
1628
|
<% dt_pickers = { datetime: 'datetimepicker', timestamp: 'datetimepicker', time: 'timepicker', date: 'datepicker' }
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1629
|
+
html_options = {}
|
1630
|
+
html_options[:class] = 'dimmed' unless val
|
1631
|
+
is_revert = true
|
1632
|
+
if bt
|
1633
|
+
html_options[:prompt] = \"Select #\{bt_name\}\" %>
|
1634
|
+
<%= f.select k.to_sym, bt[3], { value: val || '^^^brick_NULL^^^' }, html_options %>
|
1635
|
+
<%= if (bt_obj = bt_class&.find_by(bt_pair[1] => val))
|
1636
|
+
link_to('⇛', send(\"#\{bt_class.base_class._brick_index(:singular)\}_path\".to_sym, bt_obj.send(bt_class.primary_key.to_sym)), { class: 'show-arrow' })
|
1637
|
+
elsif val
|
1638
|
+
\"<span class=\\\"orphan\\\">Orphaned ID: #\{val}</span>\".html_safe
|
1639
|
+
end %>
|
1583
1640
|
<% else
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1641
|
+
col_type = if ::Brick.config.json_columns[tbl_name]&.include?(k)
|
1642
|
+
:json
|
1643
|
+
elsif col&.sql_type == 'geography'
|
1644
|
+
col.sql_type
|
1645
|
+
else
|
1646
|
+
col&.type
|
1647
|
+
end
|
1648
|
+
case (col_type ||= col&.sql_type)
|
1649
|
+
when :string, :text
|
1650
|
+
if is_bcrypt?(val) # || .readonly?
|
1594
1651
|
is_revert = false %>
|
1595
1652
|
<%= hide_bcrypt(val, nil, 1000) %>
|
1596
|
-
<%
|
1653
|
+
<% elsif col_type == :string %>
|
1597
1654
|
<%= f.text_field(k.to_sym, html_options) %>
|
1655
|
+
<% else
|
1656
|
+
is_includes_text = true %>
|
1657
|
+
<%= f.hidden_field(k.to_sym, html_options) %>
|
1658
|
+
<trix-editor input=\"<%= f.field_id(k) %>\"></trix-editor>
|
1598
1659
|
<% end %>
|
1599
1660
|
<% when :boolean %>
|
1600
1661
|
<%= f.check_box k.to_sym %>
|
@@ -1630,10 +1691,17 @@ end
|
|
1630
1691
|
<% when :primary_key
|
1631
1692
|
is_revert = false %>
|
1632
1693
|
<% when :json
|
1633
|
-
is_includes_json = true
|
1694
|
+
is_includes_json = true
|
1695
|
+
if val.is_a?(String)
|
1696
|
+
val_str = val
|
1697
|
+
else
|
1698
|
+
eheij = ActiveSupport::JSON::Encoding.escape_html_entities_in_json
|
1699
|
+
ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false if eheij
|
1700
|
+
val_str = val.to_json
|
1701
|
+
ActiveSupport::JSON::Encoding.escape_html_entities_in_json = eheij
|
1702
|
+
end %>
|
1634
1703
|
<%= # Because there are so danged many quotes in JSON, escape them specially by converting to backticks.
|
1635
1704
|
# (and previous to this, escape backticks with our own goofy code of ^^br_btick__ )
|
1636
|
-
val_str = val.is_a?(String) ? val : val.to_json # Clean up bogus JSON if necessary
|
1637
1705
|
json_field = f.hidden_field k.to_sym, { class: 'jsonpicker', value: val_str.gsub('`', '^^br_btick__').tr('\"', '`').html_safe } %>
|
1638
1706
|
<div id=\"_br_json_<%= f.field_id(k) %>\"></div>
|
1639
1707
|
<% else %>
|
@@ -1739,6 +1807,11 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
1739
1807
|
<link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdnjs.cloudflare.com/ajax/libs/slim-select/1.27.1/slimselect.min.css\">
|
1740
1808
|
<% end %>
|
1741
1809
|
|
1810
|
+
<% if is_includes_text %>
|
1811
|
+
<script src=\"https://cdn.jsdelivr.net/npm/trix@2.0/dist/trix.umd.min.js\"></script>
|
1812
|
+
<link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.jsdelivr.net/npm/trix@2.0/dist/trix.min.css\">
|
1813
|
+
<% end %>
|
1814
|
+
|
1742
1815
|
<% # Started with v0.14.4 of vanilla-jsoneditor
|
1743
1816
|
if is_includes_json %>
|
1744
1817
|
<link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.jsdelivr.net/npm/vanilla-jsoneditor/themes/jse-theme-default.min.css\">
|
@@ -1756,7 +1829,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
1756
1829
|
onChange: (function (inp2) {
|
1757
1830
|
return function (updatedContent, previousContent, contentErrors, patchResult) {
|
1758
1831
|
// console.log('onChange', updatedContent.json, updatedContent.text);
|
1759
|
-
inp2.value = updatedContent.text || JSON.stringify(updatedContent.json);
|
1832
|
+
inp2.value = (updatedContent.text || JSON.stringify(updatedContent.json)).replace(/`/g, \"\\^\\^br_btick__\").replace(/\"/g, '`');
|
1760
1833
|
};
|
1761
1834
|
})(inp)
|
1762
1835
|
}
|
data/lib/brick/version_number.rb
CHANGED
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.119
|
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-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|