From e3971517eabd123948943ff095e2944c584ba603 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 23 May 2019 12:11:11 +0300 Subject: [PATCH 1/4] addresses page improvements --- .../lib/block_scout_web/controllers/address_controller.ex | 2 +- .../lib/block_scout_web/templates/address/index.html.eex | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index d8b1fbbf60..6ce33a2773 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -26,7 +26,7 @@ defmodule BlockScoutWeb.AddressController do address_path( conn, :index, - next_page_params + Map.delete(next_page_params, "type") ) end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index e3140a0efc..47d7f2457b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -3,11 +3,11 @@

<%= gettext "Addresses" %>

- <%= 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 %>
- <%= 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 %>
From 236a56f1a9df23b9a48721b7f85966483a56513f Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 23 May 2019 12:33:08 +0300 Subject: [PATCH 2/4] hide navigation button if a page has no items --- .../assets/js/lib/async_listing_load.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/block_scout_web/assets/js/lib/async_listing_load.js b/apps/block_scout_web/assets/js/lib/async_listing_load.js index 0d7f427fd3..dd1b8e4335 100644 --- a/apps/block_scout_web/assets/js/lib/async_listing_load.js +++ b/apps/block_scout_web/assets/js/lib/async_listing_load.js @@ -48,6 +48,8 @@ export const asyncInitialState = { loading: false, /* if there was an error fetching items */ requestError: false, + /* if response has no items */ + emptyResponse: false, /* if it is loading the first page */ loadingFirstPage: true, /* link to the next page */ @@ -90,6 +92,7 @@ export function asyncReducer (state = asyncInitialState, action) { return Object.assign({}, state, { requestError: false, + emptyResponse: action.items.length === 0, items: action.items, nextPagePath: action.nextPagePath, prevPagePath: prevPagePath @@ -169,6 +172,10 @@ export const elements = { }, '[data-async-listing] [data-next-page-button]': { render ($el, state) { + if (state.emptyResponse) { + return $el.hide() + } + if (state.requestError || !state.nextPagePath || state.loading) { return $el.attr('disabled', 'disabled') } @@ -179,6 +186,10 @@ export const elements = { }, '[data-async-listing] [data-prev-page-button]': { render ($el, state) { + if (state.emptyResponse) { + return $el.hide() + } + if (state.requestError || !state.prevPagePath || state.loading) { return $el.attr('disabled', 'disabled') } @@ -189,6 +200,10 @@ export const elements = { }, '[data-async-listing] [data-page-number]': { render ($el, state) { + if (state.emptyResponse) { + return $el.hide() + } + if (state.pagesStack.length === 0) { return $el.text('Page 1') } From 23645570b630b0e2ec0d4cd2c9547e105ef1e45f Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 23 May 2019 12:36:57 +0300 Subject: [PATCH 3/4] fix eslint --- apps/block_scout_web/assets/js/lib/async_listing_load.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/assets/js/lib/async_listing_load.js b/apps/block_scout_web/assets/js/lib/async_listing_load.js index dd1b8e4335..e22f6e399d 100644 --- a/apps/block_scout_web/assets/js/lib/async_listing_load.js +++ b/apps/block_scout_web/assets/js/lib/async_listing_load.js @@ -173,7 +173,7 @@ export const elements = { '[data-async-listing] [data-next-page-button]': { render ($el, state) { if (state.emptyResponse) { - return $el.hide() + return $el.hide() } if (state.requestError || !state.nextPagePath || state.loading) { @@ -201,7 +201,7 @@ export const elements = { '[data-async-listing] [data-page-number]': { render ($el, state) { if (state.emptyResponse) { - return $el.hide() + return $el.hide() } if (state.pagesStack.length === 0) { From 5c2a22782aeafc665954051fa2683dafea4f59c6 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 23 May 2019 12:38:44 +0300 Subject: [PATCH 4/4] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c9add09bb..04e77bcb09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ - [#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 - [#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