Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UNL Resource Scheduler
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
Service Desk
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
Jeff Sturek
UNL Resource Scheduler
Commits
46ac0d8b
Commit
46ac0d8b
authored
8 years ago
by
Tyler Lemburg
Browse files
Options
Downloads
Patches
Plain Diff
Add pagination to reservations view in space home
parent
a6408d81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
routes/space.rb
+14
-4
14 additions, 4 deletions
routes/space.rb
views/space_home.erb
+33
-0
33 additions, 0 deletions
views/space_home.erb
with
47 additions
and
4 deletions
routes/space.rb
+
14
−
4
View file @
46ac0d8b
...
...
@@ -6,19 +6,29 @@ get '/:service_space_url_name/?' do
require_login
load_service_space
page
=
params
[
:page
].
to_i
page
=
1
if
page
.
nil?
||
page
<=
0
reservations
=
Reservation
.
joins
(
:resource
).
includes
(
:event
).
where
(
:resources
=>
{
:service_space_id
=>
@space
.
id
}).
where
(
:user_id
=>
@user
.
id
).
where
(
'end_time >= ?'
,
Time
.
now
).
order
(
:start_time
).
all
where
(
'end_time >= ?'
,
Time
.
now
.
midnight
).
order
(
:start_time
).
limit
(
5
).
offset
((
page
-
1
)
*
5
)
total_pages
=
(
Reservation
.
joins
(
:resource
).
includes
(
:event
).
where
(
:resources
=>
{
:service_space_id
=>
@space
.
id
}).
where
(
:user_id
=>
@user
.
id
).
where
(
'end_time >= ?'
,
Time
.
now
.
midnight
).
count
+
4
)
/
5
events
=
Event
.
includes
(
:event_type
).
joins
(
:event_signups
).
where
(
:event_signups
=>
{
:user_id
=>
@user
.
id
},
:service_space_id
=>
@space
.
id
).
where
(
'end_time >= ?'
,
Time
.
now
).
where
(
'end_time >= ?'
,
Time
.
now
.
midnight
).
order
(
:start_time
).
all
erb
:space_home
,
:layout
=>
:fixed
,
:locals
=>
{
:reservations
=>
reservations
,
:events
=>
events
:events
=>
events
,
:total_pages
=>
total_pages
,
:page
=>
page
}
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
views/space_home.erb
+
33
−
0
View file @
46ac0d8b
...
...
@@ -40,6 +40,39 @@ You have no upcoming reservations. You can view upcoming trainings to get certif
<%
end
%>
</tbody>
</table>
<%
if
total_pages
>
1
%>
<script>
WDN
.
loadCSS
(
WDN
.
getTemplateFilePath
(
'
css/modules/pagination.css
'
));
</script>
<div
style=
"text-align: center;"
>
<div
style=
"display: inline-block;"
>
<ul
class=
"wdn_pagination"
data-tab=
"pending"
style=
"padding-left: 0;"
>
<%
if
page
!=
1
%>
<li
class=
"arrow prev"
><a
href=
"?page=
<%=
page
-
1
%>
"
title=
"Go to the previous page"
>
← prev
</a></li>
<%
end
%>
<%
before_ellipsis_shown
=
false
;
after_ellipsis_shown
=
false
%>
<%
(
1
..
total_pages
).
each
do
|
i
|
%>
<%
if
i
==
page
%>
<li
class=
"selected"
><span>
<%=
i
%>
</span></li>
<%
elsif
(
i
<=
3
||
i
>=
total_pages
-
2
||
i
==
page
-
1
||
i
==
page
-
2
||
i
==
page
+
1
||
$i
==
page
+
2
)
%>
<li><a
href=
"?page=
<%=
i
%>
"
title=
"Go to page
<%=
i
%>
"
>
<%=
i
%>
</a></li>
<%
elsif
(
i
<
page
&&
!
before_ellipsis_shown
)
%>
<li><span
class=
"ellipsis"
>
...
</span></li>
<%
before_ellipsis_shown
=
true
%>
<%
elsif
(
i
>
page
&&
!
after_ellipsis_shown
)
%>
<li><span
class=
"ellipsis"
>
...
</span></li>
<%
after_ellipsis_shown
=
true
%>
<%
end
%>
<%
end
%>
<%
if
page
!=
total_pages
%>
<li
class=
"arrow next"
><a
href=
"?page=
<%=
page
+
1
%>
"
title=
"Go to the next page"
>
next →
</a></li>
<%
end
%>
</ul>
</div>
</div>
<%
end
%>
<%
end
%>
<h4>
...
...
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