mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-08-07 01:13:11 +02:00
Add auto-submit for filter controls on list pages
Filter forms now auto-submit when select dropdowns change or when Enter is pressed in text inputs. Uses a data-auto-submit attribute pattern for consistency with existing data attribute conventions.
This commit is contained in:
@@ -70,9 +70,35 @@ function populateRelativeTimeElements() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize auto-submit behavior for filter forms
|
||||
* Forms with data-auto-submit attribute will auto-submit on:
|
||||
* - Change events on select and checkbox inputs
|
||||
* - Enter key on text inputs
|
||||
*/
|
||||
function initAutoSubmitForms() {
|
||||
document.querySelectorAll('form[data-auto-submit]').forEach(form => {
|
||||
// Auto-submit on select/checkbox change
|
||||
form.querySelectorAll('select, input[type="checkbox"]').forEach(el => {
|
||||
el.addEventListener('change', () => form.submit());
|
||||
});
|
||||
|
||||
// Submit on Enter key for text inputs
|
||||
form.querySelectorAll('input[type="text"]').forEach(el => {
|
||||
el.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Auto-populate when DOM is ready
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
populateRelativeTimestamps();
|
||||
populateReceiverTooltips();
|
||||
populateRelativeTimeElements();
|
||||
initAutoSubmitForms();
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<!-- Filters -->
|
||||
<div class="card bg-base-100 shadow mb-6">
|
||||
<div class="card-body py-4">
|
||||
<form method="GET" action="/advertisements" class="flex gap-4 flex-wrap items-end">
|
||||
<form method="GET" action="/advertisements" class="flex gap-4 flex-wrap items-end" data-auto-submit>
|
||||
<div class="form-control">
|
||||
<label class="label py-1">
|
||||
<span class="label-text">Search</span>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<!-- Filters -->
|
||||
<div class="card bg-base-100 shadow mb-6">
|
||||
<div class="card-body py-4">
|
||||
<form method="GET" action="/messages" class="flex gap-4 flex-wrap items-end">
|
||||
<form method="GET" action="/messages" class="flex gap-4 flex-wrap items-end" data-auto-submit>
|
||||
<div class="form-control">
|
||||
<label class="label py-1">
|
||||
<span class="label-text">Type</span>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<!-- Filters -->
|
||||
<div class="card bg-base-100 shadow mb-6">
|
||||
<div class="card-body py-4">
|
||||
<form method="GET" action="/nodes" class="flex gap-4 flex-wrap items-end">
|
||||
<form method="GET" action="/nodes" class="flex gap-4 flex-wrap items-end" data-auto-submit>
|
||||
<div class="form-control">
|
||||
<label class="label py-1">
|
||||
<span class="label-text">Search</span>
|
||||
|
||||
Reference in New Issue
Block a user