modifiche siderbar e correzioni
This commit is contained in:
@@ -29,6 +29,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>
|
||||
@@ -315,6 +318,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>
|
||||
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success">{{ session('success') }}</div>
|
||||
@endif
|
||||
@if(session('error'))
|
||||
<div class="alert alert-danger">{{ session('error') }}</div>
|
||||
@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">
|
||||
@foreach($tipologieEventi as $tipologia)
|
||||
<tr data-id="{{ $tipologia->id }}">
|
||||
<td class="text-center">
|
||||
<i class="fas fa-arrows-alt handle" style="cursor: grab;"></i>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tipologia-evento-nome">{{ $tipologia->nome }}</span>
|
||||
</td>
|
||||
<td>{{ $tipologia->descrizione ?? '-' }}</td>
|
||||
<td>
|
||||
@if($tipologia->attiva)
|
||||
<span class="badge badge-success">Attiva</span>
|
||||
@else
|
||||
<span class="badge badge-secondary">Disattivata</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-xs btn-warning" onclick="editTipologiaEvento({{ $tipologia->id }}, '{{ addslashes($tipologia->nome) }}', '{{ addslashes($tipologia->descrizione ?? '') }}', {{ $tipologia->attiva ? 'true' : 'false' }})">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
@if($tipologia->eventi()->count() == 0)
|
||||
<form method="POST" action="{{ route('impostazioni.tipologie-eventi.destroy', $tipologia->id) }}" style="display: inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-xs btn-danger" onclick="return confirm('Eliminare questa tipologia?')">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<button type="button" class="btn btn-xs btn-danger" disabled title="Eventi associati: {{ $tipologia->eventi()->count() }}">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -446,11 +523,93 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="addTipologiaEventoModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST" action="{{ route('impostazioni.tipologie-eventi.store') }}">
|
||||
@csrf
|
||||
<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">
|
||||
@csrf
|
||||
@method('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>
|
||||
@endsection
|
||||
|
||||
@section('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);
|
||||
@@ -469,6 +628,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,
|
||||
@@ -509,11 +677,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('{{ route('impostazioni.tipologie-eventi.reorder') }}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ 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>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user