mirror of https://github.com/logos-co/open-law.git
breadcrumbs splitter
This commit is contained in:
parent
b90c641580
commit
74314948d1
|
@ -6,6 +6,7 @@ from app.controllers import create_breadcrumbs
|
||||||
from .interpretation import Interpretation
|
from .interpretation import Interpretation
|
||||||
from .comment import Comment
|
from .comment import Comment
|
||||||
from .interpretation_vote import InterpretationVote
|
from .interpretation_vote import InterpretationVote
|
||||||
|
from app import schema as s
|
||||||
|
|
||||||
|
|
||||||
class Section(BaseModel):
|
class Section(BaseModel):
|
||||||
|
@ -49,6 +50,12 @@ class Section(BaseModel):
|
||||||
breadcrumbs_path = create_breadcrumbs(
|
breadcrumbs_path = create_breadcrumbs(
|
||||||
book_id=self.book_id, collection_id=self.collection.id
|
book_id=self.book_id, collection_id=self.collection.id
|
||||||
)
|
)
|
||||||
|
if len(breadcrumbs_path) > 5:
|
||||||
|
breadcrumbs_path = (
|
||||||
|
breadcrumbs_path[:3]
|
||||||
|
+ [s.BreadCrumb(type=s.BreadCrumbType.Splitter, url="", label="...")]
|
||||||
|
+ breadcrumbs_path[-2:]
|
||||||
|
)
|
||||||
return breadcrumbs_path
|
return breadcrumbs_path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -11,6 +11,7 @@ class BreadCrumbType(enum.StrEnum):
|
||||||
Collection = "Collection"
|
Collection = "Collection"
|
||||||
Section = "Section"
|
Section = "Section"
|
||||||
Interpretation = "Interpretation"
|
Interpretation = "Interpretation"
|
||||||
|
Splitter = "Splitter"
|
||||||
|
|
||||||
|
|
||||||
class BreadCrumb(BaseModel):
|
class BreadCrumb(BaseModel):
|
||||||
|
|
|
@ -7,17 +7,24 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white" data-tooltip-target="breadcrumb-{{loop.index}}-tooltip" data-tooltip-placement="bottom">
|
<span class="inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white" data-tooltip-target="breadcrumb-{{loop.index}}-tooltip" data-tooltip-placement="bottom">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if breadcrumb.type != "Splitter" %}
|
||||||
<div id="breadcrumb-{{loop.index}}-tooltip" role="tooltip" class="delay-100 absolute z-[100] invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-700 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
|
<div id="breadcrumb-{{loop.index}}-tooltip" role="tooltip" class="delay-100 absolute z-[100] invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-700 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
|
||||||
{{ breadcrumb.label }}
|
{{ breadcrumb.label }}
|
||||||
<div class="tooltip-arrow" data-popper-arrow></div>
|
<div class="tooltip-arrow" data-popper-arrow></div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
<span class="select-none">{{ breadcrumb.label }}</span>
|
<span class="select-none">{{ breadcrumb.label }}</span>
|
||||||
|
|
||||||
{% if not loop.index==local_breadcrumbs|length %}
|
{% if not loop.index==local_breadcrumbs|length %}
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% if not loop.index==local_breadcrumbs|length-1 %}
|
{% if not loop.index==local_breadcrumbs|length-1 %}
|
||||||
<svg aria-hidden="true" class="w-4 h-4 text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path> </svg>
|
<svg aria-hidden="true" class="w-4 h-4 text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path> </svg>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue