diff --git a/frontend/src/components/modal/TagAutocomplete.vue b/frontend/src/components/modal/TagAutocomplete.vue index 43ab0e1..65f3527 100644 --- a/frontend/src/components/modal/TagAutocomplete.vue +++ b/frontend/src/components/modal/TagAutocomplete.vue @@ -72,7 +72,7 @@ - Create "{{ parsedName }}" as {{ parsedKind }} + {{ createLabel }} @@ -178,14 +178,34 @@ watch(query, () => { }, 200) }) +// A same-name character ALREADY exists. Characters are unique by +// (name, kind, fandom), so this is still a valid distinct tag in another fandom. +const sameNameCharExists = computed(() => + parsedKind.value === 'character' && + hits.value.some(h => + h.kind === 'character' && h.name.toLowerCase() === parsedName.value.toLowerCase(), + ), +) + const allowCreate = computed(() => { const q = parsedName.value if (!q) return false + // Characters disambiguate by fandom, so a same-named character in a DIFFERENT + // fandom is a valid new tag — always offer Create (the fandom picker resolves + // it; find_or_create is idempotent if you re-pick the same fandom). Other + // kinds are unique by (name, kind): an exact match means it already exists. + if (parsedKind.value === 'character') return true return !hits.value.some(h => h.name.toLowerCase() === q.toLowerCase() && h.kind === parsedKind.value, ) }) +const createLabel = computed(() => + sameNameCharExists.value + ? `Create another "${parsedName.value}" character (different fandom)` + : `Create "${parsedName.value}" as ${parsedKind.value}`, +) + function scorePct (s) { return `${Math.round(s.score * 100)}%` } // This image's suggestions that match the typed query, minus any the server