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
Jérome Perrin
gitlab-ce
Commits
fa570525
Commit
fa570525
authored
Feb 23, 2016
by
Jacob Schatz
Committed by
Phil Hughes
Mar 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds small AJAX optimistic functionality to todos.
Fixes #13656 A good first step and boring solution.
parent
4171933c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
5 deletions
+67
-5
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+2
-1
app/assets/javascripts/todos.js.coffee
app/assets/javascripts/todos.js.coffee
+48
-0
app/assets/stylesheets/framework/flash.scss
app/assets/stylesheets/framework/flash.scss
+6
-0
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+6
-1
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/dispatcher.js.coffee
View file @
fa570525
...
...
@@ -14,7 +14,6 @@ class Dispatcher
path
=
page
.
split
(
':'
)
shortcut_handler
=
null
switch
page
when
'projects:issues:index'
Issues
.
init
()
...
...
@@ -25,6 +24,8 @@ class Dispatcher
new
ZenMode
()
when
'projects:milestones:show'
,
'groups:milestones:show'
,
'dashboard:milestones:show'
new
Milestone
()
when
'dashboard:todos:index'
new
Todos
()
when
'projects:milestones:new'
,
'projects:milestones:edit'
new
ZenMode
()
new
DropzoneInput
(
$
(
'.milestone-form'
))
...
...
app/assets/javascripts/todos.js.coffee
0 → 100644
View file @
fa570525
class
@
Todos
_this
=
null
;
constructor
:
(
@
name
)
->
_this
=
@
@
initBtnListeners
()
initBtnListeners
:
->
$
(
'.done-todo'
).
on
(
'click'
,
@
doneClicked
)
doneClicked
:
(
e
)
->
$this
=
$
(
this
)
doneURL
=
$this
.
attr
(
'href'
)
e
.
preventDefault
()
e
.
stopImmediatePropagation
()
$spinner
=
$
(
'<i></i>'
).
addClass
(
'fa fa-spinner fa-spin'
)
$this
.
addClass
(
"disabled"
)
$this
.
append
(
$spinner
)
$
.
ajax
type
:
'POST'
url
:
doneURL
dataType
:
'json'
data
:
'_method'
:
'delete'
error
:
(
data
,
textStatus
,
jqXHR
)
->
new
Flash
(
'Unable to update your todos.'
,
'alert'
)
_this
.
clearDone
(
$this
.
closest
(
'li'
))
return
success
:
(
data
,
textStatus
,
jqXHR
)
->
new
Flash
(
data
.
notice
,
'success'
)
_this
.
clearDone
(
$this
.
closest
(
'li'
))
return
clearDone
:
(
$row
)
->
$ul
=
$row
.
closest
(
'ul'
)
$row
.
remove
()
if
not
$ul
.
find
(
'li'
).
length
Turbolinks
.
visit
(
location
.
href
)
else
$pendingBadge
=
$
(
'.todos-pending .badge'
)
$pendingBadge
.
text
parseInt
(
$pendingBadge
.
text
())
-
1
$doneBadge
=
$
(
'.todos-done .badge'
)
$doneBadge
.
text
parseInt
(
$doneBadge
.
text
())
+
1
$mainTodosPendingBadge
=
$
(
'.todos-pending-count'
)
$mainTodosPendingBadge
.
text
parseInt
(
$mainTodosPendingBadge
.
text
())
-
1
return
\ No newline at end of file
app/assets/stylesheets/framework/flash.scss
View file @
fa570525
...
...
@@ -5,6 +5,12 @@
width
:
100%
;
z-index
:
100
;
.flash-success
{
@extend
.alert
;
@extend
.alert-success
;
margin
:
0
;
}
.flash-notice
{
@extend
.alert
;
@extend
.alert-info
;
...
...
app/controllers/dashboard/todos_controller.rb
View file @
fa570525
...
...
@@ -8,9 +8,14 @@ class Dashboard::TodosController < Dashboard::ApplicationController
def
destroy
todo
.
done!
todo_notice
=
'Todo was successfully marked as done.'
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'Todo was successfully marked as done.'
}
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
todo_notice
}
format
.
js
{
render
nothing:
true
}
format
.
json
do
render
json:
{
status:
'OK'
,
notice:
todo_notice
}
end
end
end
...
...
app/views/dashboard/todos/_todo.html.haml
View file @
fa570525
...
...
@@ -16,7 +16,7 @@
-
if
todo
.
pending?
.todo-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
todo
],
method: :delete
,
class:
'btn'
=
link_to
'Done'
,
[
:dashboard
,
todo
],
method: :delete
,
class:
'btn
done-todo
'
.todo-body
.todo-note
...
...
app/views/dashboard/todos/index.html.haml
View file @
fa570525
...
...
@@ -3,13 +3,15 @@
.top-area
%ul
.nav-links
%li
{
class:
(
'active'
if
params
[
:state
].
blank?
||
params
[
:state
]
==
'pending'
)}
-
todo_pending_active
=
(
'active'
if
params
[
:state
].
blank?
||
params
[
:state
]
==
'pending'
)
%li
{
class:
"todos-pending #{todo_pending_active}"
}
=
link_to
todos_filter_path
(
state:
'pending'
)
do
%span
To do
%span
{
class:
'badge'
}
=
todos_pending_count
%li
{
class:
(
'active'
if
params
[
:state
]
==
'done'
)}
-
todo_done_active
=
(
'active'
if
params
[
:state
]
==
'done'
)
%li
{
class:
"todos-done #{todo_done_active}"
}
=
link_to
todos_filter_path
(
state:
'done'
)
do
%span
Done
...
...
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