diff options
author | dartcafe <github@dartcafe.de> | 2020-09-17 11:22:48 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2020-09-17 11:22:48 +0300 |
commit | 6ed13d1486970f7242f6df5abe3d3a436b85ac50 (patch) | |
tree | 52261ed17ef33cb0558c7bef2a6909feaed06c86 | |
parent | 4765dd1283c94143842faa3c0b9a84dcf3a5d58f (diff) |
define default settings for view modesv1.5.2-view2
-rw-r--r-- | src/js/components/Navigation/NavigationSettings.vue | 57 | ||||
-rw-r--r-- | src/js/store/modules/settings.js | 11 | ||||
-rw-r--r-- | src/js/views/Vote.vue | 54 |
3 files changed, 88 insertions, 34 deletions
diff --git a/src/js/components/Navigation/NavigationSettings.vue b/src/js/components/Navigation/NavigationSettings.vue index 4c31d57f..dc5f481e 100644 --- a/src/js/components/Navigation/NavigationSettings.vue +++ b/src/js/components/Navigation/NavigationSettings.vue @@ -26,6 +26,14 @@ type="checkbox" class="checkbox"> <label for="calendarPeek">{{ t('polls', 'Use calendar lookup') }}</label> + <input id="defaultViewTextPoll" v-model="defaultViewTextPoll" + type="checkbox" class="checkbox"> + <label for="defaultViewTextPoll">{{ t('polls', 'Text polls default to table view') }}</label> + + <input id="defaultViewDatePoll" v-model="defaultViewDatePoll" + type="checkbox" class="checkbox"> + <label for="defaultViewDatePoll">{{ t('polls', 'Date polls default to table view') }}</label> + <input id="experimental" v-model="experimental" type="checkbox" class="checkbox"> <label for="experimental">{{ t('polls', 'Try experimental styles') }}</label> @@ -55,11 +63,52 @@ import { mapState } from 'vuex' export default { name: 'NavigationSettings', + data() { + return { + viewOptions: [ + 'desktop', + 'mobile', + ], + } + }, + computed: { ...mapState({ settings: state => state.settings.user, }), // Add bindings + calendarPeek: { + get() { + return this.settings.calendarPeek + }, + set(value) { + this.writeValue({ calendarPeek: value }) + }, + }, + defaultViewTextPoll: { + get() { + return (this.settings.defaultViewTextPoll === 'mobile') + }, + set(value) { + if (value) { + this.writeValue({ defaultViewTextPoll: 'mobile' }) + } else { + this.writeValue({ defaultViewTextPoll: 'desktop' }) + } + }, + }, + defaultViewDatePoll: { + get() { + return (this.settings.defaultViewDatePoll === 'mobile') + }, + set(value) { + if (value) { + this.writeValue({ defaultViewDatePoll: 'mobile' }) + } else { + this.writeValue({ defaultViewDatePoll: 'desktop' }) + } + }, + }, experimental: { get() { return this.settings.experimental @@ -92,14 +141,6 @@ export default { this.writeValue({ glassyNavigation: value }) }, }, - calendarPeek: { - get() { - return this.settings.calendarPeek - }, - set(value) { - this.writeValue({ calendarPeek: value }) - }, - }, glassySidebar: { get() { return this.settings.glassySidebar diff --git a/src/js/store/modules/settings.js b/src/js/store/modules/settings.js index 8753c492..4fd933d3 100644 --- a/src/js/store/modules/settings.js +++ b/src/js/store/modules/settings.js @@ -32,11 +32,13 @@ const defaultSettings = () => { imageUrl: '', glassyNavigation: false, glassySidebar: false, - defaultView: { - textPoll: 'mobile', - datePoll: 'desktop', - }, + defaultViewTextPoll: 'mobile', + defaultViewDatePoll: 'desktop', }, + viewModes: [ + 'mobile', + 'desktop', + ], } } @@ -79,7 +81,6 @@ const actions = { throw error }) }, - } export default { namespaced, state, mutations, actions } diff --git a/src/js/views/Vote.vue b/src/js/views/Vote.vue index 3265043e..15973bb1 100644 --- a/src/js/views/Vote.vue +++ b/src/js/views/Vote.vue @@ -128,8 +128,8 @@ export default { delay: 50, isLoading: true, ranked: false, - manualViewDatePoll: false, - manualViewTextPoll: false, + manualViewDatePoll: '', + manualViewTextPoll: '', } }, @@ -148,37 +148,33 @@ export default { viewTextPoll() { if (this.manualViewTextPoll) { - if (this.settings.user.defaultView.textPoll === 'desktop') { - return 'mobile' + return this.manualViewTextPoll + } else { + if (window.innerWidth > 480) { + return this.settings.user.defaultViewTextPoll } else { - return 'desktop' + return 'mobile' } - } else { - return this.settings.user.defaultView.textPoll } }, viewDatePoll() { if (this.manualViewDatePoll) { - if (this.settings.user.defaultView.datePoll === 'desktop') { - return 'mobile' - } else { - return 'desktop' - } + return this.manualViewDatePoll } else { - if (window.innerWidth < 481) { - return 'mobile' + if (window.innerWidth > 480) { + return this.settings.user.defaultViewDatePoll } else { - return this.settings.user.defaultView.datePoll + return 'mobile' } } }, viewMode() { - if (this.poll.type === 'datePoll') { - return this.viewDatePoll - } else if (this.poll.type === 'textPoll') { + if (this.poll.type === 'textPoll') { return this.viewTextPoll + } else if (this.poll.type === 'datePoll') { + return this.viewDatePoll } else { return 'desktop' } @@ -275,6 +271,14 @@ export default { emit('toggle-sidebar', { open: true, activeTab: 'options' }) }, + getNextViewMode() { + if (this.settings.viewModes.indexOf(this.viewMode) < 0) { + return this.settings.viewModes[1] + } else { + return this.settings.viewModes[(this.settings.viewModes.indexOf(this.viewMode) + 1) % this.settings.viewModes.length] + } + }, + openConfiguration() { emit('toggle-sidebar', { open: true, activeTab: 'configuration' }) }, @@ -286,9 +290,17 @@ export default { toggleView() { emit('transitions-off', { delay: 500 }) if (this.poll.type === 'datePoll') { - this.manualViewDatePoll = !this.manualViewDatePoll - } else { - this.manualViewTextPoll = !this.manualViewTextPoll + if (this.manualViewDatePoll) { + this.manualViewDatePoll = '' + } else { + this.manualViewDatePoll = this.getNextViewMode() + } + } else if (this.poll.type === 'textPoll') { + if (this.manualViewTextPoll) { + this.manualViewTextPoll = '' + } else { + this.manualViewTextPoll = this.getNextViewMode() + } } }, |