First interactions with controller using ajax done, nothing functional done yet.

This commit is contained in:
Christian Wolf 2019-06-11 16:36:36 +02:00
parent 404ccf3498
commit 7210dff28c
4 changed files with 119 additions and 2 deletions

View File

@ -0,0 +1,19 @@
<?php
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
// No direct access.
defined('_JEXEC') or die;
class ClubsControllerClubposition extends BaseController
{
public function save()
{
echo new JsonResponse('abc', null, false, true);
// jexit();
}
}

View File

@ -20,6 +20,7 @@
border-style: solid; border-style: solid;
/*visibility: visible;*/ /*visibility: visible;*/
overflow: auto; overflow: auto;
padding: 1em;
} }
#dialog-club > .background { #dialog-club > .background {
@ -37,6 +38,10 @@
display: none; display: none;
} }
.dialog-entry-hidden {
visibility: hidden;
}
.form-disabled { .form-disabled {
overflow: hidden; overflow: hidden;
} }

View File

@ -15,7 +15,6 @@ jQuery(function($){
}); });
function closeDialog() { function closeDialog() {
// console.log('b');
$('#dialog-club > .dialog').html(''); $('#dialog-club > .dialog').html('');
$('body').removeClass('form-disabled'); $('body').removeClass('form-disabled');
$('#dialog-club').addClass('dialog-hidden'); $('#dialog-club').addClass('dialog-hidden');
@ -23,12 +22,30 @@ jQuery(function($){
$(document).on('click', '#clubposition-abort', function(ev){ $(document).on('click', '#clubposition-abort', function(ev){
ev.preventDefault(); ev.preventDefault();
// console.log('a');
closeDialog(); closeDialog();
}); });
$(document).on('change', '#clubposition-state', function(){
if($('#clubposition-state').val() == "vacant")
$('#clubposition-user').addClass('dialog-entry-hidden');
else
$('#clubposition-user').removeClass('dialog-entry-hidden');
});
$(document).on('click', '#clubposition-save', function(ev){ $(document).on('click', '#clubposition-save', function(ev){
ev.preventDefault(); ev.preventDefault();
//alert('Not yet implemented');
var data = $('#clubposition-form').serializeArray();
$.post($('#clubposition-form').attr('action'), data, function(data){
console.log(data)
if(data.success)
{
console.log("all right!");
}
});
}); });
}); });

View File

@ -0,0 +1,76 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
?>
<form id='clubposition-form' method="post" action="<?php echo Route::_('index.php?option=com_clubs&task=clubposition.save&format=json') ?>">
<input type='hidden' name='id' value='<?php echo $this->id; ?>'>
<h1>Posten bearbeiten</h1>
<table>
<tr id='clubposition-user'>
<td>Person: </td>
<td>
<select>
<?php foreach($this->users as $u): ?>
<option value='<?php echo $u->getId();?>'><?php echo $u->getName(); ?> (<?php echo $u->getCity(); ?>)</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td>Funktion: </td>
<td>
<select>
<?php foreach($this->positions as $p): ?>
<option value='<?php echo $p->getId(); ?>'><?php echo $p->getName(); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td>Status</td>
<td>
<select name='state' id='clubposition-state'>
<option value='regular'>regul&auml;r</option>
<option value='temporary'>kommisarisch</option>
<option value='vacant'>vakant</option>
</select>
</td>
</tr>
<tr>
<td>Admin: </td>
<td>
<input type='checkbox' name='admin' value='1'>
</td>
</tr>
<tr>
<td>Adresse (optional): </td>
<td>
<textarea name='address' rows='4'></textarea>
</td>
</tr>
<tr>
<td>E-Mail (optional): </td>
<td>
<input type='text' name='mail'>
</td>
</tr>
<tr>
<td>Telefon-Nr. (optional): </td>
<td>
<input type='text' name='phone'>
</td>
</tr>
</table>
</form>
<a href='#' id='clubposition-save'>Speichern</a>
<a href='#' id='clubposition-abort'>Abbrechen</a>