Popup Modifica Tags aggiornato e funzionante
This commit is contained in:
parent
377b41c629
commit
b8fd41357f
@ -25,14 +25,10 @@ class TagController extends Controller
|
||||
return view('components.calendar');
|
||||
}
|
||||
|
||||
public function updateTag(Request $request)
|
||||
public function updateTag($id)
|
||||
{
|
||||
$id=$request['id'];
|
||||
$tags=tag::getById($id);
|
||||
return view('conti.tags.update',
|
||||
[
|
||||
'tags'=> $tags,
|
||||
]);
|
||||
return json_encode($tags);
|
||||
}
|
||||
|
||||
public function updatePostTag(Request $request)
|
||||
|
@ -1,54 +1,93 @@
|
||||
@extends('admin')
|
||||
@section('content')
|
||||
@extends('admin') @section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">Lista dei tag</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">Lista dei tag</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<!-- Content here -->
|
||||
<form action="" method="POST">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="tag" class="form-label">Tag</label>
|
||||
<input type="text" class="form-control" id="tag" name="tag_name">
|
||||
</div>
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="tag" class="form-label">Tag</label> <input type="text"
|
||||
class="form-control" id="tag" name="tag_name">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Inserisci nuovo Tag</button>
|
||||
</form>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover" id="tags">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tag</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($tags as $tag)
|
||||
<tr>
|
||||
<td><a href="movimenti/filter/tags?tag={{ $tag->id }}">{{ $tag->tag_name; }}</a></td>
|
||||
<td>
|
||||
<a class="btn btn-primary" href="/admin/tagmodify?id={{ $tag->id; }}"><i class="fa fa-pencil-square-o fw"></i></a>
|
||||
<a class="btn btn-danger" href="/admin/tagdelete?id={{ $tag->id; }}"><i class="fa fa-trash-o fa-fw"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover"
|
||||
id="tags">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tag</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($tags as $tag)
|
||||
<tr>
|
||||
<td><a href="movimenti/filter/tags?tag={{ $tag->id }}">{{
|
||||
$tag->tag_name; }}</a></td>
|
||||
<td><button class="btn btn-warning btn-detail open_modal" value="{{ $tag->id; }}">Edit</button> <a
|
||||
class="btn btn-danger" href="/admin/tagdelete?id={{ $tag->id; }}"><i
|
||||
class="fa fa-trash-o fa-fw"></i></a> </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Modifica tags</div>
|
||||
<div class="panel-body">
|
||||
<form action="tagmodify" method="POST">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="tag_name" class="form-label">Tag</label> <input
|
||||
type="text" class="form-control" id="tag_name" size="50"
|
||||
name="tag_name" value="">
|
||||
</div>
|
||||
<input type="hidden" name="id" id="tag_id" value="">
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- /.col-lg-12 -->
|
||||
|
||||
<!-- /.col-lg-12 -->
|
||||
|
||||
@endsection
|
||||
@section('script')
|
||||
@endsection @section('script')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tags').DataTable({
|
||||
responsive: true
|
||||
});
|
||||
$(document).on('click','.open_modal',function(){
|
||||
var url = "tagmodify";
|
||||
var riga_id= $(this).val();
|
||||
$.getJSON(url + '/' + riga_id, function (data) {
|
||||
//success data
|
||||
console.log(data[0]);
|
||||
console.log(data[0].tag_name);
|
||||
$('#tag_name').val(data[0].tag_name);
|
||||
$('#tag_id').val(data[0].id);
|
||||
$('#myModal').modal('show');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
@ -54,7 +54,7 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
||||
// TAGS
|
||||
Route::get('tags', [TagController::class,'listTags'])->name('tags');
|
||||
Route::post('tags', [TagController::class,'insTags']);
|
||||
Route::get('tagmodify', [TagController::class,'updateTag']);
|
||||
Route::get('tagmodify/{id}', [TagController::class,'updateTag']);
|
||||
Route::post('tagmodify', [TagController::class,'updatePostTag']);
|
||||
// CONSUMI
|
||||
Route::get('letturegas', [ContatoreGasController::class,'listLettureGas'])->name('gas');
|
||||
|
Loading…
Reference in New Issue
Block a user