From 40e112fc5b4896c52d5aa09ea2ad2a9da6eccfa1 Mon Sep 17 00:00:00 2001
From: Dan Brown <ssddanbrown@googlemail.com>
Date: Fri, 27 Jan 2023 13:26:58 +0000
Subject: [PATCH] Extracted text & added dropdown for book sort move actions

Primarily styling and testing left to do.
---
 resources/lang/en/entities.php                | 11 ++++++-
 resources/sass/_lists.scss                    |  4 +--
 .../books/parts/sort-box-actions.blade.php    | 31 +++++++++++++------
 .../views/books/parts/sort-box.blade.php      |  2 +-
 4 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/resources/lang/en/entities.php b/resources/lang/en/entities.php
index 5b019e848..834cfacba 100644
--- a/resources/lang/en/entities.php
+++ b/resources/lang/en/entities.php
@@ -150,7 +150,16 @@ return [
     '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_sort_move_up' => 'Move Up',
+    'books_sort_move_down' => 'Move Down',
+    'books_sort_move_prev_book' => 'Move To Previous Book',
+    'books_sort_move_next_book' => 'Move To Next Book',
+    'books_sort_move_prev_chapter' => 'Move Into Previous Chapter',
+    'books_sort_move_next_chapter' => 'Move Into Next Chapter',
+    'books_sort_move_book_start' => 'Move To Start of Book',
+    'books_sort_move_book_end' => 'Move To End of Book',
+    'books_sort_move_before_chapter' => 'Move To Before Chapter',
+    'books_sort_move_after_chapter' => 'Move To After Chapter',
     'books_copy' => 'Copy Book',
     'books_copy_success' => 'Book successfully copied',
 
diff --git a/resources/sass/_lists.scss b/resources/sass/_lists.scss
index 1ae801267..39b2afee6 100644
--- a/resources/sass/_lists.scss
+++ b/resources/sass/_lists.scss
@@ -232,7 +232,7 @@
 }
 
 // Sortable Lists
-.sortable-page-list, .sortable-page-list ul {
+.sortable-page-list, .sortable-page-sublist {
   list-style: none;
 }
 .sort-box {
@@ -278,7 +278,7 @@
   > ul {
     margin-inline-start: 0;
   }
-  ul {
+  .sortable-page-sublist {
     margin-bottom: $-m;
     margin-top: 0;
     padding-inline-start: $-m;
diff --git a/resources/views/books/parts/sort-box-actions.blade.php b/resources/views/books/parts/sort-box-actions.blade.php
index 0c91f42da..c9a1d323e 100644
--- a/resources/views/books/parts/sort-box-actions.blade.php
+++ b/resources/views/books/parts/sort-box-actions.blade.php
@@ -1,12 +1,23 @@
 <div class="sort-box-actions">
-    <button type="button" data-move="up">Move Up</button>
-    <button type="button" data-move="down">Move Down</button>
-    <button type="button" data-move="prev_book">Move To Previous Book</button>
-    <button type="button" data-move="next_book">Move To Next Book</button>
-    <button type="button" data-move="prev_chapter">Move Into Previous Chapter</button>
-    <button type="button" data-move="next_chapter">Move Into Next Chapter</button>
-    <button type="button" data-move="book_start">Move To Start of Book</button>
-    <button type="button" data-move="book_end">Move To End of Book</button>
-    <button type="button" data-move="before_chapter">Move To Before Chapter</button>
-    <button type="button" data-move="after_chapter">Move To After Chapter</button>
+    <button type="button" data-move="up" title="{{ trans('entities.books_sort_move_up') }}">@icon('chevron-up')</button>
+    <button type="button" data-move="down"
+            title="{{ trans('entities.books_sort_move_down') }}">@icon('chevron-down')</button>
+    <div class="dropdown-container" component="dropdown">
+        <button refs="dropdown@toggle"
+                title="{{ trans('common.more') }}"
+                aria-haspopup="true"
+                aria-expanded="false">
+            @icon('more')
+        </button>
+        <div refs="dropdown@menu" class="dropdown-menu" role="menu">
+            <button type="button" class="text-item" data-move="prev_book">{{ trans('entities.books_sort_move_prev_book') }}</button>
+            <button type="button" class="text-item" data-move="next_book">{{ trans('entities.books_sort_move_next_book') }}</button>
+            <button type="button" class="text-item" data-move="prev_chapter">{{ trans('entities.books_sort_move_prev_chapter') }}</button>
+            <button type="button" class="text-item" data-move="next_chapter">{{ trans('entities.books_sort_move_next_chapter') }}</button>
+            <button type="button" class="text-item" data-move="book_start">{{ trans('entities.books_sort_move_book_start') }}</button>
+            <button type="button" class="text-item" data-move="book_end">{{ trans('entities.books_sort_move_book_end') }}</button>
+            <button type="button" class="text-item" data-move="before_chapter">{{ trans('entities.books_sort_move_before_chapter') }}</button>
+            <button type="button" class="text-item" data-move="after_chapter">{{ trans('entities.books_sort_move_after_chapter') }}</button>
+        </div>
+    </div>
 </div>
\ No newline at end of file
diff --git a/resources/views/books/parts/sort-box.blade.php b/resources/views/books/parts/sort-box.blade.php
index 77a03f831..33448f483 100644
--- a/resources/views/books/parts/sort-box.blade.php
+++ b/resources/views/books/parts/sort-box.blade.php
@@ -36,7 +36,7 @@
                 </div>
                 @include('books.parts.sort-box-actions')
                 @if($bookChild->isA('chapter'))
-                    <ul>
+                    <ul class="sortable-page-sublist">
                         @foreach($bookChild->visible_pages as $page)
                             <li class="text-page"
                                 data-id="{{$page->id}}" data-type="page"