From a1cc1f20098eb5d333a435dada01e94dd0dbb38b Mon Sep 17 00:00:00 2001 From: Jonathan Pagel Date: Sat, 15 Apr 2023 09:26:36 +0200 Subject: [PATCH] AppSettings: Add FilePicker for notesPath like in #990 Signed-off-by: Jonathan Pagel --- src/components/AppSettings.vue | 37 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) 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)