Refactored common list handling operations to new class

This commit is contained in:
Dan Brown 2022-10-30 15:16:06 +00:00
parent f75091a1c5
commit ec4cbbd004
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
17 changed files with 212 additions and 143 deletions

View File

@ -3,6 +3,7 @@
namespace BookStack\Actions\Queries; namespace BookStack\Actions\Queries;
use BookStack\Actions\Webhook; use BookStack\Actions\Webhook;
use BookStack\Util\SimpleListOptions;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
/** /**
@ -10,19 +11,14 @@ use Illuminate\Pagination\LengthAwarePaginator;
*/ */
class WebhooksAllPaginatedAndSorted class WebhooksAllPaginatedAndSorted
{ {
/** public function run(int $count, SimpleListOptions $listOptions): LengthAwarePaginator
* @param array{sort: string, order: string, search: string} $sortData
*/
public function run(int $count, array $sortData): LengthAwarePaginator
{ {
$sort = $sortData['sort'];
$query = Webhook::query()->select(['*']) $query = Webhook::query()->select(['*'])
->withCount(['trackedEvents']) ->withCount(['trackedEvents'])
->orderBy($sort, $sortData['order']); ->orderBy($listOptions->getSort(), $listOptions->getOrder());
if ($sortData['search']) { if ($listOptions->getSearch()) {
$term = '%' . $sortData['search'] . '%'; $term = '%' . $listOptions->getSearch() . '%';
$query->where(function ($query) use ($term) { $query->where(function ($query) use ($term) {
$query->where('name', 'like', $term) $query->where('name', 'like', $term)
->orWhere('endpoint', 'like', $term); ->orWhere('endpoint', 'like', $term);

View File

@ -3,6 +3,7 @@
namespace BookStack\Auth\Queries; namespace BookStack\Auth\Queries;
use BookStack\Auth\Role; use BookStack\Auth\Role;
use BookStack\Util\SimpleListOptions;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
/** /**
@ -10,22 +11,19 @@ use Illuminate\Pagination\LengthAwarePaginator;
*/ */
class RolesAllPaginatedAndSorted class RolesAllPaginatedAndSorted
{ {
/** public function run(int $count, SimpleListOptions $listOptions): LengthAwarePaginator
* @param array{sort: string, order: string, search: string} $sortData
*/
public function run(int $count, array $sortData): LengthAwarePaginator
{ {
$sort = $sortData['sort']; $sort = $listOptions->getSort();
if ($sort === 'created_at') { if ($sort === 'created_at') {
$sort = 'users.created_at'; $sort = 'users.created_at';
} }
$query = Role::query()->select(['*']) $query = Role::query()->select(['*'])
->withCount(['users', 'permissions']) ->withCount(['users', 'permissions'])
->orderBy($sort, $sortData['order']); ->orderBy($sort, $listOptions->getOrder());
if ($sortData['search']) { if ($listOptions->getSearch()) {
$term = '%' . $sortData['search'] . '%'; $term = '%' . $listOptions->getSearch() . '%';
$query->where(function ($query) use ($term) { $query->where(function ($query) use ($term) {
$query->where('display_name', 'like', $term) $query->where('display_name', 'like', $term)
->orWhere('description', 'like', $term); ->orWhere('description', 'like', $term);

View File

@ -3,6 +3,7 @@
namespace BookStack\Auth\Queries; namespace BookStack\Auth\Queries;
use BookStack\Auth\User; use BookStack\Auth\User;
use BookStack\Util\SimpleListOptions;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
/** /**
@ -13,12 +14,9 @@ use Illuminate\Pagination\LengthAwarePaginator;
*/ */
class UsersAllPaginatedAndSorted class UsersAllPaginatedAndSorted
{ {
/** public function run(int $count, SimpleListOptions $listOptions): LengthAwarePaginator
* @param array{sort: string, order: string, search: string} $sortData
*/
public function run(int $count, array $sortData): LengthAwarePaginator
{ {
$sort = $sortData['sort']; $sort = $listOptions->getSort();
if ($sort === 'created_at') { if ($sort === 'created_at') {
$sort = 'users.created_at'; $sort = 'users.created_at';
} }
@ -27,10 +25,10 @@ class UsersAllPaginatedAndSorted
->scopes(['withLastActivityAt']) ->scopes(['withLastActivityAt'])
->with(['roles', 'avatar']) ->with(['roles', 'avatar'])
->withCount('mfaValues') ->withCount('mfaValues')
->orderBy($sort, $sortData['order']); ->orderBy($sort, $listOptions->getOrder());
if ($sortData['search']) { if ($listOptions->getSearch()) {
$term = '%' . $sortData['search'] . '%'; $term = '%' . $listOptions->getSearch() . '%';
$query->where(function ($query) use ($term) { $query->where(function ($query) use ($term) {
$query->where('name', 'like', $term) $query->where('name', 'like', $term)
->orWhere('email', 'like', $term); ->orWhere('email', 'like', $term);

View File

@ -15,6 +15,7 @@ use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException; use BookStack\Exceptions\NotFoundException;
use BookStack\Facades\Activity; use BookStack\Facades\Activity;
use BookStack\References\ReferenceFetcher; use BookStack\References\ReferenceFetcher;
use BookStack\Util\SimpleListOptions;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Throwable; use Throwable;
@ -35,13 +36,16 @@ class BookController extends Controller
/** /**
* Display a listing of the book. * Display a listing of the book.
*/ */
public function index() public function index(Request $request)
{ {
$view = setting()->getForCurrentUser('books_view_type'); $view = setting()->getForCurrentUser('books_view_type');
$sort = setting()->getForCurrentUser('books_sort', 'name'); $listOptions = SimpleListOptions::fromRequest($request, 'books')->withSortOptions([
$order = setting()->getForCurrentUser('books_sort_order', 'asc'); 'name' => trans('common.sort_name'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
]);
$books = $this->bookRepo->getAllPaginated(18, $sort, $order); $books = $this->bookRepo->getAllPaginated(18, $listOptions->getSort(), $listOptions->getOrder());
$recents = $this->isSignedIn() ? $this->bookRepo->getRecentlyViewed(4) : false; $recents = $this->isSignedIn() ? $this->bookRepo->getRecentlyViewed(4) : false;
$popular = $this->bookRepo->getPopular(4); $popular = $this->bookRepo->getPopular(4);
$new = $this->bookRepo->getRecentlyCreated(4); $new = $this->bookRepo->getRecentlyCreated(4);
@ -56,8 +60,7 @@ class BookController extends Controller
'popular' => $popular, 'popular' => $popular,
'new' => $new, 'new' => $new,
'view' => $view, 'view' => $view,
'sort' => $sort, 'listOptions' => $listOptions,
'order' => $order,
]); ]);
} }

View File

@ -10,6 +10,7 @@ use BookStack\Entities\Tools\ShelfContext;
use BookStack\Exceptions\ImageUploadException; use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException; use BookStack\Exceptions\NotFoundException;
use BookStack\References\ReferenceFetcher; use BookStack\References\ReferenceFetcher;
use BookStack\Util\SimpleListOptions;
use Exception; use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
@ -30,18 +31,16 @@ class BookshelfController extends Controller
/** /**
* Display a listing of the book. * Display a listing of the book.
*/ */
public function index() public function index(Request $request)
{ {
$view = setting()->getForCurrentUser('bookshelves_view_type'); $view = setting()->getForCurrentUser('bookshelves_view_type');
$sort = setting()->getForCurrentUser('bookshelves_sort', 'name'); $listOptions = SimpleListOptions::fromRequest($request, 'bookshelves')->withSortOptions([
$order = setting()->getForCurrentUser('bookshelves_sort_order', 'asc');
$sortOptions = [
'name' => trans('common.sort_name'), 'name' => trans('common.sort_name'),
'created_at' => trans('common.sort_created_at'), 'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'), 'updated_at' => trans('common.sort_updated_at'),
]; ]);
$shelves = $this->shelfRepo->getAllPaginated(18, $sort, $order); $shelves = $this->shelfRepo->getAllPaginated(18, $listOptions->getSort(), $listOptions->getOrder());
$recents = $this->isSignedIn() ? $this->shelfRepo->getRecentlyViewed(4) : false; $recents = $this->isSignedIn() ? $this->shelfRepo->getRecentlyViewed(4) : false;
$popular = $this->shelfRepo->getPopular(4); $popular = $this->shelfRepo->getPopular(4);
$new = $this->shelfRepo->getRecentlyCreated(4); $new = $this->shelfRepo->getRecentlyCreated(4);
@ -55,9 +54,7 @@ class BookshelfController extends Controller
'popular' => $popular, 'popular' => $popular,
'new' => $new, 'new' => $new,
'view' => $view, 'view' => $view,
'sort' => $sort, 'listOptions' => $listOptions,
'order' => $order,
'sortOptions' => $sortOptions,
]); ]);
} }
@ -100,16 +97,21 @@ class BookshelfController extends Controller
* *
* @throws NotFoundException * @throws NotFoundException
*/ */
public function show(ActivityQueries $activities, string $slug) public function show(Request $request, ActivityQueries $activities, string $slug)
{ {
$shelf = $this->shelfRepo->getBySlug($slug); $shelf = $this->shelfRepo->getBySlug($slug);
$this->checkOwnablePermission('bookshelf-view', $shelf); $this->checkOwnablePermission('bookshelf-view', $shelf);
$sort = setting()->getForCurrentUser('shelf_books_sort', 'default'); $listOptions = SimpleListOptions::fromRequest($request, 'shelf_books')->withSortOptions([
$order = setting()->getForCurrentUser('shelf_books_sort_order', 'asc'); 'default' => trans('common.sort_default'),
'name' => trans('common.sort_name'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
]);
$sort = $listOptions->getSort();
$sortedVisibleShelfBooks = $shelf->visibleBooks()->get() $sortedVisibleShelfBooks = $shelf->visibleBooks()->get()
->sortBy($sort === 'default' ? 'pivot.order' : $sort, SORT_REGULAR, $order === 'desc') ->sortBy($sort === 'default' ? 'pivot.order' : $sort, SORT_REGULAR, $listOptions->getOrder() === 'desc')
->values() ->values()
->all(); ->all();
@ -124,8 +126,7 @@ class BookshelfController extends Controller
'sortedVisibleShelfBooks' => $sortedVisibleShelfBooks, 'sortedVisibleShelfBooks' => $sortedVisibleShelfBooks,
'view' => $view, 'view' => $view,
'activity' => $activities->entityActivity($shelf, 20, 1), 'activity' => $activities->entityActivity($shelf, 20, 1),
'order' => $order, 'listOptions' => $listOptions,
'sort' => $sort,
'referenceCount' => $this->referenceFetcher->getPageReferenceCountToEntity($shelf), 'referenceCount' => $this->referenceFetcher->getPageReferenceCountToEntity($shelf),
]); ]);
} }

View File

@ -6,6 +6,7 @@ use BookStack\Auth\Permissions\PermissionsRepo;
use BookStack\Auth\Queries\RolesAllPaginatedAndSorted; use BookStack\Auth\Queries\RolesAllPaginatedAndSorted;
use BookStack\Auth\Role; use BookStack\Auth\Role;
use BookStack\Exceptions\PermissionsException; use BookStack\Exceptions\PermissionsException;
use BookStack\Util\SimpleListOptions;
use Exception; use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
@ -26,20 +27,22 @@ class RoleController extends Controller
{ {
$this->checkPermission('user-roles-manage'); $this->checkPermission('user-roles-manage');
$listDetails = [ $listOptions = SimpleListOptions::fromRequest($request, 'roles')->withSortOptions([
'search' => $request->get('search', ''), 'display_name' => trans('common.sort_name'),
'sort' => setting()->getForCurrentUser('roles_sort', 'display_name'), 'users_count' => trans('settings.roles_assigned_users'),
'order' => setting()->getForCurrentUser('roles_sort_order', 'asc'), 'permissions_count' => trans('settings.roles_permissions_provided'),
]; 'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
]);
$roles = (new RolesAllPaginatedAndSorted())->run(20, $listDetails); $roles = (new RolesAllPaginatedAndSorted())->run(20, $listOptions);
$roles->appends(['search' => $listDetails['search']]); $roles->appends($listOptions->getPaginationAppends());
$this->setPageTitle(trans('settings.roles')); $this->setPageTitle(trans('settings.roles'));
return view('settings.roles.index', [ return view('settings.roles.index', [
'roles' => $roles, 'roles' => $roles,
'listDetails' => $listDetails, 'listOptions' => $listOptions,
]); ]);
} }

View File

@ -10,6 +10,7 @@ use BookStack\Auth\UserRepo;
use BookStack\Exceptions\ImageUploadException; use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\UserUpdateException; use BookStack\Exceptions\UserUpdateException;
use BookStack\Uploads\ImageRepo; use BookStack\Uploads\ImageRepo;
use BookStack\Util\SimpleListOptions;
use Exception; use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -36,20 +37,23 @@ class UserController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
$this->checkPermission('users-manage'); $this->checkPermission('users-manage');
$listDetails = [
'search' => $request->get('search', ''),
'sort' => setting()->getForCurrentUser('users_sort', 'name'),
'order' => setting()->getForCurrentUser('users_sort_order', 'asc'),
];
$users = (new UsersAllPaginatedAndSorted())->run(20, $listDetails); $listOptions = SimpleListOptions::fromRequest($request, 'users')->withSortOptions([
'name' => trans('common.sort_name'),
'email' => trans('auth.email'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
'last_activity_at' => trans('settings.users_latest_activity'),
]);
$users = (new UsersAllPaginatedAndSorted())->run(20, $listOptions);
$this->setPageTitle(trans('settings.users')); $this->setPageTitle(trans('settings.users'));
$users->appends(['search' => $listDetails['search']]); $users->appends($listOptions->getPaginationAppends());
return view('users.index', [ return view('users.index', [
'users' => $users, 'users' => $users,
'listDetails' => $listDetails, 'listOptions' => $listOptions,
]); ]);
} }
@ -256,7 +260,18 @@ class UserController extends Controller
return redirect()->back(500); return redirect()->back(500);
} }
return $this->changeListSort($id, $request, $type); $this->checkPermissionOrCurrentUser('users-manage', $id);
$sort = substr($request->get('sort') ?: 'name', 0, 50);
$order = $request->get('order') === 'desc' ? 'desc' : 'asc';
$user = $this->userRepo->getById($id);
$sortKey = $type . '_sort';
$orderKey = $type . '_sort_order';
setting()->putUser($user, $sortKey, $sort);
setting()->putUser($user, $orderKey, $order);
return redirect()->back(302, [], "/settings/users/{$id}");
} }
/** /**
@ -309,36 +324,4 @@ class UserController extends Controller
setting()->putUser(user(), 'code-language-favourites', implode(',', $currentFavorites)); setting()->putUser(user(), 'code-language-favourites', implode(',', $currentFavorites));
} }
/**
* Changed the stored preference for a list sort order.
*/
protected function changeListSort(int $userId, Request $request, string $listName)
{
$this->checkPermissionOrCurrentUser('users-manage', $userId);
$sort = $request->get('sort');
// TODO - Need to find a better way to validate sort options
// Probably better to do a simple validation here then validate at usage.
$validSorts = [
'name', 'created_at', 'updated_at', 'default', 'email', 'last_activity_at', 'display_name',
'users_count', 'permissions_count', 'endpoint', 'active',
];
if (!in_array($sort, $validSorts)) {
$sort = 'name';
}
$order = $request->get('order');
if (!in_array($order, ['asc', 'desc'])) {
$order = 'asc';
}
$user = $this->userRepo->getById($userId);
$sortKey = $listName . '_sort';
$orderKey = $listName . '_sort_order';
setting()->putUser($user, $sortKey, $sort);
setting()->putUser($user, $orderKey, $order);
return redirect()->back(302, [], "/settings/users/$userId");
}
} }

View File

@ -5,6 +5,7 @@ namespace BookStack\Http\Controllers;
use BookStack\Actions\ActivityType; use BookStack\Actions\ActivityType;
use BookStack\Actions\Queries\WebhooksAllPaginatedAndSorted; use BookStack\Actions\Queries\WebhooksAllPaginatedAndSorted;
use BookStack\Actions\Webhook; use BookStack\Actions\Webhook;
use BookStack\Util\SimpleListOptions;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class WebhookController extends Controller class WebhookController extends Controller
@ -21,20 +22,22 @@ class WebhookController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$listDetails = [ $listOptions = SimpleListOptions::fromRequest($request, 'webhooks')->withSortOptions([
'search' => $request->get('search', ''), 'name' => trans('common.sort_name'),
'sort' => setting()->getForCurrentUser('webhooks_sort', 'name'), 'endpoint' => trans('settings.webhooks_endpoint'),
'order' => setting()->getForCurrentUser('webhooks_sort_order', 'asc'), 'created_at' => trans('common.sort_created_at'),
]; 'updated_at' => trans('common.sort_updated_at'),
'active' => trans('common.status'),
]);
$webhooks = (new WebhooksAllPaginatedAndSorted())->run(20, $listDetails); $webhooks = (new WebhooksAllPaginatedAndSorted())->run(20, $listOptions);
$webhooks->appends(['search' => $listDetails['search']]); $webhooks->appends($listOptions->getPaginationAppends());
$this->setPageTitle(trans('settings.webhooks')); $this->setPageTitle(trans('settings.webhooks'));
return view('settings.webhooks.index', [ return view('settings.webhooks.index', [
'webhooks' => $webhooks, 'webhooks' => $webhooks,
'listDetails' => $listDetails, 'listOptions' => $listOptions,
]); ]);
} }

View File

@ -0,0 +1,104 @@
<?php
namespace BookStack\Util;
use Illuminate\Http\Request;
/**
* Handled options commonly used for item lists within the system, providing a standard
* model for handling and validating sort, order and search options.
*/
class SimpleListOptions
{
protected string $typeKey;
protected string $sort;
protected string $order;
protected string $search;
protected array $sortOptions = [];
public function __construct(string $typeKey, string $sort, string $order, string $search = '')
{
$this->typeKey = $typeKey;
$this->sort = $sort;
$this->order = $order;
$this->search = $search;
}
/**
* Create a new instance from the given request.
* Takes the item type (plural) that's used as a key for storing sort preferences.
*/
public static function fromRequest(Request $request, string $typeKey): self
{
$search = $request->get('search', '');
$sort = setting()->getForCurrentUser($typeKey . '_sort', '');
$order = setting()->getForCurrentUser($typeKey . '_sort_order', 'asc');
return new static($typeKey, $sort, $order, $search);
}
/**
* Configure the valid sort options for this set of list options.
* Provided sort options must be an array, keyed by search properties
* with values being user-visible option labels.
* Returns current options for easy fluent usage during creation.
*/
public function withSortOptions(array $sortOptions): self
{
$this->sortOptions = array_merge($this->sortOptions, $sortOptions);
return $this;
}
/**
* Get the current order option.
*/
public function getOrder(): string
{
return strtolower($this->order) === 'desc' ? 'desc' : 'asc';
}
/**
* Get the current sort option.
*/
public function getSort(): string
{
$default = array_key_first($this->sortOptions) ?? 'name';
$sort = $this->sort ?: $default;
if (empty($this->sortOptions) || array_key_exists($sort, $this->sortOptions)) {
return $sort;
}
return $default;
}
/**
* Get the set search term.
*/
public function getSearch(): string
{
return $this->search;
}
/**
* Get the data to append for pagination.
*/
public function getPaginationAppends(): array
{
return ['search' => $this->search];
}
/**
* Get the data required by the sort control view.
*/
public function getSortControlData(): array
{
return [
'options' => $this->sortOptions,
'order' => $this->getOrder(),
'sort' => $this->getSort(),
'type' => $this->typeKey,
];
}
}

View File

@ -1,7 +1,7 @@
@extends('layouts.tri') @extends('layouts.tri')
@section('body') @section('body')
@include('books.parts.list', ['books' => $books, 'view' => $view]) @include('books.parts.list', ['books' => $books, 'view' => $view, 'listOptions' => $listOptions])
@stop @stop
@section('left') @section('left')

View File

@ -2,13 +2,7 @@
<div class="grid half v-center no-row-gap"> <div class="grid half v-center no-row-gap">
<h1 class="list-heading">{{ trans('entities.books') }}</h1> <h1 class="list-heading">{{ trans('entities.books') }}</h1>
<div class="text-m-right my-m"> <div class="text-m-right my-m">
@include('common.sort', $listOptions->getSortControlData())
@include('common.sort', ['options' => [
'name' => trans('common.sort_name'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
], 'order' => $order, 'sort' => $sort, 'type' => 'books'])
</div> </div>
</div> </div>
@if(count($books) > 0) @if(count($books) > 0)

View File

@ -22,18 +22,15 @@
<div> <div>
<div class="block inline mr-xs"> <div class="block inline mr-xs">
<form method="get" action="{{ url("/settings/roles") }}"> <form method="get" action="{{ url("/settings/roles") }}">
<input type="text" name="search" placeholder="{{ trans('common.search') }}" @if($listDetails['search']) value="{{$listDetails['search']}}" @endif> <input type="text"
name="search"
placeholder="{{ trans('common.search') }}"
value="{{ $listOptions->getSearch() }}">
</form> </form>
</div> </div>
</div> </div>
<div class="justify-flex-end"> <div class="justify-flex-end">
@include('common.sort', ['options' => [ @include('common.sort', $listOptions->getSortControlData())
'display_name' => trans('common.sort_name'),
'users_count' => trans('settings.roles_assigned_users'),
'permissions_count' => trans('settings.roles_permissions_provided'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
], 'order' => $listDetails['order'], 'sort' => $listDetails['sort'], 'type' => 'roles'])
</div> </div>
</div> </div>

View File

@ -23,18 +23,15 @@
<div> <div>
<div class="block inline mr-xs"> <div class="block inline mr-xs">
<form method="get" action="{{ url("/settings/webhooks") }}"> <form method="get" action="{{ url("/settings/webhooks") }}">
<input type="text" name="search" placeholder="{{ trans('common.search') }}" @if($listDetails['search']) value="{{$listDetails['search']}}" @endif> <input type="text"
name="search"
placeholder="{{ trans('common.search') }}"
value="{{ $listOptions->getSearch() }}">
</form> </form>
</div> </div>
</div> </div>
<div class="justify-flex-end"> <div class="justify-flex-end">
@include('common.sort', ['options' => [ @include('common.sort', $listOptions->getSortControlData())
'name' => trans('common.sort_name'),
'endpoint' => trans('settings.webhooks_endpoint'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
'active' => trans('common.status'),
], 'order' => $listDetails['order'], 'sort' => $listDetails['sort'], 'type' => 'webhooks'])
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
@extends('layouts.tri') @extends('layouts.tri')
@section('body') @section('body')
@include('shelves.parts.list', ['shelves' => $shelves, 'view' => $view]) @include('shelves.parts.list', ['shelves' => $shelves, 'view' => $view, 'listOptions' => $listOptions])
@stop @stop
@section('right') @section('right')

View File

@ -3,7 +3,7 @@
<div class="grid half v-center"> <div class="grid half v-center">
<h1 class="list-heading">{{ trans('entities.shelves') }}</h1> <h1 class="list-heading">{{ trans('entities.shelves') }}</h1>
<div class="text-right"> <div class="text-right">
@include('common.sort', ['options' => $sortOptions, 'order' => $order, 'sort' => $sort, 'type' => 'bookshelves']) @include('common.sort', $listOptions->getSortControlData())
</div> </div>
</div> </div>

View File

@ -23,12 +23,7 @@
<h1 class="flex fit-content break-text">{{ $shelf->name }}</h1> <h1 class="flex fit-content break-text">{{ $shelf->name }}</h1>
<div class="flex"></div> <div class="flex"></div>
<div class="flex fit-content text-m-right my-m ml-m"> <div class="flex fit-content text-m-right my-m ml-m">
@include('common.sort', ['options' => [ @include('common.sort', $listOptions->getSortControlData())
'default' => trans('common.sort_default'),
'name' => trans('common.sort_name'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
], 'order' => $order, 'sort' => $sort, 'type' => 'shelf_books'])
</div> </div>
</div> </div>

View File

@ -20,18 +20,15 @@
<div> <div>
<div class="block inline mr-xs"> <div class="block inline mr-xs">
<form method="get" action="{{ url("/settings/users") }}"> <form method="get" action="{{ url("/settings/users") }}">
<input type="text" name="search" placeholder="{{ trans('settings.users_search') }}" @if($listDetails['search']) value="{{$listDetails['search']}}" @endif> <input type="text"
name="search"
placeholder="{{ trans('settings.users_search') }}"
value="{{ $listOptions->getSearch() }}">
</form> </form>
</div> </div>
</div> </div>
<div class="justify-flex-end"> <div class="justify-flex-end">
@include('common.sort', ['options' => [ @include('common.sort', $listOptions->getSortControlData())
'name' => trans('common.sort_name'),
'email' => trans('auth.email'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
'last_activity_at' => trans('settings.users_latest_activity'),
], 'order' => $listDetails['order'], 'sort' => $listDetails['sort'], 'type' => 'users'])
</div> </div>
</div> </div>