diff --git a/src/components/AppSettings.vue b/src/components/AppSettings.vue index 5840e9c90..92cbd0460 100644 --- a/src/components/AppSettings.vue +++ b/src/components/AppSettings.vue @@ -21,15 +21,13 @@

{{ t('notes', 'Folder to store your notes') }}

-
- -
+

@@ -86,6 +84,8 @@ import { NcAppSettingsSection, } from '@nextcloud/vue' +import { FilePicker, FilePickerType } from '@nextcloud/dialogs' + import { setSettings } from '../NotesService.js' import store from '../store.js' import HelpMobile from './HelpMobile.vue' @@ -153,6 +153,25 @@ export default { }, methods: { + onChangeNotePath(event) { + // Code Example from: https://github.com/nextcloud/text/blob/main/src/components/Menu/ActionInsertLink.vue#L130-L155 + const filePicker = new FilePicker( + t('text', 'Select folder to link to'), + false, // multiselect + ['text/directory'], // mime filter + true, // modal + FilePickerType.Choose, // type + true, // directories + event.target.value === '' ? '/' : event.target.value // path + ) + filePicker.pick().then((file) => { + const client = OC.Files.getClient() + client.getFileInfo(file).then((_status, fileInfo) => { + this.settings.notesPath = fileInfo.path === '/' ? `/${fileInfo.name}` : `${fileInfo.path}/${fileInfo.name}` + this.onChangeSettingsReload() + }) + }) + }, onChangeSettings() { this.saving = true return setSettings(this.settings)