Fix some enhancements & new features

This commit is contained in:
Ludovic CANDELLIER
2020-07-26 16:51:45 +02:00
parent fcd26d13de
commit 1179b5ca31
54 changed files with 975 additions and 341 deletions

View File

@@ -1,13 +1,10 @@
@include('load.datatables')
<div id="{{ $model }}-datatable-content">
@include('components.datatables.header')
{{$dataTable->table(['class'=>'table table-bordered table-hover table-striped w-100 mb-0'])}}
</div>
@push('css')
<link rel="stylesheet" href="{{ asset('assets/plugins/datatables.min.css') }}">
@endpush
@push('scripts')
<script src="{{ asset('assets/plugins/datatables.min.js') }}"></script>
<script src="{{ asset('vendor/datatables/buttons.server-side.js') }}"></script>
@push('js')
@include('components.js.datatable', ['route' => $route, 'model' => $model])
@endpush

View File

@@ -8,10 +8,28 @@
$colvis.on( 'click', function () {
var table = window.LaravelDataTables["{{ $model }}-table"];
console.log(table);
console.log(table.column(1).dataSrc());
var header = table.column(1).header();
console.log($(header).html());
var visible = table.column(1).visible();
console.log(visible);
/*
// var names = table.columns().names();
columns = table.columns();
console.log(columns);
var names = columns.names();
console.log(names);
// table.search($search.val()).draw();
buttons = table.buttons();
console.log(table.button('colvis'));
console.log(buttons);
*/
/*
for (var i = buttons.length - 1; i >= 0; i--) {
console.log(buttons[i]);

View File

@@ -4,27 +4,25 @@
</button>
<ul class="dropdown-menu" x-placement="bottom-start">
<li class="dropdown-item excelWithFilter"><a href="#"><i class="fa fa-file-excel"></i> Exporter la sélection</a></li>
<li class="dropdown-item"><a href="#" class="excelWithFilter"><i class="fa fa-file-excel"></i> Exporter la sélection</a></li>
<li class="dropdown-item"><a href="{{ $route }}/exportExcel"><i class="fa fa-file-excel"></i> Exporter la liste complète</a></li>
<li class="dropdown-item"><a href="#"><i class="fa fa-file-pdf"></i> Exporter la sélection</a></li>
<div class="dropdown-divider"></div>
<li class="dropdown-item"><a href="#" class="pdfWithFilter"><i class="fa fa-file-pdf"></i> Exporter la sélection</a></li>
<li class="dropdown-item"><a href="{{ $route }}/exportPDF"><i class="fa fa-file-pdf"></i> Exporter la liste complète</a></li>
</ul>
</span>
@push('js')
<script>
$('.excelWithFilter').click(function() {
/*
var data = $('#filters').serializeJSON();
var query = encodeURIComponent(JSON.stringify(data));
console.log(data);
console.log(query);
var url = "{{ $route }}/exportExcel?filters=" + query;
console.log(url);
*/
var data = $('#filters').serialize();
var url = "{{ $route }}/exportExcel?" + data;
window.location = url;
})
</script>
@endpush
<script>
$('.excelWithFilter').click(function() {
var data = $('#filters').serialize();
var url = "{{ $route }}/exportExcel?" + data;
window.location = url;
})
$('.pdfWithFilter').click(function() {
var data = $('#filters').serialize();
var url = "{{ $route }}/exportPDF?" + data;
window.location = url;
})
</script>
@endpush

View File

@@ -1,6 +1,9 @@
<div class="datatable-export-buttons">
@include('components.datatables.buttons.print')
@include('components.datatables.buttons.download')
@if (isset($with_exports) && $with_exports)
@include('components.datatables.buttons.download')
@endif
</div>

View File

@@ -4,8 +4,8 @@
</button>
<ul class="dropdown-menu" x-placement="bottom-start">
<li class="dropdown-item btn-print"><a href="#">Imprimer la sélection</a></li>
<li class="dropdown-item"><a href="{{ $route }}/print">Imprimer la liste complète</a></li>
<li class="dropdown-item printWithFilter"><a href="#" target="_BLANK">Imprimer la sélection</a></li>
<li class="dropdown-item"><a href="{{ $route }}/print" target="_BLANK">Imprimer la liste complète</a></li>
</ul>
</span>
@@ -16,6 +16,12 @@
var table = window.LaravelDataTables["{{ $model }}-table"];
table.button(1).trigger();
});
$('.printWithFilter').click(function() {
var data = $('#filters').serialize();
var url = "{{ $route }}/print?" + data;
window.location = url;
})
</script>
@endpush

View File

@@ -3,11 +3,17 @@
@include('components.datatables.buttons.pageLength')
<span class="input-group-text"><i class="fa fa-search"></i></span>
</div>
<input type="text" class="form-control search-btn" placeholder="Rechercher..." value="">
<div class="input-group-append">
@include('components.datatables.buttons.filters')
@include('components.datatables.buttons.colvis')
</div>
<input type="text" class="form-control search-btn" placeholder="Rechercher..." value="">
@if ((isset($with_filters) and $with_filters) || (isset($with_colvis) and $with_colvis))
<div class="input-group-append">
@if (isset($with_filters) && $with_filters)
@include('components.datatables.buttons.filters')
@endif
@if (isset($with_colvis) && $with_colvis)
@include('components.datatables.buttons.colvis')
@endif
</div>
@endif
</div>
@push('js')
@@ -15,7 +21,7 @@
var $search = $('#{{ $model }}-table-header .search-btn');
$search.on( 'keyup click', function () {
var table = window.LaravelDataTables["{{ $model }}-table"];
table.search($search.val()).draw();
} );
table.search($search.val()).draw();
} );
</script>
@endpush

View File

@@ -1,11 +1,3 @@
<script>
$.extend( true, $.fn.dataTable.defaults, {
language: {
url: "/assets/vendor/boilerplate/js/datatables/i18n/French.json"
},
});
</script>
{{$dataTable->scripts()}}
<script>
@@ -14,22 +6,27 @@
var table = window.LaravelDataTables["{{ $model }}-table"];
$('.btn-edit').off('click').click(function() {
var id = table.row(this).id();
$('.btn-edit').off('click').click(function(e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
url = '{{ $route }}' + '/edit/' + id;
console.log(url);
openURL(url);
});
$('.btn-show').off('click').click(function() {
var id = table.row(this).id();
$('.btn-show').off('click').click(function(e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
url = '{{ $route }}' + '/show/' + id;
openURL(url);
});
$('.btn-del').off('click').click(function (e) {
e.preventDefault();
var id = table.row(this).id();
// var id = table.row(this).id();
var id = $(this).data('id');
bootbox.confirm("{{ __('admin.confirmdelete') }}", function (result) {
if (result === false) return;
@@ -39,7 +36,7 @@
method: 'delete',
headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}'},
success: function(){
line.remove();
// line.remove();
table.draw();
growl("{{ __('admin.deletesuccess') }}", 'success');
}