Commit 393ef83e authored by dm141569's avatar dm141569 Committed by BZ

Prepare form for new Meetup

parent 2906d82b
......@@ -10,7 +10,7 @@ use DB;
/**
* Bug? Es wird die Version 5 verwendet, ist noch in Entwicklung
* Die Querys, in denen gleich die Teilnehmer mit abgerufen werden, funktionieren.
* Es ist aber nicht möglich diese als JSON zurück zu geben.
* Es ist aber nicht möglich diese als JSON zurück zu geben.
* Deshalb Workaround: Eigene Funktion = +1 Requests
*/
class HomeController extends Controller {
......@@ -30,16 +30,16 @@ class HomeController extends Controller {
* @Get("/")
*/
public function index()
{
{
// $events = DB::table('events')->get();
$events = Event::orderBy('time', 'asc')
->get()
->groupBy('date');
return Response::json($events);
}
/**
* Get event by id
*
......@@ -48,12 +48,12 @@ class HomeController extends Controller {
public function show($id)
{
// funkt nicht, WHY?: Event::with('participants')...
// $event = DB::table('events')->find($id);
// $event = DB::table('events')->find($id);
$event = Event::find($id);
return Response::json($event);
}
/**
* Workaround, Get participants by event id
*
......@@ -62,12 +62,12 @@ class HomeController extends Controller {
public function participants($id) {
$ps = DB::table('participants')
->where('event_id', $id)
->get();
// funkt nicht, WHY?: $ps = Participant::find($id);
->get();
// funkt nicht, WHY?: $ps = Participant::find($id);
return Response::json($ps);
}
/**
* Add new event
*
......@@ -75,7 +75,7 @@ class HomeController extends Controller {
*/
public function create()
{
$success = DB::table('events')->insert([
/* $success = DB::table('events')->insert([
'name' => 'Bernhard',
'contact' => 'mt111073@fhstp.ac.at',
'sport' => 'Laufen',
......@@ -85,14 +85,14 @@ class HomeController extends Controller {
'updated_at' => '1413543572',
'created_at' => '1413543572'
]);
if ($success) {
return true;
} else {
return false;
}
} */
}
/**
* Attend to an event
*
......@@ -107,7 +107,7 @@ class HomeController extends Controller {
'updated_at' => '',
'created_at' => ''
]);
if ($success) {
return true;
} else {
......
html, body {
}
#attend {
#details {
display: none;
}
......@@ -7,38 +7,62 @@ SPORTMEETUPFH.Main = (function() {
/** Private */
var data = null;
var data = null;
var currentEvent = null;
/**
* Create a new meetup
*/
function createMeetup() {
// Validierung findet mit HTML5 statt, müsste eigentlich auch noch spearat mit JS und am Backend stattfinden, aus Zeitgründen wird das weggelassen.
$.post('/1', {
name: $('#name').val(),
contact: $('#contact').val(),
sport: $('#sport').val(),
date: $('#date').val(),
time: $('#time').val()
});
return false;
}
/**
* Details for a Meetup
* and possibility to attent
*/
function attend() {
var currentEvent = data[ $(this).data('event-date') ][ $(this).data('event-array-id') ];
function details() {
currentEvent = data[ $(this).data('meetup-date') ][ $(this).data('meetup-array-id') ];
var header = $(document.createElement('header'));
var h1 = $(document.createElement('h1'));
console.debug(currentEvent);
$('.sport').text(currentEvent.sport);
$('.name').text(currentEvent.name);
$('.date').text(currentEvent.date);
$('.time').text(currentEvent.time);
$('.meeting-place').text(currentEvent.meeting_place);
$('#events').fadeOut('slow', function() {
$('#attend').fadeIn('slow');
$('#meetups').fadeOut('slow', function() {
$('#details').fadeIn('slow');
});
return false;
}
/**
* Back Button for attend view
* Attend button
*/
function btnAttend() {
console.debug(currentEvent);
}
/**
* Back button for attend view
*/
function backButton(e) {
$('#attend').fadeOut('slow', function() {
$('#events').fadeIn('slow');
function btnBack() {
$('#details').fadeOut('slow', function() {
$('#meetups').fadeIn('slow');
});
return false;
......@@ -66,20 +90,23 @@ SPORTMEETUPFH.Main = (function() {
header.append(h1);
section.append(header);
$('#events').append(section);
$('#meetups').append(section);
$.each(value, function(k, v) {
var div = $(document.createElement('div'));
$(div).data('event-array-id', k);
$(div).data('event-date', v.date);
$(div).data('meetup-array-id', k);
$(div).data('meetup-date', v.date);
$(div).append(v.name);
$(div).append(v.sport);
$(div).append(v.time);
$(div).bind('click', attend);
$(div).bind('click', details);
$(section).append(div);
$(section)
.append(div)
.hide()
.slideDown();
});
});
......@@ -93,7 +120,9 @@ SPORTMEETUPFH.Main = (function() {
* Setup up event listeners
*/
initListeners: function() {
$('#back').bind('click', backButton);
$('#create').submit(createMeetup);
$('#btn-attend').bind('click', btnAttend);
$('#btn-back').bind('click', btnBack);
}
}
}());
......
......@@ -10,19 +10,49 @@
</head>
<body>
<header>
SportMeetupFH
Sportmeetup FH, Mobile Forschungsgruppe macht Mobil, bei Arbeit, Sport und Spiel... HAHA WITZIG
</header>
<main role="main">
<section id="events">
</section>
<article id="meetups">
<section id="create-meetup">
<form id="create" method="post" action="/">
<fieldset>
<legend>Sportmeetup erstellen</legend>
<section id="attend" data-to="0">
<label for="name">Dein Name:</label>
<input type="text" name="name" id="name" placeholder="Name eingeben" required="required" />
<label for="contact">Kontaktdaten:</label>
<input type="text" name="contact" id="contact" placeholder="E-Mail, Telefon,..." required="required"/>
<label for="sport">Sportart:</label>
<input type="text" name="sport" id="sport" placeholder="Sportart eintragen" required="required"/>
<label for="date">Datum:</label>
<input type="date" name="date" id="date" placeholder="An welchem Tag soll das stattfinden?" required="required"/>
<label for="time">Zeit:</label>
<input type="time" name="time" id="time" placeholder="zu welcher Uhrzeit?" required="required"/>
<label for="meetup-place">Treffpunkt:</label>
<input type="text" name="meetup-place" id="meetup-place" placeholder="Wo trefft ihr euch?" required="required"/>
<label for="notes">Notizen:</label>
<input type="text" name="notes" id="notes" placeholder="Sonstige Bemerkungen" />
<input type="submit" name="submit-create" id="submit-create" value="Erstellen"/>
</fieldset>
</form>
</section>
</article>
<aside id="details">
<header>
<h1></h1>
</header>
<div class="content">
<div id="content">
Sport: <span class="sport"></span>
Meetup erstellt von <span class="name"></span>
Treffpunkt um am <span class="date"></span> um <span class="time"></span> Uhr.
......@@ -30,10 +60,15 @@
Notizen: <span class="notes"></span>
</div>
<div id="attend">
Name, Kontaktdaten
<button id="btn-attend">Mitmachen</button>
</div>
<footer>
<a href="/" title="Back" id="back">&lt; Zurück</a>
<a href="/" title="Back" id="btn-back">&lt; Zurück</a>
</footer>
</section>
</aside>
</main>
<footer>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment