Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions catatan_rilis.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Di rilis ini, versi 2606.0.0 berisi penambahan dan perbaikan yang diminta penggu
10. [#1021](https://github.com/OpenSID/OpenKab/issues/1021) Ubah field isi artikel menjadi rich editor
11. [#1025](https://github.com/OpenSID/OpenKab/issues/1025) Arahkan/Infokan pembuatan kategori artikel ketika kategori kosong saat membuat artikel opensid
12. [#1031](https://github.com/OpenSID/OpenKab/issues/1031) Arahkan/Infokan pembuatan kategori artikel ketika kategori kosong saat membuat artikel di pengaturan web -> artikel
13. [#1041](https://github.com/OpenSID/OpenKab/issues/1041) Tambahkan fungsi global untuk debounce search datatable



Expand Down
41 changes: 35 additions & 6 deletions resources/views/layouts/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ function apiProxyGet(endpoint, params, callback) {

$.ajax({
url: url,
type: 'GET',
type: 'GET',
success: function(response) {
if (callback) callback(response);
},
error: function(response) {
if (callback) callback({
data: [],
data: [],
meta: {
pagination: {
total: 0
}
}
});

Swal.fire(
'Error!',
response.responseJSON.error || 'Gagal mengambil data dari API',
Expand All @@ -46,7 +46,7 @@ function apiProxyGet(endpoint, params, callback) {
}
});
}
document.addEventListener("DOMContentLoaded", function(event) {
document.addEventListener("DOMContentLoaded", function(event) {
$.ajax({
type: "get",
url: "/api/v1/identitas",
Expand All @@ -69,7 +69,36 @@ function apiProxyGet(endpoint, params, callback) {
$.extend($.fn.dataTable.defaults, {
language: {
url: "{{ asset('vendor/datatable/id.json') }}"
}
},
searchDelay: 500,
});

$(document).on('init.dt', function(e, settings) {
if (e.namespace !== 'dt') return;

var table = new $.fn.dataTable.Api(settings);
var searchDelay = table.init().searchDelay || 500;
var searchInput = $('div.dataTables_filter input', table.table().container());
var debounceTimer = null;
var previousSearch = null;

searchInput.off('keyup.DT input.DT search.DT keydown.DT');

searchInput.on('keyup input', function() {
var currentValue = this.value;

if (previousSearch === currentValue) return;

previousSearch = currentValue;

clearTimeout(debounceTimer);

debounceTimer = setTimeout(function() {
if (table.search() !== currentValue) {
table.search(currentValue).draw();
}
}, searchDelay);
});
});


Expand Down Expand Up @@ -121,4 +150,4 @@ function filter_open() {
});
})
</script>
@endpush
@endpush