Fix some comment UI rendering bugs

This commit is contained in:
Jonas Franz 2018-07-06 17:02:01 +02:00
parent fbaeb02b2d
commit 5dd39d3bca
No known key found for this signature in database
GPG Key ID: 506AEEBE80BEDECD
3 changed files with 35 additions and 10 deletions

View File

@ -67,6 +67,14 @@ func (d *DiffLine) GetType() int {
return int(d.Type)
}
// GetCommentSide returns the comment side of the first comment, if not set returns empty string
func (d *DiffLine) GetCommentSide() string {
if len(d.Comments) == 0 {
return ""
}
return d.Comments[0].DiffSide()
}
// DiffSection represents a section of a DiffFile.
type DiffSection struct {
Name string

View File

@ -123,16 +123,32 @@
</td>
</tr>
{{if gt (len $line.Comments) 0}}
<tr>
<td colspan="4" class="add-comment-left add-comment-right">
<div class="field comment-code-cloud">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
</ui>
</div>
<tr class="add-code-comment">
<td class="lines-num"></td>
<td class="add-comment-left">
{{if eq $line.GetCommentSide "previous"}}
<div class="field comment-code-cloud">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
</ui>
</div>
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $ "comment" (index $line.Comments 0)}}
</div>
</div>
{{end}}
</td>
<td class="lines-num"></td>
<td class="add-comment-right">
{{if eq $line.GetCommentSide "proposed"}}
<div class="field comment-code-cloud">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
</ui>
</div>
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $ "comment" (index $line.Comments 0)}}
</div>
{{end}}
</td>
</tr>
{{end}}

View File

@ -24,7 +24,8 @@
</tr>
{{if gt (len $line.Comments) 0}}
<tr>
<td colspan="4" class="add-comment-left add-comment-right">
<td colspan="2" class="lines-num"></td>
<td class="add-comment-left add-comment-right">
<div class="field comment-code-cloud">
<div class="comment-list">
<ui class="ui comments">