Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AppSettings.vue « components « src - github.com/nextcloud/notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d031802606937b211a652d9e5af2b8b88d65b63b (plain)
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
<template>
	<AppNavigationSettings :title="t('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', 'path to notes')"
					@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="ext in extensions" :key="ext" :value="ext">
					{{ ext }}
				</option>
			</select>
		</div>
	</AppNavigationSettings>
</template>

<script>
import {
	AppNavigationSettings,
} from '@nextcloud/vue'

import { setSettings } from '../NotesService'
import store from '../store'

export default {
	name: 'AppSettings',

	components: {
		AppNavigationSettings,
	},

	data: function() {
		return {
			extensions: ['.txt', '.md'],
			saving: false,
		}
	},

	computed: {
		settings() {
			return store.state.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>