summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/pages/page-editor.vue
blob: 35b4008e4fdeb0680534747df1fa0ad6f57547a7 (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
<template>
<mk-ui>
	<main>
		<x-page-editor v-if="page !== undefined" :page="page" :readonly="readonly"/>
	</main>
</mk-ui>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
	components: {
		XPageEditor: () => import('../../../common/views/components/page-editor/page-editor.vue').then(m => m.default)
	},

	props: {
		pageId: {
			type: String,
			required: false
		},
		pageName: {
			type: String,
			required: false
		},
		user: {
			type: String,
			required: false
		}
	},

	data() {
		return {
			page: undefined,
			readonly: false
		};
	},

	created() {
		if (this.pageId) {
			this.$root.api('pages/show', {
				pageId: this.pageId,
			}).then(page => {
				this.page = page;
			});
		} else if (this.pageName && this.user) {
			this.$root.api('pages/show', {
				name: this.pageName,
				username: this.user,
			}).then(page => {
				this.readonly = true;
				this.page = page;
			});
		} else {
			this.page = null;
		}
	}
});
</script>

<style lang="stylus" scoped>
main
	margin 0 auto
	padding 16px
	max-width 900px

</style>