diff options
author | blueworrybear <blueworrybear@gmail.com> | 2019-10-15 20:19:32 +0800 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-10-15 13:19:32 +0100 |
commit | 8c909820a9fd1697bb690ec0451c4ead97b51505 (patch) | |
tree | bda76eca8361237fbd5bc59bda58b278a516ffd6 /templates | |
parent | d7d348ea86bd8066aeb079ad121120095d5cba4d (diff) | |
download | gitea-8c909820a9fd1697bb690ec0451c4ead97b51505.tar.gz gitea-8c909820a9fd1697bb690ec0451c4ead97b51505.zip |
Enable Uploading/Removing Attachments When Editing an Issue/Comment (#8426)
Diffstat (limited to 'templates')
-rw-r--r-- | templates/repo/issue/view_content.tmpl | 25 | ||||
-rw-r--r-- | templates/repo/issue/view_content/attachments.tmpl | 9 | ||||
-rw-r--r-- | templates/repo/issue/view_content/comments.tmpl | 12 |
3 files changed, 26 insertions, 20 deletions
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index acabe34782..29d48d7089 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -46,7 +46,7 @@ {{end}} </div> <div class="raw-content hide">{{.Issue.Content}}</div> - <div class="edit-content-zone hide" data-write="issue-{{.Issue.ID}}-write" data-preview="issue-{{.Issue.ID}}-preview" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}"></div> + <div class="edit-content-zone hide" data-write="issue-{{.Issue.ID}}-write" data-preview="issue-{{.Issue.ID}}-preview" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div> </div> {{$reactions := .Issue.Reactions.GroupByType}} {{if $reactions}} @@ -57,15 +57,7 @@ {{if .Issue.Attachments}} <div class="ui bottom attached segment"> <div class="ui small images"> - {{range .Issue.Attachments}} - <a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}"> - {{if FilenameIsImage .Name}} - <img class="ui image" src="{{AppSubUrl}}/attachments/{{.UUID}}" title='{{$.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'> - {{else}} - <span class="ui image octicon octicon-desktop-download" title='{{$.i18n.Tr "repo.issues.attachment.download" .Name}}'></span> - {{end}} - </a> - {{end}} + {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}} </div> </div> {{end}} @@ -182,6 +174,19 @@ <div class="ui bottom attached tab preview segment markdown"> {{$.i18n.Tr "loading"}} </div> + {{if .IsAttachmentEnabled}} + <div class="comment-files"></div> + <div class="ui basic button dropzone" id="comment-dropzone" + data-upload-url="{{AppSubUrl}}/attachments" + data-remove-url="{{AppSubUrl}}/attachments/delete" + data-csrf="{{.CsrfToken}}" 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> + {{end}} <div class="text right edit buttons"> <div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div> <div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div> diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl new file mode 100644 index 0000000000..e2d7d1b9de --- /dev/null +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -0,0 +1,9 @@ +{{range .Attachments}} + <a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}"> + {{if FilenameIsImage .Name}} + <img class="ui image" src="{{AppSubUrl}}/attachments/{{.UUID}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'> + {{else}} + <span class="ui image octicon octicon-desktop-download" title='{{$.ctx.i18n.Tr "repo.issues.attachment.download" .Name}}'></span> + {{end}} + </a> +{{end}}
\ No newline at end of file diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index a5f25954c7..e3ea9ba822 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -55,7 +55,7 @@ {{end}} </div> <div class="raw-content hide">{{.Content}}</div> - <div class="edit-content-zone hide" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}"></div> + <div class="edit-content-zone hide" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> </div> {{$reactions := .Reactions.GroupByType}} {{if $reactions}} @@ -66,15 +66,7 @@ {{if .Attachments}} <div class="ui bottom attached segment"> <div class="ui small images"> - {{range .Attachments}} - <a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}"> - {{if FilenameIsImage .Name}} - <img class="ui image" src="{{AppSubUrl}}/attachments/{{.UUID}}" title='{{$.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'> - {{else}} - <span class="ui image octicon octicon-desktop-download" title='{{$.i18n.Tr "repo.issues.attachment.download" .Name}}'></span> - {{end}} - </a> - {{end}} + {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments}} </div> </div> {{end}} |