diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index a61832dd3..cf0c84cfe 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -56,9 +56,11 @@
{{.Issue.Content}}
{{if .Issue.Attachments}} -
-
- {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}} +
+
+
+ {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}} +
{{end}}
diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl index 3c69dbc2b..f42027d79 100644 --- a/templates/repo/issue/view_content/attachments.tmpl +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -2,7 +2,7 @@
{{if FilenameIsImage .Name}} - {{svg "octicon-file-media" 16}} + {{svg "octicon-file" 16}} {{else}} {{svg "octicon-desktop-download" 16}} {{end}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index e52b4979f..87dc49004 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -53,9 +53,11 @@
{{.Content}}
{{if .Attachments}} -
-
- {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments}} +
+
+
+ {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments}} +
{{end}}
diff --git a/web_src/js/index.js b/web_src/js/index.js index 6fe6d3777..a6a840b1a 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -980,7 +980,9 @@ async function initRepository() { $editContentZone.find('.cancel.button').on('click', () => { $renderContent.show(); $editContentZone.hide(); - dz.emit('reload'); + if (dz) { + dz.emit('reload'); + } }); $editContentZone.find('.save.button').on('click', () => { $renderContent.show(); @@ -994,7 +996,7 @@ async function initRepository() { context: $editContentZone.data('context'), files: $attachments }, (data) => { - if (data.length === 0) { + if (data.length === 0 || data.content.length === 0) { $renderContent.html($('#no-content').html()); } else { $renderContent.html(data.content); @@ -1002,21 +1004,27 @@ async function initRepository() { highlight(this); }); } - const $content = $segment.parent(); - if (!$content.find('.ui.small.images').length) { + const $content = $segment; + if (!$content.find('.dropzone-attachments').length) { if (data.attachments !== '') { - $content.append( - '
' - ); - $content.find('.ui.small.images').html(data.attachments); + $content.append(` +
+
+
+
+
+ `); + $content.find('.dropzone-attachments .grid').html(data.attachments); } } else if (data.attachments === '') { - $content.find('.ui.small.images').parent().remove(); + $content.find('.dropzone-attachments').remove(); } else { - $content.find('.ui.small.images').html(data.attachments); + $content.find('.dropzone-attachments .grid').html(data.attachments); + } + if (dz) { + dz.emit('submit'); + dz.emit('reload'); } - dz.emit('submit'); - dz.emit('reload'); }); }); } else {