Skip to content
Snippets Groups Projects
Commit b1184a9d authored by john's avatar john
Browse files

attempt to make bookbuilder working with pubsweet

parent a71e56e9
No related branches found
No related tags found
No related merge requests found
...@@ -30,9 +30,7 @@ export class BookBuilder extends React.Component { ...@@ -30,9 +30,7 @@ export class BookBuilder extends React.Component {
componentWillMount () { componentWillMount () {
const { actions, book } = this.props const { actions, book } = this.props
const { getUsers, getTeams, getCollections, getFragments } = actions const { getCollections, getFragments, getTeams, getUsers } = actions
// console.log(this.props.actions)
getUsers().then( getUsers().then(
() => getTeams() () => getTeams()
...@@ -42,10 +40,25 @@ export class BookBuilder extends React.Component { ...@@ -42,10 +40,25 @@ export class BookBuilder extends React.Component {
return getCollections() return getCollections()
} }
).then( ).then(
() => getFragments(book) () => {
console.log(book.id)
if (book.id) getFragments(book)
}
) )
} }
// componentWillReceiveProps (nextProps) {
// const { actions, book } = nextProps
// const { getFragments } = actions
// //
// console.log(book)
// console.log(this.props)
// //
// // if (book.id && book.id !== this.props.id) {
// // // getFragments(book)
// // }
// }
componentDidMount () { componentDidMount () {
// I'm using the ref inside the render function it was created in // I'm using the ref inside the render function it was created in
// So it won't be available until didMount // So it won't be available until didMount
...@@ -61,6 +74,8 @@ export class BookBuilder extends React.Component { ...@@ -61,6 +74,8 @@ export class BookBuilder extends React.Component {
return t.teamType.name === 'Production Editor' && t.object.id === book.id return t.teamType.name === 'Production Editor' && t.object.id === book.id
}) })
if (!productionEditorsTeam) return console.log('to crash')
const productionEditors = _.filter(users, function (u) { const productionEditors = _.filter(users, function (u) {
return _.includes(productionEditorsTeam.members, u.id) return _.includes(productionEditorsTeam.members, u.id)
}) })
...@@ -226,14 +241,14 @@ export class BookBuilder extends React.Component { ...@@ -226,14 +241,14 @@ export class BookBuilder extends React.Component {
} }
BookBuilder.propTypes = { BookBuilder.propTypes = {
actions: React.PropTypes.object.isRequired,
book: React.PropTypes.object.isRequired, book: React.PropTypes.object.isRequired,
chapters: React.PropTypes.array.isRequired, chapters: React.PropTypes.array.isRequired,
actions: React.PropTypes.object.isRequired, // error: React.PropTypes.string,
error: React.PropTypes.string,
// userRoles: React.PropTypes.array,
teams: React.PropTypes.array, teams: React.PropTypes.array,
users: React.PropTypes.array, users: React.PropTypes.array,
user: React.PropTypes.object user: React.PropTypes.object
// userRoles: React.PropTypes.array,
} }
function mapStateToProps (state, ownProps) { function mapStateToProps (state, ownProps) {
...@@ -241,6 +256,8 @@ function mapStateToProps (state, ownProps) { ...@@ -241,6 +256,8 @@ function mapStateToProps (state, ownProps) {
return c.id === ownProps.params.id return c.id === ownProps.params.id
}) })
console.log(state)
let chapters = _.sortBy(_.filter(state.fragments, function (f) { let chapters = _.sortBy(_.filter(state.fragments, function (f) {
return f.book === book.id && f.id && !f.deleted return f.book === book.id && f.id && !f.deleted
}), 'index') }), 'index')
......
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