From 14c8a0ae8c39eab726c3b95938b77b40264571f0 Mon Sep 17 00:00:00 2001
From: Lukas Gygi <Lukas Gygi>
Date: Sat, 23 Apr 2016 22:35:46 +0200
Subject: [PATCH] changes to eventstool

---
 admin/tools/events.tool | 200 ++++++++++++++++++++++------------------
 1 file changed, 109 insertions(+), 91 deletions(-)

diff --git a/admin/tools/events.tool b/admin/tools/events.tool
index cd7b69e..d1c6011 100644
--- a/admin/tools/events.tool
+++ b/admin/tools/events.tool
@@ -1,4 +1,4 @@
-<div class="users-table-wrapper">
+<div class="events-table-wrapper">
   <div class="tools-full-height">
     <table class="table table-hover events-table" id="events-table">
       <thead>
@@ -44,7 +44,7 @@
 
 <!-- modal for creating new events-->
 
-<div class="modal show" id="new-event-modal" role="dialog">
+<div class="modal fade" id="new-event-modal" role="dialog">
   <div class="modal-dialog">
     <div class="modal-content">
       <div class="modal-header">
@@ -52,95 +52,99 @@
         <h4 class="modal-title">Create new Event</h4>
       </div>
       <div class="modal-body">
-        <div class="form-group">
-          <label for="title_de">Title</label>
-          <input type="text" class="form-control" id="title_de"></input>
-        </div>
-        <div class="form-group">
-          <label for="description_de">Description</label>
-          <textarea type="text" class="form-control" rows="3" id="description_de"></textarea>
-        </div>
-        <div class="form-group">
-          <label for="catchphrase_de">Catchphrase</label>
-          <input type="text" class="form-control" id="catchphrase_de"></input>
-        </div>
-
-        <div class="form-group">
-          <label for="time_start">Start Time</label>
-          <input type="datetime" class="form-control" id="time_start"></input>
-        </div>
-        <div class="form-group">
-          <label for="time_end">End Time</label>
-          <input type="datetime" class="form-control" id="time_end"></input>
-        </div>
-
-        <label class="checkbox-inline">
-          <input type="checkbox" id="signup-required" value="">No Signup
-        </label>
-        <label class="checkbox-inline">
-          <input type="checkbox" id="no-signup-limit" value="">No Signup Limit
-        </label>
-
-        <div class="form-group">
-          <label for="spots">Spots</label>
-          <input type="number" class="form-control" id="spots"></input>
-        </div>
-
-        <label class="checkbox-inline">
-          <input type="checkbox" id="allow_email_signup" value="">Only amiv Members
-        </label>
-
-        <div class="form-group">
-          <label for="time_register_start">Start of Registration</label>
-          <input type="datetime" class="form-control" id="time_register_start"></input>
-        </div>
-        <div class="form-group">
-          <label for="time_register_end">End of Registration</label>
-          <input type="datetime" class="form-control" id="time_register_end"></input>
-        </div>
-
-        <div class="form-group">
-          <label for="location">Location</label>
-          <input type="text" class="form-control" id="location"></input>
-        </div>
-
-        <div class="form-group">
-          <label for="price">Price</label>
-          <input type="text" class="form-control" id="price"></input>
-        </div>
-
-        <div>
-          <label class="checkbox-inline">
-            <input type="checkbox" id="show_website" value="">Show on Webstite (requires banner image and title)
-          </label>
-        </div>
-        <div>
+        <form id="new-event">
+          <div class="form-group">
+            <label for="title_de">Title</label>
+            <input type="text" class="form-control" id="title_de"></input>
+          </div>
+          <div class="form-group">
+            <label for="description_de">Description</label>
+            <textarea type="text" class="form-control" rows="3" id="description_de"></textarea>
+          </div>
+          <div class="form-group">
+            <label for="catchphrase_de">Catchphrase</label>
+            <input type="text" class="form-control" id="catchphrase_de"></input>
+          </div>
+
+          <div class="form-group">
+            <label for="time_start">Start Time</label>
+            <input type="datetime" class="form-control" id="time_start"></input>
+          </div>
+          <div class="form-group">
+            <label for="time_end">End Time</label>
+            <input type="datetime" class="form-control" id="time_end"></input>
+          </div>
+
+            <label class="checkbox-inline">
+              <input type="checkbox" id="signup-required" value="">No Signup
+            </label>
+
           <label class="checkbox-inline">
-            <input type="checkbox" id="show_infoscreen" value="">Show ond Infoscreen (requires infoscreen image)
+            <input type="checkbox" id="no-signup-limit" value="">No Signup Limit
           </label>
-        </div>
-        <div>
+
+          <div class="form-group">
+            <label for="spots">Spots</label>
+            <input type="number" class="form-control" id="spots"></input>
+          </div>
+
           <label class="checkbox-inline">
-            <input type="checkbox" id="show announce" value="">Show in Announce (requires stuff)
+            <input type="checkbox" id="allow_email_signup" value="">Only amiv Members
           </label>
