Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

When filtering a view please use the newly introduced /documentView/{windowId}/{viewId}/filter endpoint #740 #746

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/actions/AppActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ export function createViewRequest(
});
}

export function filterViewRequest(windowType, viewId, filters){
return () => axios.post(config.API_URL + '/documentView/' + windowType +
'/'+viewId+'/filter', {
'filters': filters
});
}

export function addNotification(title, msg, time, notifType, shortMsg){
return {
type: types.ADD_NOTIFICATION,
Expand Down
29 changes: 27 additions & 2 deletions src/components/app/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import {

import {
createViewRequest,
browseViewRequest
browseViewRequest,
filterViewRequest
} from '../../actions/AppActions';

class DocumentList extends Component {
Expand Down Expand Up @@ -267,7 +268,11 @@ class DocumentList extends Component {
if(viewId && !isNewFilter){
this.browseView();
}else{
this.createView();
if(viewId){
this.filterView();
} else {
this.createView();
}
}
setModalTitle && setModalTitle(response.data.caption)
})
Expand All @@ -282,6 +287,7 @@ class DocumentList extends Component {
})
})
}

/*
* If viewId exist, than browse that view.
*/
Expand Down Expand Up @@ -316,6 +322,25 @@ class DocumentList extends Component {
})
}

filterView = () => {
const {
dispatch, windowType
} = this.props;

const {page, sort, filters, viewId} = this.state;

dispatch(filterViewRequest(
windowType, viewId, filters
)).then(response => {
this.mounted && this.setState({
data: response.data,
viewId: response.data.viewId
}, () => {
this.getData(response.data.viewId, page, sort);
})
})
}

getData = (id, page, sortingQuery, refresh) => {
const {dispatch, windowType, updateUri, setNotFound} = this.props;

Expand Down