Skip to content

Commit 8982461

Browse files
committed
AppSettings: Add FilePicker for notesPath like in #990
Signed-off-by: Jonathan Pagel <jonny_tischbein@systemli.org>
1 parent 53dcee3 commit 8982461

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

src/App.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import { loadState } from '@nextcloud/initial-state'
5757
import { showSuccess, TOAST_UNDO_TIMEOUT, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs'
5858
import '@nextcloud/dialogs/dist/index.css'
5959
60-
import InfoIcon from 'vue-material-design-icons/Information.vue'
6160
import PlusIcon from 'vue-material-design-icons/Plus.vue'
6261
import CogIcon from 'vue-material-design-icons/Cog.vue'
6362
@@ -75,7 +74,6 @@ export default {
7574
components: {
7675
AppSettings,
7776
EditorHint,
78-
InfoIcon,
7977
NavigationList,
8078
NcAppContent,
8179
NcAppNavigation,

src/components/AppSettings.vue

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,27 @@
77
@update:open="setSettingsOpen($event)"
88
>
99
<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>
1919
</NcAppSettingsSection>
2020
<NcAppSettingsSection id="notes-path-section" :title="t('notes', 'Notes path')">
2121
<p class="app-settings-section__desc">
2222
{{ t('notes', 'Folder to store your notes') }}
2323
</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+
>
3331
</NcAppSettingsSection>
3432
<NcAppSettingsSection id="file-suffix-section" :title="t('notes', 'File extension')">
3533
<p class="app-settings-section__desc">
@@ -86,6 +84,8 @@ import {
8684
NcAppSettingsSection,
8785
} from '@nextcloud/vue'
8886
87+
import { FilePicker, FilePickerType } from '@nextcloud/dialogs'
88+
8989
import { setSettings } from '../NotesService.js'
9090
import store from '../store.js'
9191
import HelpMobile from './HelpMobile.vue'
@@ -153,6 +153,25 @@ export default {
153153
},
154154
155155
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+
},
156175
onChangeSettings() {
157176
this.saving = true
158177
return setSettings(this.settings)

0 commit comments

Comments
 (0)