From bd89dd55a334e00cc5b4ca590687d667b896f1a0 Mon Sep 17 00:00:00 2001 From: Daniel Kos Date: Fri, 28 Dec 2018 09:47:21 +0100 Subject: [PATCH] Add criteria changed flag to request items Feature #14348 Arvados-DCO-1.1-Signed-off-by: Daniel Kos --- src/store/data-explorer/data-explorer-action.ts | 6 +++--- .../data-explorer-middleware-service.ts | 2 +- .../data-explorer/data-explorer-middleware.ts | 14 +++++++------- .../search-results-middleware-service.ts | 7 +++++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/store/data-explorer/data-explorer-action.ts b/src/store/data-explorer/data-explorer-action.ts index 5bed4ac1..546ec8f3 100644 --- a/src/store/data-explorer/data-explorer-action.ts +++ b/src/store/data-explorer/data-explorer-action.ts @@ -9,7 +9,7 @@ import { DataTableFilters } from '~/components/data-table-filters/data-table-fil export const dataExplorerActions = unionize({ CLEAR: ofType<{ id: string }>(), RESET_PAGINATION: ofType<{ id: string }>(), - REQUEST_ITEMS: ofType<{ id: string }>(), + REQUEST_ITEMS: ofType<{ id: string, criteriaChanged?: boolean }>(), SET_FETCH_MODE: ofType<({ id: string, fetchMode: DataTableFetchMode })>(), SET_COLUMNS: ofType<{ id: string, columns: DataColumns }>(), SET_FILTERS: ofType<{ id: string, columnName: string, filters: DataTableFilters }>(), @@ -29,8 +29,8 @@ export const bindDataExplorerActions = (id: string) => ({ dataExplorerActions.CLEAR({ id }), RESET_PAGINATION: () => dataExplorerActions.RESET_PAGINATION({ id }), - REQUEST_ITEMS: () => - dataExplorerActions.REQUEST_ITEMS({ id }), + REQUEST_ITEMS: (criteriaChanged?: boolean) => + dataExplorerActions.REQUEST_ITEMS({ id, criteriaChanged }), SET_FETCH_MODE: (payload: { fetchMode: DataTableFetchMode }) => dataExplorerActions.SET_FETCH_MODE({ ...payload, id }), SET_COLUMNS: (payload: { columns: DataColumns }) => diff --git a/src/store/data-explorer/data-explorer-middleware-service.ts b/src/store/data-explorer/data-explorer-middleware-service.ts index 82ba5b4b..57fd0b59 100644 --- a/src/store/data-explorer/data-explorer-middleware-service.ts +++ b/src/store/data-explorer/data-explorer-middleware-service.ts @@ -25,7 +25,7 @@ export abstract class DataExplorerMiddlewareService { return getDataExplorerColumnFilters(columns, columnName); } - abstract requestItems(api: MiddlewareAPI): void; + abstract requestItems(api: MiddlewareAPI, criteriaChanged?: boolean): void; } export const getDataExplorerColumnFilters = (columns: DataColumns, columnName: string): DataTableFilters => { diff --git a/src/store/data-explorer/data-explorer-middleware.ts b/src/store/data-explorer/data-explorer-middleware.ts index f90f9a6c..e377f341 100644 --- a/src/store/data-explorer/data-explorer-middleware.ts +++ b/src/store/data-explorer/data-explorer-middleware.ts @@ -20,24 +20,24 @@ export const dataExplorerMiddleware = (service: DataExplorerMiddlewareService): }; dataExplorerActions.match(action, { SET_PAGE: handleAction(() => { - api.dispatch(actions.REQUEST_ITEMS()); + api.dispatch(actions.REQUEST_ITEMS(false)); }), SET_ROWS_PER_PAGE: handleAction(() => { - api.dispatch(actions.REQUEST_ITEMS()); + api.dispatch(actions.REQUEST_ITEMS(true)); }), SET_FILTERS: handleAction(() => { api.dispatch(actions.RESET_PAGINATION()); - api.dispatch(actions.REQUEST_ITEMS()); + api.dispatch(actions.REQUEST_ITEMS(true)); }), TOGGLE_SORT: handleAction(() => { - api.dispatch(actions.REQUEST_ITEMS()); + api.dispatch(actions.REQUEST_ITEMS(true)); }), SET_EXPLORER_SEARCH_VALUE: handleAction(() => { api.dispatch(actions.RESET_PAGINATION()); - api.dispatch(actions.REQUEST_ITEMS()); + api.dispatch(actions.REQUEST_ITEMS(true)); }), - REQUEST_ITEMS: handleAction(() => { - service.requestItems(api); + REQUEST_ITEMS: handleAction(({ criteriaChanged }) => { + service.requestItems(api, criteriaChanged); }), default: () => next(action) }); diff --git a/src/store/search-results-panel/search-results-middleware-service.ts b/src/store/search-results-panel/search-results-middleware-service.ts index dd96a024..de325222 100644 --- a/src/store/search-results-panel/search-results-middleware-service.ts +++ b/src/store/search-results-panel/search-results-middleware-service.ts @@ -28,7 +28,7 @@ export class SearchResultsMiddlewareService extends DataExplorerMiddlewareServic super(id); } - async requestItems(api: MiddlewareAPI) { + async requestItems(api: MiddlewareAPI, criteriaChanged?: boolean) { const state = api.getState(); const userUuid = state.auth.user!.uuid; const dataExplorer = getDataExplorer(state.dataExplorer, this.getId()); @@ -61,7 +61,10 @@ export class SearchResultsMiddlewareService extends DataExplorerMiddlewareServic }; api.dispatch(updateResources(list.items)); - api.dispatch(appendItems(list)); + api.dispatch(criteriaChanged + ? setItems(list) + : appendItems(list) + ); } catch { api.dispatch(couldNotFetchSearchResults()); -- 2.30.2