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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
d53ae7f1
Commit
d53ae7f1
authored
Feb 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "Mark all as done" button
parent
57d16552
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
5 deletions
+49
-5
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+15
-1
app/helpers/todos_helper.rb
app/helpers/todos_helper.rb
+26
-0
app/views/dashboard/todos/index.html.haml
app/views/dashboard/todos/index.html.haml
+8
-4
No files found.
app/controllers/dashboard/todos_controller.rb
View file @
d53ae7f1
class
Dashboard::TodosController
<
Dashboard
::
ApplicationController
class
Dashboard::TodosController
<
Dashboard
::
ApplicationController
before_filter
:find_todos
,
only:
[
:index
,
:destroy_all
]
def
index
def
index
@todos
=
TodosFinder
.
new
(
current_user
,
params
).
execute
@todos
=
@todos
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@todos
=
@todos
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
end
...
@@ -13,9 +14,22 @@ class Dashboard::TodosController < Dashboard::ApplicationController
...
@@ -13,9 +14,22 @@ class Dashboard::TodosController < Dashboard::ApplicationController
end
end
end
end
def
destroy_all
@todos
.
each
(
&
:done
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'All todos were marked as done.'
}
format
.
js
{
render
nothing:
true
}
end
end
private
private
def
todo
def
todo
@todo
||=
current_user
.
todos
.
find
(
params
[
:id
])
@todo
||=
current_user
.
todos
.
find
(
params
[
:id
])
end
end
def
find_todos
@todos
=
TodosFinder
.
new
(
current_user
,
params
).
execute
end
end
end
app/helpers/todos_helper.rb
View file @
d53ae7f1
...
@@ -19,6 +19,32 @@ module TodosHelper
...
@@ -19,6 +19,32 @@ module TodosHelper
todo
.
project
,
todo
.
target
],
anchor:
anchor
)
todo
.
project
,
todo
.
target
],
anchor:
anchor
)
end
end
def
todos_filter_params
{
state:
params
[
:state
],
project_id:
params
[
:project_id
],
author_id:
params
[
:author_id
],
type:
params
[
:type
],
action_id:
params
[
:action_id
],
}
end
def
todos_filter_path
(
options
=
{})
without
=
options
.
delete
(
:without
)
options
=
todos_filter_params
.
merge
(
options
)
if
without
.
present?
without
.
each
do
|
key
|
options
.
delete
(
key
)
end
end
path
=
request
.
path
path
<<
"?
#{
options
.
to_param
}
"
path
end
def
todo_actions_options
def
todo_actions_options
actions
=
[
actions
=
[
OpenStruct
.
new
(
id:
''
,
title:
'Any Action'
),
OpenStruct
.
new
(
id:
''
,
title:
'Any Action'
),
...
...
app/views/dashboard/todos/index.html.haml
View file @
d53ae7f1
...
@@ -4,21 +4,25 @@
...
@@ -4,21 +4,25 @@
.top-area
.top-area
%ul
.nav-links
%ul
.nav-links
%li
{
class:
(
'active'
if
params
[
:state
].
blank?
||
params
[
:state
]
==
'pending'
)}
%li
{
class:
(
'active'
if
params
[
:state
].
blank?
||
params
[
:state
]
==
'pending'
)}
=
link_to
page
_filter_path
(
state:
'pending'
)
do
=
link_to
todos
_filter_path
(
state:
'pending'
)
do
%span
%span
To do
To do
%span
{
class:
'badge'
}
%span
{
class:
'badge'
}
=
todos_pending_count
=
todos_pending_count
%li
{
class:
(
'active'
if
params
[
:state
]
==
'done'
)}
%li
{
class:
(
'active'
if
params
[
:state
]
==
'done'
)}
=
link_to
page
_filter_path
(
state:
'done'
)
do
=
link_to
todos
_filter_path
(
state:
'done'
)
do
%span
%span
Done
Done
%span
{
class:
'badge'
}
%span
{
class:
'badge'
}
=
todos_done_count
=
todos_done_count
.nav-controls
-
if
@todos
.
any?
(
&
:pending?
)
=
link_to
'Mark all as done'
,
destroy_all_dashboard_todos_path
(
todos_filter_params
),
class:
'btn'
,
method: :delete
.todos-filters
.todos-filters
.gray-content-block.second-block
.gray-content-block.second-block
=
form_tag
page_filter_path
(
without:
[
:assignee_id
,
:milestone_title
,
:label_name
,
:scope
,
:sort
]),
method: :get
,
class:
'filter-form'
do
=
form_tag
todos_filter_path
(
without:
[
:project_id
,
:author_id
,
:type
,
:action_id
]),
method: :get
,
class:
'filter-form'
do
.filter-item.inline
.filter-item.inline
=
select_tag
(
'project_id'
,
todo_projects_options
,
=
select_tag
(
'project_id'
,
todo_projects_options
,
class:
'select2 trigger-submit'
,
include_blank:
true
,
class:
'select2 trigger-submit'
,
include_blank:
true
,
...
@@ -47,7 +51,7 @@
...
@@ -47,7 +51,7 @@
=
render
group
[
1
]
=
render
group
[
1
]
=
paginate
@todos
,
theme:
"gitlab"
=
paginate
@todos
,
theme:
"gitlab"
-
else
-
else
.nothing-here-block
No todos to show
.nothing-here-block
You're all done!
:javascript
:javascript
new
UsersSelect
();
new
UsersSelect
();
...
...
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