Browse Source

Prevent empty div when editing comment (#12404)

* Prevent empty div when editing comment

The template for attachments needs to remove whitespace and return empty when there are no attachments.

Fix #10220
for-closed-social
zeripath 4 years ago
committed by GitHub
parent
commit
33391e04fe
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions
  1. +3
    -3
      routers/repo/issue.go
  2. +2
    -2
      templates/repo/issue/view_content/attachments.tmpl

+ 3
- 3
routers/repo/issue.go View File

@ -1975,7 +1975,7 @@ func updateAttachments(item interface{}, files []string) error {
case *models.Comment: case *models.Comment:
attachments = content.Attachments attachments = content.Attachments
default: default:
return fmt.Errorf("Unknow Type")
return fmt.Errorf("Unknown Type: %T", content)
} }
for i := 0; i < len(attachments); i++ { for i := 0; i < len(attachments); i++ {
if util.IsStringInSlice(attachments[i].UUID, files) { if util.IsStringInSlice(attachments[i].UUID, files) {
@ -1993,7 +1993,7 @@ func updateAttachments(item interface{}, files []string) error {
case *models.Comment: case *models.Comment:
err = content.UpdateAttachments(files) err = content.UpdateAttachments(files)
default: default:
return fmt.Errorf("Unknow Type")
return fmt.Errorf("Unknown Type: %T", content)
} }
if err != nil { if err != nil {
return err return err
@ -2005,7 +2005,7 @@ func updateAttachments(item interface{}, files []string) error {
case *models.Comment: case *models.Comment:
content.Attachments, err = models.GetAttachmentsByCommentID(content.ID) content.Attachments, err = models.GetAttachmentsByCommentID(content.ID)
default: default:
return fmt.Errorf("Unknow Type")
return fmt.Errorf("Unknown Type: %T", content)
} }
return err return err
} }

+ 2
- 2
templates/repo/issue/view_content/attachments.tmpl View File

@ -1,4 +1,4 @@
{{range .Attachments}}
{{- range .Attachments -}}
<div class="twelve wide column" style="padding: 6px;"> <div class="twelve wide column" style="padding: 6px;">
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'> <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
{{if FilenameIsImage .Name}} {{if FilenameIsImage .Name}}
@ -12,4 +12,4 @@
<div class="four wide column" style="padding: 0px;"> <div class="four wide column" style="padding: 0px;">
<span class="ui text grey right">{{.Size | FileSize}}</span> <span class="ui text grey right">{{.Size | FileSize}}</span>
</div> </div>
{{end}}
{{end -}}

Loading…
Cancel
Save