Merge pull request #3014 from BrianCArnold/UpdateMatchImportTagsAndNarrators

Change Tags and Narrators to work the same as Genres on the Match page.
This commit is contained in:
advplyr 2024-05-26 14:39:03 -05:00 committed by GitHub
commit 8ec9da143f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 14 deletions

View File

@ -79,7 +79,7 @@
<div v-if="selectedMatchOrig.narrator" class="flex items-center py-2"> <div v-if="selectedMatchOrig.narrator" class="flex items-center py-2">
<ui-checkbox v-model="selectedMatchUsage.narrator" checkbox-bg="bg" @input="checkboxToggled" /> <ui-checkbox v-model="selectedMatchUsage.narrator" checkbox-bg="bg" @input="checkboxToggled" />
<div class="flex-grow ml-4"> <div class="flex-grow ml-4">
<ui-text-input-with-label v-model="selectedMatch.narrator" :disabled="!selectedMatchUsage.narrator" :label="$strings.LabelNarrators" /> <ui-multi-select v-model="selectedMatch.narrator" :items="narrators" :disabled="!selectedMatchUsage.narrator" :label="$strings.LabelNarrators" />
<p v-if="mediaMetadata.narratorName" class="text-xs ml-1 text-white text-opacity-60">{{ $strings.LabelCurrently }} {{ mediaMetadata.narratorName || '' }}</p> <p v-if="mediaMetadata.narratorName" class="text-xs ml-1 text-white text-opacity-60">{{ $strings.LabelCurrently }} {{ mediaMetadata.narratorName || '' }}</p>
</div> </div>
</div> </div>
@ -122,7 +122,7 @@
<div v-if="selectedMatchOrig.tags" class="flex items-center py-2"> <div v-if="selectedMatchOrig.tags" class="flex items-center py-2">
<ui-checkbox v-model="selectedMatchUsage.tags" checkbox-bg="bg" @input="checkboxToggled" /> <ui-checkbox v-model="selectedMatchUsage.tags" checkbox-bg="bg" @input="checkboxToggled" />
<div class="flex-grow ml-4"> <div class="flex-grow ml-4">
<ui-text-input-with-label v-model="selectedMatch.tags" :disabled="!selectedMatchUsage.tags" :label="$strings.LabelTags" /> <ui-multi-select v-model="selectedMatch.tags" :items="tags" :disabled="!selectedMatchUsage.tags" :label="$strings.LabelTags" />
<p v-if="media.tags" class="text-xs ml-1 text-white text-opacity-60">{{ $strings.LabelCurrently }} {{ media.tags.join(', ') }}</p> <p v-if="media.tags" class="text-xs ml-1 text-white text-opacity-60">{{ $strings.LabelCurrently }} {{ media.tags.join(', ') }}</p>
</div> </div>
</div> </div>
@ -280,6 +280,9 @@ export default {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['libraries/getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
filterData() {
return this.$store.state.libraries.filterData
},
providers() { providers() {
if (this.isPodcast) return this.$store.state.scanners.podcastProviders if (this.isPodcast) return this.$store.state.scanners.podcastProviders
return this.$store.state.scanners.providers return this.$store.state.scanners.providers
@ -305,11 +308,16 @@ export default {
isPodcast() { isPodcast() {
return this.mediaType == 'podcast' return this.mediaType == 'podcast'
}, },
narrators() {
return this.filterData.narrators || []
},
genres() { genres() {
const filterData = this.$store.state.libraries.filterData || {} const currentGenres = this.filterData.genres || []
const currentGenres = filterData.genres || []
const selectedMatchGenres = this.selectedMatch.genres || [] const selectedMatchGenres = this.selectedMatch.genres || []
return [...new Set([...currentGenres, ...selectedMatchGenres])] return [...new Set([...currentGenres, ...selectedMatchGenres])]
},
tags() {
return this.filterData.tags || []
} }
}, },
methods: { methods: {
@ -479,6 +487,12 @@ export default {
// match.genres = match.genres.join(',') // match.genres = match.genres.join(',')
match.genres = match.genres.split(',').map((g) => g.trim()) match.genres = match.genres.split(',').map((g) => g.trim())
} }
if (match.tags && !Array.isArray(match.tags)) {
match.tags = match.tags.split(',').map((g) => g.trim())
}
if (match.narrator && !Array.isArray(match.narrator)) {
match.narrator = match.narrator.split(',').map((g) => g.trim())
}
} }
console.log('Select Match', match) console.log('Select Match', match)
@ -522,11 +536,11 @@ export default {
) )
updatePayload.metadata.authors = authorPayload updatePayload.metadata.authors = authorPayload
} else if (key === 'narrator') { } else if (key === 'narrator') {
updatePayload.metadata.narrators = this.selectedMatch[key].split(',').map((v) => v.trim()) updatePayload.metadata.narrators = this.selectedMatch[key]
} else if (key === 'genres') { } else if (key === 'genres') {
updatePayload.metadata.genres = [...this.selectedMatch[key]] updatePayload.metadata.genres = [...this.selectedMatch[key]]
} else if (key === 'tags') { } else if (key === 'tags') {
updatePayload.tags = this.selectedMatch[key].split(',').map((v) => v.trim()) updatePayload.tags = this.selectedMatch[key]
} else if (key === 'itunesId') { } else if (key === 'itunesId') {
updatePayload.metadata.itunesId = Number(this.selectedMatch[key]) updatePayload.metadata.itunesId = Number(this.selectedMatch[key])
} else { } else {

View File

@ -302,6 +302,14 @@ export default {
this.recalcMenuPos() this.recalcMenuPos()
}) })
}, },
resetInput() {
this.textInput = null
this.currentSearch = null
this.selectedMenuItemIndex = null
this.$nextTick(() => {
this.blur()
})
},
insertNewItem(item) { insertNewItem(item) {
this.selected.push(item) this.selected.push(item)
this.$emit('input', this.selected) this.$emit('input', this.selected)
@ -316,15 +324,18 @@ export default {
submitForm() { submitForm() {
if (!this.textInput) return if (!this.textInput) return
var cleaned = this.textInput.trim() const cleaned = this.textInput.trim()
var matchesItem = this.items.find((i) => { if (!cleaned) {
return i === cleaned this.resetInput()
})
if (matchesItem) {
this.clickedOption(null, matchesItem)
} else { } else {
this.insertNewItem(this.textInput) const matchesItem = this.items.find((i) => i === cleaned)
if (matchesItem) {
this.clickedOption(null, matchesItem)
} else {
this.insertNewItem(cleaned)
}
} }
if (this.$refs.input) this.$refs.input.style.width = '24px' if (this.$refs.input) this.$refs.input.style.width = '24px'
}, },
scroll() { scroll() {
@ -352,4 +363,4 @@ input:read-only {
color: #aaa; color: #aaa;
background-color: #444; background-color: #444;
} }
</style> </style>