Skip to content

Commit 393e75d

Browse files
committed
AppSettings: Add FilePicker for notesPath
Signed-off-by: Jonathan Pagel <jonny_tischbein@systemli.org>
1 parent 6dca9d7 commit 393e75d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/components/AppSettings.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
type="text"
1111
name="notesPath"
1212
:placeholder="t('notes', 'Root directory')"
13-
@change="onChangeSettingsReload"
14-
><input type="submit" class="icon-confirm" value="">
13+
@click="onChangeNotePath"
14+
>
1515
</form>
1616
</div>
1717
<div class="settings-block">
@@ -51,6 +51,7 @@ import {
5151
} from '@nextcloud/vue'
5252
5353
import { setSettings } from '../NotesService.js'
54+
import { FilePicker, FilePickerType } from '@nextcloud/dialogs'
5455
import store from '../store.js'
5556
5657
export default {
@@ -89,6 +90,25 @@ export default {
8990
},
9091
9192
methods: {
93+
onChangeNotePath(input) {
94+
// Code Example from: https://github.com/nextcloud/text/blob/main/src/components/Menu/ActionInsertLink.vue#L130-L155
95+
const filePicker = new FilePicker(
96+
t('text', 'Select folder to link to'),
97+
false, // multiselect
98+
[], // mime filter
99+
true, // modal
100+
FilePickerType.Choose, // type
101+
true, // directories
102+
'/' // path
103+
)
104+
filePicker.pick().then((file) => {
105+
const client = OC.Files.getClient()
106+
client.getFileInfo(file).then((_status, fileInfo) => {
107+
this.settings.notesPath = fileInfo.path === '/' ? `/${fileInfo.name}` : `${fileInfo.path}/${fileInfo.name}`
108+
this.onChangeSettingsReload()
109+
})
110+
})
111+
},
92112
onChangeSettings() {
93113
this.saving = true
94114
return setSettings(this.settings)

0 commit comments

Comments
 (0)