brick 1.0.87 → 1.0.88
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 +4 -4
- data/lib/brick/extensions.rb +6 -27
- data/lib/brick/frameworks/rails/engine.rb +20 -4
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +35 -0
- 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: 9e346878b216d9e54ee0ca15be13ec0c2348f8cdf81d14a1eb4bc24ccb07aadb
|
|
4
|
+
data.tar.gz: 92b54e7227fad318508104690158b5c756cc37171e7eeaaaba41d7da97c5518f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8797a5e8924e3a89fd958f05d1bd442cf457428257cd697e438e1e6fe93427bc035177cea79fad47c6484427b30d2e3dc778f7a2166bc0fe27d383ce8659c1c
|
|
7
|
+
data.tar.gz: 0bd6d3cc1ad92a1ec897b1524fde2e3f6849c783705312908d206460f9060677c93c295f3f3b89ddd514e2b3d5faeae4900472b0f4a1419e57e91046a190b3f7
|
data/lib/brick/extensions.rb
CHANGED
|
@@ -841,34 +841,9 @@ if Object.const_defined?('ActionView')
|
|
|
841
841
|
args.first) ||
|
|
842
842
|
@_brick_model
|
|
843
843
|
# If not provided, do a best-effort to automatically determine the resource class or object
|
|
844
|
-
sti_type = nil
|
|
845
844
|
filter_parts = []
|
|
846
845
|
klass_or_obj ||= begin
|
|
847
|
-
|
|
848
|
-
v_parts = v.first.split('.')
|
|
849
|
-
v_parts.shift if v_parts.first == 'public'
|
|
850
|
-
s[v_parts.join('.')] = v.first
|
|
851
|
-
end
|
|
852
|
-
c_path_parts = controller_path.split('/')
|
|
853
|
-
klass = nil
|
|
854
|
-
while c_path_parts.present?
|
|
855
|
-
possible_c_path = c_path_parts.join('.')
|
|
856
|
-
possible_c_path_singular = c_path_parts[0..-2] + [c_path_parts.last.singularize]
|
|
857
|
-
possible_sti = possible_c_path_singular.join('/').camelize
|
|
858
|
-
break if (
|
|
859
|
-
res_name = res_names[possible_c_path] ||
|
|
860
|
-
((klass = Brick.config.sti_namespace_prefixes.key?("::#{possible_sti}") && possible_sti.constantize) &&
|
|
861
|
-
(sti_type = possible_sti)) ||
|
|
862
|
-
# %%% Used to have the more flexible: (DidYouMean::SpellChecker.new(dictionary: res_names.keys).correct(possible_c_path)).first
|
|
863
|
-
res_names[possible_c_path] || res_names[possible_c_path_singular.join('.')]
|
|
864
|
-
) &&
|
|
865
|
-
(
|
|
866
|
-
klass ||
|
|
867
|
-
((rel = ::Brick.relations.fetch(res_name, nil)) &&
|
|
868
|
-
(klass ||= rel[:class_name]&.constantize))
|
|
869
|
-
)
|
|
870
|
-
c_path_parts.shift
|
|
871
|
-
end
|
|
846
|
+
klass, sti_type = ::Brick.ctrl_to_klass(controller_path)
|
|
872
847
|
if klass
|
|
873
848
|
type_col = klass.inheritance_column # Usually 'type'
|
|
874
849
|
filter_parts << "#{type_col}=#{sti_type}" if sti_type && klass.column_names.include?(type_col)
|
|
@@ -1811,7 +1786,11 @@ end.class_exec do
|
|
|
1811
1786
|
initializer_loaded = false
|
|
1812
1787
|
orig_schema = nil
|
|
1813
1788
|
if (relations = ::Brick.relations).empty?
|
|
1814
|
-
#
|
|
1789
|
+
# Very first thing, load inflections since we'll be using .pluralize and .singularize on table and model names
|
|
1790
|
+
if File.exist?(inflections = ::Rails.root.join('config/initializers/inflections.rb'))
|
|
1791
|
+
load inflections
|
|
1792
|
+
end
|
|
1793
|
+
# Now the Brick initializer since there may be important schema things configured
|
|
1815
1794
|
if File.exist?(brick_initializer = ::Rails.root.join('config/initializers/brick.rb'))
|
|
1816
1795
|
initializer_loaded = load brick_initializer
|
|
1817
1796
|
end
|
|
@@ -502,6 +502,16 @@ window.addEventListener(\"pageshow\", function() {
|
|
|
502
502
|
}
|
|
503
503
|
});
|
|
504
504
|
|
|
505
|
+
// Add \"Are you sure?\" behaviour to any data-confirm buttons out there
|
|
506
|
+
document.querySelectorAll(\"input[type=submit][data-confirm]\").forEach(function (btn) {
|
|
507
|
+
btn.addEventListener(\"click\", function (evt) {
|
|
508
|
+
if (!confirm(this.getAttribute(\"data-confirm\"))) {
|
|
509
|
+
evt.preventDefault();
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
|
|
505
515
|
function changeout(href, param, value, trimAfter) {
|
|
506
516
|
var hrefParts = href.split(\"?\");
|
|
507
517
|
var params = hrefParts.length > 1 ? hrefParts[1].split(\"&\") : [];
|
|
@@ -556,13 +566,19 @@ if (grid) {
|
|
|
556
566
|
if (lastHighCell) lastHighCell.classList.remove(\"highlight\");
|
|
557
567
|
}
|
|
558
568
|
var lastHighHeader = gridHighHeader;
|
|
559
|
-
gridHighHeader = headerCols[gridHighCell.cellIndex]
|
|
560
|
-
if (lastHighHeader !== gridHighHeader) {
|
|
569
|
+
if ((gridHighHeader = headerCols[gridHighCell.cellIndex]) && lastHighHeader !== gridHighHeader) {
|
|
561
570
|
if (gridHighHeader) gridHighHeader.classList.add(\"highlight\");
|
|
562
571
|
if (lastHighHeader) lastHighHeader.classList.remove(\"highlight\");
|
|
563
572
|
}
|
|
564
573
|
}
|
|
565
574
|
}
|
|
575
|
+
// // LESS TOUCHY NAVIGATION BACK OR FORWARD IN HISTORY WHEN USING MOUSE WHEEL
|
|
576
|
+
// grid.addEventListener(\"wheel\", function (evt) {
|
|
577
|
+
// grid.scrollLeft += evt.deltaX;
|
|
578
|
+
// document.body.scrollTop += (evt.deltaY * 0.6);
|
|
579
|
+
// evt.preventDefault();
|
|
580
|
+
// return false;
|
|
581
|
+
// });
|
|
566
582
|
}
|
|
567
583
|
function setHeaderSizes() {
|
|
568
584
|
// console.log(\"start\");
|
|
@@ -1185,7 +1201,7 @@ end
|
|
|
1185
1201
|
<% end %>
|
|
1186
1202
|
|
|
1187
1203
|
#{unless args.first == 'new'
|
|
1188
|
-
confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: 'Are you sure?' }" : "form: { data: { turbo_confirm: 'Are you sure?' } }"
|
|
1204
|
+
confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: 'Delete #{model_name} -- Are you sure?' }" : "form: { data: { turbo_confirm: 'Delete #{model_name} -- Are you sure?' } }"
|
|
1189
1205
|
hms_headers.each_with_object(+'') do |hm, s|
|
|
1190
1206
|
# %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
|
|
1191
1207
|
next if hm.first.options[:through] && !hm.first.through_reflection
|
|
@@ -1250,7 +1266,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
|
1250
1266
|
if (mermaidCode) return; // Cut it short if we've already rendered the diagram
|
|
1251
1267
|
|
|
1252
1268
|
mermaidCode = document.createElement(\"SCRIPT\");
|
|
1253
|
-
mermaidCode.setAttribute(\"src\", \"https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js\");
|
|
1269
|
+
mermaidCode.setAttribute(\"src\", \"https://cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js\");
|
|
1254
1270
|
mermaidCode.addEventListener(\"load\", function () {
|
|
1255
1271
|
mermaid.initialize({
|
|
1256
1272
|
startOnLoad: true,
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
|
@@ -563,6 +563,41 @@ In config/initializers/brick.rb appropriate entries would look something like:
|
|
|
563
563
|
end
|
|
564
564
|
puts "\n"
|
|
565
565
|
end
|
|
566
|
+
|
|
567
|
+
# Attempt to determine an ActiveRecord::Base class and additional STI information when given a controller's path
|
|
568
|
+
def ctrl_to_klass(ctrl_path, res_names = {})
|
|
569
|
+
klass = nil
|
|
570
|
+
sti_type = nil
|
|
571
|
+
|
|
572
|
+
if res_names.empty?
|
|
573
|
+
::Brick.relations.each_with_object({}) do |v, s|
|
|
574
|
+
v_parts = v.first.split('.')
|
|
575
|
+
v_parts.shift if v_parts.first == 'public'
|
|
576
|
+
res_names[v_parts.join('.')] = v.first
|
|
577
|
+
end
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
c_path_parts = ctrl_path.split('/')
|
|
581
|
+
while c_path_parts.present?
|
|
582
|
+
possible_c_path = c_path_parts.join('.')
|
|
583
|
+
possible_c_path_singular = c_path_parts[0..-2] + [c_path_parts.last.singularize]
|
|
584
|
+
possible_sti = possible_c_path_singular.join('/').camelize
|
|
585
|
+
break if (
|
|
586
|
+
res_name = res_names[possible_c_path] ||
|
|
587
|
+
((klass = Brick.config.sti_namespace_prefixes.key?("::#{possible_sti}") && possible_sti.constantize) &&
|
|
588
|
+
(sti_type = possible_sti)) ||
|
|
589
|
+
# %%% Used to have the more flexible: (DidYouMean::SpellChecker.new(dictionary: res_names.keys).correct(possible_c_path)).first
|
|
590
|
+
res_names[possible_c_path] || res_names[possible_c_path_singular.join('.')]
|
|
591
|
+
) &&
|
|
592
|
+
(
|
|
593
|
+
klass ||
|
|
594
|
+
((rel = ::Brick.relations.fetch(res_name, nil)) &&
|
|
595
|
+
(klass ||= rel[:class_name]&.constantize))
|
|
596
|
+
)
|
|
597
|
+
c_path_parts.shift
|
|
598
|
+
end
|
|
599
|
+
[klass, sti_type]
|
|
600
|
+
end
|
|
566
601
|
end
|
|
567
602
|
|
|
568
603
|
module RouteSet
|
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.88
|
|
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-11-
|
|
11
|
+
date: 2022-11-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|