Skip to content

Commit

Permalink
Pagination error fixed; stuff with next and previous pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcat323 committed Oct 11, 2018
1 parent c11d469 commit 39ca2c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/components/Repositories.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@
<nav aria-label="...">
<ul class="pager">
<li :class="previousFirst" @click="previous"><router-link :to="{name: 'page', params: { id: Number(page) - 1 } }" @click="previous">Previous</router-link></li>
<li :class="nextLast" @click="next"><router-link :to="{name: 'page', params: { id: Number(page) + 1 } }" @click="next">Next</router-link></li>
<li :class="nextCheck" @click="next"><router-link :to="{name: 'page', params: { id: Number(page) + 1 } }" @click="next">Next</router-link></li>
</ul>
</nav>
</div>
</template>
<script>
export default {
data() {
return {
query: ''
}
},
methods: {
next() {
var args = {
Expand Down Expand Up @@ -59,7 +54,18 @@
},
nextLast() {
return (this.page == 10) ? 'disabled' : 'works';
},
nextCheck() {
if (this.page !== 10) {
if (this.repositories.length <= 100 && this.repositories.length * Number(this.page) >= this.args.count) {
return 'disabled';
} else {
return 'works';
}
}
return 'disabled';
}
},
}
}
</script>
1 change: 0 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const router = new VueRouter({
routes: [
{ path: '/', component: Home },
{ path: '/page/:id', name: 'page', component: Page }

]
});

Expand Down
1 change: 1 addition & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const store = new Vuex.Store({
Vue.http.get(url).then(function (response) {
var list = response.body.items,
total_count = response.body.total_count;
args.count = total_count;
commit('set', {type: 'repositories', items: list});
commit('set', {type: 'args', items: args});
}, function (error) {
Expand Down

0 comments on commit 39ca2c3

Please sign in to comment.