-        </div>
 
-        <button type="button" class"btn" data-toggle="collapse" data-target="#english-collapse">show english fields</button>
-
-        <div id="english-collapse" class="collapse">
           <div class="form-group">
-            <label for="title_en">Title english</label>
-            <input type="text" class="form-control" id="title_en"></input>
+            <label for="time_register_start">Start of Registration</label>
+            <input type="datetime" class="form-control" id="time_register_start"></input>
+          </div>
+          <div class="form-group">
+            <label for="time_register_end">End of Registration</label>
+            <input type="datetime" class="form-control" id="time_register_end"></input>
           </div>
+
           <div class="form-group">
-            <label for="description_en">Description english</label>
-            <textarea type="text" class="form-control" rows="3" id="description_en"></textarea>
+            <label for="location">Location</label>
+            <input type="text" class="form-control" id="location"></input>
           </div>
+
           <div class="form-group">
-            <label for="catchphrase_en">Catchphrase english</label>
-            <input type="text" class="form-control" id="catchphrase_en"></input>
+            <label for="price">Price</label>
+            <input type="number" class="form-control" id="price"></input>
+          </div>
+
+          <div>
+            <label class="checkbox-inline">
+              <input type="checkbox" id="show_website" value="">Show on Webstite (requires banner image and title)
+            </label>
+          </div>
+          <div>
+            <label class="checkbox-inline">
+              <input type="checkbox" id="show_infoscreen" value="">Show ond Infoscreen (requires infoscreen image)
+            </label>
           </div>
-        </div>
+          <div>
+            <label class="checkbox-inline">
+              <input type="checkbox" id="show announce" value="">Show in Announce (requires stuff)
+            </label>
+          </div>
+
+          <button type="button" class"btn" data-toggle="collapse" data-target="#english-collapse">show english fields</button>
+
+          <div name="english-collapse" class="collapse">
+            <div class="form-group">
+              <label for="title_en">Title english</label>
+              <input type="text" class="form-control" id="title_en"></input>
+            </div>
+            <div class="form-group">
+              <label for="description_en">Description english</label>
+              <textarea type="text" class="form-control" rows="3" id="description_en"></textarea>
+            </div>
+            <div class="form-group">
+              <label for="catchphrase_en">Catchphrase english</label>
+              <input type="text" class="form-control" id="catchphrase_en"></input>
+            </div>
+          </div>
+          <!-- <input type="submit"> -->
+        </form>
       </div>
       <div class="modal-footer">
         <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@@ -151,10 +155,14 @@
 </div>
 
 <style>
-.users-table-wrapper {
+.events-table-wrapper {
   position: relative;
 }
-.users-table-wrapper>div {
+.events-table-wrapper>div {
+  overflow: auto;
+}
+
+#new-event-modal {
   overflow: auto;
 }
 
@@ -194,6 +202,8 @@ amivcore.events.GET({
     $('#events-table tbody').append('<tr name="' + ret['_items'][n]['id'] + '"">' + tmp + '</tr>');
   }
 
+
+
   //show modal on click of the table
   $('#events-table tbody tr').click(function(event) {
     var id = $(this).attr('name')
@@ -208,7 +218,6 @@ amivcore.events.GET({
       var temp = '<td>' + field + '</td><td>' + clickedEvent[field] + '</td>';
       $('#event-details-table tbody').append('<tr>' + temp + '</tr>');
     }
-    //var clicked = $.grep(_items, function(e){ return e.id == ; })[];
   });
 
 });
@@ -216,15 +225,24 @@ $('#detail-modal').on("hidden.bs.modal", function(e) {
   $(e.target).removeData("bs.modal").find(".modal-content tbody").empty();
 });
 
+tools.ui.menu({
+  'New Event':{
+    callback: function (){
+      $('#new-event-modal').modal('show');
+    }
+  }
+});
+
 function submitNewEvent(){
   console.log("submitting new event");
-
-  amivcore.events.POST({data:{"allow_email_signup":true, 'title_de':'fuck this shit'}})
+  var newEvent = { data: {}};
+  newEvent["data"]["title_de"] = "test"//$("#title_de").val();
+  // newEvent["data"]["allow_email_signup"] = $(#signup-required).is(':checked');
+  // newEvent["data"]["allow_email_signup"] = $(#signup-required).is(':checked');
+  // newEvent["data"]["spots"] = parseInt(newEvent["data"]["spots"]);
+  //newEvent["data"]["price"] = parseInt(newEvent["data"]["price"]);
+
+  console.log(newEvent);
+  //console.log(amivcore.events.POST({data:{"allow_email_signup":true, 'title_de':'fucking awesome event', 'spots':-1}}));
 }
-
-$(document).ready(function() {
-  //  $('#time_start').datetimepicker({
-  //  locale: 'de'
-  //});
-});
 </script>
-- 
GitLab