Commit 5b451e75 authored by Maxime Chaillet's avatar Maxime Chaillet

clean the code taking advantage of the new implementation of selection filters...

clean the code taking advantage of the new implementation of selection filters usable for both logbook views. It fixes #52.
parent d400a582
......@@ -191,14 +191,9 @@ class EventContainer extends React.Component {
*/
setView(view) {
if (view && view !== this.state.view) {
if (view === DOC_VIEW) {
this.downloadEvents(0, getSelectionFilterForAllComments(), true);
}
if (view === LIST_VIEW) {
this.downloadEvents(0, getSelectionFiltersBySearchCriteria([], this.state.view), true);
}
this.setState({ view: view })
this.downloadEvents(0, getSelectionFiltersBySearchCriteria([], view), true);
}
this.setState({ view: view })
}
/**
......@@ -298,12 +293,7 @@ class EventContainer extends React.Component {
activePage: 1,
});
if (this.state.view === LIST_VIEW) {
this.downloadEvents(0, getSelectionFiltersBySearchCriteria([], this.state.view), true);
}
if (this.state.view === DOC_VIEW) {
this.downloadEvents(0, getSelectionFilterForAllComments(), true);
}
this.downloadEvents(0, getSelectionFiltersBySearchCriteria([], this.state.view), true);
}
/**
......@@ -407,12 +397,12 @@ class EventContainer extends React.Component {
/**
* Create the event on ICAT+ server
* @param {*} newEvent event object to be created
* @param {String} sessionId session Id required for HTTP request authentication
* @param {*} investigationId investigation Id to which the event will be added to.
* @param {*} onSuccess callback function executed after the asymchronous event creation process succeeded.
*/
* Create the event on ICAT+ server
* @param {*} newEvent event object to be created
* @param {String} sessionId session Id required for HTTP request authentication
* @param {*} investigationId investigation Id to which the event will be added to.
* @param {*} onSuccess callback function executed after the asymchronous event creation process succeeded.
*/
createEvent(newEvent, sessionId, investigationId, onSuccess) {
axios({
method: 'post',
......@@ -455,24 +445,6 @@ class EventContainer extends React.Component {
}
}
/**
* Get the selection filter which selects all comments in the database (annotations and commented notifications).
* @returns {Object} selection filter in the mongoDB format
*/
export function getSelectionFilterForAllComments() {
return {
$or: [
{ type: "annotation" },
{
$and: [
{ type: "notification" },
{ previousVersionEvent: { $ne: null } }
]
}
]
}
}
function mapStateToProps(state) {
return {
user: state.user,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment