From: Jean-René ROUET Date: Tue, 11 Jul 2023 11:28:20 +0000 (+0200) Subject: add priority on page and chapter create X-Git-Tag: v23.08~1^2~10^2~2 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/4d399f6ba77610635d4d1399b9ac3d5302c63b9c add priority on page and chapter create --- diff --git a/app/Entities/Repos/ChapterRepo.php b/app/Entities/Repos/ChapterRepo.php index 588854c7e..dadeec7f8 100644 --- a/app/Entities/Repos/ChapterRepo.php +++ b/app/Entities/Repos/ChapterRepo.php @@ -49,7 +49,7 @@ class ChapterRepo { $chapter = new Chapter(); $chapter->book_id = $parentBook->id; - $chapter->priority = (new BookContents($parentBook))->getLastPriority() + 1; + $chapter->priority = $chapter->priority ?: (new BookContents($parentBook))->getLastPriority() + 1; $this->baseRepo->create($chapter, $input); Activity::add(ActivityType::CHAPTER_CREATE, $chapter); diff --git a/app/Entities/Repos/PageRepo.php b/app/Entities/Repos/PageRepo.php index 521519dc0..637f4133a 100644 --- a/app/Entities/Repos/PageRepo.php +++ b/app/Entities/Repos/PageRepo.php @@ -164,7 +164,7 @@ class PageRepo $draft->draft = false; $draft->revision_count = 1; - $draft->priority = $this->getNewPriority($draft); + $draft->priority = $draft->priority ?: $this->getNewPriority($draft); $draft->save(); $this->revisionRepo->storeNewForPage($draft, trans('entities.pages_initial_revision'));