diff --git a/public/js/index.js b/public/js/index.js index f1d308457..972f8f30d 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2194,14 +2194,33 @@ function initTopicbar() { }, }); } -function toggleDuedateForm() { - $('#add_deadline_form').fadeToggle(150); +function toggleDeadlineForm() { + $('#deadlineForm').fadeToggle(150); } -function deleteDueDate(url) { - $.post(url, { - '_csrf': csrf, - },function( data ) { - window.location.reload(); +function setDeadline() { + var deadline = $('#deadlineDate').val(); + updateDeadline(deadline); +} + +function updateDeadline(deadlineString) { + var issue_api_url = suburl + '/api/v1/repos/' + $('meta[name=_repo_owner]').attr("content") + '/' + $('meta[name=_repo_name]').attr("content") + '/issues/' + $('meta[name=_issue_index]').attr("content"); + + $('#deadline-loader').addClass('loading'); + + var realDeadline = null; + if (deadlineString !== '') { + realDeadline = deadlineString + 'T13:55:29.764Z'; + } + + $.ajax(issue_api_url + '/deadline', { + data: JSON.stringify({ + 'due_date': realDeadline, + }), + contentType: 'application/json', + type: 'POST', + complete: function () { + window.location.reload(); + } }); } diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index d8214e380..3295d08dd 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -338,7 +338,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { func UpdateIssueDeadline(ctx *context.APIContext, form api.CreateDeadlineOption) { // swagger:operation POST /repos/{owner}/{repo}/issues/{index}/deadline issue issueCreateIssueDeadline // --- - // summary: Set an issue deadline + // summary: Set an issue deadline. If set to null, the deadline is deleted. // consumes: // - application/json // produces: diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index a486d9b9b..14752e265 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -21,6 +21,13 @@ {{if .SearchLimit}} {{end}} + {{with .Repository}} + + + {{end}} + {{with .Issue}} + + {{end}} {{if .GoGetImport}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 648533fca..f6d05598c 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -194,6 +194,7 @@
{{.i18n.Tr "repo.issues.due_date"}} +
{{if gt .Issue.DeadlineUnix 0}}

@@ -203,8 +204,8 @@ {{end}} {{if and .IsSigned .IsRepositoryWriter}}
- Edit - - Remove + Edit - + Remove {{end}}

{{else}} @@ -212,20 +213,17 @@ {{end}} {{if and .IsSigned .IsRepositoryWriter}} -
- {{$.CsrfTokenHtml}} -
- - -
-
+ {{end}} - +