summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/pages/deck/deck.tl-column.vue
blob: ffe1da670b99a34d9ab8159bced8c554fa40f770 (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
<template>
<x-column :menu="menu" :name="name" :column="column" :is-stacked="isStacked">
	<span slot="header">
		<template v-if="column.type == 'home'">%fa:home%</template>
		<template v-if="column.type == 'local'">%fa:R comments%</template>
		<template v-if="column.type == 'global'">%fa:globe%</template>
		<template v-if="column.type == 'list'">%fa:list%</template>
		<span>{{ name }}</span>
	</span>

	<div class="editor" style="padding:0 12px" v-if="edit">
		<mk-switch v-model="column.isMediaOnly" @change="onChangeSettings" text="%i18n:@is-media-only%"/>
		<mk-switch v-model="column.isMediaView" @change="onChangeSettings" text="%i18n:@is-media-view%"/>
	</div>
	<x-list-tl v-if="column.type == 'list'" :list="column.list" :media-only="column.isMediaOnly" :media-view="column.isMediaView"/>
	<x-tl v-else :src="column.type" :media-only="column.isMediaOnly" :media-view="column.isMediaView"/>
</x-column>
</template>

<script lang="ts">
import Vue from 'vue';
import XColumn from './deck.column.vue';
import XTl from './deck.tl.vue';
import XListTl from './deck.list-tl.vue';

export default Vue.extend({
	components: {
		XColumn,
		XTl,
		XListTl
	},

	props: {
		column: {
			type: Object,
			required: true
		},
		isStacked: {
			type: Boolean,
			required: true
		}
	},

	data() {
		return {
			edit: false,
			menu: [{
				icon: '%fa:cog%',
				text: '%i18n:@edit%',
				action: () => {
					this.edit = !this.edit;
				}
			}]
		}
	},

	computed: {
		name(): string {
			if (this.column.name) return this.column.name;

			switch (this.column.type) {
				case 'home': return '%i18n:common.deck.home%';
				case 'local': return '%i18n:common.deck.local%';
				case 'global': return '%i18n:common.deck.global%';
				case 'list': return this.column.list.title;
			}
		}
	},

	methods: {
		onChangeSettings(v) {
			this.$store.dispatch('settings/saveDeck');
		}
	}
});
</script>