diff --git a/frontend/app/components/partials/ContentSidebar.vue b/frontend/app/components/partials/ContentSidebar.vue index c32591cc..597a53a6 100644 --- a/frontend/app/components/partials/ContentSidebar.vue +++ b/frontend/app/components/partials/ContentSidebar.vue @@ -7,7 +7,7 @@ import { AnchorMap, AnchoredMap, ClearAnchoredMap, SetActivePane } from '~/servi import { emitter } from '~/services/Emitter'; import { BuildColorMenu } from '~/services/EntryColors'; import { BuildItemRows } from '~/services/ItemFolders'; -import Server from '~/services/Server'; +import Server, { getBaseUrl } from '~/services/Server'; import { ClearWindow, CreateWindow, GetFirstWindowId } from '~/services/Windows'; import { HideContextMenu, ShowContextMenu } from '~/services/ContextMenu'; import { ACTOR_DRAG_TYPE } from '~/services/MapTokens'; @@ -283,6 +283,13 @@ function itemSummary(item) { return `${t(`campaigns.item.categories.${item.category}`)} · ${t(`campaigns.item.rarities.${item.rarity}`)} · ${t('campaigns.item.quantity-short')} ${item.quantity}`; } +// An item's icon in the sidebar: an uploaded filename served from /api/public, or a full URL +// (Foundry sends its own icon as one) — the same rule the item window uses. +function itemImageUrl(image) { + if (!image) return ''; + return /^(https?:|data:|\/\/)/i.test(image) ? image : `${getBaseUrl()}/public/${image}`; +} + function mapSummary(map) { return t('campaigns.map.summary', { size: map.gridSize, scale: map.scale }); } @@ -670,9 +677,11 @@ onBeforeUnmount(() => { @toggle="toggleFolder(row.folder._id)" />
- + + {{ row.item.name }} - {{ t('campaigns.synced') }}
@@ -865,6 +874,15 @@ onBeforeUnmount(() => { } .entity-entry-meta, .entity-entry-description { font-size: 12px; opacity: 0.72; } .entity-entry-description { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; } +/* An item row leads with the item's own icon on the left of its name, standing in for the + "SYNCED" text it used to show (Syndria98/dragonroll#53). */ +.entity-entry-title { display: flex; align-items: center; gap: 9px; min-width: 0; } +.entity-entry-image { + flex: 0 0 30px; width: 30px; height: 30px; box-sizing: border-box; + display: grid; place-items: center; overflow: hidden; + border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-background-soft); +} +.entity-entry-image img { width: 100%; height: 100%; object-fit: contain; } @media (max-width: 900px) { .notes-sidebar { diff --git a/tests/item-entry-display.test.js b/tests/item-entry-display.test.js new file mode 100644 index 00000000..a9e21ccc --- /dev/null +++ b/tests/item-entry-display.test.js @@ -0,0 +1,69 @@ +// Tests for Syndria98/dragonroll#53: the item row in the campaign sidebar dropped its "SYNCED" +// text badge and now leads with the item's own icon on the left of the entry. +// +// The repository root installs no dependencies, so these read the sidebar component the way +// tests/sidebar-entity-entry.test.js does — the checks are about the markup and style of the row. +// +// Run with `npm test` from the repository root, or `node --test tests/`. + +const { test } = require("node:test"); +const assert = require("node:assert/strict"); +const fs = require("node:fs"); +const path = require("node:path"); + +const source = fs.readFileSync( + path.join(__dirname, "..", "frontend", "app", "components", "partials", "ContentSidebar.vue"), + "utf8" +); + +// The block that renders the item rows, from the items section down to its closing template. The +// items section is followed by the maps section (`v-else`), so the first `` that leads +// there ends it; the inner `v-for` close is followed by another close, not by `v-else`. +const itemSection = + /