Move charge actions to ChargeController, implemented charge delete

This commit is contained in:
2024-07-26 12:33:42 +10:00
parent 756f550b43
commit 9380850395
7 changed files with 107 additions and 70 deletions

View File

@@ -41,8 +41,8 @@
{{ $oo->processed ? 'YES' : 'NO' }}
@if(! $oo->processed)
<span class="float-right">
<a class="charge_edit" id="{{ $oo->id }}" href="#"><i class="fas fa-fw fa-edit"></i></a>
<a class="charge_delete" id="{{ $oo->id }}" href="#"><i class="fas fa-fw fa-trash"></i></a>
<a class="charge_edit" data-id="{{ $oo->id }}" href="#"><i class="fas fa-fw fa-edit"></i></a>
<a class="charge_delete" data-id="{{ $oo->id }}" href="{{ url('/r/charge/delete',$oo->id) }}"><i class="fas fa-fw fa-trash"></i></a>
</span>
@endif
</td>
@@ -59,7 +59,7 @@
</div>
</div>
<x-leenooks::modal.delete trigger="charge_delete"/>
<x-leenooks::modal.delete hide="row" trigger="charge_delete"/>
@section('page-scripts')
<script type="text/javascript">
@@ -70,33 +70,31 @@
$(document).ready(function() {
var loaded = [];
$('.charge_edit').on('click',function(item) {
// Open our charge add tab automatically
$('.nav-item a[href="#charge_add"]').tab('show');
$('.charge_edit').on('click',function() {
var that = $(this);
if (loaded[item.currentTarget.id])
if (loaded[that.data('id')])
return false;
console.log(item.currentTarget.id);
// Prepopulate with the details of the charge
$.ajax({
url: '{{ url('r/charge/edit') }}',
method: 'POST',
data: { id: item.currentTarget.id },
data: { id: that.data('id') },
dataType: 'html',
}).done(function(html) {
// Open our charge add tab aut1omatically
$('.nav-item a[href="#charge_add"]').tab('show');
$('div[id="charge_add"]').empty().append(html);
loaded[item.currentTarget.id] = true;
loaded[that.data('id')] = true;
}).fail(function() {
alert('Failed');
alert('Hmm, that didnt work?');
});
return false;
});
});
//<a href="{{ url('/api/charge/delete',$o->id) }}">
</script>
@append