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

FeatureSettings.vue « Settings « components « js « src - github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c103fabb1032eaec9ebd22657fe2e4194d2f464 (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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!--
  - @copyright Copyright (c) 2018 René Gieling <github@dartcafe.de>
  -
  - @author René Gieling <github@dartcafe.de>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - This program is free software: you can redistribute it and/or modify
  - it under the terms of the GNU Affero General Public License as
  - published by the Free Software Foundation, either version 3 of the
  - License, or (at your option) any later version.
  -
  - This program is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  - GNU Affero General Public License for more details.
  -
  - You should have received a copy of the GNU Affero General Public License
  - along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -
  -->

<template>
	<div>
		<div class="user_settings">
			<CheckBoxDiv v-model="calendarPeek" :label="t('polls', 'Use calendar lookup')" />
			<div class="settings_details">
				{{ t('polls', 'Check, if an option in a date poll is conflicting with or near an entry in your calendar.') }}
				{{ t('polls', 'Opt in to the calendars, which should be checked.') }}

				<div v-for="(calendar) in calendarChoices" :key="calendar.key" class="calendar-item">
					<CheckBoxDiv v-model="calendar.selected" :label="calendar.name"
						@input="clickedCalendar(calendar)">
						<template #before>
							<span class="bully" :style="{ backgroundColor: calendar.displayColor }" />
						</template>
					</CheckBoxDiv>
				</div>
			</div>
		</div>

		<div class="user_settings">
			<CheckBoxDiv v-model="defaultViewTextPoll" :label="t('polls', 'Text polls default to list view')" />
			<div class="settings_details">
				{{ t('polls', 'Check this, if you prefer to display text poll in a vertical aligned list rather than in the grid view. The initial default is list view.') }}
			</div>
		</div>

		<div class="user_settings">
			<CheckBoxDiv v-model="defaultViewDatePoll" :label="t('polls', 'Date polls default to list view')" />
			<div class="settings_details">
				{{ t('polls', 'Check this, if you prefer to display date poll in a vertical view rather than in the grid view. The initial default is grid view.') }}
			</div>
		</div>
	</div>
</template>

<script>

import { mapState } from 'vuex'
import CheckBoxDiv from '../Base/CheckBoxDiv'

export default {
	name: 'FeatureSettings',

	components: {
		CheckBoxDiv,
	},

	computed: {
		...mapState({
			settings: state => state.settings.user,
			calendars: state => state.settings.availableCalendars,
		}),
		// Add bindings
		calendarPeek: {
			get() {
				return this.settings.calendarPeek
			},
			set(value) {
				this.writeValue({ calendarPeek: value })
			},
		},

		calendarChoices() {
			return this.calendars.map(calendar => ({
				key: calendar.key.toString(),
				name: calendar.name,
				displayColor: calendar.displayColor,
				selected: this.settings.checkCalendars.includes(calendar.key.toString()),
			}), this)
		},

		defaultViewTextPoll: {
			get() {
				return (this.settings.defaultViewTextPoll === 'list-view')
			},
			set(value) {
				if (value) {
					this.writeValue({ defaultViewTextPoll: 'list-view' })
				} else {
					this.writeValue({ defaultViewTextPoll: 'table-view' })
				}
			},
		},
		defaultViewDatePoll: {
			get() {
				return (this.settings.defaultViewDatePoll === 'list-view')
			},
			set(value) {
				if (value) {
					this.writeValue({ defaultViewDatePoll: 'list-view' })
				} else {
					this.writeValue({ defaultViewDatePoll: 'table-view' })
				}
			},
		},
	},

	methods: {
		async writeValue(value) {
			await this.$store.commit('settings/setPreference', value)
			this.$store.dispatch('settings/write')
		},

		async clickedCalendar(calendar) {
			if (this.settings.checkCalendars.includes(calendar.key)) {
				await this.writeValue({ checkCalendars: this.settings.checkCalendars.filter(item => item !== calendar.key.toString()) })
			} else {
				await this.$store.commit('settings/addCheckCalendar', { calendar: calendar })
			}
			this.$store.dispatch('settings/write')
		},
	},
}
</script>

<style>
	.user_settings {
		padding-top: 16px;
	}

	.settings_details {
		padding-top: 8px;
		margin-left: 26px;
	}

	.bully {
		display: inline-block;
		width: 11px;
		height: 11px;
		border-radius: 50%;
		margin: 0 4px 0 0;
	}
</style>