cloudlog/application/views/emeinitials/index.php
Peter Goodhall aa636697bd Add HTMX component and filters for EME initials
Introduce an HTMX-driven filtering UI and a server-side component for EME initials. The controller Emeinitials.php was simplified (removed inline POST handling in index) and now exposes component_eme_results() which accepts band/mode (defaulting to 'All'), determines the user's date format, loads initials via Emeinitials_model, and returns a partial view. A new view emeinitales/component_results.php renders the results table or a no-data alert. The index view was refactored to an HTMX-enabled filters form, async results container (#emeResults), a Reset button, and a small client-side handler to reset and re-submit the form. These changes enable dynamic filtering without a full page reload and clean up server-side responsibilities.
2026-04-26 22:20:45 +01:00

78 lines
3.3 KiB
PHP

<div class="container">
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2 mb-3">
<div>
<h1 class="mb-0"><?php echo lang('statistics_emeinitials'); ?></h1>
<p class="text-muted mb-0">Track first EME callsign initials by band and mode.</p>
</div>
</div>
<div class="card shadow-sm mb-4">
<div class="card-header py-3">
<h2 class="h5 mb-0">Filters</h2>
</div>
<div class="card-body">
<form id="emeFiltersForm"
class="form"
hx-post="<?php echo site_url('emeinitials/component_eme_results'); ?>"
hx-target="#emeResults"
hx-swap="innerHTML"
hx-trigger="change from:select, submit">
<div class="row g-3 align-items-end">
<div class="col-md-4">
<label class="form-label" for="band"><?php echo lang('gen_hamradio_band') ?></label>
<select id="band" name="band" class="form-select">
<option value="All"><?php echo lang('general_word_all') ?></option>
<?php foreach($worked_bands as $band) {
echo '<option value="' . $band . '">' . $band . '</option>' . "\n";
} ?>
</select>
</div>
<div class="col-md-4">
<label class="form-label" for="mode"><?php echo lang('gen_hamradio_mode') ?></label>
<select id="mode" name="mode" class="form-select">
<option value="All"><?php echo lang('general_word_all') ?></option>
<?php
foreach($modes->result() as $mode){
if ($mode->submode == null) {
echo '<option value="' . $mode->mode . '">' . $mode->mode . '</option>' . "\n";
} else {
echo '<option value="' . $mode->submode . '">' . $mode->submode . '</option>' . "\n";
}
}
?>
</select>
</div>
<div class="col-md-4 d-flex justify-content-md-end gap-2">
<button type="button" class="btn btn-outline-secondary" id="emeResetButton">Reset</button>
<button id="button1id" type="submit" class="btn btn-primary"><?php echo lang('filter_options_show') ?></button>
</div>
</div>
</form>
</div>
</div>
<div id="emeResults"
hx-post="<?php echo site_url('emeinitials/component_eme_results'); ?>"
hx-target="this"
hx-swap="innerHTML"
hx-include="#emeFiltersForm"
hx-trigger="load"></div>
</div>
<script>
document.addEventListener('click', function (event) {
if (event.target && event.target.id === 'emeResetButton') {
const form = document.getElementById('emeFiltersForm');
if (!form) {
return;
}
form.reset();
if (window.htmx) {
htmx.trigger(form, 'submit');
}
}
});
</script>