Add itemsPerPage selector to pagination
This commit is contained in:
parent
c3526af06c
commit
f5c839f1f9
@ -114,8 +114,12 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
itemsPerPage() {
|
itemsPerPage(value) {
|
||||||
|
if (this.page > 0) {
|
||||||
this.page = 0;
|
this.page = 0;
|
||||||
|
} else {
|
||||||
|
this.updateList(value, this.page);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
page(value) {
|
page(value) {
|
||||||
this.updateList(this.itemsPerPage, value);
|
this.updateList(this.itemsPerPage, value);
|
||||||
|
|||||||
@ -6,6 +6,12 @@
|
|||||||
<button @click="gotoPage(page + 1)">Next</button>
|
<button @click="gotoPage(page + 1)">Next</button>
|
||||||
<button @click="gotoPage(maxPages)">Last</button>
|
<button @click="gotoPage(maxPages)">Last</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pagination">
|
||||||
|
<button class="unselectable">Items per page</button>
|
||||||
|
|
||||||
|
<button :class="{ active: (itemsPerPage === n) }" @click="setPageSize(n)" v-for="n of [5, 10, 20, 50]" :key="n">{{ n }}</button>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -29,6 +35,9 @@ export default {
|
|||||||
this.$emit('update:page', page);
|
this.$emit('update:page', page);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setPageSize(n) {
|
||||||
|
this.$emit('update:itemsPerPage', n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
13
resources/scss/_pagination.scss
vendored
13
resources/scss/_pagination.scss
vendored
@ -2,10 +2,14 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
|
||||||
|
&:not(:last-of-type) {
|
||||||
|
margin-bottom: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
background-color: #1c2d35;
|
background-color: $background;
|
||||||
border: 1px solid white;
|
border: 1px solid white;
|
||||||
color: white;
|
color: $text-color;
|
||||||
|
|
||||||
height: 40px;
|
height: 40px;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
@ -17,8 +21,9 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:not(.unselectable):hover {
|
button:not(.unselectable):hover,
|
||||||
background-color: #2d3e46;
|
button.active {
|
||||||
|
background-color: $background-lighter;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:not(:last-child) {
|
button:not(:last-child) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user