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-15 19:52:59 +0100
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Commit
448ac61b48c557359e98d605ca0c6023d3f7b3c1
448ac61b
2 parents
753f6394
89331790
Merge branch 'master' into release
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
6 deletions
app/Http/Controllers/BookController.php
app/Repos/BookRepo.php
app/Repos/PageRepo.php
resources/assets/js/pages/page-form.js
tests/Entity/SortTest.php
app/Http/Controllers/BookController.php
View file @
448ac61
...
...
@@ -151,7 +151,7 @@ class BookController extends Controller
{
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$this
->
checkOwnablePermission
(
'book-update'
,
$book
);
$bookChildren
=
$this
->
bookRepo
->
getChildren
(
$book
);
$bookChildren
=
$this
->
bookRepo
->
getChildren
(
$book
,
true
);
$books
=
$this
->
bookRepo
->
getAll
(
false
);
$this
->
setPageTitle
(
'Sort Book '
.
$book
->
getShortName
());
return
view
(
'books/sort'
,
[
'book'
=>
$book
,
'current'
=>
$book
,
'books'
=>
$books
,
'bookChildren'
=>
$bookChildren
]);
...
...
app/Repos/BookRepo.php
View file @
448ac61
...
...
@@ -198,16 +198,23 @@ class BookRepo extends EntityRepo
* Returns a sorted collection of Pages and Chapters.
* Loads the bookslug onto child elements to prevent access database access for getting the slug.
* @param Book $book
* @param bool $filterDrafts
* @return mixed
*/
public
function
getChildren
(
Book
$book
)
public
function
getChildren
(
Book
$book
,
$filterDrafts
=
false
)
{
$pageQuery
=
$book
->
pages
()
->
where
(
'chapter_id'
,
'='
,
0
);
$pageQuery
=
$this
->
restrictionService
->
enforcePageRestrictions
(
$pageQuery
,
'view'
);
if
(
$filterDrafts
)
{
$pageQuery
=
$pageQuery
->
where
(
'draft'
,
'='
,
false
);
}
$pages
=
$pageQuery
->
get
();
$chapterQuery
=
$book
->
chapters
()
->
with
([
'pages'
=>
function
(
$query
)
{
$chapterQuery
=
$book
->
chapters
()
->
with
([
'pages'
=>
function
(
$query
)
use
(
$filterDrafts
)
{
$this
->
restrictionService
->
enforcePageRestrictions
(
$query
,
'view'
);
if
(
$filterDrafts
)
$query
->
where
(
'draft'
,
'='
,
false
);
}]);
$chapterQuery
=
$this
->
restrictionService
->
enforceChapterRestrictions
(
$chapterQuery
,
'view'
);
$chapters
=
$chapterQuery
->
get
();
...
...
app/Repos/PageRepo.php
View file @
448ac61
...
...
@@ -154,10 +154,10 @@ class PageRepo extends EntityRepo
/**
* Get a new draft page instance.
* @param Book $book
* @param Chapter|
nul
l $chapter
* @param Chapter|
boo
l $chapter
* @return static
*/
public
function
getDraftPage
(
Book
$book
,
$chapter
)
public
function
getDraftPage
(
Book
$book
,
$chapter
=
false
)
{
$page
=
$this
->
page
->
newInstance
();
$page
->
name
=
'New Page'
;
...
...
resources/assets/js/pages/page-form.js
View file @
448ac61
...
...
@@ -11,7 +11,7 @@ var mceOptions = module.exports = {
extended_valid_elements
:
'pre[*]'
,
automatic_uploads
:
false
,
valid_children
:
"-div[p|pre|h1|h2|h3|h4|h5|h6|blockquote]"
,
plugins
:
"image table textcolor paste link fullscreen imagetools code hr autosave"
,
plugins
:
"image table textcolor paste link fullscreen imagetools code hr autosave
lists
"
,
imagetools_toolbar
:
'imageoptions'
,
toolbar
:
"undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr | removeformat code fullscreen"
,
content_style
:
"body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}"
,
...
...
tests/Entity/SortTest.php
0 → 100644
View file @
448ac61
<?php
class
SortTest
extends
TestCase
{
protected
$book
;
public
function
setUp
()
{
parent
::
setUp
();
$this
->
book
=
\BookStack\Book
::
first
();
}
public
function
test_drafts_do_not_show_up
()
{
$this
->
asAdmin
();
$pageRepo
=
app
(
'\BookStack\Repos\PageRepo'
);
$draft
=
$pageRepo
->
getDraftPage
(
$this
->
book
);
$this
->
visit
(
$this
->
book
->
getUrl
())
->
see
(
$draft
->
name
)
->
visit
(
$this
->
book
->
getUrl
()
.
'/sort'
)
->
dontSee
(
$draft
->
name
);
}
}
\ No newline at end of file
Please
register
or
sign in
to post a comment