Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable all tasks to be placed on timed hold #10728

Merged
merged 8 commits into from
May 14, 2019

Conversation

lowellrex
Copy link
Contributor

@lowellrex lowellrex commented May 13, 2019

Connects #9207.

  • Adds "Place task on hold" option to tasks that don't already have that option
    • Creates modal similar to the existing on hold page for ColocatedTasks
    • Continues using existing system for ColocatedTasks

@lowellrex lowellrex self-assigned this May 13, 2019
@ghost ghost added the In-Progress label May 13, 2019
@codeclimate
Copy link

codeclimate bot commented May 13, 2019

Code Climate has analyzed commit 9d272ae and detected 0 issues on this pull request.

View more on Code Climate.

multi_transaction do
if parent_task.is_a?(Task)
parent_task.update!(instructions: [parent_task.instructions, instructions].flatten.compact)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds instructions to the task that is being placed on hold so that the instructions display in the task snapshot.

@@ -10,17 +10,22 @@ class TimedHoldTask < GenericTask
after_create :cancel_active_siblings

attr_accessor :days_on_hold
validates :days_on_hold, presence: true, inclusion: { in: 1..100 }, on: :create
validates :days_on_hold, presence: true, inclusion: { in: 1..120 }, on: :create
Copy link
Contributor Author

@lowellrex lowellrex May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

120 days is a preset option for the colocated on hold length, so this matches that.

});
}

render = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Majority of this render function is copied from the existing ColocatedPlaceHoldView component that this modal will eventually replace entirely.

I didn't bother to factor out any of this into shared functions because the old component will be going away in short order as part of #9207.

@@ -62,4 +62,80 @@
end
end
end

describe "timed holds" do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Front-end tests for this new feature.

@lowellrex lowellrex requested a review from tomas-nava May 13, 2019 17:18
Copy link
Contributor

@tomas-nava tomas-nava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙆‍♂️looks good to me!

@lowellrex lowellrex added the Ready-to-Merge This PR is ready to be merged and will be picked up by va-bot to automatically merge to master label May 14, 2019
@lowellrex lowellrex merged commit bbd2a55 into master May 14, 2019
@lowellrex lowellrex deleted the lowell/9207_place_tasks_on_hold branch May 14, 2019 12:59
@ghost ghost removed the In-Progress label May 14, 2019
@@ -58,6 +61,8 @@ def available_actions(user)

[]
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for disabling Rubocop here? Why not extract the different arrays into well-named methods that represent the different action types? For example:

def available_actions(user)
  return [] unless user

  return actions_when_task_assigned_to_user if assigned_to == user

  if task_is_assigned_to_user_within_organization?(user)
    return actions_when_task_is_assigned_to_user_within_organization
  end

  if task_is_assigned_to_users_organization?(user)
    return actions_when_task_is_assigned_to_users_organization
  end

  []
end

def actions_when_task_is_assigned_to_user
  [
    Constants.TASK_ACTIONS.ASSIGN_TO_TEAM.to_h,
    Constants.TASK_ACTIONS.REASSIGN_TO_PERSON.to_h,
    appropriate_timed_hold_task_action,
    Constants.TASK_ACTIONS.MARK_COMPLETE.to_h,
    Constants.TASK_ACTIONS.CANCEL_TASK.to_h
  ]
end

def actions_when_task_is_assigned_to_user_within_organization
  [
    Constants.TASK_ACTIONS.REASSIGN_TO_PERSON.to_h
  ]
end

def actions_when_task_is_assigned_to_users_organization
  [
    Constants.TASK_ACTIONS.ASSIGN_TO_TEAM.to_h,
    Constants.TASK_ACTIONS.ASSIGN_TO_PERSON.to_h,
    Constants.TASK_ACTIONS.MARK_COMPLETE.to_h,
    Constants.TASK_ACTIONS.CANCEL_TASK.to_h
  ]
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready-to-Merge This PR is ready to be merged and will be picked up by va-bot to automatically merge to master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants