Commit 188e6a7a3fba5ca3705d6e0c5ab09b3cf89700a3

Authored by Dmitriy Zaporozhets
2 parents c918000b b49c1cb1

Merge pull request #3369 from hiroponz/display-note-count

Display note count on network graph.
app/assets/javascripts/branch-graph.js.coffee
... ... @@ -131,7 +131,7 @@ class BranchGraph
131 131 shortrefs = refs
132 132 # Truncate if longer than 15 chars
133 133 shortrefs = shortrefs.substr(0, 15) + "…" if shortrefs.length > 17
134   - text = r.text(x + 8, y, shortrefs).attr(
  134 + text = r.text(x + 4, y, shortrefs).attr(
135 135 "text-anchor": "start"
136 136 font: "10px Monaco, monospace"
137 137 fill: "#FFF"
... ... @@ -139,7 +139,7 @@ class BranchGraph
139 139 )
140 140 textbox = text.getBBox()
141 141 # Create rectangle based on the size of the textbox
142   - rect = r.rect(x, y - 7, textbox.width + 15, textbox.height + 5, 4).attr(
  142 + rect = r.rect(x, y - 7, textbox.width + 5, textbox.height + 5, 4).attr(
143 143 fill: "#000"
144 144 "fill-opacity": .5
145 145 stroke: "none"
... ... @@ -206,22 +206,19 @@ class BranchGraph
206 206  
207 207 # Build line shape
208 208 if parent[1] is commit.space
209   - d1 = [0, 5]
210   - d2 = [0, 10]
211   - arrow = "l-2,5,4,0,-2,-5"
  209 + offset = [0, 5]
  210 + arrow = "l-2,5,4,0,-2,-5,0,5"
212 211  
213 212 else if parent[1] < commit.space
214   - d1 = [3, 3]
215   - d2 = [7, 5]
216   - arrow = "l5,0,-2,4,-3,-4"
  213 + offset = [3, 3]
  214 + arrow = "l5,0,-2,4,-3,-4,4,2"
217 215  
218 216 else
219   - d1 = [-3, 3]
220   - d2 = [-7, 5]
221   - arrow = "l-5,0,2,4,3,-4"
  217 + offset = [-3, 3]
  218 + arrow = "l-5,0,2,4,3,-4,-4,2"
222 219  
223 220 # Start point
224   - route = ["M", x + d1[0], y + d1[1]]
  221 + route = ["M", x + offset[0], y + offset[1]]
225 222  
226 223 # Add arrow if not first parent
227 224 if i > 0
... ... @@ -230,7 +227,6 @@ class BranchGraph
230 227 # Circumvent if overlap
231 228 if commit.space isnt parentCommit.space or commit.space isnt parent[1]
232 229 route.push(
233   - "L", x + d2[0], y + d2[1],
234 230 "L", parentX2, y + 10,
235 231 "L", parentX2, parentY - 5,
236 232 )
... ...
app/helpers/graph_helper.rb
1 1 module GraphHelper
2   - def join_with_space(ary)
3   - ary.collect{|r|r.name}.join(" ") unless ary.nil?
  2 + def get_refs(commit)
  3 + refs = ""
  4 + refs += commit.refs.collect{|r|r.name}.join(" ") if commit.refs
  5 +
  6 + # append note count
  7 + notes = @project.notes.for_commit_id(commit.id)
  8 + refs += "[#{notes.count}]" if notes.any?
  9 +
  10 + refs
4 11 end
5 12  
6 13 def parents_zip_spaces(parents, parent_spaces)
... ...
app/views/graph/show.json.erb
... ... @@ -13,7 +13,7 @@
13 13 },
14 14 time: c.time,
15 15 space: c.spaces.first,
16   - refs: join_with_space(c.refs),
  16 + refs: get_refs(c),
17 17 id: c.sha,
18 18 date: c.date,
19 19 message: c.message,
... ...