Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
983d35df
Commit
983d35df
authored
3 years ago
by
Štěpán Farka
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] pagination range
parent
017d50ac
No related branches found
No related tags found
2 merge requests
!436
Release
,
!434
Feature/misc enhancements 2
Pipeline
#7366
passed
3 years ago
Stage: build
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
shared/templates/styleguide/2.3.x/pagination.html
+5
-5
5 additions, 5 deletions
shared/templates/styleguide/2.3.x/pagination.html
shared/templatetags/shared_tags.py
+20
-0
20 additions, 0 deletions
shared/templatetags/shared_tags.py
with
25 additions
and
5 deletions
shared/templates/styleguide/2.3.x/pagination.html
+
5
−
5
View file @
983d35df
{% load wagtailcore_tags %}
{% load wagtailcore_tags
shared_tags
%}
<div
class=
"pagination-container"
>
<div
class=
"pagination-container"
>
<nav
class=
"pagination space-x-1"
>
<nav
class=
"pagination space-x-1"
>
...
@@ -6,15 +6,15 @@
...
@@ -6,15 +6,15 @@
{% if paginator.has_previous %}
{% if paginator.has_previous %}
<a
href=
"{% pageurl page %}?page={{ paginator.previous_page_number }}{{ extra_query }}"
class=
"btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed btn--inverted-icon"
>
<a
href=
"{% pageurl page %}?page={{ paginator.previous_page_number }}{{ extra_query }}"
class=
"btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed btn--inverted-icon"
>
<div
class=
"btn__body-wrap"
>
<div
class=
"btn__body-wrap"
>
<div
class=
"btn__body "
>
p
ředchozí
</div>
<div
class=
"btn__body "
>
P
ředchozí
</div>
<div
class=
"btn__icon "
>
<div
class=
"btn__icon "
>
<i
class=
"ico--chevron-left"
></i>
<i
class=
"ico--chevron-left"
></i>
</div>
</div>
</div>
</div>
</a>
</a>
{% endif %}
{% endif %}
{% get_pagination_range paginator.number paginator.paginator.page_range as pagination_range %}
{% for i in paginat
or.paginator.page
_range %}
{% for i in paginat
ion
_range %}
{% if i == paginator.number %}
{% if i == paginator.number %}
<a
href=
"{% pageurl page %}?page={{ i }}{{ extra_query }}"
class=
"btn btn--grey-500 btn--condensed hidden md:inline-block"
>
<a
href=
"{% pageurl page %}?page={{ i }}{{ extra_query }}"
class=
"btn btn--grey-500 btn--condensed hidden md:inline-block"
>
{% else %}
{% else %}
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
{% if paginator.has_next %}
{% if paginator.has_next %}
<a
href=
"{% pageurl page %}?page={{ paginator.next_page_number }}{{ extra_query }}"
class=
"btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed"
>
<a
href=
"{% pageurl page %}?page={{ paginator.next_page_number }}{{ extra_query }}"
class=
"btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed"
>
<div
class=
"btn__body-wrap"
>
<div
class=
"btn__body-wrap"
>
<div
class=
"btn__body "
>
d
alší
</div>
<div
class=
"btn__body "
>
D
alší
</div>
<div
class=
"btn__icon "
>
<div
class=
"btn__icon "
>
<i
class=
"ico--chevron-right"
></i>
<i
class=
"ico--chevron-right"
></i>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
shared/templatetags/shared_tags.py
0 → 100644
+
20
−
0
View file @
983d35df
from
django
import
template
register
=
template
.
Library
()
@register.simple_tag
def
get_pagination_range
(
current_page
:
int
,
all_page_range
:
range
):
surrounding_count
=
2
if
current_page
>
surrounding_count
:
if
current_page
+
surrounding_count
<=
all_page_range
[
-
1
]:
return
range
(
current_page
-
surrounding_count
,
current_page
+
surrounding_count
+
1
)
else
:
return
range
(
current_page
-
surrounding_count
,
all_page_range
[
-
1
]
+
1
)
else
:
if
current_page
+
surrounding_count
<=
all_page_range
[
-
1
]:
return
range
(
all_page_range
[
0
],
current_page
+
surrounding_count
+
1
)
else
:
return
range
(
all_page_range
[
0
],
all_page_range
[
-
1
]
+
1
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment