erd_map 0.1.4 → 0.1.5

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: ed4d072a4862423c842760702dbb6d1e51d749e3dcb53968a53f34a7780962f6
4
- data.tar.gz: 5da740ea6a8613083bcb5dcd4274087482189f9cbc0ec8e56e8c4032c4c9e3be
3
+ metadata.gz: ff2d016ce1d70f303ba81a480185f13058d35cb1f0cd98c224637eaadaac481b
4
+ data.tar.gz: a48d58de84ed40da26d8327aac5fb2241c51ddf1333eca9365398ce72fb79628
5
5
  SHA512:
6
- metadata.gz: c887c21acfb720eb0ae8a3a2b5d6aa1caeca816ccf68781384e29a901a2e8dafb30bb6bde4524b3c46319da7ad10e53eb384535c5f01e8733d304cdadd9e86bc
7
- data.tar.gz: 0ae4645e25e70ad6b709c37ab2525285bf421ede860b9eed22e0ef307fafcfe29461da9fbbe81430030877a269396b7fca2eea43aed0a39aed8f85760daad8d0
6
+ metadata.gz: 0aad4e151277b66e1996d5953552de91f9798e2e566f5b01869cad123c6c7e83cd69f35960cc6741ecda719d77da118b172e63e1b2efc168512663e23153752c
7
+ data.tar.gz: bdf8341667f56d3ed3ed20a9c3204a485b078a81ee2288942c83e9b6821e22e4e4db989afdbaf677de8529c19e3a0a895930bc3e3c7aac8cd7a4c48486687275
data/lib/erd_map/graph.rb CHANGED
@@ -99,6 +99,15 @@ module ErdMap
99
99
  end
100
100
  end
101
101
 
102
+ def nodes_with_i18n_labels
103
+ return @nodes_with_i18n_labels if @nodes_with_i18n_labels
104
+ @nodes_with_i18n_labels = {}
105
+ whole_models.each do |model|
106
+ @nodes_with_i18n_labels[model.name] = model.model_name.human(default: "")
107
+ end
108
+ @nodes_with_i18n_labels
109
+ end
110
+
102
111
  def association_columns
103
112
  return @association_columns if @association_columns
104
113
 
@@ -42,11 +42,11 @@ module ErdMap
42
42
  layoutsByChunkData: graph.layouts_by_chunk.to_json,
43
43
  chunkedNodesData: graph.chunked_nodes.to_json,
44
44
  nodeWithCommunityIndexData: graph.node_with_community_index.to_json,
