Commit 7d01a432 authored by Marco Sehrer's avatar Marco Sehrer
Browse files

Let UIStore trigger element fetching when collection is selected

Store currentCollectionID in UIStore
parent 8cd31405
......@@ -27,15 +27,8 @@ export default class CollectionSubtree extends React.Component {
UIStore.unlisten(this.onChange.bind(this));
}
componentWillUpdate(nextProps, nextState) {
if(nextState.selected) {
// TODO also for reactions and so on
ElementActions.fetchSamplesByCollectionId(this.state.root.id)
}
}
onChange(state) {
if(state.selectedCollectionIds[0] == this.state.root.id) {
if(state.currentCollectionId == this.state.root.id) {
this.setState({selected: true});
} else {
this.setState({selected: false});
......
import alt from '../alt';
import UIActions from '../actions/UIActions';
import ElementActions from '../actions/ElementActions';
import ElementStore from './ElementStore';
import ArrayUtils from '../utils/ArrayUtils';
......@@ -9,7 +10,7 @@ class UIStore {
constructor() {
this.state = {
checkedSampleIds: Immutable.List(),
selectedCollectionIds: []
currentCollectionId: null
};
this.bindListeners({
......@@ -60,7 +61,7 @@ class UIStore {
handleDeselectAllElements(type) {
switch(type) {
case 'collection':
this.state.selectedCollectionIds = [];
this.state.currentCollectionId = null;
break;
}
}
......@@ -68,7 +69,9 @@ class UIStore {
handleSelectElement(element) {
switch(element.type) {
case 'collection':
this.state.selectedCollectionIds.push(element.id);
this.state.currentCollectionId = element.id;
// TODO also for reactions and so on
ElementActions.fetchSamplesByCollectionId(element.id)
break;
}
}
......
Supports Markdown
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