|
7 | 7 | @update:open="setSettingsOpen($event)" |
8 | 8 | > |
9 | 9 | <NcAppSettingsSection id="help-basics" :title="t('notes', 'Basics')"> |
10 | | - <div class="feature icon-add"> |
11 | | - {{ t('notes', 'Start writing a note by clicking on “{newnote}” in the app navigation.', { newnote: t('notes', 'New note') }) }} |
12 | | - </div> |
13 | | - <div class="feature icon-fullscreen"> |
14 | | - {{ t('notes', 'Write down your thoughts without any distractions.') }} |
15 | | - </div> |
16 | | - <div class="feature icon-files-dark"> |
17 | | - {{ t('notes', 'Organize your notes in categories.') }} |
18 | | - </div> |
| 10 | + <div class="feature icon-add"> |
| 11 | + {{ t('notes', 'Start writing a note by clicking on “{newnote}” in the app navigation.', { newnote: t('notes', 'New note') }) }} |
| 12 | + </div> |
| 13 | + <div class="feature icon-fullscreen"> |
| 14 | + {{ t('notes', 'Write down your thoughts without any distractions.') }} |
| 15 | + </div> |
| 16 | + <div class="feature icon-files-dark"> |
| 17 | + {{ t('notes', 'Organize your notes in categories.') }} |
| 18 | + </div> |
19 | 19 | </NcAppSettingsSection> |
20 | 20 | <NcAppSettingsSection id="notes-path-section" :title="t('notes', 'Notes path')"> |
21 | 21 | <p class="app-settings-section__desc"> |
22 | 22 | {{ t('notes', 'Folder to store your notes') }} |
23 | 23 | </p> |
24 | | - <form @submit.prevent="onChangeSettingsReload"> |
25 | | - <input id="notesPath" |
26 | | - v-model="settings.notesPath" |
27 | | - type="text" |
28 | | - name="notesPath" |
29 | | - :placeholder="t('notes', 'Root directory')" |
30 | | - @change="onChangeSettingsReload" |
31 | | - ><input type="submit" class="icon-confirm" value=""> |
32 | | - </form> |
| 24 | + <input id="notesPath" |
| 25 | + v-model="settings.notesPath" |
| 26 | + type="text" |
| 27 | + name="notesPath" |
| 28 | + :placeholder="t('notes', 'Root directory')" |
| 29 | + @click="onChangeNotePath" |
| 30 | + > |
33 | 31 | </NcAppSettingsSection> |
34 | 32 | <NcAppSettingsSection id="file-suffix-section" :title="t('notes', 'File extension')"> |
35 | 33 | <p class="app-settings-section__desc"> |
@@ -86,6 +84,8 @@ import { |
86 | 84 | NcAppSettingsSection, |
87 | 85 | } from '@nextcloud/vue' |
88 | 86 |
|
| 87 | +import { FilePicker, FilePickerType } from '@nextcloud/dialogs' |
| 88 | +
|
89 | 89 | import { setSettings } from '../NotesService.js' |
90 | 90 | import store from '../store.js' |
91 | 91 | import HelpMobile from './HelpMobile.vue' |
@@ -153,6 +153,25 @@ export default { |
153 | 153 | }, |
154 | 154 |
|
155 | 155 | methods: { |
| 156 | + onChangeNotePath(event) { |
| 157 | + // Code Example from: https://github.com/nextcloud/text/blob/main/src/components/Menu/ActionInsertLink.vue#L130-L155 |
| 158 | + const filePicker = new FilePicker( |
| 159 | + t('text', 'Select folder to link to'), |
| 160 | + false, // multiselect |
| 161 | + ['text/directory'], // mime filter |
| 162 | + true, // modal |
| 163 | + FilePickerType.Choose, // type |
| 164 | + true, // directories |
| 165 | + event.target.value === '' ? '/' : event.target.value // path |
| 166 | + ) |
| 167 | + filePicker.pick().then((file) => { |
| 168 | + const client = OC.Files.getClient() |
| 169 | + client.getFileInfo(file).then((_status, fileInfo) => { |
| 170 | + this.settings.notesPath = fileInfo.path === '/' ? `/${fileInfo.name}` : `${fileInfo.path}/${fileInfo.name}` |
| 171 | + this.onChangeSettingsReload() |
| 172 | + }) |
| 173 | + }) |
| 174 | + }, |
156 | 175 | onChangeSettings() { |
157 | 176 | this.saving = true |
158 | 177 | return setSettings(this.settings) |
|
0 commit comments