Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2016-04-07 19:03:00 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
afc3583be875a1d7fd66b6ef14752c08695edab3
afc3583b
1 parent
cbff2c60
Made new pages in chapters have a better inital priority
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
app/Http/Controllers/PageController.php
app/Repos/ChapterRepo.php
app/Http/Controllers/PageController.php
View file @
afc3583
...
...
@@ -88,7 +88,6 @@ class PageController extends Controller
$input
=
$request
->
all
();
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$input
[
'priority'
]
=
$this
->
bookRepo
->
getNewPriority
(
$book
);
$draftPage
=
$this
->
pageRepo
->
getById
(
$pageId
,
true
);
...
...
@@ -96,6 +95,12 @@ class PageController extends Controller
$parent
=
$chapterId
!==
0
?
$this
->
chapterRepo
->
getById
(
$chapterId
)
:
$book
;
$this
->
checkOwnablePermission
(
'page-create'
,
$parent
);
if
(
$parent
->
isA
(
'chapter'
))
{
$input
[
'priority'
]
=
$this
->
chapterRepo
->
getNewPriority
(
$parent
);
}
else
{
$input
[
'priority'
]
=
$this
->
bookRepo
->
getNewPriority
(
$parent
);
}
$page
=
$this
->
pageRepo
->
publishDraft
(
$draftPage
,
$input
);
Activity
::
add
(
$page
,
'page_create'
,
$book
->
id
);
...
...
app/Repos/ChapterRepo.php
View file @
afc3583
...
...
@@ -137,6 +137,18 @@ class ChapterRepo extends EntityRepo
}
/**
* Get a new priority value for a new page to be added
* to the given chapter.
* @param Chapter $chapter
* @return int
*/
public
function
getNewPriority
(
Chapter
$chapter
)
{
$lastPage
=
$chapter
->
pages
->
last
();
return
$lastPage
!==
null
?
$lastPage
->
priority
+
1
:
0
;
}
/**
* Get chapters by the given search term.
* @param string $term
* @param array $whereTerms
...
...
Please
register
or
sign in
to post a comment