feat(artist): editable display name + rename surface; drop name-uniqueness (#130 step 1)
First step of decoupling artist identity/storage/display. migration 0077 drops uq_artist_name so the display name is free text (two genuinely different creators can share a name); the slug stays the immutable, unique storage/identity key (the on-disk path component — untouched, so nothing moves). ArtistService.rename + PATCH /api/artists/<id> change the name ONLY. Frontend: inline pencil-edit on the artist header (mirrors TagCard), slug/route unaffected so no navigation. Fixes the operator's 'no surface to rename an artist' + the name-collision fragility. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDgx8bQS5YrGRK76v8HUnM
This commit is contained in:
@@ -1,8 +1,21 @@
|
||||
<template>
|
||||
<header class="fc-artist-header">
|
||||
<div class="fc-artist-header__left">
|
||||
<h1 class="fc-artist-header__name">{{ name }}</h1>
|
||||
<span v-if="stats" class="fc-artist-header__stats">{{ stats }}</span>
|
||||
<template v-if="!editing">
|
||||
<h1 class="fc-artist-header__name">{{ name }}</h1>
|
||||
<v-icon
|
||||
class="fc-artist-header__edit" size="16" icon="mdi-pencil"
|
||||
title="Rename artist (display name only)" @click="startEdit"
|
||||
/>
|
||||
</template>
|
||||
<v-text-field
|
||||
v-else
|
||||
v-model="draft"
|
||||
density="compact" variant="outlined" hide-details autofocus
|
||||
class="fc-artist-header__edit-field"
|
||||
@keydown.enter="submit" @keydown.esc="cancel" @blur="cancel"
|
||||
/>
|
||||
<span v-if="stats && !editing" class="fc-artist-header__stats">{{ stats }}</span>
|
||||
</div>
|
||||
<v-tabs
|
||||
:model-value="modelValue"
|
||||
@@ -34,7 +47,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { formatLocalDate } from '../../utils/date.js'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -45,7 +58,23 @@ const props = defineProps({
|
||||
modelValue: { type: String, required: true },
|
||||
})
|
||||
|
||||
defineEmits(['update:modelValue'])
|
||||
const emit = defineEmits(['update:modelValue', 'rename'])
|
||||
|
||||
// Inline rename (display name only — #130). Mirrors TagCard's pencil-edit.
|
||||
const editing = ref(false)
|
||||
const draft = ref('')
|
||||
function startEdit () {
|
||||
draft.value = props.name
|
||||
editing.value = true
|
||||
}
|
||||
function cancel () {
|
||||
editing.value = false
|
||||
}
|
||||
function submit () {
|
||||
const next = draft.value.trim()
|
||||
editing.value = false
|
||||
if (next && next !== props.name) emit('rename', next)
|
||||
}
|
||||
|
||||
const stats = computed(() => {
|
||||
const parts = []
|
||||
@@ -111,6 +140,20 @@ const stats = computed(() => {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.fc-artist-header__edit {
|
||||
flex: 0 0 auto;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
color: rgb(var(--v-theme-on-surface-variant));
|
||||
transition: opacity .15s ease;
|
||||
}
|
||||
.fc-artist-header__left:hover .fc-artist-header__edit { opacity: .7; }
|
||||
.fc-artist-header__edit:hover { opacity: 1; }
|
||||
.fc-artist-header__edit-field {
|
||||
max-width: 340px;
|
||||
font-family: 'Fraunces', Georgia, serif;
|
||||
}
|
||||
|
||||
.fc-artist-header__tabs {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,16 @@ export const useArtistStore = defineStore('artist', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Rename the DISPLAY name only (#130). The slug is immutable, so the route
|
||||
// (slug-based) and on-disk paths are unaffected — just patch the shown name.
|
||||
async function rename (name) {
|
||||
if (!overview.value) return
|
||||
const id = overview.value.id
|
||||
const body = await api.patch(`/api/artists/${id}`, { body: { name } })
|
||||
if (overview.value && overview.value.id === id) overview.value.name = body.name
|
||||
return body
|
||||
}
|
||||
|
||||
const hasMoreImages = computed(() => !started || nextCursor.value !== null)
|
||||
const postCount = computed(() => overview.value?.post_count ?? null)
|
||||
const imageCount = computed(() => overview.value?.image_count ?? null)
|
||||
@@ -81,6 +91,6 @@ export const useArtistStore = defineStore('artist', () => {
|
||||
return {
|
||||
overview, images, loading, imagesLoading, error, notFound,
|
||||
hasMoreImages, postCount, imageCount, lastAdded,
|
||||
load, loadMoreImages,
|
||||
load, loadMoreImages, rename,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
:image-count="store.imageCount"
|
||||
:post-count="store.postCount"
|
||||
:last-added="store.lastAdded"
|
||||
@rename="onRename"
|
||||
/>
|
||||
<v-container fluid class="pt-2 pb-4">
|
||||
<!-- "N new since last visit" banner. Visible only on the initial
|
||||
@@ -59,6 +60,7 @@ import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
import { useArtistStore } from '../stores/artist.js'
|
||||
import { toast } from '../utils/toast.js'
|
||||
import ArtistHeader from '../components/artist/ArtistHeader.vue'
|
||||
import ArtistPostsTab from '../components/artist/ArtistPostsTab.vue'
|
||||
import ArtistGalleryTab from '../components/artist/ArtistGalleryTab.vue'
|
||||
@@ -76,6 +78,17 @@ const { tab, resolve } = useTabQuery(
|
||||
() => ((store.postCount ?? 0) > 0 ? 'posts' : 'gallery'),
|
||||
)
|
||||
|
||||
// Rename the artist's display name (#130). Slug/route unchanged, so no
|
||||
// navigation — the header just reflects the new name; also refresh the tab title.
|
||||
async function onRename (name) {
|
||||
try {
|
||||
await store.rename(name)
|
||||
document.title = `${store.overview.name} — FabledCurator`
|
||||
} catch (e) {
|
||||
toast({ text: `Rename failed: ${e.message}`, type: 'error' })
|
||||
}
|
||||
}
|
||||
|
||||
// One-shot banner — reset on each new artist-slug load so it re-appears
|
||||
// when navigating between artists that each have unseen content.
|
||||
const unseenBanner = ref(false)
|
||||
|
||||
Reference in New Issue
Block a user