brick 1.0.63 → 1.0.64
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brick/frameworks/rails/engine.rb +56 -27
- 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: c48ee6a2f143563e2e443f6edf0dc0e04e800e8fae6951e05b0362956129e950
|
4
|
+
data.tar.gz: f632f6e795dcf9b3aeb97e36a37c8074302c5967206b5f415a9a4b862bb4fda7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cd5e05899a2f780a0bbf378f8f49e49f604b90cf122f2cd7efe34839c434af814c9a228f36bd18b112cd8e40b6736e88742ea0f2a1a0b55ac3f8f573e614918
|
7
|
+
data.tar.gz: a34a9f47746159f6b4b39f8a3cd994055e022be9eefe8737b73c63e5d475b283ae3b99a6a11e3faf140ca6efbf67d7f400e03147a757c237c8875f11ea2c0ea4
|
@@ -182,8 +182,6 @@ module Brick
|
|
182
182
|
h1, h3 {
|
183
183
|
margin-bottom: 0;
|
184
184
|
}
|
185
|
-
#resourceName {
|
186
|
-
}
|
187
185
|
#imgErd {
|
188
186
|
background-image:url(assets/brick_erd.png);
|
189
187
|
background-size: 100% 100%;
|
@@ -453,25 +451,27 @@ window.addEventListener(\"pageshow\", function() {
|
|
453
451
|
|
454
452
|
function changeout(href, param, value, trimAfter) {
|
455
453
|
var hrefParts = href.split(\"?\");
|
456
|
-
|
454
|
+
var params = hrefParts.length > 1 ? hrefParts[1].split(\"&\") : [];
|
455
|
+
if (param === undefined || param === null || param === -1) {
|
457
456
|
hrefParts = hrefParts[0].split(\"://\");
|
458
457
|
var pathParts = hrefParts[hrefParts.length - 1].split(\"/\");
|
459
458
|
if (value === undefined)
|
460
459
|
// A couple possibilities if it's namespaced, starting with two parts in the path -- and then try just one
|
461
460
|
return [pathParts.slice(1, 3).join('/'), pathParts.slice(1, 2)[0]];
|
462
|
-
else
|
463
|
-
|
461
|
+
else {
|
462
|
+
var queryString = param ? \"?\" + params.join(\"&\") : \"\";
|
463
|
+
return hrefParts[0] + \"://\" + pathParts[0] + \"/\" + value + queryString;
|
464
|
+
}
|
464
465
|
}
|
465
466
|
if (trimAfter) {
|
466
467
|
var pathParts = hrefParts[0].split(\"/\");
|
467
468
|
while (pathParts.lastIndexOf(trimAfter) !== pathParts.length - 1) pathParts.pop();
|
468
469
|
hrefParts[0] = pathParts.join(\"/\");
|
469
470
|
}
|
470
|
-
|
471
|
-
params = params.reduce(function (s, v) { var parts = v.split(\"=\"); if (parts[1] !== null) s[parts[0]] = parts[1]; return s; }, {});
|
471
|
+
params = params.reduce(function (s, v) { var parts = v.split(\"=\"); if (parts[1]) s[parts[0]] = parts[1]; return s; }, {});
|
472
472
|
if (value === undefined) return params[param];
|
473
473
|
params[param] = value;
|
474
|
-
var finalParams = Object.keys(params).reduce(function (s, v) { if (params[v]
|
474
|
+
var finalParams = Object.keys(params).reduce(function (s, v) { if (params[v]) s.push(v + \"=\" + params[v]); return s; }, []).join(\"&\");
|
475
475
|
return hrefParts[0] + (finalParams.length > 0 ? \"?\" + finalParams : \"\");
|
476
476
|
}
|
477
477
|
|
@@ -677,25 +677,53 @@ erDiagram
|
|
677
677
|
<% model_short_name = #{@_brick_model.name.split('::').last.inspect}
|
678
678
|
callbacks = {}
|
679
679
|
@_brick_bt_descrip.each do |bt|
|
680
|
-
|
681
|
-
callbacks[bt_name =
|
682
|
-
#
|
683
|
-
|
684
|
-
|
680
|
+
bt_class = bt[1].first.first
|
681
|
+
callbacks[bt_name = bt_class.name.split('::').last] = bt_class
|
682
|
+
is_has_one = #{@_brick_model.name}.reflect_on_association(bt.first).inverse_of&.macro == :has_one ||
|
683
|
+
::Brick.config.has_ones&.fetch('#{@_brick_model.name}', nil)&.key?(bt.first.to_s)
|
684
|
+
%> <%= \"#\{model_short_name} #\{is_has_one ? '||' : '}o'}--|| #\{bt_name} : \\\"#\{
|
685
685
|
bt.first unless bt.first.to_s == bt[1].first.first.name.underscore.singularize.tr('/', '_')
|
686
686
|
}\\\"\".html_safe %>
|
687
|
-
<% end
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
687
|
+
<% end
|
688
|
+
last_through = nil
|
689
|
+
@_brick_hm_counts.each do |hm|
|
690
|
+
# Skip showing self-referencing HM links since they would have already been drawn while evaluating the BT side
|
691
|
+
next if (hm_class = hm.last.klass) == #{@_brick_model.name}
|
692
|
+
|
693
|
+
callbacks[hm_name = hm_class.name.split('::').last] = hm_class
|
694
|
+
if (through = hm.last.options[:through]&.to_s) # has_many :through (HMT)
|
695
|
+
callbacks[through.singularize.camelize] = (through_assoc = hm.last.source_reflection).active_record
|
696
|
+
if last_through == through # Same HM, so no need to build it again, and for clarity just put in a blank line
|
697
|
+
%><%= \"\n\"
|
698
|
+
%><% else
|
699
|
+
%> <%= \"#\{model_short_name} ||--o{ #\{through_assoc.active_record.name}\".html_safe %> : \"\"
|
700
|
+
<% last_through = through
|
701
|
+
end
|
702
|
+
%> <%= \"#\{through_assoc.active_record.name} }o--|| #\{hm_name}\".html_safe %> : \"\"
|
703
|
+
<%= \"#\{model_short_name} }o..o{ #\{hm_name} : \\\"#\{hm.first}\\\"\".html_safe %><%
|
704
|
+
else # has_many
|
705
|
+
%> <%= \"#\{model_short_name} ||--o{ #\{hm_name} : \\\"#\{
|
706
|
+
hm_name unless hm.first.to_s == hm_class.name.underscore.pluralize.tr('/', '_')
|
707
|
+
}\\\"\".html_safe %><%
|
708
|
+
end %>
|
709
|
+
<% end
|
710
|
+
callbacks.merge({model_short_name => #{@_brick_model.name}}).each do |cb_k, cb_class|
|
711
|
+
cb_relation = ::Brick.relations[cb_class.table_name]
|
712
|
+
pkeys = cb_relation[:pkey]&.first&.last
|
713
|
+
fkeys = cb_relation[:fks]&.values&.each_with_object([]) { |fk, s| s << fk[:fk] if fk.fetch(:is_bt, nil) }
|
714
|
+
%> <%= cb_k %> {<%
|
715
|
+
pkeys&.each do |pk| %>
|
716
|
+
<%= \"int #\{pk} \\\"PK#\{' fk' if fkeys&.include?(pk)}\\\"\".html_safe %><%
|
717
|
+
end %><%
|
718
|
+
fkeys&.each do |fk|
|
719
|
+
if fk.is_a?(Array)
|
720
|
+
fk.each do |fk_part| %>
|
721
|
+
<%= \"int #\{fk_part} \\\" fk\\\"\".html_safe unless pkeys&.include?(fk_part) %><%
|
722
|
+
end
|
723
|
+
else %>
|
724
|
+
<%= \"int #\{fk} \\\" fk\\\"\".html_safe unless pkeys&.include?(fk) %><%
|
725
|
+
end
|
726
|
+
end %>
|
699
727
|
}
|
700
728
|
<% end
|
701
729
|
# callback < %= cb_k % > erdClick
|
@@ -1034,7 +1062,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
1034
1062
|
var imgErd = document.getElementById(\"imgErd\");
|
1035
1063
|
var mermaidErd = document.getElementById(\"mermaidErd\");
|
1036
1064
|
var mermaidCode;
|
1037
|
-
var cbs = {<%= callbacks.map { |k, v| \"#\{k}: \\\"#\{v.underscore.pluralize}\\\"\" }.join(', ').html_safe %>};
|
1065
|
+
var cbs = {<%= callbacks.map { |k, v| \"#\{k}: \\\"#\{v.name.underscore.pluralize}\\\"\" }.join(', ').html_safe %>};
|
1038
1066
|
imgErd.addEventListener(\"click\", showErd);
|
1039
1067
|
function showErd() {
|
1040
1068
|
imgErd.style.display = \"none\";
|
@@ -1049,13 +1077,14 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
1049
1077
|
securityLevel: \"loose\",
|
1050
1078
|
mermaid: {callback: function(objId) {
|
1051
1079
|
var svg = document.getElementById(objId);
|
1080
|
+
svg.removeAttribute(\"width\");
|
1052
1081
|
var cb;
|
1053
1082
|
for(cb in cbs) {
|
1054
1083
|
var gErd = svg.getElementById(cb);
|
1055
1084
|
gErd.setAttribute(\"class\", \"relatedModel\");
|
1056
1085
|
gErd.addEventListener(\"click\",
|
1057
1086
|
function (evt) {
|
1058
|
-
location.href = changeout(changeout(location.href,
|
1087
|
+
location.href = changeout(changeout(location.href, -1, cbs[this.id]), \"_brick_erd\", \"1\");
|
1059
1088
|
}
|
1060
1089
|
);
|
1061
1090
|
}
|
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.64
|
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-
|
11
|
+
date: 2022-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|