From 1b0b821a0a0a201cf67791d001ab0797ab72f352 Mon Sep 17 00:00:00 2001
From: Robert Goldmann <deadlocker@gmx.de>
Date: Fri, 13 Nov 2020 20:18:06 +0100
Subject: [PATCH] #40 - handle and save roadmap start date

---
 client/blueprints/Roadmaps.py             | 7 ++++++-
 client/static/js/main.js                  | 6 ++++++
 client/templates/admin/roadmaps/edit.html | 9 +++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/client/blueprints/Roadmaps.py b/client/blueprints/Roadmaps.py
index 9887439..d4fd078 100644
--- a/client/blueprints/Roadmaps.py
+++ b/client/blueprints/Roadmaps.py
@@ -40,6 +40,10 @@ def construct_blueprint(urlBuilder):
             return render_template('error.html', message=LOCALIZATION['error_param_invalid'])
 
         _, roadmap = ApiRequest.send_api_request(urlBuilder.build_url('roadmap', ID), requests.get, {}, [])
+
+        if roadmap['StartDate'] == '-':
+            roadmap['StartDate'] = ''
+
         return render_template('admin/roadmaps/edit.html',
                                title='Edit Roadmap',
                                roadmap=roadmap,
@@ -50,7 +54,8 @@ def construct_blueprint(urlBuilder):
     def edit_post():
         success, response = ApiRequest.send_api_request(urlBuilder.build_url('roadmap'),
                                                         requests.put, request.form,
-                                                        [('ID', int), ('Projectname', str), ('Hidden', bool)])
+                                                        [('ID', int), ('Projectname', str),
+                                                         ('Hidden', bool), ('StartDate', str)])
 
         if not success:
             return response
diff --git a/client/static/js/main.js b/client/static/js/main.js
index b75cb0c..5abcee5 100644
--- a/client/static/js/main.js
+++ b/client/static/js/main.js
@@ -148,12 +148,18 @@ function validateLoginForm()
 function validateNewRoadmapForm()
 {
     var projectName = $('#project-name').val();
+    var startDate = document.getElementById('start-date');
 
     if(isNull(projectName))
     {
         alert("Please enter a project name.");
         return false;
     }
+
+    if(isNull(startDate.value))
+    {
+        startDate.value = "01.01.2000";
+    }
 }
 
 function validateNewMilestoneForm()
diff --git a/client/templates/admin/roadmaps/edit.html b/client/templates/admin/roadmaps/edit.html
index 1af9e28..2c832eb 100644
--- a/client/templates/admin/roadmaps/edit.html
+++ b/client/templates/admin/roadmaps/edit.html
@@ -20,6 +20,15 @@
                             </div>
                         </div>
 
+                        <div class="row center-align">
+                            <div class="col s12 m8 offset-m2 l6 offset-l3">
+                                <div class="col s12 left-align">
+                                    <label for="start-date" style="font-size: 1rem;">Due Date</label>
+                                    <input type="text" class="datepicker" id="start-date" name="StartDate" value="{% if roadmap %}{{ roadmap["StartDate"] }}{% endif %}">
+                                </div>
+                            </div>
+                        </div>
+
                         <div class="col s12 m8 offset-m2 l6 offset-l3">
                             <div class="input-field col s12">
                                 <p>
-- 
GitLab