mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
Merge 5431665dfe into 1d0b7e383a
This commit is contained in:
commit
a3315e1237
4 changed files with 49 additions and 7 deletions
|
|
@ -8,7 +8,7 @@
|
|||
<div class="bg-bg rounded-lg px-2 py-6 sm:p-6 md:p-8" @click.stop>
|
||||
<div class="flex">
|
||||
<div class="grow p-1 min-w-48 sm:min-w-64 md:min-w-80">
|
||||
<ui-input-dropdown ref="newSeriesSelect" v-model="selectedSeries.name" :items="existingSeriesNames" :disabled="!isNewSeries" :label="$strings.LabelSeriesName" @input="seriesNameInputHandler" />
|
||||
<ui-input-dropdown ref="newSeriesSelect" v-model="selectedSeries.name" :items="existingSeriesNames" :label="$strings.LabelSeriesName" @input="seriesNameInputHandler" />
|
||||
</div>
|
||||
<div class="w-24 sm:w-28 md:w-40 p-1">
|
||||
<ui-text-input-with-label ref="sequenceInput" v-model="selectedSeries.sequence" :label="$strings.LabelSequence" />
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export default {
|
|||
return {
|
||||
selectedSeries: null,
|
||||
originalSeriesSequence: null,
|
||||
originalSeriesName: null,
|
||||
showSeriesForm: false
|
||||
}
|
||||
},
|
||||
|
|
@ -61,6 +62,7 @@ export default {
|
|||
}
|
||||
|
||||
this.originalSeriesSequence = _series.sequence
|
||||
this.originalSeriesName = _series.name
|
||||
this.showSeriesForm = true
|
||||
},
|
||||
addNewSeries() {
|
||||
|
|
@ -71,6 +73,7 @@ export default {
|
|||
}
|
||||
|
||||
this.originalSeriesSequence = null
|
||||
this.originalSeriesName = null
|
||||
this.showSeriesForm = true
|
||||
},
|
||||
submitSeriesForm() {
|
||||
|
|
@ -81,6 +84,18 @@ export default {
|
|||
|
||||
var existingSeriesIndex = this.seriesItems.findIndex((se) => se.id === this.selectedSeries.id)
|
||||
|
||||
// Check if renaming to a name that already exists in the library (different series)
|
||||
var seriesSameName = this.series.find((se) => se.name.toLowerCase() === this.selectedSeries.name.toLowerCase())
|
||||
if (seriesSameName && seriesSameName.id !== this.selectedSeries.id) {
|
||||
// If editing an existing series and trying to rename to an existing name, block it
|
||||
if (!this.selectedSeries.id.startsWith('new-')) {
|
||||
this.$toast.error(this.$strings.ToastSeriesDuplicateName)
|
||||
return
|
||||
}
|
||||
// For new series, use the existing series id instead
|
||||
this.selectedSeries.id = seriesSameName.id
|
||||
}
|
||||
|
||||
var existingSeriesSameName = this.seriesItems.findIndex((se) => se.name.toLowerCase() === this.selectedSeries.name.toLowerCase())
|
||||
if (existingSeriesSameName >= 0 && existingSeriesIndex < 0) {
|
||||
console.error('Attempt to add duplicate series')
|
||||
|
|
@ -88,11 +103,6 @@ export default {
|
|||
return
|
||||
}
|
||||
|
||||
var seriesSameName = this.series.find((se) => se.name.toLowerCase() === this.selectedSeries.name.toLowerCase())
|
||||
if (existingSeriesIndex < 0 && seriesSameName) {
|
||||
this.selectedSeries.id = seriesSameName.id
|
||||
}
|
||||
|
||||
var selectedSeriesCopy = { ...this.selectedSeries }
|
||||
selectedSeriesCopy.displayName = selectedSeriesCopy.sequence ? `${selectedSeriesCopy.name} #${selectedSeriesCopy.sequence}` : selectedSeriesCopy.name
|
||||
|
||||
|
|
@ -105,7 +115,25 @@ export default {
|
|||
this.seriesItems = seriesCopy
|
||||
}
|
||||
|
||||
// If this is an existing series (not new), update the series name immediately
|
||||
if (!this.selectedSeries.id.startsWith('new-')) {
|
||||
const hasNameChanged = this.originalSeriesName && this.selectedSeries.name !== this.originalSeriesName
|
||||
if (hasNameChanged) {
|
||||
this.updateSeriesName(this.selectedSeries.id, this.selectedSeries.name)
|
||||
}
|
||||
}
|
||||
|
||||
this.showSeriesForm = false
|
||||
},
|
||||
async updateSeriesName(seriesId, name) {
|
||||
try {
|
||||
await this.$axios.$patch(`/api/series/${seriesId}`, { name })
|
||||
this.$toast.success(this.$strings.ToastSeriesUpdateSuccess)
|
||||
} catch (error) {
|
||||
console.error('Failed to update series name:', error)
|
||||
const errorMsg = error.response?.data || this.$strings.ToastSeriesUpdateFailed
|
||||
this.$toast.error(errorMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue