diff --git a/packages/admin/components/PlaylistList.vue b/packages/admin/components/PlaylistList.vue
index 8dd188c..be2d76d 100644
--- a/packages/admin/components/PlaylistList.vue
+++ b/packages/admin/components/PlaylistList.vue
@@ -236,7 +236,7 @@
:enter-active-class="props.type === 'main' ? 'transition-opacity' : ''"
:leave-active-class="props.type === 'main' ? 'transition-opacity delay-75' : ''"
:leave-to-class="props.type === 'main' ? 'opacity-0' : ''"
- @click="modifyingTarget.id = song.$id; modifyingTarget.field = 'name'; modifying = true"
+ @click="modifyStart({ id: song.$id, field: 'name' })"
>
>(new Set())
-const modifying = ref(false)
+interface ModifyTarget {
+ id: Song['$id']
+ field: 'name' | 'artist' | 'payment_amount' | 'language'
+}
const modifyingTarget = ref<{
- id: Song['$id'] | null
- field: 'name' | 'artist' | 'payment_amount' | 'language' | null
+ // eslint-disable-next-line no-use-before-define
+ [P in keyof ModifyTarget]: ModifyTarget[P] | null
}>({
id: null,
field: null
})
const modifyingInput = ref>()
-watch(modifying, (value) => {
- value ?
- nextTick(() => modifyingInput.value?.[0]?.focus()) :
- nextTick(() => modifyingInput.value?.[0]?.blur())
-})
+
+function modifyStart (target: ModifyTarget) {
+ modifyingTarget.value.id = target.id
+ modifyingTarget.value.field = target.field
+ nextTick(() => modifyingInput.value?.[0]?.focus())
+}
+function modifyFinish (changes: Song) {
+ modifyingTarget.value.id = null
+ modifyingTarget.value.field = null
+ emit('stageChanges', changes)
+}
+function modifyNext (currentTarget: ModifyTarget) {
+ const fields: Array = ['name', 'artist', 'payment_amount', 'language']
+ modifyingInput.value?.[0]?.blur()
+ modifyingTarget.value.id = currentTarget.id
+ modifyingTarget.value.field = fields[fields.findIndex(field => field === currentTarget.field) + 1]
+ nextTick(() => modifyingInput.value?.[0]?.focus())
+}
function create () {
const id = crypto.randomUUID()
@@ -510,6 +532,6 @@ function create () {
setTimeout(() => scrollList('bottom'), 50)
modifyingTarget.value.id = id
modifyingTarget.value.field = 'name'
- setTimeout(() => { modifying.value = true }, 2000)
+ setTimeout(() => modifyingInput.value?.[0]?.focus(), 2000)
}