Skip to content

Commit

Permalink
more pagination buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkorotkov committed Apr 25, 2020
1 parent 94b2820 commit c2e9dbb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/components/pagination/Pagination.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
$: page = current_page + 1
$: total_pages = total_items > 0 ? Math.ceil(total_items / items_per_page) : 0
$: prevDisabled = disable || current_page == 0
$: nextDisabled = disable || current_page == total_pages - 1
$: firstDisabled = prevDisabled
$: lastDisabled = nextDisabled
$: shouldDisplay =
total_items > items_per_page &&
!isNaN(current_page) &&
Expand All @@ -31,6 +35,18 @@
trigger('next', ++current_page)
trigger('change', current_page)
}
const onClickFirst = event => {
if (prevDisabled) return
trigger('first', (current_page = 0))
trigger('change', current_page)
}
const onClickLast = event => {
if (nextDisabled) return
trigger('last', (current_page = total_pages - 1))
trigger('change', current_page)
}
</script>

<style>
Expand All @@ -46,6 +62,13 @@
{#if shouldDisplay}
Page {page} of {total_pages}
<div class="ui pagination menu {className}">
<a
class="icon item"
class:disabled={firstDisabled}
on:click={onClickFirst}
href="javascript:;">
<i class="angle double left icon" />
</a>
<a
class="icon item"
class:disabled={prevDisabled}
Expand All @@ -60,5 +83,12 @@
href="javascript:;">
<i class="right chevron icon" />
</a>
<a
class="icon item"
class:disabled={lastDisabled}
on:click={onClickLast}
href="javascript:;">
<i class="angle double right icon" />
</a>
</div>
{/if}
6 changes: 5 additions & 1 deletion src/store/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ export const search = store => {
store.dispatch('search/loading', false)
store.dispatch('notification/add', {
type: 'error',
message: get(error, 'response.data.error.reason', error.message),
message: get(
error,
'response.data.error.root_cause[0].reason',
get(error, 'response.data.error.reason', error.message)
),
})
}
})
Expand Down

0 comments on commit c2e9dbb

Please sign in to comment.