From 730f539029385109e3e3b9557bca6f7a8b8a8855 Mon Sep 17 00:00:00 2001
From: Dan Brown <ssddanbrown@googlemail.com>
Date: Thu, 27 Jul 2023 14:27:45 +0100
Subject: [PATCH] Notifications: Started entity watch UI

---
 resources/icons/{view.svg => watch.svg}       |  0
 resources/sass/_lists.scss                    |  3 +
 resources/sass/_text.scss                     |  1 +
 resources/views/books/show.blade.php          |  2 +-
 resources/views/entities/meta.blade.php       |  8 +++
 .../views/entities/watch-controls.blade.php   | 71 +++++++++++++++++++
 6 files changed, 84 insertions(+), 1 deletion(-)
 rename resources/icons/{view.svg => watch.svg} (100%)
 create mode 100644 resources/views/entities/watch-controls.blade.php

diff --git a/resources/icons/view.svg b/resources/icons/watch.svg
similarity index 100%
rename from resources/icons/view.svg
rename to resources/icons/watch.svg
diff --git a/resources/sass/_lists.scss b/resources/sass/_lists.scss
index ad0803e71..64411014d 100644
--- a/resources/sass/_lists.scss
+++ b/resources/sass/_lists.scss
@@ -681,6 +681,9 @@ ul.pagination {
   &.wide {
     min-width: 220px;
   }
+  &.xl-limited {
+    width: 280px;
+  }
   .text-muted {
     color: #999;
     fill: #999;
diff --git a/resources/sass/_text.scss b/resources/sass/_text.scss
index 7cade9607..a3e6f09ac 100644
--- a/resources/sass/_text.scss
+++ b/resources/sass/_text.scss
@@ -365,6 +365,7 @@ li.checkbox-item, li.task-list-item {
 }
 
 .break-text {
+  white-space: normal;
   word-wrap: break-word;
   overflow-wrap: break-word;
 }
diff --git a/resources/views/books/show.blade.php b/resources/views/books/show.blade.php
index 8bb41c18b..f126c6219 100644
--- a/resources/views/books/show.blade.php
+++ b/resources/views/books/show.blade.php
@@ -67,7 +67,7 @@
 @stop
 
 @section('right')
-    <div class="mb-xl">
+    <div class="mb-xl" style="z-index: 1000; opacity: 1;">
         <h5>{{ trans('common.details') }}</h5>
         <div class="blended-links">
             @include('entities.meta', ['entity' => $book])
diff --git a/resources/views/entities/meta.blade.php b/resources/views/entities/meta.blade.php
index 7ad61f1b1..b657d82de 100644
--- a/resources/views/entities/meta.blade.php
+++ b/resources/views/entities/meta.blade.php
@@ -68,4 +68,12 @@
             </div>
         </a>
     @endif
+
+    <div class="dropdown-container">
+        <div class="entity-meta-item">
+            @icon('watch')
+            <span>Watching with default preferences</span>
+        </div>
+        @include('entities.watch-controls', ['entity' => $entity])
+    </div>
 </div>
\ No newline at end of file
diff --git a/resources/views/entities/watch-controls.blade.php b/resources/views/entities/watch-controls.blade.php
new file mode 100644
index 000000000..ab4af0f77
--- /dev/null
+++ b/resources/views/entities/watch-controls.blade.php
@@ -0,0 +1,71 @@
+<form action="{{ $entity->getUrl('/') }}" method="GET">
+{{--    {{ method_field('PUT') }}--}}
+
+    <ul class="dropdown-menu xl-limited anchor-left" style="display: block;">
+        <li>
+            <button name="level" value="default" class="icon-item">
+                <span class="text-pos pt-m">{!!  request()->query('level') === 'default' ? icon('check-circle') : '' !!}</span>
+                <div class="break-text">
+                    <div class="mb-xxs"><strong>Default Preferences</strong></div>
+                    <div class="text-muted text-small">
+                        Revert watching to just your default notification preferences.
+                    </div>
+                </div>
+            </button>
+        </li>
+        <li><hr class="my-none"></li>
+        <li>
+            <button name="level" value="ignore" class="icon-item">
+                <span class="text-pos pt-m">{!!  request()->query('level') === 'ignore' ? icon('check-circle') : '' !!}</span>
+                <div class="break-text">
+                    <div class="mb-xxs"><strong>Ignore</strong></div>
+                    <div class="text-muted text-small">
+                        Ignore all notifications, including those from user-level preferences.
+                    </div>
+                </div>
+            </button>
+        </li>
+        <li><hr class="my-none"></li>
+        <li>
+            <button name="level" value="new" class="icon-item">
+                <span class="text-pos pt-m">{!!  request()->query('level') === 'new' ? icon('check-circle') : '' !!}</span>
+                <div class="break-text">
+                    <div class="mb-xxs"><strong>New Pages</strong></div>
+                    <div class="text-muted text-small">
+                        Notify when any new page is created within this item.
+                    </div>
+                </div>
+            </button>
+        </li>
+        <li><hr class="my-none"></li>
+        <li>
+            <button name="level" value="updates" class="icon-item">
+                <span class="text-pos pt-m">{!!  request()->query('level') === 'updates' ? icon('check-circle') : '' !!}</span>
+                <div class="break-text">
+                    <div class="mb-xxs"><strong>All Page Updates</strong></div>
+                    <div class="text-muted text-small">
+                        Notify upon all new pages and page changes.
+                    </div>
+                </div>
+            </button>
+        </li>
+        <li><hr class="my-none"></li>
+        <li>
+            <button name="level" value="comments" class="icon-item">
+                <span class="text-pos pt-m">{!!  request()->query('level') === 'comments' ? icon('check-circle') : '' !!}</span>
+                <div class="break-text">
+                    <div class="mb-xxs"><strong>All Page Updates & Comments</strong></div>
+                    <div class="text-muted text-small">
+                        Notify upon all new pages, page changes and new comments.
+                    </div>
+                </div>
+            </button>
+        </li>
+        <li><hr class="my-none"></li>
+        <li>
+            <div class="text-small text-muted px-l pb-xxs pt-xs">
+                <a href="{{ url('/preferences/notifications') }}" target="_blank">Change default notification preferences</a>
+            </div>
+        </li>
+    </ul>
+</form>
\ No newline at end of file