Skip to content

feat(cards): add Deck tab to card detail page - #63

Open
gjuillot wants to merge 3 commits into
Altered-Community:preprodfrom
gjuillot:feat/card-page-deck-tab-53d252
Open

feat(cards): add Deck tab to card detail page#63
gjuillot wants to merge 3 commits into
Altered-Community:preprodfrom
gjuillot:feat/card-page-deck-tab-53d252

Conversation

@gjuillot

Copy link
Copy Markdown
Contributor
image

Summary

  • Adds a "Deck" tab to the card detail page (pages/card.php), after Général/Règles/Cartes Altérées/Lore — visible only to logged-in users.
  • Lists the user's own decks in a compact format, filterable by name and by a single active faction (defaults to the faction of the card being viewed, derived from its reference).
  • Hovering a deck reveals an "Add to deck" button. Clicking it adds the current card to that deck and permanently freezes the row in an "Added" state — no re-offering "Add" on hover afterwards, even across search/filter re-renders.
  • New minimal deck-add-card plugin API endpoint, since the decks API has no incremental "add one card" operation: it fetches the deck's current card list, bumps/adds the quantity, and PATCHes the full list back (mirrors the existing save flow already used by deckbuilder.php).

Details

  • The whole tab (button + pane) is gated server-side on kcIsLoggedIn() — entirely absent from the HTML when logged out, not just hidden by CSS.
  • Faction filter is single-select (always exactly one active); filtering happens server-side via the existing ?ajax=my&faction= param on pages/decks.php.
  • Fetches every page of ?ajax=my (hardcoded to 21 items/page server-side) so the list is never silently truncated for users with more than 21 decks.
  • Empty state shows the selected faction's icon + name.
  • New plugins/core-altered-cards/api/deck-add-card.php (registered in plugin.json), gated on login + CSRF token, following the same api/favorites-toggle.php proxy convention.

Files changed

  • plugins/core-altered-cards/pages/card.php — tab markup, i18n, JS
  • plugins/core-altered-cards/api/deck-add-card.php — new endpoint
  • plugins/core-altered-cards/plugin.json — endpoint registration
  • plugins/core-altered-cards/assets/style.css — compact row + hover-reveal button styles

Test plan

  • Deck tab absent when logged out
  • Deck tab appears when logged in, card's own faction pre-selected
  • Switching the faction filter re-fetches and shows the right decks
  • Searching by name filters the visible list
  • Hovering a deck reveals "Add to deck"; clicking it adds the card and freezes the row on success
  • Full deck list shows for users with more than 21 decks (pagination)

gjuillot and others added 2 commits July 25, 2026 00:23
Adds a login-gated "Deck" tab after Lore showing the user's own decks in a
compact list, filterable by name and by a single active faction (defaulting
to the viewed card's faction). Hovering a deck reveals an "Add to deck"
button that posts to a new deck-add-card endpoint, which fetches the deck's
current card list and PATCHes back the updated quantities (the decks API has
no incremental add operation).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Merge the name search and faction filter onto one row to save vertical space.
- Fetch every page of the user's decks instead of only the first 21.
- Show the faction icon/name in the "no decks" empty state.
- Freeze a deck's row permanently in the "Added" state once a card is added,
  instead of reverting it a few seconds later and re-offering "Add to deck"
  on hover.
- Drop the now-unused "view all my decks" link (superseded by full pagination).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@JulesTeachup

Copy link
Copy Markdown

I would have used a fixed button instead of a hover thing to have the feature be usable on mobile and more easy to understand how it worked.

Hover-to-reveal made the action hard to discover, especially on the touch
devices the previous hover fallback was compensating for. The button now
stays visible; it only changes appearance once clicked (frozen "Added" state).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gjuillot

Copy link
Copy Markdown
Contributor Author

I would have used a fixed button instead of a hover thing to have the feature be usable on mobile and more easy to understand how it worked.

You're right. Done

@gjuillot gjuillot closed this Jul 29, 2026
@gjuillot

Copy link
Copy Markdown
Contributor Author

Closed by accident

@gjuillot gjuillot reopened this Jul 29, 2026
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