From b05b42314a0f626cb1090392f4ae1e745015315e Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 9 May 2018 19:52:43 +0200 Subject: [PATCH] Added client-side validation + not ignore error messages from the api --- public/js/index.js | 13 ++++++++++++- templates/repo/issue/view_content/sidebar.tmpl | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/public/js/index.js b/public/js/index.js index eca9aef47..c51a12e33 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2255,10 +2255,17 @@ function setDeadline() { } function updateDeadline(deadlineString) { + $('#deadline-err-invalid-date').hide(); $('#deadline-loader').addClass('loading'); var realDeadline = null; if (deadlineString !== '') { + var dateToMatch = /([0-9]){4}-([0-9]){2}-([0-9]){2}\b/ + if (!dateToMatch.test(deadlineString)) { + $('#deadline-loader').removeClass('loading'); + $('#deadline-err-invalid-date').show(); + return false; + } realDeadline = deadlineString + 'T13:55:29.764Z'; } @@ -2268,8 +2275,12 @@ function updateDeadline(deadlineString) { }), contentType: 'application/json', type: 'POST', - complete: function () { + success: function () { window.location.reload(); + }, + error: function () { + $('#deadline-loader').removeClass('loading'); + $('#deadline-err-invalid-date').show(); } }); } diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 2375fc208..a3f56aa29 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -212,6 +212,10 @@
{{.i18n.Tr "repo.issues.due_date"}}
+ {{if gt .Issue.DeadlineUnix 0}}