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
Boxiang Sun
gitlab-ce
Commits
20d382a8
Commit
20d382a8
authored
Jun 08, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved todo creation over to project todos controller
parent
f8a8999a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
41 deletions
+33
-41
app/assets/javascripts/right_sidebar.js.coffee
app/assets/javascripts/right_sidebar.js.coffee
+2
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+0
-14
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+0
-14
app/controllers/projects/todos_controller.rb
app/controllers/projects/todos_controller.rb
+28
-0
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+0
-10
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-1
config/routes.rb
config/routes.rb
+2
-2
No files found.
app/assets/javascripts/right_sidebar.js.coffee
View file @
20d382a8
...
...
@@ -58,6 +58,8 @@ class @Sidebar
dataType
:
'json'
data
:
todo_id
:
$this
.
attr
(
'data-id'
)
issuable_id
:
$this
.
data
(
'issuable'
)
issuable_type
:
$this
.
data
(
'issuable-type'
)
beforeSend
:
->
$this
.
disable
()
$todoLoading
.
removeClass
'hidden'
...
...
app/controllers/projects/issues_controller.rb
View file @
20d382a8
...
...
@@ -164,20 +164,6 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
def
todo
json_data
=
Hash
.
new
if
params
[
:todo_id
].
nil?
TodoService
.
new
.
mark_todo
(
issue
,
current_user
)
json_data
[
:todo
]
=
current_user
.
todos
.
find_by
(
state: :pending
,
action:
Todo
::
MARKED
,
target_id:
issue
.
id
)
else
current_user
.
todos
.
find_by_id
(
params
[
:todo_id
]).
update
(
state: :done
)
end
render
json:
json_data
.
merge
({
count:
current_user
.
todos
.
pending
.
count
})
end
protected
def
issue
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
20d382a8
...
...
@@ -260,20 +260,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render
json:
response
end
def
todo
json_data
=
Hash
.
new
if
params
[
:todo_id
].
nil?
TodoService
.
new
.
mark_todo
(
merge_request
,
current_user
)
json_data
[
:todo
]
=
current_user
.
todos
.
find_by
(
state: :pending
,
action:
Todo
::
MARKED
,
target_id:
merge_request
.
id
)
else
current_user
.
todos
.
find_by_id
(
params
[
:todo_id
]).
update
(
state: :done
)
end
render
json:
json_data
.
merge
({
count:
current_user
.
todos
.
pending
.
count
})
end
protected
def
selected_target_project
...
...
app/controllers/projects/todos_controller.rb
0 → 100644
View file @
20d382a8
class
Projects::TodosController
<
Projects
::
ApplicationController
def
create
json_data
=
Hash
.
new
if
params
[
:todo_id
].
nil?
TodoService
.
new
.
mark_todo
(
issuable
,
current_user
)
json_data
[
:todo
]
=
current_user
.
todos
.
find_by
(
state: :pending
,
action:
Todo
::
MARKED
,
target_id:
issuable
.
id
)
else
current_user
.
todos
.
find_by_id
(
params
[
:todo_id
]).
update
(
state: :done
)
end
render
json:
json_data
.
merge
({
count:
current_user
.
todos
.
pending
.
count
})
end
private
def
issuable
@issuable
||=
begin
case
params
[
:issuable_type
]
when
"issue"
@project
.
issues
.
find
(
params
[
:issuable_id
])
when
"merge_request"
@project
.
merge_requests
.
find
(
params
[
:issuable_id
])
end
end
end
end
app/helpers/issuables_helper.rb
View file @
20d382a8
...
...
@@ -67,16 +67,6 @@ module IssuablesHelper
end
end
def
issuable_todo_path
(
issuable
)
project
=
issuable
.
project
if
issuable
.
kind_of?
(
MergeRequest
)
todo_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
issuable
.
iid
,
:json
)
else
todo_namespace_project_issue_path
(
project
.
namespace
,
project
,
issuable
.
iid
,
:json
)
end
end
def
has_todo
(
issuable
)
unless
current_user
.
nil?
current_user
.
todos
.
find_by
(
target_id:
issuable
.
id
,
state: :pending
)
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
20d382a8
...
...
@@ -9,7 +9,7 @@
%a
.gutter-toggle.pull-right.js-sidebar-toggle
{
role:
"button"
,
href:
"#"
,
aria:
{
label:
"Toggle sidebar"
}
}
=
sidebar_gutter_toggle_icon
-
if
current_user
%button
.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo
{
type:
"button"
,
aria:
{
label:
(
todo
.
nil?
?
"Add Todo"
:
"Mark Done"
)
},
data:
{
todo_text:
"Add Todo"
,
mark_text:
"Mark Done"
,
id:
(
todo
.
id
unless
todo
.
nil?
),
url:
issuable_todo_path
(
issuable
)
}
}
%button
.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo
{
type:
"button"
,
aria:
{
label:
(
todo
.
nil?
?
"Add Todo"
:
"Mark Done"
)
},
data:
{
todo_text:
"Add Todo"
,
mark_text:
"Mark Done"
,
id:
(
todo
.
id
unless
todo
.
nil?
),
issuable:
issuable
.
id
,
issuable_type:
issuable
.
class
.
name
.
underscore
,
url:
namespace_project_todos_path
(
@project
.
namespace
,
@project
,
:json
)
}
}
%span
.js-issuable-todo-text
-
if
todo
.
nil?
Add Todo
...
...
config/routes.rb
View file @
20d382a8
...
...
@@ -679,7 +679,6 @@ Rails.application.routes.draw do
post
:toggle_subscription
post
:toggle_award_emoji
post
:remove_wip
post
:todo
end
collection
do
...
...
@@ -760,7 +759,6 @@ Rails.application.routes.draw do
get
:referenced_merge_requests
get
:related_branches
get
:can_create_branch
post
:todo
end
collection
do
post
:bulk_update
...
...
@@ -791,6 +789,8 @@ Rails.application.routes.draw do
end
end
resources
:todos
,
only:
[
:create
],
constraints:
{
id:
/\d+/
}
resources
:uploads
,
only:
[
:create
]
do
collection
do
get
":secret/:filename"
,
action: :show
,
as: :show
,
constraints:
{
filename:
/[^\/]+/
}
...
...
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