summaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-10-11 00:49:59 +0100
committerGitHub <noreply@github.com>2020-10-11 00:49:59 +0100
commit7eb846013299465e4cd73f76f13a00984183146e (patch)
tree0263f6af28d7b3247545fff3632ba94c9119a58e /web_src/js
parent6f2784911fe739d3b83787b7984c1b8a2fb31690 (diff)
downloadgitea-7eb846013299465e4cd73f76f13a00984183146e.tar.gz
gitea-7eb846013299465e4cd73f76f13a00984183146e.zip
Fix attachments list in edit comment (#13036)
#11141 broke the appearance of dropzone attachments when editting comments causing poorly updating lists. This PR fixes this. Fix #12583 Signed-off-by: Andrew Thornton art27@cantab.net
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/index.js34
1 files changed, 21 insertions, 13 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index e4f1575391..e1fd24f37c 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -940,7 +940,7 @@ async function initRepository() {
dz.removeAllFiles(true);
$files.empty();
$.each(data, function () {
- const imgSrc = `${$dropzone.data('upload-url')}/${this.uuid}`;
+ const imgSrc = `${$dropzone.data('link-url')}/${this.uuid}`;
dz.emit('addedfile', this);
dz.emit('thumbnail', this, imgSrc);
dz.emit('complete', this);
@@ -976,7 +976,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();
@@ -990,26 +992,32 @@ 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);
}
- 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(
- '<div class="ui bottom attached segment"><div class="ui small images"></div></div>'
- );
- $content.find('.ui.small.images').html(data.attachments);
+ $content.append(`
+ <div class="dropzone-attachments">
+ <div class="ui clearing divider"></div>
+ <div class="ui middle aligned padded grid">
+ </div>
+ </div>
+ `);
+ $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');
renderMarkdownContent();
});
});