fix(tags): allow creating a same-named character in a different fandom
The autocomplete suppressed the Create row whenever any existing tag matched name+kind — but characters are unique by (name, kind, fandom), so a same-named character in a different fandom (e.g. another "Raven") is a valid distinct tag. allowCreate now always offers Create for the character kind; the fandom picker disambiguates and find_or_create is idempotent if the same fandom is re-picked. The Create row reads "Create another \"Raven\" character (different fandom)" when a same-name character already exists. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
This commit is contained in:
@@ -72,7 +72,7 @@
|
|||||||
</v-icon>
|
</v-icon>
|
||||||
</template>
|
</template>
|
||||||
<v-list-item-title>
|
<v-list-item-title>
|
||||||
Create "{{ parsedName }}" as {{ parsedKind }}
|
{{ createLabel }}
|
||||||
</v-list-item-title>
|
</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
@@ -178,14 +178,34 @@ watch(query, () => {
|
|||||||
}, 200)
|
}, 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 allowCreate = computed(() => {
|
||||||
const q = parsedName.value
|
const q = parsedName.value
|
||||||
if (!q) return false
|
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 =>
|
return !hits.value.some(h =>
|
||||||
h.name.toLowerCase() === q.toLowerCase() && h.kind === parsedKind.value,
|
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)}%` }
|
function scorePct (s) { return `${Math.round(s.score * 100)}%` }
|
||||||
|
|
||||||
// This image's suggestions that match the typed query, minus any the server
|
// This image's suggestions that match the typed query, minus any the server
|
||||||
|
|||||||
Reference in New Issue
Block a user