]> BookStack Code Mirror - bookstack/commitdiff
add priority on page and chapter create
authorJean-René ROUET <redacted>
Tue, 11 Jul 2023 11:28:20 +0000 (13:28 +0200)
committerJean-René ROUET <redacted>
Tue, 11 Jul 2023 11:28:20 +0000 (13:28 +0200)
app/Entities/Repos/ChapterRepo.php
app/Entities/Repos/PageRepo.php

index 588854c7e91c34b05280a3458ed13ff72d5f7fa1..dadeec7f897d41132f94741923301b16ca047810 100644 (file)
@@ -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);
 
index 521519dc08d607d8a831015adc55e942f46b47bd..637f4133a9061fcc9e7c2b7583ad6aab0ab09b35 100644 (file)
@@ -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'));