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

update indexes when removing chapter with patches

parent 5b9e82ba
No related branches found
No related tags found
No related merge requests found
...@@ -19,9 +19,9 @@ export class Chapter extends React.Component { ...@@ -19,9 +19,9 @@ export class Chapter extends React.Component {
} }
} }
update (changedChapter) { update (patch) {
const { book, update } = this.props const { book, update } = this.props
update(book, changedChapter) update(book, patch)
} }
toggleUpload () { toggleUpload () {
......
...@@ -61,13 +61,18 @@ export class Division extends React.Component { ...@@ -61,13 +61,18 @@ export class Division extends React.Component {
}) })
_.forEach(chaptersToModify, function (c) { _.forEach(chaptersToModify, function (c) {
c.index -= 1 const patch = {
update(book, c) id: c.id,
index: (c.index - 1)
}
update(book, patch)
}) })
} }
// Reorder chapters // Reorder chapters
_onMove (dragIndex, hoverIndex) { _onMove (dragIndex, hoverIndex) {
// hovering over current position
if (dragIndex === hoverIndex) { return } if (dragIndex === hoverIndex) { return }
const { book, chapters, update } = this.props const { book, chapters, update } = this.props
......
...@@ -56,7 +56,6 @@ export class Dashboard extends React.Component { ...@@ -56,7 +56,6 @@ export class Dashboard extends React.Component {
Once you have the new book's db id, make the teams for it as well. Once you have the new book's db id, make the teams for it as well.
*/ */
createBook (newTitle) { createBook (newTitle) {
console.log('called')
const { createCollection } = this.props.actions const { createCollection } = this.props.actions
const book = { const book = {
......
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