NOW MANAGED ON CODEBERG
Sorting: Added content misses from last commit, started settings
Dan Browna34023f71557
diff --git a/app/Sorting/SortSet.php b/app/Sorting/SortSet.phpnew file mode 100644index 000000000..42e1e0951--- /dev/null+++ b/app/Sorting/SortSet.php@@ -0,0 +1,35 @@+<?php++namespace BookStack\Sorting;++use Carbon\Carbon;+use Illuminate\Database\Eloquent\Model;++/**+ * @property int $id+ * @property string $name+ * @property string $sequence+ * @property Carbon $created_at+ * @property Carbon $updated_at+ */+class SortSet extends Model+{+ /**+ * @return SortSetOption[]+ */+ public function getOptions(): array+ {+ $strOptions = explode(',', $this->sequence);+ $options = array_map(fn ($val) => SortSetOption::tryFrom($val), $strOptions);+ return array_filter($options);+ }++ /**+ * @param SortSetOption[] $options+ */+ public function setOptions(array $options): void+ {+ $values = array_map(fn (SortSetOption $opt) => $opt->value, $options);+ $this->sequence = implode(',', $values);+ }+}diff --git a/database/migrations/2025_01_29_180933_create_sort_sets_table.php b/database/migrations/2025_01_29_180933_create_sort_sets_table.phpnew file mode 100644index 000000000..bf9780c5b--- /dev/null+++ b/database/migrations/2025_01_29_180933_create_sort_sets_table.php@@ -0,0 +1,29 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::create('sort_sets', function (Blueprint $table) {+ $table->increments('id');+ $table->string('name');+ $table->text('sequence');+ $table->timestamps();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::dropIfExists('sort_sets');+ }+};diff --git a/lang/en/settings.php b/lang/en/settings.phpindex c0b6b692a..b20152bfe 100644--- a/lang/en/settings.php+++ b/lang/en/settings.php@@ -74,6 +74,13 @@ return ['reg_confirm_restrict_domain_desc' => 'Enter a comma separated list of email domains you would like to restrict registration to. Users will be sent an email to confirm their address before being allowed to interact with the application. <br> Note that users will be able to change their email addresses after successful registration.','reg_confirm_restrict_domain_placeholder' => 'No restriction set',+ // Sorting Settings+ 'sorting' => 'Sorting',+ 'sorting_book_default' => 'Default Book Sort',+ 'sorting_book_default_desc' => 'Select the default sort set to apply to new books. This won\'t affect existing books, and can be overridden per-book.',+ 'sorting_sets' => 'Sort Sets',+ 'sorting_sets_desc' => 'These are predefined sorting operations which can be applied to content in the system.',+// Maintenance settings'maint' => 'Maintenance','maint_image_cleanup' => 'Cleanup Images',diff --git a/resources/views/settings/categories/sorting.blade.php b/resources/views/settings/categories/sorting.blade.phpnew file mode 100644index 000000000..153ea0e3b--- /dev/null+++ b/resources/views/settings/categories/sorting.blade.php@@ -0,0 +1,49 @@+@extends('settings.layout')++@section('card')+ <h1 id="sorting" class="list-heading">{{ trans('settings.sorting') }}</h1>+ <form action="{{ url("/settings/sorting") }}" method="POST">+ {{ csrf_field() }}+ <input type="hidden" name="section" value="sorting">++ <div class="setting-list">+ <div class="grid half gap-xl items-center">+ <div>+ <label for="setting-sorting-book-default"+ class="setting-list-label">{{ trans('settings.sorting_book_default') }}</label>+ <p class="small">{{ trans('settings.sorting_book_default_desc') }}</p>+ </div>+ <div>+ <select id="setting-sorting-book-default" name="setting-sorting-book-default"+ @if($errors->has('setting-sorting-book-default')) class="neg" @endif>+ <option value="0" @if(intval(setting('sorting-book-default', '0')) === 0) selected @endif>+ -- {{ trans('common.none') }} --+ </option>+{{-- TODO--}}+{{-- @foreach(\BookStack\Users\Models\Role::all() as $role)--}}+{{-- <option value="{{$role->id}}"--}}+{{-- data-system-role-name="{{ $role->system_name ?? '' }}"--}}+{{-- @if(intval(setting('registration-role', '0')) === $role->id) selected @endif--}}+{{-- >--}}+{{-- {{ $role->display_name }}--}}+{{-- </option>--}}+{{-- @endforeach--}}+ </select>+ </div>+ </div>++ </div>++ <div class="form-group text-right">+ <button type="submit" class="button">{{ trans('settings.settings_save') }}</button>+ </div>+ </form>+@endsection++@section('after-card')+ <div class="card content-wrap auto-height">+ <h2 class="list-heading">{{ trans('settings.sorting_sets') }}</h2>+ <p class="text-muted">{{ trans('settings.sorting_sets_desc') }}</p>+{{-- TODO--}}+ </div>+@endsection\ No newline at end of filediff --git a/resources/views/settings/layout.blade.php b/resources/views/settings/layout.blade.phpindex a59b58d53..930d407a5 100644--- a/resources/views/settings/layout.blade.php+++ b/resources/views/settings/layout.blade.php@@ -13,6 +13,7 @@<a href="{{ url('/settings/features') }}" class="{{ $category === 'features' ? 'active' : '' }}">@icon('star') {{ trans('settings.app_features_security') }}</a><a href="{{ url('/settings/customization') }}" class="{{ $category === 'customization' ? 'active' : '' }}">@icon('palette') {{ trans('settings.app_customization') }}</a><a href="{{ url('/settings/registration') }}" class="{{ $category === 'registration' ? 'active' : '' }}">@icon('security') {{ trans('settings.reg_settings') }}</a>+ <a href="{{ url('/settings/sorting') }}" class="{{ $category === 'sorting' ? 'active' : '' }}">@icon('sort') {{ trans('settings.sorting') }}</a></nav><h5 class="mt-xl">{{ trans('settings.system_version') }}</h5>@@ -29,6 +30,7 @@<div class="card content-wrap auto-height">@yield('card')</div>+ @yield('after-card')</div></div>