Merge pull request #2009 from poanetwork/ab-addresse-page-improvements

addresses page improvements
pull/2018/head
Ayrat Badykov 6 years ago committed by GitHub
commit 746939b6d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 15
      apps/block_scout_web/assets/js/lib/async_listing_load.js
  3. 2
      apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex
  4. 4
      apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex

@ -58,6 +58,7 @@
- [#1917](https://github.com/poanetwork/blockscout/pull/1917) - Force block refetch if transaction is re-collated in a different block - [#1917](https://github.com/poanetwork/blockscout/pull/1917) - Force block refetch if transaction is re-collated in a different block
- [#1992](https://github.com/poanetwork/blockscout/pull/1992) - fix: support https for wobserver polling - [#1992](https://github.com/poanetwork/blockscout/pull/1992) - fix: support https for wobserver polling
- [#1966](https://github.com/poanetwork/blockscout/pull/1966) - fix: add fields for contract filter performance - [#1966](https://github.com/poanetwork/blockscout/pull/1966) - fix: add fields for contract filter performance
- [#2009](https://github.com/poanetwork/blockscout/pull/2009) - addresses page improvements
### Chore ### Chore

@ -48,6 +48,8 @@ export const asyncInitialState = {
loading: false, loading: false,
/* if there was an error fetching items */ /* if there was an error fetching items */
requestError: false, requestError: false,
/* if response has no items */
emptyResponse: false,
/* if it is loading the first page */ /* if it is loading the first page */
loadingFirstPage: true, loadingFirstPage: true,
/* link to the next page */ /* link to the next page */
@ -90,6 +92,7 @@ export function asyncReducer (state = asyncInitialState, action) {
return Object.assign({}, state, { return Object.assign({}, state, {
requestError: false, requestError: false,
emptyResponse: action.items.length === 0,
items: action.items, items: action.items,
nextPagePath: action.nextPagePath, nextPagePath: action.nextPagePath,
prevPagePath: prevPagePath prevPagePath: prevPagePath
@ -169,6 +172,10 @@ export const elements = {
}, },
'[data-async-listing] [data-next-page-button]': { '[data-async-listing] [data-next-page-button]': {
render ($el, state) { render ($el, state) {
if (state.emptyResponse) {
return $el.hide()
}
if (state.requestError || !state.nextPagePath || state.loading) { if (state.requestError || !state.nextPagePath || state.loading) {
return $el.attr('disabled', 'disabled') return $el.attr('disabled', 'disabled')
} }
@ -179,6 +186,10 @@ export const elements = {
}, },
'[data-async-listing] [data-prev-page-button]': { '[data-async-listing] [data-prev-page-button]': {
render ($el, state) { render ($el, state) {
if (state.emptyResponse) {
return $el.hide()
}
if (state.requestError || !state.prevPagePath || state.loading) { if (state.requestError || !state.prevPagePath || state.loading) {
return $el.attr('disabled', 'disabled') return $el.attr('disabled', 'disabled')
} }
@ -189,6 +200,10 @@ export const elements = {
}, },
'[data-async-listing] [data-page-number]': { '[data-async-listing] [data-page-number]': {
render ($el, state) { render ($el, state) {
if (state.emptyResponse) {
return $el.hide()
}
if (state.pagesStack.length === 0) { if (state.pagesStack.length === 0) {
return $el.text('Page 1') return $el.text('Page 1')
} }

@ -26,7 +26,7 @@ defmodule BlockScoutWeb.AddressController do
address_path( address_path(
conn, conn,
:index, :index,
next_page_params Map.delete(next_page_params, "type")
) )
end end

@ -3,11 +3,11 @@
<div class="card-body" data-async-load data-async-listing="<%= @current_path %>"> <div class="card-body" data-async-load data-async-listing="<%= @current_path %>">
<h1 class="card-title"><%= gettext "Addresses" %></h1> <h1 class="card-title"><%= gettext "Addresses" %></h1>
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
<div data-items data-selector="top-addresses-list"></div> <div data-items data-selector="top-addresses-list"></div>
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
</div> </div>
</div> </div>
</section> </section>

Loading…
Cancel
Save