1414 <option v-for =" f in rootFoldersStore.folders" :key =" f.id" :value =" f.id" >
1515 {{ f.name || f.path }}
1616 </option >
17+ <option :value =" null" >
18+ Choose another folder...
19+ </option >
1720 </select >
1821 </div >
1922
175178 :folders =" rootFoldersStore.folders"
176179 />
177180 </div >
181+
182+ <RootFolderFormModal
183+ v-if =" addRootFolder"
184+ @saved =" refreshRootFolders"
185+ @close =" addRootFolder = false"
186+ />
178187</template >
179188
180189<script setup lang="ts">
@@ -202,6 +211,7 @@ import {
202211 type LibraryImportSortDirection ,
203212 type LibraryImportSortKey ,
204213} from ' @/utils/libraryImportTable'
214+ import RootFolderFormModal from ' @/components/settings/RootFolderFormModal.vue'
205215
206216const COLUMN_WIDTH_STORAGE_KEY = ' listenarr.libraryImport.columnWidths.v1'
207217const MAX_COLUMN_WIDTH = 960
@@ -216,6 +226,7 @@ const sortKey = ref<LibraryImportSortKey>('folder')
216226const sortDirection = ref <LibraryImportSortDirection >(' asc' )
217227const columnWidths = ref <LibraryImportColumnWidths >({ ... DEFAULT_LIBRARY_IMPORT_COLUMN_WIDTHS })
218228const resizingColumn = ref <LibraryImportResizableColumnKey | null >(null )
229+ const addRootFolder = ref <boolean >(false )
219230
220231const sortOptions: Array <{ value: LibraryImportSortKey ; label: string }> = [
221232 { value: ' folder' , label: ' Book' },
@@ -271,18 +282,23 @@ onMounted(async () => {
271282 await store .initFromRootFolder (defaultFolder .id )
272283 }
273284
274- const action = configStore .applicationSettings ?.completedFileAction
275- store .inputMode = action === ' Move' || ! action ? ' move' : ' hardlink/copy'
285+ store .action = ' none'
276286})
277287
278288onBeforeUnmount (() => {
279289 stopResize ()
280290})
281291
282292async function onFolderChange() {
283- if (! selectedFolderId .value ) return
284- store .stopProcessing ()
285- await store .initFromRootFolder (selectedFolderId .value )
293+ // Selected a valid root folder
294+ if (selectedFolderId .value ) {
295+ store .stopProcessing ()
296+ await store .initFromRootFolder (selectedFolderId .value )
297+ }
298+ // Tries to create a new root folder
299+ else {
300+ addRootFolder .value = true ;
301+ }
286302}
287303
288304async function startScan() {
@@ -404,6 +420,18 @@ function persistColumnWidths() {
404420 // Non-fatal: resizing still works for the current session.
405421 }
406422}
423+
424+ async function refreshRootFolders() {
425+ addRootFolder .value = false
426+
427+ await rootFoldersStore .load ()
428+
429+ const newFolder = rootFoldersStore .getLast ();
430+ if (newFolder ) {
431+ selectedFolderId .value = newFolder .id
432+ await store .initFromRootFolder (newFolder .id )
433+ }
434+ }
407435 </script >
408436
409437<style scoped>
0 commit comments