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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
77d7910b
Commit
77d7910b
authored
Feb 15, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow user to mark each task as done manually
parent
c8f2d18a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
1 deletion
+43
-1
app/controllers/dashboard/tasks_controller.rb
app/controllers/dashboard/tasks_controller.rb
+23
-0
app/models/ability.rb
app/models/ability.rb
+11
-0
app/models/task.rb
app/models/task.rb
+4
-0
app/views/dashboard/tasks/_task.html.haml
app/views/dashboard/tasks/_task.html.haml
+4
-0
config/routes.rb
config/routes.rb
+1
-1
No files found.
app/controllers/dashboard/tasks_controller.rb
View file @
77d7910b
class
Dashboard::TasksController
<
Dashboard
::
ApplicationController
class
Dashboard::TasksController
<
Dashboard
::
ApplicationController
before_action
:authorize_destroy_task!
,
only:
[
:destroy
]
def
index
def
index
@tasks
=
case
params
[
:state
]
@tasks
=
case
params
[
:state
]
when
'done'
when
'done'
...
@@ -12,4 +14,25 @@ class Dashboard::TasksController < Dashboard::ApplicationController
...
@@ -12,4 +14,25 @@ class Dashboard::TasksController < Dashboard::ApplicationController
@pending_count
=
current_user
.
tasks
.
pending
.
count
@pending_count
=
current_user
.
tasks
.
pending
.
count
@done_count
=
current_user
.
tasks
.
done
.
count
@done_count
=
current_user
.
tasks
.
done
.
count
end
end
def
destroy
task
.
done!
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_tasks_path
,
notice:
'Task was successfully marked as done.'
}
format
.
js
{
render
nothing:
true
}
end
end
private
def
authorize_destroy_task!
unless
can?
(
current_user
,
:destroy_task
,
task
)
return
render_404
end
end
def
task
@task
||=
current_user
.
tasks
.
find
(
params
[
:id
])
end
end
end
app/models/ability.rb
View file @
77d7910b
...
@@ -17,6 +17,7 @@ class Ability
...
@@ -17,6 +17,7 @@ class Ability
when
Namespace
then
namespace_abilities
(
user
,
subject
)
when
Namespace
then
namespace_abilities
(
user
,
subject
)
when
GroupMember
then
group_member_abilities
(
user
,
subject
)
when
GroupMember
then
group_member_abilities
(
user
,
subject
)
when
ProjectMember
then
project_member_abilities
(
user
,
subject
)
when
ProjectMember
then
project_member_abilities
(
user
,
subject
)
when
Task
then
task_abilities
(
user
,
subject
)
else
[]
else
[]
end
.
concat
(
global_abilities
(
user
))
end
.
concat
(
global_abilities
(
user
))
end
end
...
@@ -416,6 +417,16 @@ class Ability
...
@@ -416,6 +417,16 @@ class Ability
rules
rules
end
end
def
task_abilities
(
user
,
task
)
rules
=
[]
if
task
&&
task
.
user
==
user
rules
<<
:destroy_task
end
rules
end
def
abilities
def
abilities
@abilities
||=
begin
@abilities
||=
begin
abilities
=
Six
.
new
abilities
=
Six
.
new
...
...
app/models/task.rb
View file @
77d7910b
...
@@ -32,6 +32,10 @@ class Task < ActiveRecord::Base
...
@@ -32,6 +32,10 @@ class Task < ActiveRecord::Base
scope
:done
,
->
{
with_state
(
:done
)
}
scope
:done
,
->
{
with_state
(
:done
)
}
state_machine
:state
,
initial: :pending
do
state_machine
:state
,
initial: :pending
do
event
:done
do
transition
pending: :done
end
state
:pending
state
:pending
state
:done
state
:done
end
end
...
...
app/views/dashboard/tasks/_task.html.haml
View file @
77d7910b
...
@@ -11,6 +11,10 @@
...
@@ -11,6 +11,10 @@
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
-
if
task
.
body?
-
if
task
.
body?
.task-body
.task-body
.task-note
.task-note
...
...
config/routes.rb
View file @
77d7910b
...
@@ -333,7 +333,7 @@ Rails.application.routes.draw do
...
@@ -333,7 +333,7 @@ Rails.application.routes.draw do
resources
:groups
,
only:
[
:index
]
resources
:groups
,
only:
[
:index
]
resources
:snippets
,
only:
[
:index
]
resources
:snippets
,
only:
[
:index
]
resources
:tasks
,
only:
[
:index
]
resources
:tasks
,
only:
[
:index
,
:destroy
]
resources
:projects
,
only:
[
:index
]
do
resources
:projects
,
only:
[
:index
]
do
collection
do
collection
do
...
...
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