ctucx.git: ctucx.things

simple inventory management web-app

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 
<style lang="scss">
#share label {
	font-weight: bold;
}
</style>

<template>
	<span class="headerItem hasPopover">
		<PopoverHover id="share" @shown="focusShare">
			<span slot="target"><i class="lpSprite lpLink" /> Share</span>
			<div slot="content" class="lpFields">
				<div class="lpField">
					<label for="shareUrl">Share your list</label>
					<input id="shareUrl" v-select-on-bus="'show-share-box'"  v-select-on-focus type="text" :value="shareUrl">
				</div>
				<a id="csvUrl" :href="csvUrl" target="_blank" class="lpHref"><i class="lpSprite lpSpriteDownload" />Export to CSV</a>
			</div>
		</PopoverHover>
	</span>
</template>

<script>
import PopoverHover from './popoverHover.vue';

export default {
	name: 'Share',
	components: {
		PopoverHover,
	},
	computed: {
		library() {
			return this.$store.state.library;
		},
		list() {
			return this.library.getListById(this.library.defaultListId);
		},
		externalId() {
			return this.list.externalId || '';
		},
		baseUrl() {
			const location = window.location;
			return location.origin ? location.origin : `${location.protocol}//${location.hostname}`;
		},
		shareUrl() {
			return `${this.baseUrl}/list/${this.list.id}`;
		},
		csvUrl() {
			return `${this.baseUrl}/csv/${this.list.id}`;
		},
	}
};
</script>