use filters applied from server response
This commit is contained in:
parent
4a0c57f1b9
commit
973281461a
@ -51,21 +51,17 @@ class _RouteserversSelect extends React.Component {
|
||||
const appliedFilter = this.props.applied[0] || {value: undefined};
|
||||
|
||||
if (appliedFilter.value !== undefined) {
|
||||
const filter = _.findWhere(sortedFiltersAvailable, {
|
||||
value: appliedFilter.value
|
||||
});
|
||||
|
||||
// Just render this, with a button for removal
|
||||
return (
|
||||
<table className="select-ctrl">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="select-container">
|
||||
{filter.name}
|
||||
{appliedFilter.name}
|
||||
</td>
|
||||
<td>
|
||||
<button className="btn btn-remove"
|
||||
onClick={() => this.props.onRemove(filter.value)}>
|
||||
onClick={() => this.props.onRemove(appliedFilter.value)}>
|
||||
<i className="fa fa-times" />
|
||||
</button>
|
||||
</td>
|
||||
@ -121,9 +117,6 @@ class _PeersFilterSelect extends React.Component {
|
||||
const appliedFilter = this.props.applied[0] || {value: undefined};
|
||||
|
||||
if (appliedFilter.value !== undefined) {
|
||||
const filter = _.findWhere(sortedFiltersAvailable, {
|
||||
value: appliedFilter.value
|
||||
});
|
||||
|
||||
// Just render this, with a button for removal
|
||||
return (
|
||||
@ -131,11 +124,11 @@ class _PeersFilterSelect extends React.Component {
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="select-container">
|
||||
{filter.name}
|
||||
{appliedFilter.name}
|
||||
</td>
|
||||
<td>
|
||||
<button className="btn btn-remove"
|
||||
onClick={() => this.props.onRemove(filter.value)}>
|
||||
onClick={() => this.props.onRemove(appliedFilter.value)}>
|
||||
<i className="fa fa-times" />
|
||||
</button>
|
||||
</td>
|
||||
|
@ -104,6 +104,7 @@ const _loadQueryResult = function(state, payload) {
|
||||
|
||||
// Filters available
|
||||
filtersAvailable: results.filters_available,
|
||||
filtersApplied: results.filters_applied,
|
||||
|
||||
// Pagination
|
||||
pageImported: imported.pagination.page,
|
||||
|
@ -225,24 +225,37 @@ export default connect(
|
||||
state: "up"});
|
||||
}
|
||||
|
||||
let received = {
|
||||
const received = {
|
||||
loading: state.routes.receivedLoading,
|
||||
totalResults: state.routes.receivedTotalResults,
|
||||
apiStatus: state.routes.receivedApiStatus
|
||||
};
|
||||
let filtered = {
|
||||
const filtered = {
|
||||
loading: state.routes.filteredLoading,
|
||||
totalResults: state.routes.filteredTotalResults,
|
||||
apiStatus: state.routes.filteredApiStatus
|
||||
};
|
||||
let notExported = {
|
||||
const notExported = {
|
||||
loading: state.routes.notExportedLoading,
|
||||
totalResults: state.routes.notExportedTotalResults,
|
||||
apiStatus: state.routes.notExportedApiStatus
|
||||
};
|
||||
let anyLoading = state.routes.receivedLoading ||
|
||||
const anyLoading = state.routes.receivedLoading ||
|
||||
state.routes.filteredLoading ||
|
||||
state.routes.notExportedLoading;
|
||||
|
||||
const filtersApplied = mergeFilters(
|
||||
state.routes.receivedFiltersApplied,
|
||||
state.routes.filteredFiltersApplied,
|
||||
state.routes.notExportedFiltersApplied
|
||||
);
|
||||
|
||||
const filtersAvailable = mergeFilters(
|
||||
state.routes.receivedFiltersAvailable,
|
||||
state.routes.filteredFiltersAvailable,
|
||||
state.routes.notExportedFiltersAvailable
|
||||
);
|
||||
|
||||
return({
|
||||
filterValue: state.routes.filterValue,
|
||||
routes: {
|
||||
@ -259,12 +272,8 @@ export default connect(
|
||||
|
||||
anyLoading: anyLoading,
|
||||
|
||||
filtersApplied: state.routes.filtersApplied,
|
||||
filtersAvailable: mergeFilters(
|
||||
state.routes.receivedFiltersAvailable,
|
||||
state.routes.filteredFiltersAvailable,
|
||||
state.routes.notExportedFiltersAvailable
|
||||
),
|
||||
filtersApplied: filtersApplied,
|
||||
filtersAvailable: filtersAvailable,
|
||||
|
||||
linkProps: {
|
||||
routing: state.routing.locationBeforeTransitions,
|
||||
@ -278,7 +287,7 @@ export default connect(
|
||||
|
||||
query: state.routes.filterValue,
|
||||
|
||||
filtersApplied: state.routes.filtersApplied,
|
||||
filtersApplied: filtersApplied,
|
||||
},
|
||||
|
||||
relatedPeers: relatedPeers
|
||||
|
@ -24,8 +24,6 @@ const LOCATION_CHANGE = '@@router/LOCATION_CHANGE'
|
||||
|
||||
const initialState = {
|
||||
|
||||
filtersApplied: initialFilterState,
|
||||
|
||||
received: [],
|
||||
receivedLoading: false,
|
||||
receivedRequested: false,
|
||||
@ -35,6 +33,7 @@ const initialState = {
|
||||
receivedTotalPages: 0,
|
||||
receivedTotalResults: 0,
|
||||
receivedApiStatus: {},
|
||||
receivedFiltersApplied: initialFilterState,
|
||||
receivedFiltersAvailable: initialFilterState,
|
||||
|
||||
filtered: [],
|
||||
@ -46,6 +45,7 @@ const initialState = {
|
||||
filteredTotalPages: 0,
|
||||
filteredTotalResults: 0,
|
||||
filteredApiStatus: {},
|
||||
filteredFiltersApplied: initialFilterState,
|
||||
filteredFiltersAvailable: initialFilterState,
|
||||
|
||||
notExported: [],
|
||||
@ -57,6 +57,7 @@ const initialState = {
|
||||
notExportedTotalPages: 0,
|
||||
notExportedTotalResults: 0,
|
||||
notExportedApiStatus: {},
|
||||
notExportedFiltersApplied: initialFilterState,
|
||||
notExportedFiltersAvailable: initialFilterState,
|
||||
|
||||
// Derived state from location
|
||||
@ -103,7 +104,10 @@ function _handleLocationChange(state, payload) {
|
||||
notExportedPage: notExportedPage,
|
||||
|
||||
loadNotExported: loadNotExported,
|
||||
filtersApplied: filtersApplied,
|
||||
|
||||
receivedFiltersApplied: filtersApplied,
|
||||
filteredFiltersApplied: filtersApplied,
|
||||
notExportedFiltersApplied: filtersApplied,
|
||||
});
|
||||
|
||||
return nextState;
|
||||
@ -139,6 +143,7 @@ function _handleFetchRoutesSuccess(type, state, payload) {
|
||||
[stype+'Loading']: false,
|
||||
|
||||
[stype+'FiltersAvailable']: payload.filtersAvailable,
|
||||
[stype+'FiltersApplied']: payload.filtersApplied,
|
||||
});
|
||||
|
||||
return nextState;
|
||||
|
Loading…
x
Reference in New Issue
Block a user