This commit is contained in:
ludo
2024-03-03 22:52:00 +01:00
parent 26ca3eb3ca
commit 7b7295aed1
18 changed files with 465 additions and 353 deletions

View File

@@ -1,27 +1,32 @@
<div class="datatable-export-buttons float-left mr-3">
@if (!isset($with_print) || $with_print)
@include('components.datatables.buttons.print')
@endif
@if (!isset($with_print) || $with_print)
@include('components.datatables.buttons.print')
@endif
@if (isset($with_exports) && $with_exports)
@include('components.datatables.buttons.excel')
@endif
@if (isset($with_exports) && $with_exports)
@include('components.datatables.buttons.excel')
@endif
@if (isset($with_mailing) && $with_mailing)
@include('components.datatables.buttons.mail')
@endif
@if (isset($with_mailing) && $with_mailing)
@include('components.datatables.buttons.mail')
@endif
@if (isset($with_buttons))
@foreach ($with_buttons as $button)
@include($button)
@endforeach
@endif
@if (isset($with_buttons))
@foreach ($with_buttons as $button)
@include($button)
@endforeach
@endif
@if (isset($left_buttons))
@foreach ($left_buttons as $button)
@include('components.form.button', [
'class' => $button['class'] ?? null,
'icon' => $button['icon'] ?? null,
'txt' => $button['txt'] ?? null,
'id' => $button['id'] ?? null,
])
@endforeach
@endif
@if (isset($left_buttons))
@foreach ($left_buttons as $button)
@include('components.form.button', ['class' => $button['class'] ?? null, 'icon' => $button['icon'] ?? null, 'txt' => $button['txt'] ?? null, 'id' => $button['id'] ?? null ])
@endforeach
@endif
</div>

View File

@@ -1,26 +1,31 @@
<div class="row table-header" id="{{ $model }}-table-header">
<div class="col-lg-6 col-md-8 col-12 mb-2">
@include('components.datatables.search')
</div>
<div class="col-lg-4 col-md-3 col-6">
@include('components.datatables.buttons')
@if (isset($add_buttons))
@include($add_buttons)
@endif
</div>
<div class="col-lg-2 col-md-1 col-6 text-right">
@if (isset($right_buttons))
@foreach ($right_buttons as $button)
@include('components.form.button', ['class' => $button['class'] ?? null, 'icon' => $button['icon'] ?? null, 'txt' => $button['txt'] ?? null, 'id' => $button['id'] ?? null ])
@endforeach
@endif
@if (isset($right_content))
{!! $right_content !!}
@endif
<div class="col-lg-6 col-md-8 col-12 mb-2">
@include('components.datatables.search')
</div>
<div class="col-lg-4 col-md-3 col-6">
@include('components.datatables.buttons')
@if (isset($add_buttons))
@include($add_buttons)
@endif
</div>
<div class="col-lg-2 col-md-1 col-6 text-right">
@if (isset($right_buttons))
@foreach ($right_buttons as $button)
@include('components.form.button', [
'class' => $button['class'] ?? null,
'icon' => $button['icon'] ?? null,
'txt' => $button['txt'] ?? null,
'id' => $button['id'] ?? null,
])
@endforeach
@endif
@if (!(isset($with_add) && (!$with_add)))
@include('components.datatables.buttons.add')
@endif
</div>
</div>
@if (isset($right_content))
{!! $right_content !!}
@endif
@if (!(isset($with_add) && !$with_add))
@include('components.datatables.buttons.add')
@endif
</div>
</div>

View File

@@ -1,78 +1,57 @@
<script>
$('#{{ $model }}-table').on('draw.dt', function() {
$('#{{ $model }}-table').on( 'draw.dt', function () {
var table = getDatatable("{{ $model }}");
var table = getDatatable("{{ $model }}");
$('#{{ $model }}-table .btn-edit').off('click').click(function(e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
@if (isset($edit_callback))
{{ $edit_callback }}
@else
url = '{{ $route }}' + '/edit/' + id;
openURL(url);
@endif
});
$('#{{ $model }}-table .btn-edit').off('click').click(function(e) {
e.preventDefault();
var id = $(this).data('id');
@if (isset($edit_callback))
{{ $edit_callback }}
@else
url = '{{ $route }}' + '/edit/' + id;
openURL(url);
@endif
});
$('#{{ $model }}-table .btn-show').off('click').click(function(e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
@if (isset($show_callback))
{{ $show_callback }}
@else
url = '{{ $route }}' + '/show/' + id;
openURL(url);
@endif
});
$('#{{ $model }}-table .btn-show').off('click').click(function(e) {
e.preventDefault();
var id = $(this).data('id');
@if (isset($show_callback))
{{ $show_callback }}
@else
url = '{{ $route }}' + '/show/' + id;
openURL(url);
@endif
});
$('#{{ $model }}-table .btn-del').off('click').click(function (e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
$('#{{ $model }}-table .btn-del').off('click').click(function(e) {
e.preventDefault();
var id = $(this).data('id');
bootbox.confirm("{{ __('fg.confirmdelete') }}", function (result) {
if (result === false) return;
bootbox.confirm("{{ __('fg.confirmdelete') }}", function(result) {
if (result === false) return;
$.ajax({
url: '{{ $route }}' + '/destroy/' + id,
method: 'delete',
headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}'},
success: function(){
// line.remove();
@if (isset($delete_callback))
{{ $delete_callback }}
@else
table.draw();
@endif
growl("{{ __('fg.deletesuccess') }}", 'success');
}
});
});
});
$.ajax({
url: '{{ $route }}' + '/destroy/' + id,
method: 'delete',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
success: function() {
@if (isset($delete_callback))
{{ $delete_callback }}
@else
table.draw();
@endif
growl("{{ __('fg.deletesuccess') }}", 'success');
}
});
});
});
{{ $callback ?? '' }}
{{ $callback ?? '' }}
var state = table.state.loaded();
// console.log('state');
// console.log(state);
if ( state ) {
/*
table.columns().eq( 0 ).each( function ( colIdx ) {
var colSearch = state.columns[colIdx].search;
if ( colSearch.search ) {
$('.search-input-text').eq(colIdx).val( colSearch.search );
}
});
*/
}
});
// datatablesHelper.getDatatableLength('{{ $model }}', 34);
var state = table.state.loaded();
});
</script>