Skip to content

Commit

Permalink
fix: #1092 StoryBook chapter number displayed incorrectly
Browse files Browse the repository at this point in the history
- Update the chapter's sort order (in case any of the previous chapters were excluded)
  • Loading branch information
nya-elimu committed Dec 3, 2020
1 parent 2e5bf91 commit 3580f2a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ public String handleSubmit(
storyBookDao.update(storyBook);

// Store the StoryBookChapters in the database
int chapterSortOrder = 0;
for (StoryBookChapter storyBookChapter : storyBookChapters) {
storyBookChapter.setStoryBook(storyBook);

Expand Down Expand Up @@ -365,6 +366,9 @@ public String handleSubmit(
continue;
}

// Update the chapter's sort order (in case any of the previous chapters were excluded)
storyBookChapter.setSortOrder(chapterSortOrder);

// Store the chapter's image (if any)
Image chapterImage = storyBookChapter.getImage();
if (chapterImage != null) {
Expand All @@ -375,6 +379,7 @@ public String handleSubmit(
// Only store the chapter if it has an image or at least one paragraph
if ((chapterImage != null) || (!storyBookParagraphsAssociatedWithChapter.isEmpty())) {
storyBookChapterDao.create(storyBookChapter);
chapterSortOrder++;
}

// Store the chapter's paragraphs in the database
Expand Down

0 comments on commit 3580f2a

Please sign in to comment.