From 2c4c5019bca564edee541fd7f4b90d9c669e411a Mon Sep 17 00:00:00 2001 From: Johannes Wilm Date: Sat, 14 Oct 2017 18:32:21 +0200 Subject: [PATCH] 3.3.1: fix chapter numbers + ordering --- book/static/js/es6_modules/books/actions.js | 15 ++++++--------- book/static/js/es6_modules/books/templates.js | 6 +++--- setup.py | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/book/static/js/es6_modules/books/actions.js b/book/static/js/es6_modules/books/actions.js index cc8b852..3844062 100644 --- a/book/static/js/es6_modules/books/actions.js +++ b/book/static/js/es6_modules/books/actions.js @@ -401,18 +401,15 @@ export class BookActions { jQuery(document).on('click', '#add-chapter', () => { jQuery('#book-document-list td.checked').each(function () { - let documentId = parseInt(jQuery(this).attr( - 'data-id')), - lastChapterNumber = Math.max( - book.chapters.map(chapter => chapter.number) - ) - if (isNaN(lastChapterNumber)) { - lastChapterNumber = 0 - } + let documentId = parseInt(jQuery(this).attr('data-id')), + chapNums = book.chapters.map(chapter => chapter.number), + number = chapNums.length ? + Math.max.apply(Math, chapNums) + 1: + 1 book.chapters.push({ text: documentId, title: jQuery.trim(this.textContent), - number: lastChapterNumber + 1, + number, part: '' }) }) diff --git a/book/static/js/es6_modules/books/templates.js b/book/static/js/es6_modules/books/templates.js index 13f11c9..a468671 100644 --- a/book/static/js/es6_modules/books/templates.js +++ b/book/static/js/es6_modules/books/templates.js @@ -483,10 +483,10 @@ export let bookChapterListTemplate = ({book, documentList}) => { } ${ index + 1 === array.length ? + '' : ` - - ` : - '' + + ` } diff --git a/setup.py b/setup.py index bb894ac..6de6894 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='fiduswriter-books', - version='3.3.0', + version='3.3.1', packages=find_packages(), include_package_data=True, license='AGPL License',