Commit d53ae7f1 authored by Douwe Maan's avatar Douwe Maan

Add "Mark all as done" button

parent 57d16552
class Dashboard::TodosController < Dashboard::ApplicationController
before_filter :find_todos, only: [:index, :destroy_all]
def index
@todos = TodosFinder.new(current_user, params).execute
@todos = @todos.page(params[:page]).per(PER_PAGE)
end
......@@ -13,9 +14,22 @@ class Dashboard::TodosController < Dashboard::ApplicationController
end
end
def destroy_all
@todos.each(&:done)
respond_to do |format|
format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' }
format.js { render nothing: true }
end
end
private
def todo
@todo ||= current_user.todos.find(params[:id])
end
def find_todos
@todos = TodosFinder.new(current_user, params).execute
end
end
......@@ -19,6 +19,32 @@ module TodosHelper
todo.project, todo.target], anchor: anchor)
end
def todos_filter_params
{
state: params[:state],
project_id: params[:project_id],
author_id: params[:author_id],
type: params[:type],
action_id: params[:action_id],
}
end
def todos_filter_path(options = {})
without = options.delete(:without)
options = todos_filter_params.merge(options)
if without.present?
without.each do |key|
options.delete(key)
end
end
path = request.path
path << "?#{options.to_param}"
path
end
def todo_actions_options
actions = [
OpenStruct.new(id: '', title: 'Any Action'),
......
......@@ -4,21 +4,25 @@
.top-area
%ul.nav-links
%li{class: ('active' if params[:state].blank? || params[:state] == 'pending')}
= link_to page_filter_path(state: 'pending') do
= link_to todos_filter_path(state: 'pending') do
%span
To do
%span{class: 'badge'}
= todos_pending_count
%li{class: ('active' if params[:state] == 'done')}
= link_to page_filter_path(state: 'done') do
= link_to todos_filter_path(state: 'done') do
%span
Done
%span{class: 'badge'}
= todos_done_count
.nav-controls
- if @todos.any?(&:pending?)
= link_to 'Mark all as done', destroy_all_dashboard_todos_path(todos_filter_params), class: 'btn', method: :delete
.todos-filters
.gray-content-block.second-block
= form_tag page_filter_path(without: [:assignee_id, :milestone_title, :label_name, :scope, :sort]), method: :get, class: 'filter-form' do
= form_tag todos_filter_path(without: [:project_id, :author_id, :type, :action_id]), method: :get, class: 'filter-form' do
.filter-item.inline
= select_tag('project_id', todo_projects_options,
class: 'select2 trigger-submit', include_blank: true,
......@@ -47,7 +51,7 @@
= render group[1]
= paginate @todos, theme: "gitlab"
- else
.nothing-here-block No todos to show
.nothing-here-block You're all done!
:javascript
new UsersSelect();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment