aboutsummaryrefslogtreecommitdiff
path: root/templates/repo
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-03-13 05:26:17 -0400
committerUnknwon <u@gogs.io>2017-03-13 05:26:17 -0400
commit24734a33e72dbdc1da4f7341cb2cf62521ce53f8 (patch)
tree08bf90a3a5a3273336d633db33c39c9a56a3fcf2 /templates/repo
parent1df54ea0cde038e2057d083078f952c072d0dc67 (diff)
release: improve attachment handle
Diffstat (limited to 'templates/repo')
-rw-r--r--templates/repo/release/new.tmpl46
1 files changed, 28 insertions, 18 deletions
diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl
index 09b7a9f8..5530bd79 100644
--- a/templates/repo/release/new.tmpl
+++ b/templates/repo/release/new.tmpl
@@ -48,22 +48,23 @@
<label>{{.i18n.Tr "repo.release.content"}}</label>
<textarea name="content">{{.content}}</textarea>
</div>
- {{if .attachments}}
- <table class="ui table">
- <thead></thead>
- <tbody>
- {{range .attachments}}
- <tr>
- <td>
- <a target="_blank" href="{{AppSubUrl}}/attachments/{{.UUID}}" rel="nofollow">{{.Name}}</a>
- <a class="ui text red right delete-attachment-button" href="#"><i class="octicon octicon-x" data-uuid="{{.UUID}}"></i></a>
- <input name="files" type="hidden" value="{{.UUID}}">
- </td>
- </tr>
- {{end}}
- </tbody>
- </table>
- {{end}}
+ <div class="field">
+ {{if .attachments}}
+ <table class="ui table">
+ <tbody>
+ {{range .attachments}}
+ <tr>
+ <td>
+ <a target="_blank" href="{{AppSubUrl}}/attachments/{{.UUID}}" rel="nofollow">{{.Name}}</a>
+ <a class="ui text red right delete-attachment-button" href="#"><i class="octicon octicon-x" data-uuid="{{.UUID}}"></i></a>
+ <input name="files" type="hidden" value="{{.UUID}}">
+ </td>
+ </tr>
+ {{end}}
+ </tbody>
+ </table>
+ {{end}}
+ </div>
{{if .IsAttachmentEnabled}}
<div class="files"></div>
<div class="ui basic button dropzone" id="dropzone" data-upload-url="{{AppSubUrl}}/releases/attachments" data-accepts="{{.AttachmentAllowedTypes}}" data-max-file="{{.AttachmentMaxFiles}}" data-max-size="{{.AttachmentMaxSize}}" data-default-message="{{.i18n.Tr "dropzone.default_message"}}" data-invalid-input-type="{{.i18n.Tr "dropzone.invalid_input_type"}}" data-file-too-big="{{.i18n.Tr "dropzone.file_too_big"}}" data-remove-file="{{.i18n.Tr "dropzone.remove_file"}}"></div>
@@ -122,9 +123,18 @@
{{end}}
<script>
- // Delete attachment field
+ // Delete attachment row
$('.delete-attachment-button').click(function (e) {
- $(this).parentsUntil('tbody').remove();
+ var $row = $(this).parentsUntil('tbody');
+ var $tbody = $row.parentsUntil('table');
+
+ $row.remove();
+
+ // Remove the entire table if this was the last row
+ if ($tbody.children().length == 0) {
+ $tbody.parentsUntil('.field').remove();
+ }
+
e.preventDefault();
})
</script>