cloudlog/application/views/continents/index.php
Peter Goodhall 85210aa2ae Add HTMX continent component and refactor JS
Introduce an HTMX-driven continents results component and refactor the continents page/JS to load/filter results dynamically. Added Continents::component_continent_results() and a new view (continents/component_results.php) which renders the chart/table container and exposes filter params via data attributes. Updated application/views/continents/index.php to use a filter card with an HTMX-enabled form that posts to the new component endpoint and injects results into #continentResults. Reworked assets/js/sections/continents.js to centralize AJAX logic into continentsRender(), add setContinentsLoading(), handle HTMX afterSwap to initialize results, improve error/info messaging, and implement a JS reset button that triggers an HTMX submit. Overall this enables incremental loading of continent stats and simplifies the previous full-form AJAX flow.
2026-04-26 22:15:35 +01:00

63 lines
No EOL
2.7 KiB
PHP

<style>
#continentChart {
margin: 0 auto;
}
</style>
<div class="container statistics">
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2 mb-3">
<div>
<h1 class="mb-0"><?php echo $page_title; ?></h1>
<p class="text-muted mb-0">See how your QSOs are distributed across continents 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="continentFiltersForm"
name="continentFiltersForm"
class="form"
hx-post="<?php echo site_url('continents/component_continent_results'); ?>"
hx-target="#continentResults"
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">Band</label>
<select id="band" name="band" class="form-select">
<option value="">All</option>
<?php foreach($bands as $band){ ?>
<option value="<?php echo htmlentities($band); ?>"><?php echo htmlspecialchars($band); ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-4">
<label class="form-label" for="mode">Mode</label>
<select id="mode" name="mode" class="form-select">
<option value="">All</option>
<?php foreach($modes as $modeId => $mode){ ?>
<option value="<?php echo htmlspecialchars($mode); ?>"><?php echo htmlspecialchars($mode); ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-4 d-flex justify-content-md-end gap-2">
<button type="button" class="btn btn-outline-secondary" id="resetButton">Reset</button>
<button type="submit" class="btn btn-primary" id="searchButton">Show</button>
</div>
</div>
</form>
</div>
</div>
<div id="continentResults"
hx-post="<?php echo site_url('continents/component_continent_results'); ?>"
hx-target="this"
hx-swap="innerHTML"
hx-include="#continentFiltersForm"
hx-trigger="load"></div>
</div>