erd_map 0.1.4 → 0.1.6
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/erd_map/graph.rb +9 -0
- data/lib/erd_map/graph_renderer.rb +9 -6
- data/lib/erd_map/map_builder.rb +1 -13
- data/lib/erd_map/plot.rb +36 -31
- data/lib/erd_map/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29ffeeb0cb80e98ef47daa5c5e6a7d9a01f399cba46b13a9e7ad0c2d7ff41a47
|
4
|
+
data.tar.gz: 57dc614a5f358013de14dd8519704474796bccb67ce9ad7fb2f9b7baecb82423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2e6326744067203d6112deb82a6ba2b0596c8d17763798e5c64747bb6a1ef1573834e7029bc28f111dda5add572aa9c28420a122a559bd388915b08010ecee2
|
7
|
+
data.tar.gz: ab393eda5b85846e8a6d8131912d9e52691974b4bf363caf45a374065933e23ee24d6de16816424bc200af34f8b5cc8610178e161c8edd91d80d5a22a3a06a31
|
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.
|
46
|
-
selectingNodeLabel: plot.
|
47
|
-
zoomModeToggle: plot.
|
48
|
-
tapModeToggle: plot.
|
49
|
-
displayTitleModeToggle: plot.
|
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: "
|
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" },
|
data/lib/erd_map/map_builder.rb
CHANGED
@@ -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
|
30
|
-
@
|
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,38 +71,38 @@ module ErdMap
|
|
70
71
|
JS
|
71
72
|
end
|
72
73
|
|
73
|
-
class
|
74
|
+
class Header
|
74
75
|
extend Forwardable
|
75
|
-
|
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
|
+
]
|
92
|
+
end
|
76
93
|
|
77
94
|
private
|
78
95
|
|
79
|
-
def initialize
|
80
|
-
@button_set = {
|
81
|
-
left_spacer: left_spacer,
|
82
|
-
selecting_node_label: selecting_node_label,
|
83
|
-
search_box: search_box,
|
84
|
-
zoom_mode_toggle: zoom_mode_toggle,
|
85
|
-
tap_mode_toggle: tap_mode_toggle,
|
86
|
-
display_title_mode_toggle: display_title_mode_toggle,
|
87
|
-
re_layout_button: re_layout_button,
|
88
|
-
zoom_in_button: zoom_in_button,
|
89
|
-
zoom_out_button: zoom_out_button,
|
90
|
-
re_compute_button: re_compute_button,
|
91
|
-
right_spacer: right_spacer,
|
92
|
-
}
|
93
|
-
end
|
94
|
-
|
95
96
|
def left_spacer
|
96
|
-
bokeh_models.Spacer.new(width: 0, sizing_mode: "stretch_width")
|
97
|
+
@left_spacer ||= bokeh_models.Spacer.new(width: 0, sizing_mode: "stretch_width")
|
97
98
|
end
|
98
99
|
|
99
100
|
def right_spacer
|
100
|
-
bokeh_models.Spacer.new(width: 30, sizing_mode: "fixed")
|
101
|
+
@right_spacer ||= bokeh_models.Spacer.new(height: 1, width: 30, sizing_mode: "fixed")
|
101
102
|
end
|
102
103
|
|
103
104
|
def selecting_node_label
|
104
|
-
bokeh_models.Div.new(
|
105
|
+
@selecting_node_label ||= bokeh_models.Div.new(
|
105
106
|
text: "",
|
106
107
|
height: 28,
|
107
108
|
styles: { display: :flex, align_items: :center },
|
@@ -109,49 +110,49 @@ module ErdMap
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def search_box
|
112
|
-
bokeh_models.TextInput.new(placeholder: "🔍 Search model", width: 200).tap do |input|
|
113
|
+
@search_box ||= bokeh_models.TextInput.new(placeholder: "🔍 Search model", width: 200).tap do |input|
|
113
114
|
input.js_on_change("value", custom_js("searchNodes"))
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
118
|
def zoom_mode_toggle
|
118
|
-
bokeh_models.Button.new(label: "Wheel mode: fix", button_type: "default").tap do |button|
|
119
|
+
@zoom_mode_toggle ||= bokeh_models.Button.new(label: "Wheel mode: fix", button_type: "default").tap do |button|
|
119
120
|
button.js_on_click(custom_js("toggleZoomMode"))
|
120
121
|
end
|
121
122
|
end
|
122
123
|
|
123
124
|
def tap_mode_toggle
|
124
|
-
bokeh_models.Button.new(label: "Tap mode: association", button_type: "default").tap do |button|
|
125
|
+
@tap_mode_toggle ||= bokeh_models.Button.new(label: "Tap mode: association", button_type: "default").tap do |button|
|
125
126
|
button.js_on_click(custom_js("toggleTapMode"))
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
129
130
|
def display_title_mode_toggle
|
130
|
-
bokeh_models.Button.new(label: "Display mode: title", button_type: "default").tap do |button|
|
131
|
+
@display_title_mode_toggle ||= bokeh_models.Button.new(label: "Display mode: title", button_type: "default").tap do |button|
|
131
132
|
button.js_on_click(custom_js("toggleDisplayTitleMode"))
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
136
|
def re_layout_button
|
136
|
-
bokeh_models.Button.new(label: "Re-Layout", button_type: "default").tap do |button|
|
137
|
+
@re_layout_button ||= bokeh_models.Button.new(label: "Re-Layout", button_type: "default").tap do |button|
|
137
138
|
button.js_on_click(custom_js("reLayout"))
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
141
142
|
def zoom_in_button
|
142
|
-
bokeh_models.Button.new(label: "Zoom In", button_type: "primary").tap do |button|
|
143
|
+
@zoom_in_button ||= bokeh_models.Button.new(label: "Zoom In", button_type: "primary").tap do |button|
|
143
144
|
button.js_on_click(custom_js("zoomIn",))
|
144
145
|
end
|
145
146
|
end
|
146
147
|
|
147
148
|
def zoom_out_button
|
148
|
-
bokeh_models.Button.new(label: "Zoom Out", button_type: "success").tap do |button|
|
149
|
+
@zoom_out_button ||= bokeh_models.Button.new(label: "Zoom Out", button_type: "success").tap do |button|
|
149
150
|
button.js_on_click(custom_js("zoomOut"))
|
150
151
|
end
|
151
152
|
end
|
152
153
|
|
153
154
|
def re_compute_button
|
154
|
-
bokeh_models.Button.new(label: "Re-Compute", button_type: "default").tap do |button|
|
155
|
+
@re_compute_button ||= bokeh_models.Button.new(label: "Re-Compute", button_type: "default").tap do |button|
|
155
156
|
button.js_on_click(
|
156
157
|
bokeh_models.CustomJS.new(
|
157
158
|
args: { button: button },
|
@@ -189,5 +190,9 @@ module ErdMap
|
|
189
190
|
)
|
190
191
|
end
|
191
192
|
end
|
193
|
+
|
194
|
+
Header::ACCESSIBLE_PARTS.each do |name|
|
195
|
+
public define_method(name) { @header.__send__(name) }
|
196
|
+
end
|
192
197
|
end
|
193
198
|
end
|
data/lib/erd_map/version.rb
CHANGED