Skip to content

HTMX Table documentation (and refactor)#1406

Merged
phycodurus merged 23 commits intodevfrom
1111-build-htmx-table-widget
Feb 17, 2026
Merged

HTMX Table documentation (and refactor)#1406
phycodurus merged 23 commits intodevfrom
1111-build-htmx-table-widget

Conversation

@phycodurus
Copy link
Copy Markdown
Member

@phycodurus phycodurus commented Feb 10, 2026

This branch was previously merged to dev with the initial implementation of the HTMX target table. Development continued in this branch after that merge:

  • The model-independent aspects of HTMX tables is now refactored into three new base classes in tom_common/htmx_table.py
  • Customization mechanisms for general search were added
  • The Target tables implementation was refactored to use those classes
  • The out-of-band "side-loading" of the Aladin skymap was optimized so that we don't reload and rebuild the skymap every time the target filters change. Now, we just update the targets in the existing skymap.
  • Documentation has been added.

Here's the Copilot generated summary:

This pull request introduces a reusable HTMX-enabled table framework for interactive filtering, sorting, and pagination, and refactors the Target List page to use these new abstractions. It also improves the integration between HTMX tables and companion widgets, such as the Aladin skymap, by implementing an out-of-band (OOB) data update pattern. The changes are grouped into two main themes: HTMX table framework introduction and Aladin skymap integration improvements.

HTMX Table Framework Introduction

  • Added a new tom_common/htmx_table.py module providing HTMXTable, HTMXTableFilterSet, and HTMXTableViewMixin classes for reusable HTMX-driven tables, including built-in support for interactive sorting, filtering, pagination, and row selection, as well as customizable partial templates.
  • Refactored TargetTable and TargetFilterSet in tom_targets/tables.py and tom_targets/filters.py to inherit from the new HTMX table classes, simplifying their implementation and enabling easier customization. [1] [2]
  • Updated documentation to include a new section on building interactive HTMX tables, highlighting their features and usage. [1] [2]

Aladin Skymap Integration Improvements

  • Refactored the Aladin skymap partials and template tags to implement an OOB data update pattern: instead of rebuilding the viewer on each HTMX table update, only the target marker data is updated via a lightweight JSON payload and a global JavaScript function, improving performance and UX. [1] [2] [3] [4] [5]
  • Removed the old aladin_skymap_htmx.html partial and updated all relevant templates to use the new OOB update approach.

These changes establish a robust foundation for interactive tables and seamless widget updates, making future customizations and enhancements much easier.

The initial implementation in tom_targets was largely
Model-indepented and common code has been moved to three
classes in tom_common/htmx_table.py. The Target table implementation
has been refactored to extend those common classes for Targets.
Change summary:

- tom_targets/templates/tom_targets/partials/aladin_skymap.html -- Refactored target catalog management to use a single window.aladinTargetCatalog and added a global window.updateAladinTargets() function that replaces target markers without rebuilding the viewer.

- tom_targets/templates/tom_targets/partials/aladin_skymap_targets_oob.html (new) -- Lightweight Out-of-Band template that sends a <script> calling updateAladinTargets() with new target data as JSON.

- tom_targets/templatetags/targets_extras.py -- Added aladin_skymap_targets_oob template tag that serializes targets to JSON without computing Moon/Sun positions.

- tom_targets/templates/tom_targets/partials/target_table_partial.html -- Changed from including aladin_skymap_htmx.html (full rebuild) to using {% aladin_skymap_targets_oob %} (data-only update). Also fixed duplicate header lines.

- tom_targets/templates/tom_targets/target_list.html -- Simplified initial skymap include to call {% aladin_skymap %} directly. Added <div id="aladin-targets-data"> placeholder for OOB swaps.

- tom_targets/templates/tom_targets/partials/aladin_skymap_htmx.html (deleted) -- No longer needed.
@phycodurus phycodurus moved this to Needs Review in TOM Toolkit Feb 10, 2026
@phycodurus phycodurus marked this pull request as ready for review February 10, 2026 22:06
Copy link
Copy Markdown
Contributor

@Fingel Fingel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thoughtful and precise. Nice work.

Just two thoughts, but they are mostly subjective.

  1. If you haven't checked out django-template-partials, you might want to give it a look. I vastly prefer using it as an alternative to creating small template partial files like "target_table_partial.html". It was recently merged into Django 6.0. Being able to define the partials inline in the template they will be swapped into makes the templates so much easier to read and follow, in my opinion.
  2. I still think the way the skymap works is silly. Whenever I see a graph above data like this, I expect it to show the data that matches my current filters not just the items on the current page. Think about a cone search, for example. I implemented this in #1190 but it was sucked into a black hole. I'm almost certain the only reason it works the way it does currently is because it was the easiest way to implement it at the time (taking the data straight from the ListView context, which is jank.)

@jchate6
Copy link
Copy Markdown
Contributor

jchate6 commented Feb 12, 2026

@Fingel the original motivation was to allow the page to load if people had too many targets.
It was a quick and dirty way to show something consistent and in small enough numbers not to time out.

this was several sky charts ago though. Happy to do it by filter with some cap.

@phycodurus phycodurus merged commit ae31a03 into dev Feb 17, 2026
26 checks passed
@github-project-automation github-project-automation bot moved this from Needs Review to Merged (to dev) in TOM Toolkit Feb 17, 2026
@jchate6 jchate6 moved this from Merged (to dev) to Released in TOM Toolkit Feb 24, 2026
@jchate6 jchate6 deleted the 1111-build-htmx-table-widget branch March 27, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

HTMX-table search method customization documentation for HTMX-driven Tables

3 participants