Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Newspapers Platform
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
labs-team
Newspapers Platform
Commits
fda51cee
Commit
fda51cee
authored
2 years ago
by
smayer
Browse files
Options
Downloads
Patches
Plain Diff
Add page select feature to dataset pagination
parent
e52025d4
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Merging development into onb as preparation for Annolyzer release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/javascript/packs/controllers/dataset_controller.js
+9
-1
9 additions, 1 deletion
app/javascript/packs/controllers/dataset_controller.js
app/views/dataset/_pagination.html.erb
+24
-6
24 additions, 6 deletions
app/views/dataset/_pagination.html.erb
with
33 additions
and
7 deletions
app/javascript/packs/controllers/dataset_controller.js
+
9
−
1
View file @
fda51cee
...
...
@@ -3,7 +3,7 @@ import {DatasetAPI} from "../utils/dataset_api"
import
{
SearchAPI
}
from
"
../utils/search_api
"
;
export
default
class
extends
Controller
{
static
targets
=
[
]
static
targets
=
[
"
inputPage
"
]
static
values
=
{
id
:
Number
,
currentPage
:
Number
,
nbPages
:
Number
,
perPage
:
Number
,
sort
:
String
,
sortOrder
:
String
,
selectedDocuments
:
Array
}
connect
()
{
...
...
@@ -99,4 +99,12 @@ export default class extends Controller {
this
.
loadDocuments
(
this
.
idValue
,
this
.
currentPageValue
,
this
.
perPageValue
,
this
.
sortValue
,
this
.
sortOrderValue
,
$
(
"
#doctype_selection input:checked
"
).
data
(
"
doctype
"
))
}
page_select
(
event
)
{
event
.
preventDefault
()
const
input_page
=
this
.
inputPageTarget
.
value
if
(
!
Number
.
isNaN
(
input_page
)
&&
1
<=
input_page
&&
input_page
<=
this
.
nbPagesValue
&&
!
(
this
.
currentPageValue
==
input_page
))
{
this
.
currentPageValue
=
input_page
this
.
loadDocuments
(
this
.
idValue
,
this
.
currentPageValue
,
this
.
perPageValue
,
this
.
sortValue
,
this
.
sortOrderValue
,
$
(
"
#doctype_selection input:checked
"
).
data
(
"
doctype
"
))
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/views/dataset/_pagination.html.erb
+
24
−
6
View file @
fda51cee
...
...
@@ -7,9 +7,18 @@
<%
if
(
nb_pages
>
10
)
%>
<%
(
1
..
nb_pages
).
each
do
|
i
|
%>
<%
if
(
i
>=
current_page
-
2
and
i
<=
current_page
+
2
)
or
(
i
<=
1
)
or
(
i
>=
nb_pages
)
%>
<li
class=
"page-item
<%=
" active"
if
current_page
==
i
%>
"
data-action=
"click->dataset#page_button"
>
<a
class=
"page-link"
href=
"#"
>
<%=
i
%>
</a>
</li>
<%
if
i
==
current_page
%>
<li
class=
"page-item active"
>
<form
class=
"page-link"
data-action=
"dataset#page_select"
>
<input
type=
"text"
data-dataset-target=
"inputPage"
value=
"
<%=
i
%>
"
style=
"width:25px; height:20px"
>
<input
type=
"submit"
class=
"sr-only"
tabindex=
"-1"
>
</form>
</li>
<%
else
%>
<li
class=
"page-item"
data-action=
"click->dataset#page_button"
>
<a
class=
"page-link"
href=
"#"
>
<%=
i
%>
</a>
</li>
<%
end
%>
<%
elsif
(
i
==
2
and
current_page
>=
5
)
or
(
i
==
nb_pages
-
1
and
current_page
<=
nb_pages
-
4
)
%>
<li
class=
"page-item disabled"
>
<a
class=
"page-link"
href=
"#"
>
...
</a>
...
...
@@ -18,9 +27,18 @@
<%
end
%>
<%
else
%>
<%
(
1
..
nb_pages
).
each
do
|
i
|
%>
<li
class=
"page-item
<%=
" active"
if
current_page
==
i
%>
"
data-action=
"click->dataset#page_button"
>
<a
class=
"page-link"
href=
"#"
>
<%=
i
%>
</a>
</li>
<%
if
i
==
current_page
%>
<li
class=
"page-item active"
>
<form
class=
"page-link"
data-action=
"dataset#page_select"
>
<input
type=
"text"
data-dataset-target=
"inputPage"
value=
"
<%=
i
%>
"
style=
"width:30px; height:25px"
>
<input
type=
"submit"
class=
"sr-only"
tabindex=
"-1"
>
</form>
</li>
<%
else
%>
<li
class=
"page-item"
data-action=
"click->dataset#page_button"
>
<a
class=
"page-link"
href=
"#"
>
<%=
i
%>
</a>
</li>
<%
end
%>
<%
end
%>
<%
end
%>
<li
class=
"page-item
<%=
" disabled"
if
current_page
==
nb_pages
%>
"
data-action=
"click->dataset#next_page"
>
...
...
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