add link to navigation btns

This commit is contained in:
SvyatoslavArtymovych 2023-06-07 11:21:16 +03:00
parent 50df1a98c7
commit 050213475c
2 changed files with 18 additions and 19 deletions

View File

@ -21,16 +21,13 @@ def recursive_move_down(collection: m.Collection):
if section := get_next_section(child):
return section
if current.is_root:
if current.is_root or not current.parent:
return None
current = parent
parent = parent.parent
#
def get_prev_section(collection: m.Collection):
if collection.active_sections:
return collection.active_sections[-1]
@ -51,7 +48,7 @@ def recursive_move_up(collection: m.Collection):
if section := get_prev_section(child):
return section
if current.is_root:
if current.is_root or not current.parent:
return None
current = parent

View File

@ -210,17 +210,18 @@
<!-- prettier-ignore -->
{% set previous_section = section.previous_section %}
{% if previous_section %}
<button
<a
href="{{url_for('book.interpretation_view', book_id=book.id, section_id=previous_section.id)}}"
type="button"
class="{% if not section.previous_section %}cursor-not-allowed{% endif %} text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
{% if not section.previous_section %}disabled{% endif %}>
class="w-1/5 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
<!-- prettier-ignore -->
<svg aria-hidden="true" class="w-5 h-5 mr-2 -ml-1 rotate-180" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path> </svg>
<div class="flex flex-col items-end ml-5">
<p class="p-3">Book label</p>
<p class="p-3">{{ previous_section.label }}</p>
<div class="truncate flex flex-col ml-3 w-full">
<p class="p-3 truncate">{{ book.label }}</p>
<p class="p-3 text-right truncate">{{ previous_section.label }}</p>
</div>
</button>
</a>
{% else %}
<div></div>
{% endif %}
@ -228,16 +229,17 @@
<!-- prettier-ignore -->
{% set next_section = section.next_section %}
{% if next_section %}
<button
<a
href="{{url_for('book.interpretation_view', book_id=book.id, section_id=next_section.id)}}"
type="button"
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
<div class="flex flex-col items-start mr-5">
<p class="p-3">Book label</p>
<p class="p-3">{{ next_section.label }}</p>
class="w-1/5 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
<div class="truncate flex flex-col w-full">
<p class="p-3 truncate">{{ book.label }}</p>
<p class="p-3 text-left truncate">{{ next_section.label }}</p>
</div>
<svg aria-hidden="true" class="w-5 h-5 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path> </svg>
</button>
</a>
{% else %}
<div></div>
{% endif %}