Update:Library folder path editable in library edit modal until submit #2150

This commit is contained in:
advplyr 2023-09-27 17:50:32 -05:00
parent d7b2476473
commit ed82a5aa19
2 changed files with 8 additions and 6 deletions

View File

@ -20,7 +20,7 @@
<p class="px-1 text-sm font-semibold">{{ $strings.LabelFolders }}</p> <p class="px-1 text-sm font-semibold">{{ $strings.LabelFolders }}</p>
<div v-for="(folder, index) in folders" :key="index" class="w-full flex items-center py-1 px-2"> <div v-for="(folder, index) in folders" :key="index" class="w-full flex items-center py-1 px-2">
<span class="material-icons bg-opacity-50 mr-2 text-yellow-200" style="font-size: 1.2rem">folder</span> <span class="material-icons bg-opacity-50 mr-2 text-yellow-200" style="font-size: 1.2rem">folder</span>
<ui-editable-text ref="folderInput" v-model="folder.fullPath" readonly type="text" class="w-full" /> <ui-editable-text ref="folderInput" v-model="folder.fullPath" :readonly="!!folder.id" type="text" class="w-full" @blur="existingFolderInputBlurred(folder)" />
<span v-show="folders.length > 1" class="material-icons text-2xl ml-2 cursor-pointer hover:text-error" @click="removeFolder(folder)">close</span> <span v-show="folders.length > 1" class="material-icons text-2xl ml-2 cursor-pointer hover:text-error" @click="removeFolder(folder)">close</span>
</div> </div>
<div class="flex py-1 px-2 items-center w-full"> <div class="flex py-1 px-2 items-center w-full">
@ -67,10 +67,6 @@ export default {
value: 'podcast', value: 'podcast',
text: this.$strings.LabelPodcasts text: this.$strings.LabelPodcasts
} }
// {
// value: 'music',
// text: 'Music'
// }
] ]
}, },
folderPaths() { folderPaths() {
@ -110,6 +106,11 @@ export default {
formUpdated() { formUpdated() {
this.$emit('update', this.getLibraryData()) this.$emit('update', this.getLibraryData())
}, },
existingFolderInputBlurred(folder) {
if (!folder.fullPath) {
this.removeFolder(folder)
}
},
newFolderInputBlurred() { newFolderInputBlurred() {
if (this.newFolderPath) { if (this.newFolderPath) {
this.folders.push({ fullPath: this.newFolderPath }) this.folders.push({ fullPath: this.newFolderPath })
@ -149,6 +150,7 @@ export default {
this.folders = this.library ? this.library.folders.map((p) => ({ ...p })) : [] this.folders = this.library ? this.library.folders.map((p) => ({ ...p })) : []
this.icon = this.library ? this.library.icon : 'default' this.icon = this.library ? this.library.icon : 'default'
this.mediaType = this.library ? this.library.mediaType : 'book' this.mediaType = this.library ? this.library.mediaType : 'book'
this.showDirectoryPicker = false this.showDirectoryPicker = false
} }
}, },

View File

@ -120,7 +120,7 @@ export default {
for (const key in this.libraryCopy) { for (const key in this.libraryCopy) {
if (library[key] !== undefined) { if (library[key] !== undefined) {
if (key === 'folders') { if (key === 'folders') {
this.libraryCopy.folders = library.folders.map((f) => ({ ...f })) this.libraryCopy.folders = library.folders.map((f) => ({ ...f })).filter((f) => !!f.fullPath?.trim())
} else if (key === 'settings') { } else if (key === 'settings') {
for (const settingKey in library.settings) { for (const settingKey in library.settings) {
this.libraryCopy.settings[settingKey] = library.settings[settingKey] this.libraryCopy.settings[settingKey] = library.settings[settingKey]