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
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
...
@@ -58,6 +58,8 @@ class @Sidebar
dataType
:
'json'
dataType
:
'json'
data
:
data
:
todo_id
:
$this
.
attr
(
'data-id'
)
todo_id
:
$this
.
attr
(
'data-id'
)
issuable_id
:
$this
.
data
(
'issuable'
)
issuable_type
:
$this
.
data
(
'issuable-type'
)
beforeSend
:
->
beforeSend
:
->
$this
.
disable
()
$this
.
disable
()
$todoLoading
.
removeClass
'hidden'
$todoLoading
.
removeClass
'hidden'
...
...
app/controllers/projects/issues_controller.rb
View file @
20d382a8
...
@@ -164,20 +164,6 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -164,20 +164,6 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
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
protected
def
issue
def
issue
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
20d382a8
...
@@ -260,20 +260,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -260,20 +260,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render
json:
response
render
json:
response
end
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
protected
def
selected_target_project
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
...
@@ -67,16 +67,6 @@ module IssuablesHelper
end
end
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
)
def
has_todo
(
issuable
)
unless
current_user
.
nil?
unless
current_user
.
nil?
current_user
.
todos
.
find_by
(
target_id:
issuable
.
id
,
state: :pending
)
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 @@
...
@@ -9,7 +9,7 @@
%a
.gutter-toggle.pull-right.js-sidebar-toggle
{
role:
"button"
,
href:
"#"
,
aria:
{
label:
"Toggle sidebar"
}
}
%a
.gutter-toggle.pull-right.js-sidebar-toggle
{
role:
"button"
,
href:
"#"
,
aria:
{
label:
"Toggle sidebar"
}
}
=
sidebar_gutter_toggle_icon
=
sidebar_gutter_toggle_icon
-
if
current_user
-
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
%span
.js-issuable-todo-text
-
if
todo
.
nil?
-
if
todo
.
nil?
Add Todo
Add Todo
...
...
config/routes.rb
View file @
20d382a8
...
@@ -679,7 +679,6 @@ Rails.application.routes.draw do
...
@@ -679,7 +679,6 @@ Rails.application.routes.draw do
post
:toggle_subscription
post
:toggle_subscription
post
:toggle_award_emoji
post
:toggle_award_emoji
post
:remove_wip
post
:remove_wip
post
:todo
end
end
collection
do
collection
do
...
@@ -760,7 +759,6 @@ Rails.application.routes.draw do
...
@@ -760,7 +759,6 @@ Rails.application.routes.draw do
get
:referenced_merge_requests
get
:referenced_merge_requests
get
:related_branches
get
:related_branches
get
:can_create_branch
get
:can_create_branch
post
:todo
end
end
collection
do
collection
do
post
:bulk_update
post
:bulk_update
...
@@ -791,6 +789,8 @@ Rails.application.routes.draw do
...
@@ -791,6 +789,8 @@ Rails.application.routes.draw do
end
end
end
end
resources
:todos
,
only:
[
:create
],
constraints:
{
id:
/\d+/
}
resources
:uploads
,
only:
[
:create
]
do
resources
:uploads
,
only:
[
:create
]
do
collection
do
collection
do
get
":secret/:filename"
,
action: :show
,
as: :show
,
constraints:
{
filename:
/[^\/]+/
}
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