diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2017-01-16 14:11:08 +0100 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2017-02-17 22:12:19 +0100 |
commit | 26160459b56019f445a7d29abc0b72f591e1d2a9 (patch) | |
tree | bf7150c7eda9436f001decae56407ca3b3f718f8 /app/services | |
parent | 63330af84fb6ecdce4611af238af4233a436e260 (diff) | |
download | gitlab-ce-26160459b56019f445a7d29abc0b72f591e1d2a9.tar.gz |
Todo done clicking is kind of unusable.
The Done button will change to an Undo button and the line item will be greyed out.
Bold links will be unbolded.
The user can undo the task by clicking the Undo button.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/todo_service.rb | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 8ab943f4639..ad86b4f9f42 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -170,16 +170,20 @@ class TodoService # When user marks some todos as done def mark_todos_as_done(todos, current_user) - mark_todos_as_done_by_ids(todos.select(&:id), current_user) + update_todos_state_by_ids(todos.select(&:id), current_user, :done) end def mark_todos_as_done_by_ids(ids, current_user) - todos = current_user.todos.where(id: ids) + update_todos_state_by_ids(ids, current_user, :done) + end - # Only return those that are not really on that state - marked_todos = todos.where.not(state: :done).update_all(state: :done) - current_user.update_todos_count_cache - marked_todos + # When user marks some todos as pending + def mark_todos_as_pending(todos, current_user) + update_todos_state_by_ids(todos.select(&:id), current_user, :pending) + end + + def mark_todos_as_pending_by_ids(ids, current_user) + update_todos_state_by_ids(ids, current_user, :pending) end # When user marks an issue as todo @@ -194,6 +198,15 @@ class TodoService private + def update_todos_state_by_ids(ids, current_user, state) + todos = current_user.todos.where(id: ids) + + # Only return those that are not really on that state + marked_todos = todos.where.not(state: state).update_all(state: state) + current_user.update_todos_count_cache + marked_todos + end + def create_todos(users, attributes) Array(users).map do |user| next if pending_todos(user, attributes).exists? |