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
Tatuya Kamada
gitlab-ce
Commits
41c107be
Commit
41c107be
authored
Mar 17, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark all as done through AJAX
parent
421215e3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
8 deletions
+35
-8
app/assets/javascripts/todos.js.coffee
app/assets/javascripts/todos.js.coffee
+26
-5
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+4
-0
app/views/dashboard/todos/_todo.html.haml
app/views/dashboard/todos/_todo.html.haml
+1
-1
app/views/dashboard/todos/index.html.haml
app/views/dashboard/todos/index.html.haml
+4
-2
No files found.
app/assets/javascripts/todos.js.coffee
View file @
41c107be
...
@@ -5,9 +5,11 @@ class @Todos
...
@@ -5,9 +5,11 @@ class @Todos
clearListeners
:
->
clearListeners
:
->
$
(
'.done-todo'
).
off
(
'click'
)
$
(
'.done-todo'
).
off
(
'click'
)
$
(
'.js-todos-mark-all'
).
off
(
'click'
)
initBtnListeners
:
->
initBtnListeners
:
->
$
(
'.done-todo'
).
on
(
'click'
,
@
doneClicked
)
$
(
'.done-todo'
).
on
(
'click'
,
@
doneClicked
)
$
(
'.js-todos-mark-all'
).
on
(
'click'
,
@
allDoneClicked
)
doneClicked
:
(
e
)
=>
doneClicked
:
(
e
)
=>
e
.
preventDefault
()
e
.
preventDefault
()
...
@@ -22,14 +24,33 @@ class @Todos
...
@@ -22,14 +24,33 @@ class @Todos
dataType
:
'json'
dataType
:
'json'
data
:
'_method'
:
'delete'
data
:
'_method'
:
'delete'
success
:
(
data
)
=>
success
:
(
data
)
=>
@
clearDone
$this
.
closest
(
'li'
),
data
@
clearDone
$this
.
closest
(
'li'
)
@
updateBadges
data
clearDone
:
(
$row
,
data
)
->
allDoneClicked
:
(
e
)
=>
e
.
preventDefault
()
e
.
stopImmediatePropagation
()
$this
=
$
(
e
.
currentTarget
)
$this
.
disable
()
$
.
ajax
type
:
'POST'
url
:
$this
.
attr
(
'href'
)
dataType
:
'json'
data
:
'_method'
:
'delete'
success
:
(
data
)
=>
$this
.
remove
()
$
(
'.js-todos-list'
).
remove
()
@
updateBadges
data
clearDone
:
(
$row
)
->
$ul
=
$row
.
closest
(
'ul'
)
$ul
=
$row
.
closest
(
'ul'
)
$row
.
remove
()
$row
.
remove
()
$
(
'.todos-pending .badge, .todos-pending-count'
).
text
data
.
count
$
(
'.todos-done .badge'
).
text
data
.
done_count
if
not
$ul
.
find
(
'li'
).
length
if
not
$ul
.
find
(
'li'
).
length
$ul
.
parents
(
'.panel'
).
remove
()
$ul
.
parents
(
'.panel'
).
remove
()
updateBadges
:
(
data
)
->
$
(
'.todos-pending .badge, .todos-pending-count'
).
text
data
.
count
$
(
'.todos-done .badge'
).
text
data
.
done_count
app/controllers/dashboard/todos_controller.rb
View file @
41c107be
...
@@ -25,6 +25,10 @@ class Dashboard::TodosController < Dashboard::ApplicationController
...
@@ -25,6 +25,10 @@ class Dashboard::TodosController < Dashboard::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'All todos were marked as done.'
}
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'All todos were marked as done.'
}
format
.
js
{
render
nothing:
true
}
format
.
js
{
render
nothing:
true
}
format
.
json
do
find_todos
render
json:
{
count:
@todos
.
size
,
done_count:
current_user
.
todos
.
done
.
count
}
end
end
end
end
end
...
...
app/views/dashboard/todos/_todo.html.haml
View file @
41c107be
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
-
if
todo
.
pending?
-
if
todo
.
pending?
.todo-actions.pull-right
.todo-actions.pull-right
=
link_to
[
:dashboard
,
todo
],
method: :delete
,
class:
'btn btn-loading done-todo'
do
=
link_to
[
:dashboard
,
todo
],
method: :delete
,
class:
'btn btn-loading done-todo'
do
=
icon
(
'spinner spin'
)
Done
Done
=
icon
(
'spinner spin'
)
.todo-body
.todo-body
.todo-note
.todo-note
...
...
app/views/dashboard/todos/index.html.haml
View file @
41c107be
...
@@ -20,7 +20,9 @@
...
@@ -20,7 +20,9 @@
.nav-controls
.nav-controls
-
if
@todos
.
any?
(
&
:pending?
)
-
if
@todos
.
any?
(
&
:pending?
)
=
link_to
'Mark all as done'
,
destroy_all_dashboard_todos_path
(
todos_filter_params
),
class:
'btn'
,
method: :delete
=
link_to
destroy_all_dashboard_todos_path
(
todos_filter_params
),
class:
'btn btn-loading js-todos-mark-all'
,
method: :delete
do
Mark all as done
=
icon
(
'spinner spin'
)
.todos-filters
.todos-filters
.gray-content-block.second-block
.gray-content-block.second-block
...
@@ -44,7 +46,7 @@
...
@@ -44,7 +46,7 @@
.prepend-top-default
.prepend-top-default
-
if
@todos
.
any?
-
if
@todos
.
any?
-
@todos
.
group_by
(
&
:project
).
each
do
|
group
|
-
@todos
.
group_by
(
&
:project
).
each
do
|
group
|
.panel.panel-default.panel-small
.panel.panel-default.panel-small
.js-todos-list
-
project
=
group
[
0
]
-
project
=
group
[
0
]
.panel-heading
.panel-heading
=
link_to
project
.
name_with_namespace
,
namespace_project_path
(
project
.
namespace
,
project
)
=
link_to
project
.
name_with_namespace
,
namespace_project_path
(
project
.
namespace
,
project
)
...
...
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