modifiche siderbar e correzioni
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
<a href="#ruoli" class="list-group-item list-group-item-action" data-toggle="tab">
|
||||
<i class="nav-icon fas fa-users-cog mr-2"></i> Tipi di Ruolo
|
||||
</a>
|
||||
<a href="#tipologie-eventi" class="list-group-item list-group-item-action" data-toggle="tab">
|
||||
<i class="nav-icon fas fa-calendar mr-2"></i> Tipologie Eventi
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -313,6 +316,80 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="tipologie-eventi">
|
||||
<div class="card card-primary">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Tipologie Eventi</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="text-muted">Gestisci le tipologie disponibili per gli eventi del calendario.</p>
|
||||
|
||||
<?php if(session('success')): ?>
|
||||
<div class="alert alert-success"><?php echo e(session('success')); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if(session('error')): ?>
|
||||
<div class="alert alert-danger"><?php echo e(session('error')); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#addTipologiaEventoModal">
|
||||
<i class="fas fa-plus"></i> Nuova Tipologia
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered table-striped" id="tipologie-eventi-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40px;">Ordine</th>
|
||||
<th>Nome</th>
|
||||
<th>Descrizione</th>
|
||||
<th style="width: 100px;">Stato</th>
|
||||
<th style="width: 150px;">Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tipologie-eventi-sortable">
|
||||
<?php $__currentLoopData = $tipologieEventi; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tipologia): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<tr data-id="<?php echo e($tipologia->id); ?>">
|
||||
<td class="text-center">
|
||||
<i class="fas fa-arrows-alt handle" style="cursor: grab;"></i>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tipologia-evento-nome"><?php echo e($tipologia->nome); ?></span>
|
||||
</td>
|
||||
<td><?php echo e($tipologia->descrizione ?? '-'); ?></td>
|
||||
<td>
|
||||
<?php if($tipologia->attiva): ?>
|
||||
<span class="badge badge-success">Attiva</span>
|
||||
<?php else: ?>
|
||||
<span class="badge badge-secondary">Disattivata</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-xs btn-warning" onclick="editTipologiaEvento(<?php echo e($tipologia->id); ?>, '<?php echo e(addslashes($tipologia->nome)); ?>', '<?php echo e(addslashes($tipologia->descrizione ?? '')); ?>', <?php echo e($tipologia->attiva ? 'true' : 'false'); ?>)">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<?php if($tipologia->eventi()->count() == 0): ?>
|
||||
<form method="POST" action="<?php echo e(route('impostazioni.tipologie-eventi.destroy', $tipologia->id)); ?>" style="display: inline;">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php echo method_field('DELETE'); ?>
|
||||
<button type="submit" class="btn btn-xs btn-danger" onclick="return confirm('Eliminare questa tipologia?')">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<button type="button" class="btn btn-xs btn-danger" disabled title="Eventi associati: <?php echo e($tipologia->eventi()->count()); ?>">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -444,11 +521,93 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="addTipologiaEventoModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST" action="<?php echo e(route('impostazioni.tipologie-eventi.store')); ?>">
|
||||
<?php echo csrf_field(); ?>
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Nuova Tipologia Evento</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="tipologia_evento_nome">Nome *</label>
|
||||
<input type="text" name="nome" id="tipologia_evento_nome" class="form-control" required maxlength="50" placeholder="es. catechesi">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="tipologia_evento_descrizione">Descrizione</label>
|
||||
<input type="text" name="descrizione" id="tipologia_evento_descrizione" class="form-control" maxlength="255" placeholder="es. Catechesi">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Annulla</button>
|
||||
<button type="submit" class="btn btn-primary">Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="editTipologiaEventoModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST" action="" id="editTipologiaEventoForm">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php echo method_field('PUT'); ?>
|
||||
<input type="hidden" name="id" id="edit_tipologia_evento_id">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Modifica Tipologia Evento</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="edit_tipologia_evento_nome">Nome *</label>
|
||||
<input type="text" name="nome" id="edit_tipologia_evento_nome" class="form-control" required maxlength="50">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit_tipologia_evento_descrizione">Descrizione</label>
|
||||
<input type="text" name="descrizione" id="edit_tipologia_evento_descrizione" class="form-control" maxlength="255">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="edit_tipologia_evento_attiva" name="attiva" value="1">
|
||||
<label class="custom-control-label" for="edit_tipologia_evento_attiva">Attiva</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Annulla</button>
|
||||
<button type="submit" class="btn btn-primary">Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $__env->stopSection(); ?>
|
||||
|
||||
<?php $__env->startSection('scripts'); ?>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
|
||||
<script>
|
||||
function activateTabFromHash() {
|
||||
var hash = window.location.hash;
|
||||
if (hash) {
|
||||
var tabLink = document.querySelector('.list-group a[href="' + hash + '"]');
|
||||
if (tabLink) {
|
||||
$(tabLink).tab('show');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
activateTabFromHash();
|
||||
});
|
||||
|
||||
$(window).on('hashchange', function() {
|
||||
activateTabFromHash();
|
||||
});
|
||||
|
||||
function editTipologia(id, nome, descrizione, attiva) {
|
||||
$('#edit_tipologia_id').val(id);
|
||||
$('#edit_tipologia_nome').val(nome);
|
||||
@@ -467,6 +626,15 @@ function editRuolo(id, nome, descrizione, attiva) {
|
||||
$('#editRuoloModal').modal('show');
|
||||
}
|
||||
|
||||
function editTipologiaEvento(id, nome, descrizione, attiva) {
|
||||
$('#edit_tipologia_evento_id').val(id);
|
||||
$('#edit_tipologia_evento_nome').val(nome);
|
||||
$('#edit_tipologia_evento_descrizione').val(descrizione);
|
||||
$('#edit_tipologia_evento_attiva').prop('checked', attiva);
|
||||
$('#editTipologiaEventoForm').attr('action', '/impostazioni/tipologie-eventi/' + id);
|
||||
$('#editTipologiaEventoModal').modal('show');
|
||||
}
|
||||
|
||||
var sortableTipologie = Sortable.create(document.getElementById('tipologie-sortable'), {
|
||||
handle: '.handle',
|
||||
animation: 150,
|
||||
@@ -507,11 +675,34 @@ var sortableRuoli = Sortable.create(document.getElementById('ruoli-sortable'), {
|
||||
}
|
||||
});
|
||||
|
||||
var sortableTipologieEventi = Sortable.create(document.getElementById('tipologie-eventi-sortable'), {
|
||||
handle: '.handle',
|
||||
animation: 150,
|
||||
onEnd: function(evt) {
|
||||
var order = [];
|
||||
$('#tipologie-eventi-sortable tr').each(function() {
|
||||
order.push($(this).data('id'));
|
||||
});
|
||||
|
||||
fetch('<?php echo e(route('impostazioni.tipologie-eventi.reorder')); ?>', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ order: order })
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
var target = $(e.target).attr('href');
|
||||
if (target === '#ruoli') {
|
||||
sortableRuoli.refresh();
|
||||
}
|
||||
if (target === '#tipologie-eventi') {
|
||||
sortableTipologieEventi.refresh();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php $__env->stopSection(); ?>
|
||||
|
||||
Reference in New Issue
Block a user