1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
<template>
<NcAppNavigationSettings :title="t('notes', 'Notes settings')" :class="{ loading: saving }">
<div class="settings-block">
<p class="settings-hint">
<label for="notesPath">{{ t('notes', 'Folder to store your notes') }}</label>
</p>
<form @submit.prevent="onChangeSettingsReload">
<input id="notesPath"
v-model="settings.notesPath"
type="text"
name="notesPath"
:placeholder="t('notes', 'Root directory')"
@change="onChangeSettingsReload"
><input type="submit" class="icon-confirm" value="">
</form>
</div>
<div class="settings-block">
<p class="settings-hint">
<label for="fileSuffix">{{ t('notes', 'File extension for new notes') }}</label>
</p>
<select id="fileSuffix" v-model="settings.fileSuffix" @change="onChangeSettings">
<option v-for="extension in extensions" :key="extension.value" :value="extension.value">
{{ extension.label }}
</option>
</select>
<input v-show="settings.fileSuffix === 'custom'"
id="customSuffix"
v-model="settings.customSuffix"
name="customSuffix"
type="text"
placeholder=".txt"
@change="onChangeSettings"
>
</div>
<div class="settings-block">
<p class="settings-hint">
<label for="noteMode">{{ t('notes', 'Display mode for notes') }}</label>
</p>
<select id="noteMode" v-model="settings.noteMode" @change="onChangeSettings">
<option v-for="mode in noteModes" :key="mode.value" :value="mode.value">
{{ mode.label }}
</option>
</select>
</div>
</NcAppNavigationSettings>
</template>
<script>
import {
NcAppNavigationSettings,
} from '@nextcloud/vue'
import { setSettings } from '../NotesService.js'
import store from '../store.js'
export default {
name: 'AppSettings',
components: {
NcAppNavigationSettings,
},
data() {
return {
extensions: [
{ value: '.txt', label: '.txt' },
{ value: '.md', label: '.md' },
{ value: 'custom', label: t('notes', 'User defined') },
],
noteModes: [
{ value: 'edit', label: t('notes', 'Open in edit mode') },
{ value: 'preview', label: t('notes', 'Open in preview mode') },
],
saving: false,
}
},
computed: {
settings() {
return store.state.app.settings
},
},
created() {
},
methods: {
onChangeSettings() {
this.saving = true
return setSettings(this.settings)
.catch(() => {
})
.then(() => {
this.saving = false
})
},
onChangeSettingsReload() {
this.onChangeSettings()
.then(() => {
this.$emit('reload')
})
},
},
}
</script>
<style scoped>
.loading .settings-block {
visibility: hidden;
}
.settings-block + .settings-block {
padding-top: 2ex;
}
.settings-block form {
display: inline-flex;
}
</style>
|