mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Breadcrumbs: Set book/shelf lists to use name ordering
Previously in database order (id) which is not predictable nor parsable for users. For #4876
This commit is contained in:
parent
5a5f0b8de9
commit
b7d4bd5bce
@ -43,13 +43,13 @@ class SiblingFetcher
|
|||||||
if ($contextShelf) {
|
if ($contextShelf) {
|
||||||
$entities = $contextShelf->visibleBooks()->get();
|
$entities = $contextShelf->visibleBooks()->get();
|
||||||
} else {
|
} else {
|
||||||
$entities = $this->queries->books->visibleForList()->get();
|
$entities = $this->queries->books->visibleForList()->orderBy('name', 'asc')->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shelf
|
// Shelf
|
||||||
if ($entity instanceof Bookshelf) {
|
if ($entity instanceof Bookshelf) {
|
||||||
$entities = $this->queries->shelves->visibleForList()->get();
|
$entities = $this->queries->shelves->visibleForList()->orderBy('name', 'asc')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entities;
|
return $entities;
|
||||||
|
@ -356,6 +356,42 @@ class EntitySearchTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_sibling_search_for_books_provides_results_in_alphabetical_order()
|
||||||
|
{
|
||||||
|
$contextBook = $this->entities->book();
|
||||||
|
$searchBook = $this->entities->book();
|
||||||
|
|
||||||
|
$searchBook->name = 'Zebras';
|
||||||
|
$searchBook->save();
|
||||||
|
|
||||||
|
$search = $this->actingAs($this->users->viewer())->get("/search/entity/siblings?entity_id={$contextBook->id}&entity_type=book");
|
||||||
|
$this->withHtml($search)->assertElementNotContains('a:first-child', 'Zebras');
|
||||||
|
|
||||||
|
$searchBook->name = 'AAAAAAArdvarks';
|
||||||
|
$searchBook->save();
|
||||||
|
|
||||||
|
$search = $this->actingAs($this->users->viewer())->get("/search/entity/siblings?entity_id={$contextBook->id}&entity_type=book");
|
||||||
|
$this->withHtml($search)->assertElementContains('a:first-child', 'AAAAAAArdvarks');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_sibling_search_for_shelves_provides_results_in_alphabetical_order()
|
||||||
|
{
|
||||||
|
$contextShelf = $this->entities->shelf();
|
||||||
|
$searchShelf = $this->entities->shelf();
|
||||||
|
|
||||||
|
$searchShelf->name = 'Zebras';
|
||||||
|
$searchShelf->save();
|
||||||
|
|
||||||
|
$search = $this->actingAs($this->users->viewer())->get("/search/entity/siblings?entity_id={$contextShelf->id}&entity_type=bookshelf");
|
||||||
|
$this->withHtml($search)->assertElementNotContains('a:first-child', 'Zebras');
|
||||||
|
|
||||||
|
$searchShelf->name = 'AAAAAAArdvarks';
|
||||||
|
$searchShelf->save();
|
||||||
|
|
||||||
|
$search = $this->actingAs($this->users->viewer())->get("/search/entity/siblings?entity_id={$contextShelf->id}&entity_type=bookshelf");
|
||||||
|
$this->withHtml($search)->assertElementContains('a:first-child', 'AAAAAAArdvarks');
|
||||||
|
}
|
||||||
|
|
||||||
public function test_search_works_on_updated_page_content()
|
public function test_search_works_on_updated_page_content()
|
||||||
{
|
{
|
||||||
$page = $this->entities->page();
|
$page = $this->entities->page();
|
||||||
|
Loading…
Reference in New Issue
Block a user