45
- searchBox: plot.button_set[:search_box],
46
- selectingNodeLabel: plot.button_set[:selecting_node_label],
47
- zoomModeToggle: plot.button_set[:zoom_mode_toggle],
48
- tapModeToggle: plot.button_set[:tap_mode_toggle],
49
- displayTitleModeToggle: plot.button_set[:display_title_mode_toggle],
45
+ searchBox: plot.search_box,
46
+ selectingNodeLabel: plot.selecting_node_label,
47
+ zoomModeToggle: plot.zoom_mode_toggle,
48
+ tapModeToggle: plot.tap_mode_toggle,
49
+ displayTitleModeToggle: plot.display_title_mode_toggle,
50
50
  nodeLabels: {
51
51
  titleModelLabel: title_model_label,
52
52
  foreignModelLabel: foreign_model_label,
@@ -81,12 +81,14 @@ module ErdMap
81
81
 
82
82
  columns_label = []
83
83
  title_label = []
84
+ i18n_label = []
84
85
  rect_heights = []
85
86
  graph.node_names.map do |node_name|
86
87
  title_text = format_text([node_name], title: true)
87
88
  columns_text = [*title_text.scan("\n"), "\n", format_text(graph.association_columns[node_name])].join
88
89
  columns_label << columns_text
89
90
  title_label << [title_text, "\n", *columns_text.scan("\n")].join
91
+ i18n_label << [node_name, graph.nodes_with_i18n_labels[node_name]].compact_blank.join("\n")
90
92
 
91
93
  padding = 36
92
94
  line_count = columns_text.scan("\n").size + 1
@@ -102,6 +104,7 @@ module ErdMap
102
104
  radius: graph.node_radius,
103
105
  original_radius: graph.node_radius,
104
106
  rect_height: rect_heights,
107
+ i18n_label: i18n_label,
105
108
  title_label: title_label,
106
109
  columns_label: columns_label,
107
110
  fill_color: graph.node_colors,
@@ -181,7 +184,7 @@ module ErdMap
181
184
  bokeh_models.LabelSet.new(
182
185
  x: "x",
183
186
  y: "y",
184
- text: "index",
187
+ text: { field: "i18n_label" },
185
188
  source: graph_renderer.node_renderer.data_source,
186
189
  text_font_size: "12pt",
187
190
  text_color: { field: "text_color" },
@@ -33,19 +33,7 @@ module ErdMap
33
33
  bokeh_models.Column.new(
34
34
  children: [
35
35
  bokeh_models.Row.new(
36
- children: [
37
- plot.button_set[:left_spacer],
38
- plot.button_set[:selecting_node_label],
39
- plot.button_set[:search_box],
40
- plot.button_set[:zoom_mode_toggle],
41
- plot.button_set[:tap_mode_toggle],
42
- plot.button_set[:display_title_mode_toggle],
43
- plot.button_set[:re_layout_button],
44
- plot.button_set[:zoom_in_button],
45
- plot.button_set[:zoom_out_button],
46
- plot.button_set[:re_compute_button],
47
- plot.button_set[:right_spacer],
48
- ],
36
+ children: plot.header,
49
37
  sizing_mode: "stretch_width",
50
38
  ),
51
39
  plot.plot,
data/lib/erd_map/plot.rb CHANGED
@@ -26,8 +26,8 @@ module ErdMap
26
26
  end
27
27
  end
28
28
 
29
- def button_set
30
- @button_set ||= ButtonSet.new
29
+ def header
30
+ @header.to_a
31
31
  end
32
32
 
33
33
  private
@@ -36,6 +36,7 @@ module ErdMap
36
36
 
37
37
  def initialize(graph)
38
38
  @graph = graph
39
+ @header = Header.new
39
40
  register_callback
40
41
  end
41
42
 
@@ -70,14 +71,34 @@ module ErdMap
70
71
  JS
71
72
  end
72
73
 
73
- class ButtonSet
74
+ class Header
74
75
  extend Forwardable
75
- def_delegators :@button_set, :[]
76
+ ACCESSIBLE_PARTS = [:search_box, :selecting_node_label, :zoom_mode_toggle, :tap_mode_toggle, :display_title_mode_toggle]
77
+
78
+ def to_a
79
+ [
80
+ :left_spacer,
81
+ :selecting_node_label,
82
+ :search_box,
83
+ :zoom_mode_toggle,
84
+ :tap_mode_toggle,
85
+ :display_title_mode_toggle,
86
+ :re_layout_button,
87
+ :zoom_in_button,
88
+ :zoom_out_button,
89
+ :re_compute_button,
90
+ :right_spacer,
91
+ ].map { |name| @header[name] }
92
+ end
76
93
 
77
94
  private
78
95
 
96
+ ACCESSIBLE_PARTS.each do |name|
97
+ define_method(name) { @header[name] }
98
+ end
99
+
79
100
  def initialize
80
- @button_set = {
101
+ @header = {
81
102
  left_spacer: left_spacer,
82
103
  selecting_node_label: selecting_node_label,
83
104
  search_box: search_box,
@@ -189,5 +210,9 @@ module ErdMap
189
210
  )
190
211
  end
191
212
  end
213
+
214
+ Header::ACCESSIBLE_PARTS.each do |name|
215
+ public define_method(name) { @header.__send__(name) }
216
+ end
192
217
  end
193
218
  end
@@ -1,3 +1,3 @@
1
1
  module ErdMap
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erd_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - makicamel