summaryrefslogtreecommitdiff
path: root/app/controllers/projects
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-06-07 09:44:01 +0100
committerPhil Hughes <me@iamphill.com>2016-06-14 08:36:07 +0100
commitf67b06ada016915211e84a7d12a063aa25e422f3 (patch)
tree25b94f817c9971c5e347530cce1732f34ffd80f7 /app/controllers/projects
parentf34af6b83cc2663bb8a076f4df9c82047e5511ab (diff)
downloadgitlab-ce-f67b06ada016915211e84a7d12a063aa25e422f3.tar.gz
Manually create todo for issuable
Added a button into the sidebar for issues & merge requests to allow users to manually create todo items Closes #15045
Diffstat (limited to 'app/controllers/projects')
-rw-r--r--app/controllers/projects/issues_controller.rb14
-rw-r--r--app/controllers/projects/merge_requests_controller.rb14
2 files changed, 28 insertions, 0 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 4e2d3bebb2e..5678d584d4a 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -164,6 +164,20 @@ 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
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 67e7187c10d..f0eba453caa 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -260,6 +260,20 @@ 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