mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-02 02:26:57 +03:00
Sorting: Started sort set routes and form
This commit is contained in:
19
app/Sorting/SortSetController.php
Normal file
19
app/Sorting/SortSetController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace BookStack\Sorting;
|
||||
|
||||
use BookStack\Http\Controller;
|
||||
|
||||
class SortSetController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('can:settings-manage');
|
||||
// TODO - Test
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('settings.sort-sets.create');
|
||||
}
|
||||
}
|
@ -13,4 +13,32 @@ enum SortSetOption: string
|
||||
case UpdateDateDesc = 'updated_date_desc';
|
||||
case ChaptersFirst = 'chapters_first';
|
||||
case ChaptersLast = 'chapters_last';
|
||||
|
||||
/**
|
||||
* Provide a translated label string for this option.
|
||||
*/
|
||||
public function getLabel(): string
|
||||
{
|
||||
$key = $this->value;
|
||||
$label = '';
|
||||
if (str_ends_with($key, '_asc')) {
|
||||
$key = substr($key, 0, -4);
|
||||
$label = trans('settings.sort_set_op_asc');
|
||||
} elseif (str_ends_with($key, '_desc')) {
|
||||
$key = substr($key, 0, -5);
|
||||
$label = trans('settings.sort_set_op_desc');
|
||||
}
|
||||
|
||||
$label = trans('settings.sort_set_op_' . $key) . ' ' . $label;
|
||||
return trim($label);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SortSetOption[]
|
||||
*/
|
||||
public static function allExcluding(array $options): array
|
||||
{
|
||||
$all = SortSetOption::cases();
|
||||
return array_diff($all, $options);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user