Dragonroll frontend: item modifications #35

Closed
opened 2026-10-14 17:50:22 +00:00 by Syndria98 · 14 comments
Owner
  • Make that when clicking an item on the sidebar it opens a window with that item info
  • Also add a button to select the icon of an item. It should fetch from foundry's icons (if it is possible), and also add your own icon.
- Make that when clicking an item on the sidebar it opens a window with that item info - Also add a button to select the icon of an item. It should fetch from foundry's icons (if it is possible), and also add your own icon.
Syndria98 added the ai-ready label 2026-10-14 17:50:22 +00:00
Agent added the working label 2026-10-14 17:52:39 +00:00
Collaborator

Now let me look at the tests, the locale files, and the Server service:

Now let me look at the tests, the locale files, and the Server service:
Collaborator

I now have the full picture. Let me implement. Starting with the backend:

I now have the full picture. Let me implement. Starting with the backend:
Collaborator

Now the item routes — image in the partial update and an upload endpoint mirroring actor/upload-image:

Now the item routes — `image` in the partial update and an upload endpoint mirroring `actor/upload-image`:
Collaborator

Now the Foundry module: send embedded item icons as absolute URLs, and push the Dragonroll-chosen icon back into the linked world:

Now the Foundry module: send embedded item icons as absolute URLs, and push the Dragonroll-chosen icon back into the linked world:
Collaborator

Now the frontend. Register the window:

Now the frontend. Register the window:
Collaborator

Now wire the sidebar click to the new window:

Now wire the sidebar click to the new window:
Collaborator

That edit went wrong — let me check and fix:

That edit went wrong — let me check and fix:
Collaborator

Sidebar is fixed. Now the i18n strings — all three locales:

Sidebar is fixed. Now the i18n strings — all three locales:
Collaborator

Now the tests. The repo convention is dependency-free node --test files — behavior tests for pure backend services plus source scans for wiring:

Now the tests. The repo convention is dependency-free `node --test` files — behavior tests for pure backend services plus source scans for wiring:
Collaborator

Run the test suite:

Run the test suite:
Collaborator

All 80 tests pass. Let me confirm my new tests ran and do a final review of the diff:

All 80 tests pass. Let me confirm my new tests ran and do a final review of the diff:
Collaborator

Final review of the backend and module diffs:

Final review of the backend and module diffs:
Collaborator

Done — full suite green (80/80, including the 9 new tests). Here's a summary of the change for issue #35:

Frontend — item window & icon picker

  • ContentSidebar.vue: clicking an item (or Enter/Space on its row) now opens a window instead of expanding details inline. openItemSheet() mirrors openCharacterSheet() (single instance, replace-on-reopen); the old toggleEntryDetails/expandedEntryIds inline expansion is removed. Right-click Edit/Delete menu is untouched.
  • ItemSheetWindow.vue (new) + WindowDefinitions.js (item_sheet entry): shows the item's info — icon, name, category, rarity, synced badge, quantity, weight, properties, description — and follows background Foundry sync updates via campaign-entry-updated, like the character sheet does.
  • Icon selection in that window:
    • Your own icon: upload button → POST /item/upload-image?item=<id> (same flow as the character sheet's photo), plus a remove button.
    • Foundry's icons: when the item is synced, the world's own icon is kept on the item and a "Use Foundry icon" button switches back to it.
  • i18n strings added to all three locales (windows.item-sheet, campaigns.item.sheet.*); styled with var(--color-…) only.

Backend

  • models/Item.js: new image (upload filename or URL) and foundryImage (icon Foundry last sent) fields.
  • services/item-foundry.js: maps Foundry's img into image, like the actor mapper already does.
  • routes/foundry-link.js: saveFoundryItem always refreshes foundryImage, so Foundry's icon survives the fullSync preserve-edits rule and user overrides.
  • routes/item.js: /update accepts image; new POST /upload-image (multipart, ownership-checked) mirroring the actor route.

Foundry module (dragonroll-foundry/scripts/api.js)

  • Actor-embedded items now go through serializeFoundryItem, so their icons are sent as absolute URLs (Dragonroll renders them outside Foundry) — same rule already applied to actor portraits.
  • A Dragonroll-chosen icon travels back to the linked world (img on item create/update), and an empty icon leaves the world's choice alone instead of erasing it.

Tests

  • tests/item-sheet-window.test.js (new, dependency-free node --test): behavior tests for the Foundry→item icon mapping plus wiring checks (model fields, sync keep, upload/update routes, window registration, sidebar click, module serialization) and locale coverage. npm test: 80 pass, 0 fail.
Done — full suite green (80/80, including the 9 new tests). Here's a summary of the change for issue #35: ## Frontend — item window & icon picker - **`ContentSidebar.vue`**: clicking an item (or Enter/Space on its row) now opens a window instead of expanding details inline. `openItemSheet()` mirrors `openCharacterSheet()` (single instance, replace-on-reopen); the old `toggleEntryDetails`/`expandedEntryIds` inline expansion is removed. Right-click Edit/Delete menu is untouched. - **`ItemSheetWindow.vue`** (new) + **`WindowDefinitions.js`** (`item_sheet` entry): shows the item's info — icon, name, category, rarity, synced badge, quantity, weight, properties, description — and follows background Foundry sync updates via `campaign-entry-updated`, like the character sheet does. - **Icon selection** in that window: - *Your own icon*: upload button → `POST /item/upload-image?item=<id>` (same flow as the character sheet's photo), plus a remove button. - *Foundry's icons*: when the item is synced, the world's own icon is kept on the item and a **"Use Foundry icon"** button switches back to it. - i18n strings added to all three locales (`windows.item-sheet`, `campaigns.item.sheet.*`); styled with `var(--color-…)` only. ## Backend - **`models/Item.js`**: new `image` (upload filename or URL) and `foundryImage` (icon Foundry last sent) fields. - **`services/item-foundry.js`**: maps Foundry's `img` into `image`, like the actor mapper already does. - **`routes/foundry-link.js`**: `saveFoundryItem` always refreshes `foundryImage`, so Foundry's icon survives the fullSync preserve-edits rule and user overrides. - **`routes/item.js`**: `/update` accepts `image`; new `POST /upload-image` (multipart, ownership-checked) mirroring the actor route. ## Foundry module (`dragonroll-foundry/scripts/api.js`) - Actor-embedded items now go through `serializeFoundryItem`, so their icons are sent as absolute URLs (Dragonroll renders them outside Foundry) — same rule already applied to actor portraits. - A Dragonroll-chosen icon travels back to the linked world (`img` on item create/update), and an empty icon leaves the world's choice alone instead of erasing it. ## Tests - **`tests/item-sheet-window.test.js`** (new, dependency-free `node --test`): behavior tests for the Foundry→item icon mapping plus wiring checks (model fields, sync keep, upload/update routes, window registration, sidebar click, module serialization) and locale coverage. `npm test`: 80 pass, 0 fail.
Collaborator

Implementation is ready for review: #39

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/39
Agent added help wanted and removed working labels 2026-10-14 18:08:20 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#35