mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-12 16:08:08 +00:00
Improves sortable ux
- Fixes multi-select functionality. - Updated other books to be sticky. - Added some general intro/desc text. - Updated sort boxes to be collapsible. - Cleaned up other books styling.
This commit is contained in:
parent
03ad288aaa
commit
a3e7e754b9
7 changed files with 51 additions and 15 deletions
resources
js/components
lang/en
sass
views/books
|
@ -1,4 +1,4 @@
|
|||
import Sortable from "sortablejs";
|
||||
import Sortable, {MultiDrag} from "sortablejs";
|
||||
import {Component} from "./component";
|
||||
import {htmlToDom} from "../services/dom";
|
||||
|
||||
|
@ -44,6 +44,8 @@ export class BookSort extends Component {
|
|||
this.sortContainer = this.$refs.sortContainer;
|
||||
this.input = this.$refs.input;
|
||||
|
||||
Sortable.mount(new MultiDrag());
|
||||
|
||||
const initialSortBox = this.container.querySelector('.sort-box');
|
||||
this.setupBookSortable(initialSortBox);
|
||||
this.setupSortPresets();
|
||||
|
@ -104,7 +106,7 @@ export class BookSort extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* Setup the given book container element to have sortable items.
|
||||
* Set up the given book container element to have sortable items.
|
||||
* @param {Element} bookContainer
|
||||
*/
|
||||
setupBookSortable(bookContainer) {
|
||||
|
@ -125,8 +127,8 @@ export class BookSort extends Component {
|
|||
}
|
||||
};
|
||||
|
||||
for (let sortElem of sortElems) {
|
||||
new Sortable(sortElem, {
|
||||
for (const sortElem of sortElems) {
|
||||
Sortable.create(sortElem, {
|
||||
group: sortElem.classList.contains('sort-list') ? bookGroupConfig : chapterGroupConfig,
|
||||
animation: 150,
|
||||
fallbackOnBody: true,
|
||||
|
@ -135,7 +137,7 @@ export class BookSort extends Component {
|
|||
dragClass: 'bg-white',
|
||||
ghostClass: 'primary-background-light',
|
||||
multiDrag: true,
|
||||
multiDragKey: 'CTRL',
|
||||
multiDragKey: 'Control',
|
||||
selectedClass: 'sortable-selected',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ return [
|
|||
'books_search_this' => 'Search this book',
|
||||
'books_navigation' => 'Book Navigation',
|
||||
'books_sort' => 'Sort Book Contents',
|
||||
'books_sort_desc' => 'Move chapters and pages within a book to reorganise its contents. Other books can be added which allows easy moving of chapters and pages between books.',
|
||||
'books_sort_named' => 'Sort Book :bookName',
|
||||
'books_sort_name' => 'Sort by Name',
|
||||
'books_sort_created' => 'Sort by Created Date',
|
||||
|
@ -148,6 +149,7 @@ return [
|
|||
'books_sort_chapters_first' => 'Chapters First',
|
||||
'books_sort_chapters_last' => 'Chapters Last',
|
||||
'books_sort_show_other' => 'Show Other Books',
|
||||
'books_sort_show_other_desc' => 'Add other books here to include them in the sort operation, and allow easy cross-book reorganisation.',
|
||||
'books_sort_save' => 'Save New Order',
|
||||
'books_copy' => 'Copy Book',
|
||||
'books_copy_success' => 'Book successfully copied',
|
||||
|
|
|
@ -268,6 +268,11 @@ body.flexbox {
|
|||
}
|
||||
}
|
||||
|
||||
.sticky-top-m {
|
||||
position: sticky;
|
||||
top: $-m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visibility
|
||||
*/
|
||||
|
|
|
@ -302,6 +302,20 @@
|
|||
.sortable-page-list li.placeholder:before {
|
||||
position: absolute;
|
||||
}
|
||||
.sort-box summary {
|
||||
list-style: none;
|
||||
font-size: .9rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.sort-box summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
details.sort-box summary .caret-container svg {
|
||||
transition: transform ease-in-out 120ms;
|
||||
}
|
||||
details.sort-box[open] summary .caret-container svg {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.activity-list-item {
|
||||
padding: $-s 0;
|
||||
|
|
|
@ -199,6 +199,9 @@ $loadingSize: 10px;
|
|||
.entity-item-snippet {
|
||||
display: none;
|
||||
}
|
||||
h4 {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<div class="sort-box" data-type="book" data-id="{{ $book->id }}">
|
||||
<h5 class="text-book entity-list-item no-hover py-xs pl-none">
|
||||
<span>@icon('book')</span>
|
||||
<span>{{ $book->name }}</span>
|
||||
</h5>
|
||||
<details class="sort-box" data-type="book" data-id="{{ $book->id }}" open>
|
||||
<summary>
|
||||
<h5 class="flex-container-row items-center justify-flex-start gap-xs">
|
||||
<div class="text-book text-bigger caret-container">
|
||||
@icon('caret-right')
|
||||
</div>
|
||||
<div class="entity-list-item no-hover py-s text-book px-none">
|
||||
<span>@icon('book')</span>
|
||||
<span>{{ $book->name }}</span>
|
||||
</div>
|
||||
</h5>
|
||||
</summary>
|
||||
<div class="sort-box-options pb-sm">
|
||||
<button type="button" data-sort="name" class="button outline small">{{ trans('entities.books_sort_name') }}</button>
|
||||
<button type="button" data-sort="created" class="button outline small">{{ trans('entities.books_sort_created') }}</button>
|
||||
|
@ -45,4 +52,4 @@
|
|||
@endforeach
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
<div class="grid left-focus gap-xl">
|
||||
<div>
|
||||
<div component="book-sort" class="card content-wrap">
|
||||
<h1 class="list-heading mb-l">{{ trans('entities.books_sort') }}</h1>
|
||||
<div component="book-sort" class="card content-wrap auto-height">
|
||||
<h1 class="list-heading">{{ trans('entities.books_sort') }}</h1>
|
||||
<p class="text-muted">{{ trans('entities.books_sort_desc') }}</p>
|
||||
|
||||
<div refs="book-sort@sortContainer">
|
||||
@include('books.parts.sort-box', ['book' => $book, 'bookChildren' => $bookChildren])
|
||||
</div>
|
||||
|
@ -35,8 +37,9 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<main class="card content-wrap">
|
||||
<h2 class="list-heading mb-m">{{ trans('entities.books_sort_show_other') }}</h2>
|
||||
<main class="card content-wrap auto-height sticky-top-m">
|
||||
<h2 class="list-heading">{{ trans('entities.books_sort_show_other') }}</h2>
|
||||
<p class="text-muted">{{ trans('entities.books_sort_show_other_desc') }}</p>
|
||||
|
||||
@include('entities.selector', ['name' => 'books_list', 'selectorSize' => 'compact', 'entityTypes' => 'book', 'entityPermission' => 'update', 'showAdd' => true])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue