From b1cf40edd038a31f404fe0f904f057029828c581 Mon Sep 17 00:00:00 2001 From: xiaomai Date: Thu, 7 May 2026 09:59:10 +0800 Subject: [PATCH] feat(frontend): add thumbnail support to TagsSelect component Display item and pokemon images in dropdown options and selected values Update Admin, Dish, Habitat, Pokemon, and Recipe views to pass image URLs --- frontend/src/components/TagsSelect.vue | 19 ++++++++--- frontend/src/styles/main.css | 46 +++++++++++++++++++++++++- frontend/src/views/AdminView.vue | 4 ++- frontend/src/views/DishView.vue | 2 +- frontend/src/views/HabitatEdit.vue | 4 +-- frontend/src/views/PokemonEdit.vue | 7 ++-- frontend/src/views/RecipeEdit.vue | 4 +-- 7 files changed, 71 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/TagsSelect.vue b/frontend/src/components/TagsSelect.vue index 402b084..996c2c3 100644 --- a/frontend/src/components/TagsSelect.vue +++ b/frontend/src/components/TagsSelect.vue @@ -8,12 +8,14 @@ export type TagsSelectOption = { id: number | string; name: string; label?: string; + thumbnailUrl?: string | null; }; type OptionRow = { value: string; label: string; id: string; + thumbnailUrl: string | null; }; type CandidateRow = { type: 'option'; id: string; value: string; label: string } | { type: 'create'; id: string }; @@ -65,7 +67,8 @@ const optionRows = computed(() => props.options.map((option, index) => ({ value: String(option.id), label: option.label ?? option.name, - id: `${props.id}-option-${index}` + id: `${props.id}-option-${index}`, + thumbnailUrl: option.thumbnailUrl ?? null })) ); @@ -79,9 +82,10 @@ const maxReached = computed(() => props.multiple && props.max > 0 && modelValues const selectedRows = computed(() => modelValues.value .map((value) => optionRows.value.find((option) => option.value === value)) - .filter((option) => option !== undefined) + .filter((option): option is OptionRow => option !== undefined) ); const selectedLabel = computed(() => selectedRows.value[0]?.label ?? ''); +const selectedThumbnailUrl = computed(() => selectedRows.value[0]?.thumbnailUrl ?? ''); const filteredRows = computed(() => { const keyword = search.value.trim().toLowerCase(); @@ -360,6 +364,7 @@ watch( - {{ selectedLabel }} + + + {{ selectedLabel }} + {{ placeholderText }}