From ef6813abc9277f29515cb571c4c4ddc373482e58 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 16 Jul 2018 14:43:00 +0200 Subject: Issue due date api (#3890) * Implemented basic api endpoint to manage deadlines * Fixed checking for permissions * Updating a deadline from the ui is now entirely done via the api * cleanup * Cosmetics * fixed lint + fmt * Added swagger model definition for deadline response * Updated gitea-sdk * Updated gitea-sdk * More cleanup * Generate swagger json * Merge branch 'master' of https://github.com/go-gitea/gitea into issue-due-date-api # Conflicts: # public/swagger.v1.json * Fixed permission to update a deadline via api * Re-added form to change a deadline * Added client-side validation + not ignore error messages from the api * Added locale for error message * Merge branch 'master' of https://github.com/go-gitea/gitea # Conflicts: # models/issue_comment.go * Proper date validation * Fixed indention * moved css to css file * added documentation for error codes * after merge cleanup * Added swagger description * DO NOTHING BUT TRIGGER THAT F*CKIN CI SO IT PICKS UP THE LATEST COMMIT AS IT SHOULD * DO NOTHING BUT TRIGGER THAT F*CKIN CI SO IT PICKS UP THE LATEST COMMIT AS IT SHOULD * regenerated stylesheets --- public/js/index.js | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index 667f27ce46..21a55d0e44 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2447,14 +2447,44 @@ 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) { + $('#deadline-err-invalid-date').hide(); + $('#deadline-loader').addClass('loading'); + + var realDeadline = null; + if (deadlineString !== '') { + + var newDate = Date.parse(deadlineString) + + if (isNaN(newDate)) { + $('#deadline-loader').removeClass('loading'); + $('#deadline-err-invalid-date').show(); + return false; + } + realDeadline = new Date(newDate); + } + + $.ajax($('#update-issue-deadline-form').attr('action') + '/deadline', { + data: JSON.stringify({ + 'due_date': realDeadline, + }), + contentType: 'application/json', + type: 'POST', + success: function () { + window.location.reload(); + }, + error: function () { + $('#deadline-loader').removeClass('loading'); + $('#deadline-err-invalid-date').show(); + } }); } -- cgit v1.2.3