Skip to content
Snippets Groups Projects
Commit 1007d29b authored by gingeneer's avatar gingeneer
Browse files

a lot of changes to events tool, added datetimepicker

parent e9578e08
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admintool</title>
<link rel="apple-touch-icon" sizes="57x57" href="res/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="res/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="res/favicon/apple-icon-72x72.png">
......@@ -125,6 +127,10 @@
<script src="lib/amiv/amivcore.js"></script>
<script src="lib/cust/main.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.14.30/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.14.30/css/bootstrap-datetimepicker.css">
</body>
</html>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.14.30/js/bootstrap-datetimepicker.min.js"></script> -->
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.14.30/css/bootstrap-datetimepicker.css"> -->
<div class="events-table-wrapper">
<div class="tools-full-height">
<table class="table table-hover events-table" id="events-table">
......@@ -57,50 +62,83 @@
<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>
<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>
<label class="checkbox-inline">
<input type="checkbox" id="signup-required" value="">No Signup
</label>
<!-- <div class="container"> -->
<!-- <div class="col-md-3"> -->
<div class="form-group">
<label for="time_start">Start Time</label>
<div class="input-group date" id="time_start">
<input type="text" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
<!-- </div> -->
<!-- <div class="col-md-3"> -->
<div class="form-group">
<label for="time_end">End Time</label>
<div class="input-group date" id="time_end">
<input type="text" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
<!-- </div> -->
<!-- </div> -->
<label class="checkbox-inline">
<input type="checkbox" id="no-signup-limit" value="">No Signup Limit
</label>
<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>
<input type="number" class="form-control" min="-1" id="spots"></input>
</div>
<!-- <div class="container"> -->
<!-- <div class="col-md-3"> -->
<div class="form-group">
<label for="time_register_start">Start of Registration</label>
<div class="input-group date" id="time_register_start">
<input type="text" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
<!-- </div> -->
<!-- <div class="col-md-3"> -->
<div class="form-group">
<label for="time_register_end">End of Registration</label>
<div class="input-group date" id="time_register_end">
<input type="text" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
<!-- </div> -->
<!-- </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>
......@@ -108,7 +146,7 @@
<div class="form-group">
<label for="price">Price</label>
<input type="number" class="form-control" id="price"></input>
<input type="number" class="form-control" min="0" id="price"></input>
</div>
<div>
......@@ -123,13 +161,13 @@
</div>
<div>
<label class="checkbox-inline">
<input type="checkbox" id="show announce" value="">Show in Announce (requires stuff)
<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 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>
......@@ -168,17 +206,25 @@
#new-event-modal .checkbox-inline{
margin-bottom: 10px;
}
#new-event-modal .form-left {
margin-right: 5px;
}
#new-event-modal .form-right {
margin-left: 5px;
}
.users-sidebar {
background: #fff;
}
</style>
<script type="text/javascript">
var showInTable = ['title_de', 'time_start', 'show_website', 'spots'];
//var tableTitles = ['Title', 'Date', 'on website', 'spots'];
amivcore.events.GET({
data: {
......@@ -191,9 +237,6 @@ amivcore.events.GET({
return;
}
// tableTitles.forEach(function(i) {
// $('.events-table thead tr').append('<th>' + i + '</th>');
// });
for (var n in ret['_items']) {
var tmp = '';
showInTable.forEach(function(i) {
......@@ -220,7 +263,45 @@ amivcore.events.GET({
}
});
$(function () {
$('#time_start').datetimepicker({
locale: "de"
});
$('#time_end').datetimepicker({
locale: "de",
useCurrent: false //Important! See issue #1075
});
$('#time_register_start').datetimepicker({
locale: "de"
});
$('#time_register_end').datetimepicker({
locale: "de",
useCurrent: false //Important! See issue #1075
});
$("#time_register_start").on("dp.change", function (e) {
$('#time_register_end').data("DateTimePicker").minDate(e.date);
});
$("#time_register_end").on("dp.change", function (e) {
$('#time_register_start').data("DateTimePicker").maxDate(e.date);
});
});
$('#signup-required').click(function(){
$('#no-signup-limit').attr('disabled',this.checked);
$('#spots').attr('disabled',this.checked);
$('#time_register_end>input').attr('disabled',this.checked);
$('#time_register_start>input').attr('disabled',this.checked);
});
$('#no-signup-limit').click(function(){
$('#spots').attr('disabled',this.checked);
});
});
$('#detail-modal').on("hidden.bs.modal", function(e) {
$(e.target).removeData("bs.modal").find(".modal-content tbody").empty();
});
......@@ -233,16 +314,85 @@ tools.ui.menu({
}
});
function submitNewEvent(){
console.log("submitting new event");
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"]);
newEvent["data"]["title_de"] = setNullIfEmpty($("#title_de").val());
newEvent["data"]["description_de"] = setNullIfEmpty($("#description_de").val());
newEvent["data"]["catchphrase_de"] = setNullIfEmpty($("#catchphrase_de").val());
if (!($("#time_start").data("DateTimePicker").date() == null)){
//for now, because the api rejects .toISOString format
newEvent["data"]["time_start"] = $("#time_start").data("DateTimePicker").date().format("YYYY-MM-DDThh:mm:ss") + "Z";
}
if (!($("#time_end").data("DateTimePicker").date() == null)){
//for now, because the api rejects .toISOString format
newEvent["data"]["time_end"] = $("#time_end").data("DateTimePicker").date().format("YYYY-MM-DDThh:mm:ss") + "Z";
}
if (!$("#signup-required").is(":checked")) {
if ($("#no-signup-limit").is(":checked")) {
newEvent["data"]["spots"] = 0;
}
else {
if ($("#spots").val() === ""){
tools.log("Please specify a number of Spots", "e");
return;
}
newEvent["data"]["spots"] = parseInt($("#spots").val());
}
if (!($("#time_register_start").data("DateTimePicker").date() == null)){
//for now, because the api rejects .toISOString format
newEvent["data"]["time_register_start"] = $("#time_register_start").data("DateTimePicker").date().format("YYYY-MM-DDThh:mm:ss") + "Z";
}
else {
tools.log('field "Start of Registration" required', 'e');
return;
}
if (!($("#time_register_end").data("DateTimePicker").date() == null)){
//for now, because the api rejects .toISOString format
newEvent["data"]["time_register_end"] = $("#time_register_end").data("DateTimePicker").date().format("YYYY-MM-DDThh:mm:ss") + "Z";
}
else {
tools.log('field "End of Registration" required', 'e');
return;
}
}
else {
newEvent["data"]["spots"] = -1;
}
newEvent["data"]["allow_email_signup"] = $("#allow_email_signup").is(':checked');
newEvent["data"]["location"] = setNullIfEmpty($("#location").val());
if (!($("#price").val() === "")) {
newEvent["data"]["price"] = Math.floor((parseFloat($("#price").val()) * 100));
}
newEvent["data"]["show_website"] = $("#show_website").is(':checked');
newEvent["data"]["show_infoscreen"] = $("#show_infoscreen").is(':checked');
newEvent["data"]["show_announce"] = $("#show_announce").is(':checked');
newEvent["data"]["title_en"] = setNullIfEmpty($("#title_en").val());
newEvent["data"]["description_en"] = setNullIfEmpty($("#description_en").val());
newEvent["data"]["catchphrase_en"] = setNullIfEmpty($("#catchphrase_en").val());
console.log(newEvent);
//console.log(amivcore.events.POST({data:{"allow_email_signup":true, 'title_de':'fucking awesome event', 'spots':-1}}));
console.log(JSON.stringify(newEvent));
var response = amivcore.events.POST(newEvent);
console.log(response);
}
function setNullIfEmpty(formData){
if (formData === ""){
return null;
}
return formData;
}
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment