Commit ab3b3c2b authored by dm141569's avatar dm141569 Committed by BZ

Add Post Method for Attend, Create AJAX call for participants

parent 874911ed
......@@ -59,7 +59,7 @@ class HomeController extends Controller {
/**
* Workaround, Get participants by event id
*
* @Get("{id}/ps")
* @Get("/{id}/ps")
*/
public function participants($id) {
$ps = DB::table('participants')
......@@ -100,20 +100,20 @@ class HomeController extends Controller {
*
* @Post("/{id}")
*/
public function attend($id)
public function attend(Request $request, $id)
{
$success = DB::table('participants')->insert([
'event_id' => $id,
'name' => 'Teilnehmer 1',
'contact' => 'mt222222@fhstp.ac.at',
'updated_at' => '',
'created_at' => ''
'name' => $request->get('name'),
'contact' => $request->get('contact'),
'updated_at' => time(),
'created_at' => time()
]);
if ($success) {
return true;
return 'true';
} else {
return false;
return 'false';
}
}
......
......@@ -70,7 +70,7 @@ SPORTMEETUPFH.Main = (function() {
});
$('#create')
.find("input[type=text], textarea")
.find('input[type=text], textarea')
.val('');
$('#meetups').empty(); // Quick and Dirty Solution
......@@ -87,6 +87,10 @@ SPORTMEETUPFH.Main = (function() {
function details() {
currentEvent = data[ $(this).data('meetup-date') ][ $(this).data('meetup-array-id') ];
$.get('/' + currentEvent.id + '/ps', function(d) {
console.debug(d);
});
var header = $(document.createElement('header'));
var h1 = $(document.createElement('h1'));
......@@ -96,6 +100,7 @@ SPORTMEETUPFH.Main = (function() {
$('.time').text(currentEvent.time);
$('.meeting-place').text(currentEvent.meeting_place);
$('#create-meetup').fadeOut('slow');
$('#meetups').fadeOut('slow', function() {
$('#details').fadeIn('slow');
});
......@@ -104,10 +109,28 @@ SPORTMEETUPFH.Main = (function() {
}
/**
* Attend button
* Attend to a meetup
*/
function btnAttend() {
console.debug(currentEvent);
function attendMeetup() {
console.debug('attending...');
console.debug(currentEvent.id);
$.post('/' + currentEvent.id, {
_token: $('#_a-token').val(),
id: currentEvent.id,
name: $('#a-name').val(),
contact: $('#a-contact').val()
});
$('#attend').fadeOut();
// @todo SUCCESS MESSAGE
$('#attend')
.find('input[type=text], textarea')
.val('');
return false;
}
/**
......@@ -115,7 +138,9 @@ SPORTMEETUPFH.Main = (function() {
*/
function btnBack() {
$('#details').fadeOut('slow', function() {
$('#create-meetup').fadeIn('slow');
$('#meetups').fadeIn('slow');
$('#attend').show();
});
return false;
......@@ -139,7 +164,7 @@ SPORTMEETUPFH.Main = (function() {
*/
initListeners: function() {
$('#create').submit(createMeetup);
$('#btn-attend').bind('click', btnAttend);
$('#attend').submit(attendMeetup);
$('#btn-back').bind('click', btnBack);
}
}
......
......@@ -63,9 +63,22 @@
Notizen: <span class="notes"></span>
</div>
<div id="attend">
Name, Kontaktdaten
<button id="btn-attend">Mitmachen</button>
<div id="attend-meetup">
<form id="attend" method="post" action="/">
<fieldset>
<legend>Sportmeetup erstellen</legend>
<input type="hidden" name="_a-token" id="_a-token" value="<?php echo csrf_token(); ?>" />
<label for="a-name">Dein Name:</label>
<input type="text" name="a-name" id="a-name" placeholder="Name eingeben" required="required" />
<label for="a-contact">Kontaktdaten:</label>
<input type="text" name="a-contact" id="a-contact" placeholder="E-Mail, Telefon,..." required="required"/>
<input type="submit" name="submit-attend" id="submit-attend" value="Mitmachen!"/>
</fieldset>
</form>
</div>
<footer>
......
No preview for this file type
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