Skip to content

Column show/hide for the overview editors, with mobile defaults - #1564

Open
barrulus wants to merge 3 commits into
Azgaar:masterfrom
barrulus:feat/editor-column-visibility-upstream
Open

Column show/hide for the overview editors, with mobile defaults#1564
barrulus wants to merge 3 commits into
Azgaar:masterfrom
barrulus:feat/editor-column-visibility-upstream

Conversation

@barrulus

@barrulus barrulus commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Reworked to the data-driven approach you asked for. The header is now generated from a per-editor column registry, and header and rows share one declared track list, so the hand-tuned grid-template-columns and all the width-measuring JavaScript are gone.

How it works. Each of the six paginated editors declares a column registry — key, label, width, fill, tooltip, sort accessor, sort type, default sort, hideable, mobile-hidden. buildTracks turns the visible columns into one CSS track list published on the dialog as --table-columns; renderEditorHeader generates the header from the same registry; header and rows are grids consuming that variable. Sorting reads each column's sortBy, so data-sortby and the sortable classes are no longer hand-written markup, and the per-editor sort-accessor records are gone.

Three consequences worth calling out:

  • Alignment is exact by construction. Cells that carry no data — the colour swatch, emblem, locate and action icons — became real registry entries with declared widths, so every pixel of a row belongs to a declared track. Measured across all six editors, every row: header-to-body drift 0px, flat and while scrolled.
  • The header moved inside the scrolling body, sticky at the top. As a sibling it was offset from the rows by the scrollbar width whenever a table scrolled, which is where the drift and the clipped last column in your screenshot came from. It also now stays visible while scrolling a long table.
  • Hiding a column drops its track rather than hiding a cell, so there is no gap and no shift, and the fill column absorbs the slack — no dead space when most columns are hidden.

The columns button now renders in the header's trailing cell instead of the bottom toolbar.

Mobile defaults are unchanged from the previous revision: 20 rows per page, bulkier columns hidden, filter and toolbar rows stacked. Defaults only — an explicit choice wins and persists per editor.

The first commit is an independent fix: these editors rendered before configuring their dialog, so the render-side width refit created the widget with the default resizable: true, and the opener's resizable: false then destroyed it. touch-punch unbinds by shared proxy guid, so that destroy also stripped the draggable's touch handlers and left the dialogs undraggable on touch devices. Renders now only refit an existing dialog.

I did not include a formatter on the column model — rows are still built by each editor's own template, so it would have no consumer until cell rendering itself becomes generic. The model has room for it when that happens.

Tests cover the pure logic (buildTracks, pagination, column persistence, sorting) under the existing environment: "node". A few DOM-level assertions are omitted rather than adding a jsdom dependency or changing the vitest config in this PR — happy to add them if you'd like the test setup extended separately.

Large editors render every row into the DOM at once, which is slow on big
maps. Each editor now renders at most one page (100 rows) via a headless
table core (src/components/dialog/table.ts): sorting and footer totals
cover the full dataset, the page resets on open/filter/sort, and the
footer pager fills the table width without widening fit-content dialogs.
Full-dataset sorting helpers extend src/components/dialog/sorting.ts.
No window globals; helpers are imported.
@netlify

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 29631b5
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/6a770de1c18e5f0008edaab1
😎 Deploy Preview https://deploy-preview-1564--afmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Azgaar
Azgaar self-requested a review August 7, 2026 11:27
@Azgaar

Azgaar commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Cool, but some columns are out of place and the last one can get cut.
image

We probably need to get rid of the current approach with grid-template-columns and use normal table/grid with strictly-defined columns width in data.

Show columns button: can it be added to the header?

Comment thread src/controllers/states-editor.ts Outdated
<div data-tip="Click to sort by state treasury. Click on a value to view and edit taxes" class="sortable hide" data-sortby="treasury">Treasury&nbsp;</div>
<div data-tip="Click to sort by state type" class="sortable alphabetically hidden show hide" data-sortby="type">Type&nbsp;</div>
<div data-tip="Click to sort by state expansion value" class="sortable hidden show hide" data-sortby="expansionism">Expansion&nbsp;</div>
<div data-tip="Click to sort by state name" class="sortable alphabetically" data-sortby="name" data-col="name">State&nbsp;</div>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

do we need data-sortby="name" and class="sortable alphabetically" now? Can be moved to the table COLUMNS definition as well.

Comment thread src/controllers/states-editor.ts Outdated
}

const STATE_COLUMNS: EditorColumn[] = [
{ key: "name", label: "Name", hideable: false },

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We can add mote params here, incl. data accessor, UI value formatter, sorting type, default sorting and so on.

barrulus added a commit to barrulus/Fantasy-Map-Generator that referenced this pull request Aug 7, 2026
…1469/Azgaar#1564)

Ports the paginated-table column show/hide stack onto the fork's
customized editors: burgs keeps megalopolis badges, the skyburg button,
GL label rebuild hooks and the altitude CSV column; states keeps the
brush/demote/merge panel. The fork's older per-editor pagination
scaffolding is replaced by the shared table.ts helpers. Dialog widths
use the fork's fitContent() helper for Firefox.
@barrulus

barrulus commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Agreed on the direction.

The misalignment and the cut-off last column both come from the header and rows being two separate layouts aligned by hand-tuned grid-template-columns, and the width-scaling code exists only to patch over that.

I'll rework it the way you describe: the COLUMNS registry becomes the single source of truth (width, accessor, formatter, sort type, default sort, hideable), the header is generated from it (so data-sortby/sortable markup goes away), and rows share the header's grid tracks so alignment is exact and a fr-track fills leftover space with no measuring code at all.
The columns button moves into the header. The touch-drag fix commit is independent of the table layout, so it survives the rework as-is.

I will rework all of this here in this PR.

These editors rendered before configuring their dialog, so the render's
width refit initialized the widget with the default resizable: true and
the opener's resizable: false then destroyed that widget. Touch-punch
unbinds by shared proxy guid, so the destroy stripped the draggable's
touch handlers too, leaving the dialogs undraggable on touch devices.
Renders now only refit an existing dialog (fitDialogIfExists) and the
opener's single configuring call creates the widget.
@barrulus
barrulus force-pushed the feat/editor-column-visibility-upstream branch from 6df76de to e363c0e Compare August 7, 2026 22:07
@barrulus
barrulus marked this pull request as draft August 7, 2026 22:14
@barrulus

barrulus commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

there is an issue in moving from the fork to FMG. Don't waste cycles on this until I have unpacked it and cleaned it up

@barrulus
barrulus force-pushed the feat/editor-column-visibility-upstream branch from e363c0e to 29631b5 Compare August 8, 2026 11:07
@barrulus
barrulus marked this pull request as ready for review August 8, 2026 11:54
@barrulus

barrulus commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

This has worked out really well. If you like how this is done, I will extend it to the remaining editors byond these 6 targeted ones

@Azgaar

Azgaar commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Generally yes, it should be expanded to all controllers, but it doesn't have to be done now.

@barrulus

barrulus commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Generally yes, it should be expanded to all controllers, but it doesn't have to be done now.

I have the plan to do this in place already, I just didn't want to hit go on all of that until you had signed off on the mechanics :)

All other editors I touch will end up with the same mechanics and utilise the same shared utils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants