|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <h1>{{{ title }}} List</h1> |
| 4 | + |
| 5 | + <div v-if="loading" class="alert alert-info">Loading...</div> |
| 6 | + <div v-if="deletedItem" class="alert alert-success">\{{ deletedItem['@id'] }} deleted.</div> |
| 7 | + <div v-if="error" class="alert alert-danger">\{{ error }}</div> |
| 8 | + |
| 9 | + <span v-if="view"> |
| 10 | + <button |
| 11 | + type="button" |
| 12 | + class="btn btn-basic btn-sm" |
| 13 | + @click="getPage(view['hydra:first'])" |
| 14 | + :disabled="!view['hydra:first']" |
| 15 | + >First</button> |
| 16 | + |
| 17 | + <button |
| 18 | + type="button" |
| 19 | + class="btn btn-basic btn-sm" |
| 20 | + @click="getPage(view['hydra:previous'])" |
| 21 | + :disabled="!view['hydra:previous']" |
| 22 | + >Previous</button> |
| 23 | + |
| 24 | + <button |
| 25 | + type="button" class="btn btn-basic btn-sm" |
| 26 | + @click="getPage(view['hydra:next'])" |
| 27 | + :disabled="!view['hydra:next']" |
| 28 | + >Next</button> |
| 29 | + |
| 30 | + <button |
| 31 | + type="button" class="btn btn-basic btn-sm" |
| 32 | + @click="getPage(view['hydra:last'])" |
| 33 | + :disabled="!view['hydra:last']" |
| 34 | + >Last</button> |
| 35 | + |
| 36 | + </span> |
| 37 | + |
| 38 | + <div class="table-responsive"> |
| 39 | + <table class="table table-striped table-hover"> |
| 40 | + <thead> |
| 41 | + <tr> |
| 42 | + <th>Id</th> |
| 43 | +{{#each fields}} |
| 44 | + <th>{{name}}</th> |
| 45 | +{{/each }} |
| 46 | + <th></th> |
| 47 | + <th></th> |
| 48 | + </tr> |
| 49 | + </thead> |
| 50 | + <tbody> |
| 51 | + <tr v-for="item in items"> |
| 52 | + <td><router-link :to="{name: '{{{titleUcFirst}}}Show', params: { id: item['@id'] }}">\{{ item['@id'] }}</router-link></td> |
| 53 | +{{#each fields}} |
| 54 | + <td><router-link v-if="item['{{{ name }}}']" :to="{name: '{{{titleUcFirst}}}Show', params: { id: item['@id'] }}">\{{ item['{{{ name }}}'] }}</router-link></td> |
| 55 | +{{/each}} |
| 56 | + <td> |
| 57 | + <router-link :to="{name: '{{{titleUcFirst}}}Show', params: { id: item['@id'] }}"> |
| 58 | + <span class="glyphicon glyphicon-search" aria-hidden="true"/> |
| 59 | + <span class="sr-only">Show</span> |
| 60 | + </router-link> |
| 61 | + </td> |
| 62 | + <td> |
| 63 | + <router-link :to="{name: '{{{titleUcFirst}}}Update', params: { id: item['@id'] }}"> |
| 64 | + <span class="glyphicon glyphicon-search" aria-hidden="true"/> |
| 65 | + <span class="sr-only">Edit</span> |
| 66 | + </router-link> |
| 67 | + </td> |
| 68 | + </tr> |
| 69 | + </tbody> |
| 70 | + </table> |
| 71 | + </div> |
| 72 | + |
| 73 | + <router-link :to="{ name: '{{{titleUcFirst}}}Create' }" class="btn btn-default">Create</router-link> |
| 74 | + </div> |
| 75 | +</template> |
| 76 | + |
| 77 | +<script> |
| 78 | +import { mapGetters, mapActions } from 'vuex'; |
| 79 | +
|
| 80 | +export default { |
| 81 | + computed: mapGetters([ |
| 82 | + 'items', |
| 83 | + 'view' |
| 84 | + ]), |
| 85 | + methods: mapActions([ |
| 86 | + 'getPage' |
| 87 | + ]), |
| 88 | + created () { |
| 89 | + this.$store.dispatch('getItems') |
| 90 | + } |
| 91 | +} |
| 92 | +</script> |
0 commit comments