Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
editoria
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yannis Barlas
editoria
Commits
79de37a4
Commit
79de37a4
authored
8 years ago
by
Alf Eaton
Committed by
john
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow books to be created
parent
6ef05881
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/components/BookBuilder/BookList.jsx
+44
-20
44 additions, 20 deletions
app/components/BookBuilder/BookList.jsx
app/routes.jsx
+2
-0
2 additions, 0 deletions
app/routes.jsx
with
46 additions
and
20 deletions
app/components/BookBuilder/BookList.jsx
+
44
−
20
View file @
79de37a4
import
React
from
'
react
'
import
React
from
'
react
'
import
ReactDOM
from
'
react-dom
'
import
{
bindActionCreators
}
from
'
redux
'
import
{
bindActionCreators
}
from
'
redux
'
import
{
connect
}
from
'
react-redux
'
import
{
connect
}
from
'
react-redux
'
import
{
Modal
}
from
'
react-bootstrap
'
import
{
Modal
,
Button
,
FormControl
,
FormGroup
,
ControlLabel
}
from
'
react-bootstrap
'
import
{
LinkContainer
}
from
'
react-router-bootstrap
'
import
*
as
Actions
from
'
pubsweet-frontend/src/actions
'
import
*
as
Actions
from
'
pubsweet-frontend/src/actions
'
import
{
Link
}
from
'
react-router
'
import
styles
from
'
./styles/bookList.local.scss
'
import
styles
from
'
./styles/bookList.local.scss
'
export
class
BookList
extends
React
.
Component
{
export
class
BookList
extends
React
.
Component
{
...
@@ -23,16 +24,34 @@ export class BookList extends React.Component {
...
@@ -23,16 +24,34 @@ export class BookList extends React.Component {
})
})
}
}
_createCollection
=
(
event
)
=>
{
event
.
preventDefault
()
this
.
props
.
actions
.
createCollection
({
title
:
ReactDOM
.
findDOMNode
(
this
.
refs
.
newBookTitle
).
value
||
'
Untitled
'
})
// TODO: allow the title to be edited
// TODO: handle errors
this
.
_toggleModal
()
}
render
()
{
render
()
{
const
{
book
}
=
this
.
props
const
{
book
s
}
=
this
.
props
const
{
showModal
}
=
this
.
state
const
{
showModal
}
=
this
.
state
let
bookTitle
=
book
?
book
.
title
:
'
Fetching...
'
let
bookId
=
book
?
book
.
id
:
''
// TODO: sort most recently created to the top
// TODO: needs a "created_at" property on each book
// if (books) {
// books.sort((a, b) => {
// return (b.created_at < a.created_at) ? -1 : ((b.created_at > a.created_at) ? 1 : 0);
// })
// }
return
(
return
(
<
div
className
=
{
styles
.
bookList
+
'
bootstrap
'
}
>
<
div
className
=
{
styles
.
bookList
+
'
bootstrap
'
}
>
{
/* FIXME: make this height: 100%, overflow: auto so it scrolls */
}
<
div
className
=
'container col-lg-offset-2 col-lg-8'
>
<
div
className
=
'container col-lg-offset-2 col-lg-8'
>
{
/* FIXME: make this a fixed header */
}
<
div
className
=
'col-lg-12'
>
<
div
className
=
'col-lg-12'
>
<
h1
className
=
{
styles
.
bookTitle
}
>
<
h1
className
=
{
styles
.
bookTitle
}
>
Books
Books
...
@@ -43,17 +62,12 @@ export class BookList extends React.Component {
...
@@ -43,17 +62,12 @@ export class BookList extends React.Component {
</
div
>
</
div
>
<
div
className
=
'col-lg-12'
>
<
div
className
=
'col-lg-12'
>
<
div
className
=
{
styles
.
bookContainer
}
>
{
books
?
books
.
map
(
book
=>
(
<
h2
>
{
bookTitle
}
</
h2
>
<
div
key
=
{
book
.
id
}
className
=
{
styles
.
bookContainer
}
>
<
LinkContainer
to
=
{
`/books/
${
bookId
}
/book-builder`
}
>
<
h2
>
{
book
.
title
}
</
h2
>
<
a
href
=
'#'
<
Link
to
=
{
`/books/
${
book
.
id
}
/book-builder`
}
className
=
{
styles
.
editBook
}
>
Edit
</
Link
>
className
=
{
styles
.
editBook
}
</
div
>
onClick
=
{
this
.
_toggleModal
}
>
))
:
'
Fetching…
'
}
Edit
</
a
>
</
LinkContainer
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
@@ -71,7 +85,16 @@ export class BookList extends React.Component {
...
@@ -71,7 +85,16 @@ export class BookList extends React.Component {
</
Modal
.
Header
>
</
Modal
.
Header
>
<
Modal
.
Body
>
<
Modal
.
Body
>
This feature is currently disabled.
<
form
onSubmit
=
{
this
.
_createCollection
}
>
<
FormGroup
>
<
ControlLabel
>
Title
</
ControlLabel
>
<
FormControl
ref
=
"newBookTitle"
name
=
"title"
type
=
"text"
placeholder
=
"Untitled"
/>
</
FormGroup
>
<
Button
bsStyle
=
"primary"
type
=
"submit"
>
<
i
className
=
'fa fa-plus'
/>
Create book
</
Button
>
</
form
>
</
Modal
.
Body
>
</
Modal
.
Body
>
<
Modal
.
Footer
>
<
Modal
.
Footer
>
...
@@ -89,12 +112,13 @@ export class BookList extends React.Component {
...
@@ -89,12 +112,13 @@ export class BookList extends React.Component {
}
}
BookList
.
propTypes
=
{
BookList
.
propTypes
=
{
book
:
React
.
PropTypes
.
object
books
:
React
.
PropTypes
.
arrayOf
(
React
.
PropTypes
.
object
),
actions
:
React
.
PropTypes
.
object
.
isRequired
}
}
function
mapStateToProps
(
state
)
{
function
mapStateToProps
(
state
,
{
params
}
)
{
return
{
return
{
book
:
state
.
collections
[
0
]
book
s
:
state
.
collections
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
app/routes.jsx
+
2
−
0
View file @
79de37a4
...
@@ -18,6 +18,8 @@ import SimpleEditorWrapper from './components/SimpleEditor/SimpleEditorWrapper'
...
@@ -18,6 +18,8 @@ import SimpleEditorWrapper from './components/SimpleEditor/SimpleEditorWrapper'
import
Login
from
'
pubsweet-component-login/Login
'
import
Login
from
'
pubsweet-component-login/Login
'
import
Signup
from
'
pubsweet-component-signup/Signup
'
import
Signup
from
'
pubsweet-component-signup/Signup
'
// FIXME: this shouldn't be using the collection as the object
const
AuthenticatedManage
=
requireAuthentication
(
const
AuthenticatedManage
=
requireAuthentication
(
Manage
,
'
create
'
,
(
state
)
=>
state
.
collections
[
0
]
Manage
,
'
create
'
,
(
state
)
=>
state
.
collections
[
0
]
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment