VPagination.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!--
  2. Copyright 2019 Hackware SpA <human@hackware.cl>
  3. This file is part of "Hackware Userland" and licensed under the terms
  4. of the GNU Affero General Public License version 3, or (at your option)
  5. a later version. You should have received a copy of this license along
  6. with the software. If not, see <https://www.gnu.org/licenses/>.
  7. -->
  8. <template>
  9. <nav v-if="totalPages > 1">
  10. <ul class="pagination justify-content-end">
  11. <li
  12. v-for="page in totalPages"
  13. :key="page"
  14. class="page-item"
  15. :class="currentPage == page ? 'disabled' : ''"
  16. >
  17. <router-link
  18. class="page-link"
  19. :to="{ name: 'transactions', query: { page: page }}"
  20. >
  21. {{ page }}
  22. </router-link>
  23. </li>
  24. </ul>
  25. </nav>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'VPagination',
  30. props: {
  31. totalPages: {
  32. type: Number,
  33. required: true,
  34. },
  35. },
  36. computed: {
  37. currentPage() {
  38. return ('page' in this.$route.query) ? this.$route.query.page : 1;
  39. },
  40. },
  41. methods: {
  42. routeTo(page) {
  43. const route = Object.assign({}, this.$route);
  44. route.query.page = page;
  45. return route;
  46. },
  47. },
  48. };
  49. </script>