1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Aligned user preference endpoints in style and behaviour

Changes their endpoints and remove the user id from the URLs.
Simplifies list changes to share a single endpoint, which aligns it to
the behaviour of the existing sort preference endpoint.
Also added test to ensure user preferences are deleted on user delete.
This commit is contained in:
Dan Brown
2022-11-09 19:30:08 +00:00
parent 24a7e8500d
commit a3fcc98d6e
16 changed files with 89 additions and 88 deletions

View File

@@ -73,7 +73,7 @@ class CodeEditor {
isFavorite ? this.favourites.add(language) : this.favourites.delete(language);
button.setAttribute('data-favourite', isFavorite ? 'true' : 'false');
window.$http.patch('/settings/users/update-code-language-favourite', {
window.$http.patch('/preferences/update-code-language-favourite', {
language: language,
active: isFavorite
});

View File

@@ -70,7 +70,6 @@ class Shortcuts {
*/
runShortcut(id) {
const el = this.container.querySelector(`[data-shortcut="${id}"]`);
console.info('Shortcut run', el);
if (!el) {
return false;
}

View File

@@ -1,4 +1,4 @@
<form action="{{ url('/settings/users/toggle-dark-mode') }}" method="post">
<form action="{{ url('/preferences/toggle-dark-mode') }}" method="post">
{{ csrf_field() }}
{{ method_field('patch') }}
@if(setting()->getForCurrentUser('dark-mode-enabled'))

View File

@@ -9,7 +9,7 @@
action="{{ url()->current() }}"
method="get"
@else
action="{{ url("/settings/users/". user()->id ."/change-sort/{$type}") }}"
action="{{ url("/preferences/change-sort/{$type}") }}"
method="post"
@endif
>

View File

@@ -1,15 +1,15 @@
<div>
<form action="{{ url("/settings/users/". user()->id ."/switch-${type}-view") }}" method="POST" class="inline">
<form action="{{ url("/preferences/change-view/" . $type) }}" method="POST" class="inline">
{!! csrf_field() !!}
{!! method_field('PATCH') !!}
<input type="hidden" value="{{ $view === 'list'? 'grid' : 'list' }}" name="view_type">
@if ($view === 'list')
<button type="submit" class="icon-list-item text-primary">
<button type="submit" name="view" value="grid" class="icon-list-item text-primary">
<span class="icon">@icon('grid')</span>
<span>{{ trans('common.grid_view') }}</span>
</button>
@else
<button type="submit" class="icon-list-item text-primary">
<button type="submit" name="view" value="list" class="icon-list-item text-primary">
<span>@icon('list')</span>
<span>{{ trans('common.list_view') }}</span>
</button>

View File

@@ -4,7 +4,7 @@ $key - Unique key for checking existing stored state.
--}}
<?php $isOpen = setting()->getForCurrentUser('section_expansion#'. $key); ?>
<button type="button" expand-toggle="{{ $target }}"
expand-toggle-update-endpoint="{{ url('/settings/users/'. user()->id .'/update-expansion-preference/' . $key) }}"
expand-toggle-update-endpoint="{{ url('/preferences/change-expansion/' . $key) }}"
expand-toggle-is-open="{{ $isOpen ? 'yes' : 'no' }}"
class="icon-list-item {{ $classes ?? '' }}">
<span>@icon('expand-text')</span>

View File

@@ -18,7 +18,7 @@
<span>{{ trans('entities.shelves_new_action') }}</span>
</a>
@endif
@include('entities.view-toggle', ['view' => $view, 'type' => 'shelves'])
@include('entities.view-toggle', ['view' => $view, 'type' => 'bookshelves'])
@include('home.parts.expand-toggle', ['classes' => 'text-primary', 'target' => '.entity-list.compact .entity-item-snippet', 'key' => 'home-details'])
@include('common.dark-mode-toggle', ['classes' => 'icon-list-item text-primary'])
</div>

View File

@@ -16,7 +16,7 @@
</a>
@endif
@include('entities.view-toggle', ['view' => $view, 'type' => 'shelves'])
@include('entities.view-toggle', ['view' => $view, 'type' => 'bookshelves'])
<a href="{{ url('/tags') }}" class="icon-list-item">
<span>@icon('tag')</span>

View File

@@ -118,7 +118,7 @@
</a>
@endif
@include('entities.view-toggle', ['view' => $view, 'type' => 'shelf'])
@include('entities.view-toggle', ['view' => $view, 'type' => 'bookshelf'])
<hr class="primary-background">