diff --git a/app/controllers/legacy_tasks_controller.rb b/app/controllers/legacy_tasks_controller.rb index 2f68f438334..96e91c7d542 100644 --- a/app/controllers/legacy_tasks_controller.rb +++ b/app/controllers/legacy_tasks_controller.rb @@ -96,6 +96,9 @@ def assign_to_judge # update the location to the assigned judge. QueueRepository.update_location_to_judge(appeal.vacols_id, assigned_to) + # Remove overtime status of an appeal when reassigning to a judge + appeal.overtime = false if appeal.overtime? + render json: { task: json_task(AttorneyLegacyTask.from_vacols( VACOLS::CaseAssignment.latest_task_for_appeal(appeal.vacols_id), diff --git a/app/models/task.rb b/app/models/task.rb index b137d902b01..eba4790cda3 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -517,6 +517,8 @@ def reassign(reassign_params, current_user) update_with_instructions(status: Constants.TASK_STATUSES.cancelled, instructions: reassign_params[:instructions]) + appeal.overtime = false if appeal.overtime? && reassign_clears_overtime? + [sibling, self, sibling.children].flatten end @@ -593,6 +595,10 @@ def cancelled_by User.find_by_id(record.whodunnit) end + def reassign_clears_overtime? + false + end + private def create_and_auto_assign_child_task(options = {}) diff --git a/app/models/tasks/attorney_task.rb b/app/models/tasks/attorney_task.rb index 9e5c44cfa93..fb371b371dc 100644 --- a/app/models/tasks/attorney_task.rb +++ b/app/models/tasks/attorney_task.rb @@ -48,6 +48,10 @@ def stays_with_reassigned_parent? super || completed? end + def reassign_clears_overtime? + true + end + def send_back_to_judge_assign! transaction do cancelled! diff --git a/app/models/tasks/judge_task.rb b/app/models/tasks/judge_task.rb index 455ec14c704..875138f0b67 100644 --- a/app/models/tasks/judge_task.rb +++ b/app/models/tasks/judge_task.rb @@ -41,4 +41,8 @@ def timeline_title def previous_task children_attorney_tasks.order(:assigned_at).last end + + def reassign_clears_overtime? + true + end end diff --git a/client/app/queue/AssignToView.jsx b/client/app/queue/AssignToView.jsx index ca9a09f70e2..4452f77e334 100644 --- a/client/app/queue/AssignToView.jsx +++ b/client/app/queue/AssignToView.jsx @@ -9,13 +9,13 @@ import COPY from '../../COPY'; import { taskById, appealWithDetailSelector } from './selectors'; -import { onReceiveAmaTasks, legacyReassignToJudge } from './QueueActions'; +import { onReceiveAmaTasks, legacyReassignToJudge, setOvertime } from './QueueActions'; import SearchableDropdown from '../components/SearchableDropdown'; import TextareaField from '../components/TextareaField'; import QueueFlowModal from './components/QueueFlowModal'; -import { requestPatch, requestSave } from './uiReducer/uiActions'; +import { requestPatch, requestSave, resetSuccessMessages } from './uiReducer/uiActions'; import { taskActionData } from './utils'; @@ -59,6 +59,8 @@ class AssignToView extends React.Component { }; } + componentDidMount = () => this.props.resetSuccessMessages(); + validateForm = () => { return this.state.selectedValue !== null && this.state.instructions !== ''; }; @@ -145,6 +147,9 @@ class AssignToView extends React.Component { return this.props.requestPatch(`/tasks/${task.taskId}`, payload, successMsg).then((resp) => { this.props.onReceiveAmaTasks(resp.body.tasks.data); + if (task.type === 'JudgeAssignTask') { + this.props.setOvertime(task.externalAppealId, false); + } }); }; @@ -241,7 +246,8 @@ class AssignToView extends React.Component { AssignToView.propTypes = { appeal: PropTypes.shape({ - externalId: PropTypes.string + externalId: PropTypes.string, + id: PropTypes.string }), assigneeAlreadySelected: PropTypes.bool, highlightFormItems: PropTypes.bool, @@ -254,8 +260,12 @@ AssignToView.propTypes = { task: PropTypes.shape({ instructions: PropTypes.string, taskId: PropTypes.string, - availableActions: PropTypes.arrayOf(PropTypes.object) - }) + availableActions: PropTypes.arrayOf(PropTypes.object), + externalAppealId: PropTypes.string, + type: PropTypes.string + }), + setOvertime: PropTypes.func, + resetSuccessMessages: PropTypes.func }; const mapStateToProps = (state, ownProps) => { @@ -274,7 +284,9 @@ const mapDispatchToProps = (dispatch) => requestPatch, requestSave, onReceiveAmaTasks, - legacyReassignToJudge + legacyReassignToJudge, + setOvertime, + resetSuccessMessages }, dispatch ); diff --git a/client/app/queue/QueueActions.js b/client/app/queue/QueueActions.js index c4bc3746936..227c198486b 100644 --- a/client/app/queue/QueueActions.js +++ b/client/app/queue/QueueActions.js @@ -220,7 +220,7 @@ export const setOvertime = (appealId, overtime) => ({ appealId, overtime } -}) +}); export const deleteTask = (taskId) => ({ type: ACTIONS.DELETE_TASK, @@ -534,6 +534,8 @@ export const reassignTasksToUser = ({ dispatch(decrementTaskCountForAttorney({ id: previousAssigneeId })); + + dispatch(setOvertime(oldTask.externalAppealId, false)); }); })); @@ -557,6 +559,8 @@ export const legacyReassignToJudge = ({ dispatch(onReceiveTasks(_.pick(allTasks, ['tasks', 'amaTasks']))); dispatch(showSuccessMessage(successMessage)); + + dispatch(setOvertime(oldTask.externalAppealId, false)); }); })); diff --git a/client/app/queue/components/AssignToAttorneyWidget.jsx b/client/app/queue/components/AssignToAttorneyWidget.jsx index fed268e3234..c39ad1cba68 100644 --- a/client/app/queue/components/AssignToAttorneyWidget.jsx +++ b/client/app/queue/components/AssignToAttorneyWidget.jsx @@ -47,6 +47,8 @@ class AssignToAttorneyWidget extends React.PureComponent { }; } + componentDidMount = () => this.props.resetSuccessMessages(); + validAssignee = () => { const { selectedAssignee } = this.props; diff --git a/spec/controllers/legacy_tasks_controller_spec.rb b/spec/controllers/legacy_tasks_controller_spec.rb index 13e7e0182c6..e382ffcf5b3 100644 --- a/spec/controllers/legacy_tasks_controller_spec.rb +++ b/spec/controllers/legacy_tasks_controller_spec.rb @@ -448,5 +448,30 @@ end it_behaves_like "judge reassigns case" end + + context "When the appeal has not been marked for overtime" do + before { FeatureToggle.enable!(:overtime_revamp) } + after { FeatureToggle.disable!(:overtime_revamp) } + + it "does not create a new work mode for the appeal" do + expect(appeal.work_mode.nil?).to be true + patch :assign_to_judge, params: { tasks: params } + expect(appeal.work_mode.nil?).to be true + end + end + + context "when the appeal has been marked for overtime" do + before do + FeatureToggle.enable!(:overtime_revamp) + appeal.overtime = true + end + after { FeatureToggle.disable!(:overtime_revamp) } + + it "removes the overtime status of the appeal" do + expect(appeal.overtime?).to be true + patch :assign_to_judge, params: { tasks: params } + expect(appeal.reload.overtime?).to be false + end + end end end diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index c35577e418a..4737df2ed14 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -897,6 +897,64 @@ end end end + + context "When the appeal has not been marked for overtime" do + let!(:appeal) { create(:appeal) } + let(:task) { create(:ama_judge_assign_task, appeal: appeal) } + + before { FeatureToggle.enable!(:overtime_revamp) } + after { FeatureToggle.disable!(:overtime_revamp) } + + it "does not create a new work mode for the appeal" do + expect(appeal.work_mode.nil?).to be true + subject + expect(appeal.work_mode.nil?).to be true + end + end + + context "When the appeal has been marked for overtime" do + shared_examples "clears overtime" do + it "sets overtime to false" do + expect(appeal.overtime?).to be true + subject + expect(appeal.overtime?).to be false + end + end + + let!(:appeal) { create(:appeal) } + let(:task) { create(:ama_task, appeal: appeal.reload) } + + before do + appeal.overtime = true + FeatureToggle.enable!(:overtime_revamp) + end + after { FeatureToggle.disable!(:overtime_revamp) } + + context "when the task type is not a judge or attorney task" do + it "does not clear the overtime status" do + expect(appeal.overtime?).to be true + subject + expect(appeal.overtime?).to be true + end + end + + context "when the task is a judge task" do + let(:task) { create(:ama_judge_assign_task, appeal: appeal) } + + it_behaves_like "clears overtime" + end + + context "when the task is an attorney task" do + let(:judge) { create(:user, :judge) } + let(:attorney) { create(:user, :attorney) } + let(:new_assignee) { create(:user, :attorney) } + let(:task) { create(:ama_attorney_rewrite_task, assigned_to: attorney, assigned_by: judge, appeal: appeal) } + + subject { task.reassign(params, judge) } + + it_behaves_like "clears overtime" + end + end end describe ".verify_org_task_unique" do