summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/components/post-form-window.vue
blob: 1d718bef15a09c302c877a35f294d75824652d27 (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
<template>
<mk-window class="mk-post-form-window" ref="window" is-modal @closed="onWindowClosed" :animation="animation">
	<template #header>
		<span class="mk-post-form-window--header">
			<span class="icon" v-if="geo"><fa icon="map-marker-alt"/></span>
			<span v-if="!reply">{{ $t('note') }}</span>
			<span v-if="reply">{{ $t('reply') }}</span>
			<span class="count" v-if="files.length != 0">{{ this.$t('attaches').replace('{}', files.length) }}</span>
			<span class="count" v-if="uploadings.length != 0">{{ this.$t('uploading-media').replace('{}', uploadings.length) }}<mk-ellipsis/></span>
		</span>
	</template>

	<div class="mk-post-form-window--body">
		<mk-note-preview v-if="reply" class="notePreview" :note="reply"/>
		<mk-post-form ref="form"
			:reply="reply"
			:mention="mention"
			@posted="onPosted"
			@change-uploadings="onChangeUploadings"
			@change-attached-files="onChangeFiles"
			@geo-attached="onGeoAttached"
			@geo-dettached="onGeoDettached"/>
	</div>
</mk-window>
</template>

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

export default Vue.extend({
	i18n: i18n('desktop/views/components/post-form-window.vue'),
	props: {
		reply: {
			type: Object,
			required: false
		},
		mention: {
			type: Object,
			required: false
		},

		animation: {
			type: Boolean,
			required: false,
			default: true
		}
	},

	data() {
		return {
			uploadings: [],
			files: [],
			geo: null
		};
	},

	mounted() {
		this.$nextTick(() => {
			(this.$refs.form as any).focus();
		});
	},

	methods: {
		onChangeUploadings(files) {
			this.uploadings = files;
		},
		onChangeFiles(files) {
			this.files = files;
		},
		onGeoAttached(geo) {
			this.geo = geo;
		},
		onGeoDettached() {
			this.geo = null;
		},
		onPosted() {
			(this.$refs.window as any).close();
		},
		onWindowClosed() {
			this.$emit('closed');
			this.destroyDom();
		}
	}
});
</script>

<style lang="stylus" scoped>
.mk-post-form-window
	.mk-post-form-window--header
		.icon
			margin-right 8px

		.count
			margin-left 8px
			opacity 0.8

			&:before
				content '('

			&:after
				content ')'

	.mk-post-form-window--body
		.notePreview
				margin 16px 22px

</style>