Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
8c0aba94
Commit
8c0aba94
authored
Apr 01, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get pagination options form the view
parent
f3134c2a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
10 deletions
+19
-10
app/assets/javascripts/todos.js.coffee
app/assets/javascripts/todos.js.coffee
+18
-9
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+0
-1
app/views/dashboard/todos/index.html.haml
app/views/dashboard/todos/index.html.haml
+1
-0
No files found.
app/assets/javascripts/todos.js.coffee
View file @
8c0aba94
class
@
Todos
class
@
Todos
constructor
:
(
@
name
)
->
constructor
:
(
opts
=
{})
->
@
todos_per_page
=
gon
.
todos_per_page
||
20
{
@
el
=
$
(
'.js-todos-options'
)
}
=
opts
@
perPage
=
@
el
.
data
(
'perPage'
)
@
clearListeners
()
@
clearListeners
()
@
initBtnListeners
()
@
initBtnListeners
()
...
@@ -59,26 +64,30 @@ class @Todos
...
@@ -59,26 +64,30 @@ class @Todos
$
(
'.todos-pending .badge, .todos-pending-count'
).
text
data
.
count
$
(
'.todos-pending .badge, .todos-pending-count'
).
text
data
.
count
$
(
'.todos-done .badge'
).
text
data
.
done_count
$
(
'.todos-done .badge'
).
text
data
.
done_count
get
Rendered
Pages
:
->
get
Total
Pages
:
->
$
(
'.gl-pagination .page'
).
length
@
el
.
data
(
'totalPages'
)
getCurrentPage
:
->
getCurrentPage
:
->
parseInt
(
$
.
trim
(
$
(
'.gl-pagination .page.active'
).
text
()))
@
el
.
data
(
'currentPage'
)
getTodosPerPage
:
->
@
el
.
data
(
'perPage'
)
redirectIfNeeded
:
(
total
)
->
redirectIfNeeded
:
(
total
)
->
currPages
=
@
get
Rendered
Pages
()
currPages
=
@
get
Total
Pages
()
currPage
=
@
getCurrentPage
()
currPage
=
@
getCurrentPage
()
newPages
=
Math
.
ceil
(
total
/
@
todos_per_page
)
newPages
=
Math
.
ceil
(
total
/
@
getTodosPerPage
()
)
url
=
location
.
href
# Includes query strings
url
=
location
.
href
# Includes query strings
# Refresh if no remaining Todos
# Refresh if no remaining Todos
if
!
total
if
not
total
location
.
reload
()
location
.
reload
()
return
return
# Do nothing if no pagination
# Do nothing if no pagination
return
if
!
currPages
return
if
not
currPages
# If new total of pages is different than we have now
# If new total of pages is different than we have now
if
newPages
isnt
currPages
if
newPages
isnt
currPages
...
...
app/controllers/dashboard/todos_controller.rb
View file @
8c0aba94
...
@@ -2,7 +2,6 @@ class Dashboard::TodosController < Dashboard::ApplicationController
...
@@ -2,7 +2,6 @@ class Dashboard::TodosController < Dashboard::ApplicationController
before_action
:find_todos
,
only:
[
:index
,
:destroy
,
:destroy_all
]
before_action
:find_todos
,
only:
[
:index
,
:destroy
,
:destroy_all
]
def
index
def
index
gon
.
todos_per_page
=
Todo
.
default_per_page
@todos
=
@todos
.
page
(
params
[
:page
])
@todos
=
@todos
.
page
(
params
[
:page
])
end
end
...
...
app/views/dashboard/todos/index.html.haml
View file @
8c0aba94
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
.prepend-top-default
.prepend-top-default
-
if
@todos
.
any?
-
if
@todos
.
any?
.js-todos-options
{
data:
{
per_page:
@todos
.
limit_value
,
current_page:
@todos
.
current_page
,
total_pages:
@todos
.
total_pages
}
}
-
@todos
.
group_by
(
&
:project
).
each
do
|
group
|
-
@todos
.
group_by
(
&
:project
).
each
do
|
group
|
.panel.panel-default.panel-small.js-todos-list
.panel.panel-default.panel-small.js-todos-list
-
project
=
group
[
0
]
-
project
=
group
[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment