mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
fixed store bindings
This commit is contained in:
parent
302f05b68e
commit
ccbf411168
20
js/app.js
20
js/app.js
@ -14,6 +14,26 @@ import alt from './alt';
|
|||||||
import fetch from './utils/fetch';
|
import fetch from './utils/fetch';
|
||||||
import AlertDismissable from './components/ascribe_forms/alert';
|
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({
|
fetch.defaults({
|
||||||
urlMap: ApiUrls,
|
urlMap: ApiUrls,
|
||||||
|
@ -15,7 +15,10 @@ let PieceListBulkModal = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return EditionListStore.getState();
|
return {
|
||||||
|
editions: EditionListStore.getState(),
|
||||||
|
user: UserStore.getState()
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
@ -37,9 +40,9 @@ let PieceListBulkModal = React.createClass({
|
|||||||
let selectedEditionList = [];
|
let selectedEditionList = [];
|
||||||
|
|
||||||
Object
|
Object
|
||||||
.keys(this.state.editionList)
|
.keys(this.state.editions.editionList)
|
||||||
.forEach((key) => {
|
.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);
|
selectedEditionList = selectedEditionList.concat(filteredEditionsForPiece);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -73,10 +76,6 @@ let PieceListBulkModal = React.createClass({
|
|||||||
EditionListActions.clearAllEditionSelections();
|
EditionListActions.clearAllEditionSelections();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess(){
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let availableAcls = this.getAvailableAcls();
|
let availableAcls = this.getAvailableAcls();
|
||||||
let selectedEditions = this.fetchSelectedEditionList();
|
let selectedEditions = this.fetchSelectedEditionList();
|
||||||
@ -104,25 +103,25 @@ let PieceListBulkModal = React.createClass({
|
|||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="transfer"
|
action="transfer"
|
||||||
editions={selectedEditions}
|
editions={selectedEditions}
|
||||||
currentUser={this.state.currentUser}
|
currentUser={this.state.user.currentUser}
|
||||||
handleSuccess={this.handleSuccess} />
|
handleSuccess={this.handleSuccess} />
|
||||||
<AclButton
|
<AclButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="consign"
|
action="consign"
|
||||||
editions={selectedEditions}
|
editions={selectedEditions}
|
||||||
currentUser={this.state.currentUser}
|
currentUser={this.state.user.currentUser}
|
||||||
handleSuccess={this.handleSuccess} />
|
handleSuccess={this.handleSuccess} />
|
||||||
<AclButton
|
<AclButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="loan"
|
action="loan"
|
||||||
editions={selectedEditions}
|
editions={selectedEditions}
|
||||||
currentUser={this.state.currentUser}
|
currentUser={this.state.user.currentUser}
|
||||||
handleSuccess={this.handleSuccess} />
|
handleSuccess={this.handleSuccess} />
|
||||||
<AclButton
|
<AclButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="share"
|
action="share"
|
||||||
editions={selectedEditions}
|
editions={selectedEditions}
|
||||||
currentUser={this.state.currentUser}
|
currentUser={this.state.user.currentUser}
|
||||||
handleSuccess={this.handleSuccess} />
|
handleSuccess={this.handleSuccess} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,7 +21,6 @@ let TableItemWrapper = React.createClass({
|
|||||||
if(column.link) {
|
if(column.link) {
|
||||||
let params = {};
|
let params = {};
|
||||||
params[column.link.paramsKey] = this.props.columnContent[column.link.contentKey];
|
params[column.link.paramsKey] = this.props.columnContent[column.link.contentKey];
|
||||||
|
|
||||||
this.transitionTo(column.link.to, params);
|
this.transitionTo(column.link.to, params);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -11,10 +11,11 @@ import Edition from './edition';
|
|||||||
* This is the component that implements resource/data specific functionality
|
* This is the component that implements resource/data specific functionality
|
||||||
*/
|
*/
|
||||||
let EditionContainer = React.createClass({
|
let EditionContainer = React.createClass({
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {'user': UserStore.getState(),
|
return {
|
||||||
'edition': EditionStore.getState()}
|
'user': UserStore.getState(),
|
||||||
|
'edition': EditionStore.getState()
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
@ -22,10 +23,11 @@ let EditionContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
EditionActions.fetchOne(this.props.params.editionId);
|
|
||||||
EditionStore.listen(this.onChange);
|
EditionStore.listen(this.onChange);
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
|
|
||||||
|
UserActions.fetchCurrentUser();
|
||||||
|
EditionActions.fetchOne(this.props.params.editionId);
|
||||||
},
|
},
|
||||||
componentDidUnmount() {
|
componentDidUnmount() {
|
||||||
EditionStore.unlisten(this.onChange);
|
EditionStore.unlisten(this.onChange);
|
||||||
@ -33,18 +35,18 @@ let EditionContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
if('title' in this.state.edition) {
|
if('title' in this.state.edition) {
|
||||||
return (
|
return (
|
||||||
<Edition edition={this.state.edition } currentUser={this.state.currentUser}></Edition>
|
<Edition
|
||||||
|
edition={this.state.edition}
|
||||||
|
currentUser={this.state.currentUser}>
|
||||||
|
</Edition>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<p>Loading</p>
|
<p>Loading</p>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@ let Header = React.createClass({
|
|||||||
UserActions.fetchCurrentUser();
|
UserActions.fetchCurrentUser();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidUnmount() {
|
||||||
|
UserStore.unlisten(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ let PieceList = React.createClass({
|
|||||||
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
|
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentDidUnmount() {
|
||||||
PieceListStore.unlisten(this.onChange);
|
PieceListStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user