caravaggio 0.0.12 → 0.0.13

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
  SHA1:
3
- metadata.gz: 2c0d90d2672df3cc81691479e1e52a1e7f1deb48
4
- data.tar.gz: f1d87ce1735d6344c04b587cdc07694160e525c5
3
+ metadata.gz: b0dda3dc3ed17236f6cd4eae3b30dcf884e4b730
4
+ data.tar.gz: 95ae12e8ea864d4ef95268402989bdf16dab5fb3
5
5
  SHA512:
6
- metadata.gz: ecabd7b1cb1e8b0ce714189c935f76a5fc39427977cdfeb1e6c8f971f4e5ec5995b8564361c9f454f007f711daae95b835afda6f67edd486b1b4e8630a6a6268
7
- data.tar.gz: e15e0217418f1089ad832348c7a5c61874292df4153c65b65145c85d03a239bf8053a0186ef24bda103dd7e35df4342a92893f31f46d98761d0b20698fe59db7
6
+ metadata.gz: 7bdfbc8e4d5dd802f6bd61021835ce49efb8d1e1735d627b2e61c1e3e0e100fc6b3909678bae7863ba48027fb3d8d261e7251a3b8235a51384e2adeae4c7cb7f
7
+ data.tar.gz: a4ade3b8b7dab76a0a3b7ca057c429aceb7908891d561f29fdfefa9fc1be4a5a8217d89a20163cc0abbb177ac8dd136d39dc0495e0b3cc377614496b1183afe1
@@ -62,6 +62,26 @@ function displayModels() {
62
62
  .text(d => d["short_name"])
63
63
  }
64
64
 
65
+ function filterClasses() {
66
+ filterValue = d3.select("#class_filter").property("value");
67
+ if(filterValue === "") {
68
+ console.log("CLEAR ME");
69
+ d3.selectAll(".class-checker").classed("hidden", false);
70
+ } else {
71
+ for(i = 0; i < models.length; ++i) {
72
+ if(models[i].id.indexOf(filterValue) == -1) {
73
+ d3.select(checkboxClassName(models[i])).classed("hidden", true);
74
+ } else {
75
+ c = d3.select(checkboxClassName(models[i])).classed("hidden", false);
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ function checkboxClassName(model) {
82
+ return "#class_" + model.friendly_name;
83
+ }
84
+
65
85
  function createMarker(defs, name, color) {
66
86
  return defs.append("marker")
67
87
  .attr('id', name + '-arrowhead')
@@ -31,15 +31,23 @@ div.sidebar {
31
31
  padding: 0px 3px;
32
32
  height: 85vh;
33
33
  min-height: 85vh;
34
- overflow-y: scroll;
35
34
  }
36
35
 
37
36
  div.left-sidebar {
38
37
  width: 15%;
39
38
  }
40
39
 
40
+ div.left-sidebar .sidebar-content {
41
+ overflow-y: scroll;
42
+ height: 65vh;
43
+ min-height: 65vh;
44
+ }
45
+
41
46
  div.right-sidebar {
42
47
  width: 18%;
48
+ overflow-y: scroll;
49
+ height: 85vh;
50
+ min-height: 85vh;
43
51
  }
44
52
 
45
53
  ul {
@@ -6,7 +6,7 @@
6
6
  <li><%= column.name %> : <%= column.sql_type %></li>
7
7
  <% end %>
8
8
  </ul>
9
- <h3>Associations</h3>
9
+ <h3>Associations From</h3>
10
10
  <ul>
11
11
  <% figure.associations.each do |association| %>
12
12
  <li>
@@ -21,4 +21,20 @@
21
21
  </li>
22
22
  <% end %>
23
23
  </ul>
24
+ <ul>
25
+ <h3>Associations To</h3>
26
+ <ul>
27
+ <% @canvas.associations_for(target: figure.name).each do |association| %>
28
+ <li>
29
+ <%= association[:source] %> : <%= association[:association_type] %> <%= association[:name] %>
30
+ <% if association[:options].present? %>
31
+ <ul>
32
+ <% association[:options].each do |option, value| %>
33
+ <li><%= option %> : <%= value %></li>
34
+ <% end %>
35
+ </ul>
36
+ <% end %>
37
+ </li>
38
+ <% end %>
39
+ </ul>
24
40
  </div>
@@ -19,14 +19,16 @@
19
19
  <li><input type="checkbox" name="links_from" id="links_from" onclick="displayModels()" checked/>Links from</li>
20
20
  <li><input type="checkbox" name="links_to" id="links_to" onclick="displayModels()" />Links to</li>
21
21
  <li><input type="checkbox" name="only_checked" id="only_checked" onclick="displayModels()" />Checked only</li>
22
+ <li><br/></li>
23
+ <li><input type="text" name="class_filter" id="class_filter" oninput="filterClasses()" placeholder="Filter" /></li>
22
24
  </ul>
23
25
  </div>
24
- <div>
26
+ <div class="sidebar-content">
25
27
  <h3>Classes</h3>
26
28
  <ul>
27
29
  <li><%= check_box_tag "ALL", "ALL", false, class: "all-model-checkbox", onclick: "setAllModels(this)" %>ALL</li>
28
30
  <% @models.each do |model| %>
29
- <li><%= check_box_tag model[:friendly_name], model[:friendly_name], false, data: {class_name: model[:id]}, class: "model-checkbox", onclick: "setModel(this)" %> <%= model[:short_name] %></li>
31
+ <li class="class-checker" id="class_<%= model[:friendly_name] %>"><%= check_box_tag model[:friendly_name], model[:friendly_name], false, data: {class_name: model[:id]}, class: "model-checkbox", onclick: "setModel(this)" %> <%= model[:short_name] %></li>
30
32
  <% end %>
31
33
  </ul>
32
34
  </div>
@@ -11,7 +11,7 @@ module Caravaggio
11
11
  ActiveRecord::Base.descendants.reject{|c| c.abstract_class}.sort{|s1, s2| s1.name <=> s2.name}.each do |model|
12
12
  begin
13
13
  figure = Figure.new(model)
14
- @figures << figure
14
+ @figures << figure unless figure.habtm?
15
15
  rescue => e
16
16
  Rails.logger.error "Failed to load #{model.name} with error #{e}"
17
17
  end
@@ -22,6 +22,10 @@ module Caravaggio
22
22
  @figures.map{|figure| figure.model}
23
23
  end
24
24
 
25
+ def associations_for(source: nil, target: nil)
26
+ associations.select{|assoc| (source.nil? || assoc[:source] == source) && (target.nil? || assoc[:target] == target)}
27
+ end
28
+
25
29
  def associations
26
30
  if @associations.nil?
27
31
  @associations = @figures.map{|figure| figure.associations}.flatten
@@ -32,6 +32,11 @@ module Caravaggio
32
32
  @to_json ||= to_h.to_json
33
33
  end
34
34
 
35
+ # identify HABTM models
36
+ def habtm?
37
+ !@source_model.attribute_names.include?("id") && @source_model.name[0..5] == "HABTM_"
38
+ end
39
+
35
40
  def model
36
41
  @source_model_hash ||= {
37
42
  id: name,
@@ -1,3 +1,3 @@
1
1
  module Caravaggio
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caravaggio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - jdzik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Shine light on ActiveRecord entities and relationships.
14
14
  email: