1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

fixed store bindings

This commit is contained in:
Tim Daubenschütz 2015-06-04 13:16:19 +02:00
parent 302f05b68e
commit ccbf411168
6 changed files with 46 additions and 22 deletions

View File

@ -14,6 +14,26 @@ import alt from './alt';
import fetch from './utils/fetch';
import AlertDismissable from './components/ascribe_forms/alert';
/*
Taken from
http://stackoverflow.com/questions/30613447/how-to-debug-reactjss-setstate?noredirect=1#comment49301874_30613447
<remove this in production>
*/
var warn = console.warn;
console.warn = function(warning) {
if (/(setState)/.test(warning)) {
throw new Error(warning);
}
warn.apply(console, arguments);
};
/*
</remove this in production>
*/
fetch.defaults({
urlMap: ApiUrls,

View File

@ -15,7 +15,10 @@ let PieceListBulkModal = React.createClass({
},
getInitialState() {
return EditionListStore.getState();
return {
editions: EditionListStore.getState(),
user: UserStore.getState()
};
},
onChange(state) {
@ -37,9 +40,9 @@ let PieceListBulkModal = React.createClass({
let selectedEditionList = [];
Object
.keys(this.state.editionList)
.keys(this.state.editions.editionList)
.forEach((key) => {
let filteredEditionsForPiece = this.state.editionList[key].filter((edition) => edition.selected);
let filteredEditionsForPiece = this.state.editions.editionList[key].filter((edition) => edition.selected);
selectedEditionList = selectedEditionList.concat(filteredEditionsForPiece);
});
@ -73,10 +76,6 @@ let PieceListBulkModal = React.createClass({
EditionListActions.clearAllEditionSelections();
},
handleSuccess(){
},
render() {
let availableAcls = this.getAvailableAcls();
let selectedEditions = this.fetchSelectedEditionList();
@ -104,25 +103,25 @@ let PieceListBulkModal = React.createClass({
availableAcls={availableAcls}
action="transfer"
editions={selectedEditions}
currentUser={this.state.currentUser}
currentUser={this.state.user.currentUser}
handleSuccess={this.handleSuccess} />
<AclButton
availableAcls={availableAcls}
action="consign"
editions={selectedEditions}
currentUser={this.state.currentUser}
currentUser={this.state.user.currentUser}
handleSuccess={this.handleSuccess} />
<AclButton
availableAcls={availableAcls}
action="loan"
editions={selectedEditions}
currentUser={this.state.currentUser}
currentUser={this.state.user.currentUser}
handleSuccess={this.handleSuccess} />
<AclButton
availableAcls={availableAcls}
action="share"
editions={selectedEditions}
currentUser={this.state.currentUser}
currentUser={this.state.user.currentUser}
handleSuccess={this.handleSuccess} />
</div>
</div>

View File

@ -21,7 +21,6 @@ let TableItemWrapper = React.createClass({
if(column.link) {
let params = {};
params[column.link.paramsKey] = this.props.columnContent[column.link.contentKey];
this.transitionTo(column.link.to, params);
}
},

View File

@ -11,10 +11,11 @@ import Edition from './edition';
* This is the component that implements resource/data specific functionality
*/
let EditionContainer = React.createClass({
getInitialState() {
return {'user': UserStore.getState(),
'edition': EditionStore.getState()}
return {
'user': UserStore.getState(),
'edition': EditionStore.getState()
};
},
onChange(state) {
@ -22,10 +23,11 @@ let EditionContainer = React.createClass({
},
componentDidMount() {
EditionActions.fetchOne(this.props.params.editionId);
EditionStore.listen(this.onChange);
UserActions.fetchCurrentUser();
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
EditionActions.fetchOne(this.props.params.editionId);
},
componentDidUnmount() {
EditionStore.unlisten(this.onChange);
@ -33,18 +35,18 @@ let EditionContainer = React.createClass({
},
render() {
if('title' in this.state.edition) {
return (
<Edition edition={this.state.edition } currentUser={this.state.currentUser}></Edition>
<Edition
edition={this.state.edition}
currentUser={this.state.currentUser}>
</Edition>
);
} else {
return (
<p>Loading</p>
);
}
}
});

View File

@ -26,6 +26,10 @@ let Header = React.createClass({
UserActions.fetchCurrentUser();
},
componentDidUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},

View File

@ -26,7 +26,7 @@ let PieceList = React.createClass({
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
},
componentWillUnmount() {
componentDidUnmount() {
PieceListStore.unlisten(this.onChange);
},