diff options
author | Jacob Schatz <jschatz1@gmail.com> | 2016-03-18 11:23:16 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2016-03-18 11:23:16 +0000 |
commit | 4cd87d31bd2d8401dbfa968494a3fc7a869dbf2d (patch) | |
tree | 3bb5a62a82d18446d432e7ea64a1fd455a1a53ac /app/controllers | |
parent | ad04a9118828ea072df46c06b599b75d1e22fd47 (diff) | |
parent | ceaa6943919041c204ec86ebea0347374dffdd44 (diff) | |
download | gitlab-ce-4cd87d31bd2d8401dbfa968494a3fc7a869dbf2d.tar.gz |
Merge branch 'optimistic-todos' into 'master'
Adds small AJAX optimistic functionality to todos.
Fixes #13656 <br/>
A good first step and boring solution. <br/>
Will make ajax call to remove each issue. <br/>
If issue is last in group of issues will refresh page. <br/>
If issues remain in group will remove row with JS. <br/>
Adds loading spinner to button and disables. <br/>
![todos-optimistic](/uploads/c6aec4a688e5125d4df55a2a3a55d4d7/todos-optimistic.gif) <br/>
cc @dzaporozhets @JobV @dbalexandre
See merge request !2946
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 43cf8fa71af..7857af9c5de 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -1,5 +1,5 @@ class Dashboard::TodosController < Dashboard::ApplicationController - before_action :find_todos, only: [:index, :destroy_all] + before_action :find_todos, only: [:index, :destroy, :destroy_all] def index @todos = @todos.page(params[:page]).per(PER_PAGE) @@ -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: { count: @todos.size, done_count: current_user.todos.done.count } + end end end @@ -20,6 +25,10 @@ class Dashboard::TodosController < Dashboard::ApplicationController respond_to do |format| format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' } format.js { render nothing: true } + format.json do + find_todos + render json: { count: @todos.size, done_count: current_user.todos.done.count } + end end end |