Skip to content

Commit 2d92c52

Browse files
committed
Added template for foo show component
1 parent a46e06c commit 2d92c52

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

templates/vue/components/foo/Show.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div>
3+
<h1>Show \{{ item && item['@id'] }}</h1>
4+
5+
<div v-if="loading" class="alert alert-info" role="status">Loading...</div>
6+
<div v-if="error" class="alert alert-danger" role="alert"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> \{{ error }}</div>
7+
<div v-if="deleteError" class="alert alert-danger" role="alert"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> \{{ deleteError }}</div>
8+
9+
<div v-if="item" class="table-responsive">
10+
<table class="table table-striped table-hover">
11+
<thead>
12+
<tr>
13+
<th>Field</th>
14+
<th>Value</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
{{#each fields}}
19+
<tr>
20+
<td>{{name}}</td>
21+
<td>\{{ item['{{{ name }}}'] }}</td>
22+
</tr>
23+
{{/each }}
24+
</tbody>
25+
</table>
26+
</div>
27+
28+
<router-link v-if="item" :to="{ name: '{{{titleUcFirst}}}List' }" class="btn btn-default">Back to list</router-link>
29+
<button @click="deleteItem(item)" class="btn btn-danger">Delete</button>
30+
</div>
31+
</template>
32+
33+
<script>
34+
import { mapGetters } from 'vuex';
35+
36+
export default {
37+
computed: mapGetters({
38+
deleteError: '{{{lc}}}/del/error',
39+
error: '{{{lc}}}/show/error',
40+
loading: '{{{lc}}}/show/loading',
41+
item: '{{{lc}}}/show/item',
42+
}),
43+
methods: {
44+
deleteItem (item) {
45+
if (window.confirm('Are you sure you want to delete this item?'))
46+
this.$store.dispatch('{{{lc}}}/del/delete', item).then(response => this.$router.push({ name: '{{{titleUcFirst}}}List' }));
47+
}
48+
},
49+
created () {
50+
this.$store.dispatch('{{{lc}}}/show/retrieve', decodeURIComponent(this.$route.params.id));
51+
},
52+
beforeDestroy() {
53+
this.$store.dispatch('{{{lc}}}/show/reset');
54+
}
55+
}
56+
</script>

0 commit comments

Comments
 (0)