Paginator.vue 1.04 KB
Newer Older
janis.streib's avatar
janis.streib committed
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
<template>
  <div class="paginator">
    <b-pagination :total-rows="items.length" v-model="currentPage" :per-page="items_per_page"
                  v-if="items && items.length > items_per_page">
    </b-pagination>
    <div class="pagination_container">
      <slot name="content_skeleton_item" v-if="items == null || items.length == 0"></slot>
      <slot name="item" v-else
            v-for="item in items.slice((currentPage-1)*items_per_page, Math.min(items.length, currentPage*items_per_page))"
            v-bind:item="item"/>
    </div>
    <b-pagination :total-rows="items.length" v-model="currentPage" :per-page="items_per_page"
                  v-if="items && items.length > items_per_page">
    </b-pagination>
  </div>
</template>

<script>
export default {
  name: 'Paginator',
  data() {
    return {
      currentPage: 1
    }
  },
  props: {
    items: {
      required: true,
      default() {
        return null
      }
    },
    items_per_page: {
      default() {
        return 25
      }
    }
  }
}
</script>

<style scoped>

</style>