Skip to content

Commit

Permalink
Merge branch 'feature/APPEALS-24914' into piedram/Fix-refactor-error
Browse files Browse the repository at this point in the history
  • Loading branch information
cacevesva authored Sep 1, 2023
2 parents 0769ed7 + 7e9ef7d commit cf1ea25
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 45 deletions.
51 changes: 27 additions & 24 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def cannot_have_children
end

def verify_user_can_create!(user, parent)

can_create = parent&.available_actions(user)&.map do |action|
parent.build_action_hash(action, user)
end&.any? do |action|
Expand Down Expand Up @@ -232,38 +231,43 @@ def create_from_params(params, user)
params = modify_params_for_create(params)

if parent_task.appeal_type == "LegacyAppeal"
special_case_for_legacy(parent_task, params)
else #regular appeal
special_case_for_legacy(parent_task, params, user)
else # regular appeal
child = create_child_task(parent_task, user, params)
parent_task.update!(status: params[:status]) if params[:status]
child
end

end


def create_parent_task(params, user)
parent_task = { }
if (params[:appeal_type] == 'LegacyAppeal' and params[:legacy_task_type] == 'AttorneyLegacyTask')
if (params[:type] == "SpecialCaseMovementTask" || params[:type] == "BlockedSpecialCaseMovementTask")
parent_task = {}
if (params[:appeal_type] == "LegacyAppeal") && (params[:legacy_task_type] == "AttorneyLegacyTask")
if params[:type] == "SpecialCaseMovementTask" || params[:type] == "BlockedSpecialCaseMovementTask"
parent_task = LegacyWorkQueue.tasks_by_appeal_id(params[:external_id])[0]
verify_user_can_create_legacy!(user, parent_task)
parent_task = Task.find(params[:parent_id])
end
else
parent_task = Task.find(params[:parent_id])
fail Caseflow::Error::ChildTaskAssignedToSameUser if parent_of_same_type_has_same_assignee(parent_task, params)

verify_user_can_create!(user, parent_task)
end
return parent_task
parent_task
end


def special_case_for_legacy(parent_task, params)
if (params[:type] == "SpecialCaseMovementTask" and parent_task.type == "RootTask")
def special_case_for_legacy(parent_task, params, user)
if (params[:type] == "SpecialCaseMovementTask") && (parent_task.type == "RootTask")
create_judge_assigned_task_for_legacy(params, parent_task)
elsif (params[:type] == "BlockedSpecialCaseMovementTask" and parent_task.type == "HearingTask")
elsif (params[:type] == "BlockedSpecialCaseMovementTask") && (parent_task.type == "HearingTask")
cancel_blocking_task_legacy(params, parent_task)
else
judge = User.find(params["assigned_to_id"])
legacy_appeal = LegacyAppeal.find(parent_task.appeal_id)
child = create_child_task(parent_task, user, params)
parent_task.update!(status: params[:status]) if params[:status]
AppealRepository.update_location!(legacy_appeal, judge.vacols_uniq_id)
child
end
end

Expand Down Expand Up @@ -311,26 +315,25 @@ def cancel_blocking_task_legacy(params, parent_task)
judge = User.find(params["assigned_to_id"])

current_child = JudgeAssignTask.create!(appeal: legacy_appeal,
parent: legacy_appeal.root_task,
assigned_to: judge,
instructions: params[:instructions],
assigned_by: params["assigned_by"])
parent: legacy_appeal.root_task,
assigned_to: judge,
instructions: params[:instructions],
assigned_by: params["assigned_by"])
AppealRepository.update_location!(legacy_appeal, judge.vacols_uniq_id)
return current_child

current_child
end

def create_judge_assigned_task_for_legacy(params, parent_task)
legacy_appeal = LegacyAppeal.find(parent_task.appeal_id)
judge = User.find(params["assigned_to_id"])

current_child = JudgeAssignTask.create!(appeal: legacy_appeal,
parent: legacy_appeal.root_task,
assigned_to: judge,
instructions: params[:instructions],
assigned_by: params["assigned_by"])
parent: legacy_appeal.root_task,
assigned_to: judge,
instructions: params[:instructions],
assigned_by: params["assigned_by"])
AppealRepository.update_location!(legacy_appeal, judge.vacols_uniq_id)
return current_child
current_child
end

def parent_of_same_type_has_same_assignee(parent_task, params)
Expand Down
2 changes: 1 addition & 1 deletion client/COPY.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"NO_CASES_IN_QUEUE_MESSAGE": "You have no cases assigned to you. You can ",
"NO_CASES_IN_QUEUE_LINK_TEXT": "search for cases",
"ATTORNEY_QUEUE_TABLE_TITLE": "Your cases",
"ATTORNEY_QUEUE_TABLE_SUCCESS_MESSAGE_DETAIL": "If you made a mistake, please email your judge to resolve the issue.",
"ATTORNEY_QUEUE_TABLE_SUCCESS_MESSAGE_DETAIL": "If you need to make any changes, please manage this case in DAS",
"ATTORNEY_QUEUE_TABLE_TASK_NEEDS_ASSIGNMENT_ERROR_MESSAGE": "Please ask your judge to assign this case to you in DAS",
"ATTORNEY_QUEUE_TABLE_TASK_NO_DOCUMENTS_READER_LINK": "View in Reader",
"ORGANIZATION_QUEUE_TABLE_TITLE": "%s cases",
Expand Down
3 changes: 2 additions & 1 deletion client/app/queue/AssignToView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class AssignToView extends React.Component {

const action = getAction(this.props);
const actionData = taskActionData(this.props);
actionData.drop_down_label = COPY.JUDGE_LEGACY_DECISION_REVIEW_TITLE
const isPulacCerullo = action && action.label === 'Pulac-Cerullo';

if (!task || task.availableActions.length === 0) {
Expand All @@ -354,6 +355,7 @@ class AssignToView extends React.Component {
submit: this.submit,
submitButtonClassNames: ['usa-button'],
submitDisabled: !this.validateForm(),
button: 'Assign',
validateForm: isPulacCerullo ?
() => {
return true;
Expand All @@ -362,7 +364,6 @@ class AssignToView extends React.Component {
};

if (task.type === 'JudgeLegacyDecisionReviewTask') {
modalProps.button = 'Assign';
modalProps.submitButtonClassNames = ['usa-button', 'usa-button-hover', 'usa-button-warning'];
modalProps.submitDisabled = this.state.modalDisableButton;
}
Expand Down
9 changes: 7 additions & 2 deletions client/app/queue/BlockedAdvanceToJudgeView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class BlockedAdvanceToJudgeView extends React.Component {
assignedByListItem(), this.getAssigneeLabel()),
detail: sprintf(COPY.ASSIGN_TASK_SUCCESS_MESSAGE_MOVE_LEGACY_APPEALS_VLJ_MESSAGE_DETAIL)
};
localStorage.setItem('SCMLegacyMsg', JSON.stringify(successMessage));
} else {
successMessage = {
title: sprintf(COPY.ASSIGN_TASK_SUCCESS_MESSAGE, this.getAssigneeLabel()),
Expand All @@ -188,7 +189,11 @@ class BlockedAdvanceToJudgeView extends React.Component {
then((resp) => {
this.props.history.replace(`/queue/appeals/${appeal.externalId}`);
if (resp.body !== null) {
this.props.onReceiveAmaTasks(resp.body.tasks.data);
if (appeal.isLegacyAppeal) {
window.location.reload();
} else {
this.props.onReceiveAmaTasks(resp.body.tasks.data);
}
}
}).
catch((err) => {
Expand Down Expand Up @@ -266,7 +271,7 @@ class BlockedAdvanceToJudgeView extends React.Component {
onChange={(option) => this.setModalOnChangeValue('selectedAssignee', option ? option.value : null)}
options={options}
/>
<h3>{sprintf(COPY.BLOCKED_SPECIAL_CASE_MOVEMENT_MODAL_INSTRUCTIONS_HEADER, selectedJudgeName)}</h3>
<h3 className="blocked-advanced-h3">{sprintf(COPY.BLOCKED_SPECIAL_CASE_MOVEMENT_MODAL_INSTRUCTIONS_HEADER, selectedJudgeName)}</h3>
<TextareaField
required
errorMessage={highlightFormItems && !this.validInstructions() ? 'Judge instructions field is required' : null}
Expand Down
16 changes: 16 additions & 0 deletions client/app/queue/CaseDetailsView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,16 @@ export const CaseDetailsView = (props) => {

localStorage.removeItem('SplitAppealSuccess');

// Retrieve Special case movement user with legacy Appeal, success and remove from the store
const scmLegacyStorage = localStorage.getItem('SCMLegacyMsg');

localStorage.removeItem('SCMLegacyMsg');

// if null, leave null, if true, check if value is true with reg expression.
const splitAppealSuccess = (splitStorage === null ? null : (/true/i).test(splitStorage));

const SCMSuccessLegacyAppeal = (scmLegacyStorage === null ? null : JSON.parse(scmLegacyStorage));

return (
<React.Fragment>
{(splitAppealSuccess && props.featureToggles.split_appeal_workflow) && (
Expand All @@ -255,6 +262,15 @@ export const CaseDetailsView = (props) => {
</Alert>
</div>
)}
{(SCMSuccessLegacyAppeal && props.featureToggles.vlj_legacy_appeal) && (
<div>
<Alert
type="success"
title={SCMSuccessLegacyAppeal.title}
message={SCMSuccessLegacyAppeal.detail}
/>
</div>
)}
{!modalIsOpen && error && (
<div {...alertPaddingStyle}>
<Alert title={error.title} type="error">
Expand Down
6 changes: 4 additions & 2 deletions client/app/queue/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ export const distributionTasksForAppeal = createSelector(

export const caseTimelineTasksForAppeal = createSelector(
[getAllTasksForAppeal],
(tasks) => orderBy(filter(completeTasksSelector(tasks), (task) => !task.hideFromCaseTimeline), ['completedAt'], ['desc'])
(tasks) => orderBy(filter(completeTasksSelector(tasks), (task) =>
!task.hideFromCaseTimeline), ['completedAt'], ['desc'])
);

export const taskSnapshotTasksForAppeal = createSelector(
[getAllTasksForAppeal],
(tasks) => orderBy(filter(incompleteTasksSelector(tasks), (task) => !task.hideFromTaskSnapshot), ['createdAt'], ['desc'])
(tasks) => orderBy(filter(incompleteTasksSelector(tasks), (task) =>
!task.hideFromTaskSnapshot), ['createdAt'], ['desc'])
);

const taskIsLegacyAttorneyJudgeTask = (task) => {
Expand Down
5 changes: 5 additions & 0 deletions client/app/styles/_style_guide.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
margin-bottom: 30px;
}

.blocked-advanced-h3 {
margin-top: 35px;
margin-bottom: 0px;
}

.sg-colors-swatches {
overflow: auto;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def format_hearing_day(hearing_day, detail_label = nil, total_slots = 0)
click_dropdown(text: Constants.TASK_ACTIONS.ASSIGN_TO_PERSON.to_h[:label])
end

click_on "Submit"
click_on "Assign"

# Your queue
visit "/queue"
Expand All @@ -573,7 +573,7 @@ def format_hearing_day(hearing_day, detail_label = nil, total_slots = 0)

click_dropdown({ text: other_user.full_name }, find(".cf-modal-body"))
fill_in COPY::ADD_COLOCATED_TASK_INSTRUCTIONS_LABEL, with: "Reassign"
click_on "Submit"
click_on "Assign"

# Case should exist in other users' queue
User.authenticate!(user: other_user)
Expand Down Expand Up @@ -605,7 +605,7 @@ def format_hearing_day(hearing_day, detail_label = nil, total_slots = 0)
expect(page).to have_content("You have assigned an administrative action")

click_dropdown(text: Constants.TASK_ACTIONS.ASSIGN_TO_PERSON.to_h[:label])
click_on "Submit"
click_on "Assign"

# Your queue
visit "/queue"
Expand Down
4 changes: 2 additions & 2 deletions spec/feature/queue/ama_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def judge_assign_to_attorney
expect(dropdown_selected_value(find(".cf-modal-body"))).to eq attorney_user.full_name
fill_in "taskInstructions", with: "Please fix this"

click_on "Submit"
click_on "Assign"

expect(page).to have_content("Task assigned to #{attorney_user.full_name}")
end
Expand Down Expand Up @@ -672,7 +672,7 @@ def judge_assign_to_attorney
expect(dropdown_selected_value(find(".cf-modal-body"))).to eq attorney_user.full_name
fill_in "taskInstructions", with: "Please fix this"

click_on "Submit"
click_on "Assign"

expect(page).to have_content("Task assigned to #{attorney_user.full_name}")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/queue/cavc_task_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@

click_dropdown(text: Constants.TASK_ACTIONS.SEND_TO_TRANSLATION_BLOCKING_DISTRIBUTION.label)
fill_in "taskInstructions", with: "Please translate the documents in spanish"
click_on "Submit"
click_on "Assign"
expect(page).to have_content COPY::ASSIGN_TASK_SUCCESS_MESSAGE % Translation.singleton.name
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/queue/mail_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
text = Constants.TASK_ACTIONS.ASSIGN_TO_PERSON.label
click_dropdown(prompt: prompt, text: text)
fill_in("taskInstructions", with: "instructions")
click_button("Submit")
click_button("Assign")

expect(page).to have_content(format(COPY::ASSIGN_TASK_SUCCESS_MESSAGE, user.full_name))
expect(page.current_path).to eq("/queue")
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/queue/motion_to_vacate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
find("div", class: "cf-select__option", text: "Assign to person").click
find(".cf-modal .cf-select__control").click
find("div", class: "cf-select__option", text: "Motions attorney").click
click_button(text: "Submit")
click_button(text: "Assign")
expect(page).to have_content("Task assigned to Motions attorney")
motions_attorney_task = VacateMotionMailTask.find_by(assigned_to: motions_attorney)
expect(motions_attorney_task).to_not be_nil
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/queue/privacy_team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
# Assignee dropdown selector should be hidden.
expect(find_all(".cf-modal-body .cf-select__control").count).to eq(0)
fill_in("taskInstructions", with: instructions_text)
find("button", text: "Submit").click
find("button", text: "Assign").click

expect(page).to have_content("Task assigned to #{PrivacyTeam.singleton.name}")

Expand Down
4 changes: 2 additions & 2 deletions spec/feature/queue/quality_review_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
find("div", class: "cf-select__option", text: Constants.TASK_ACTIONS.ASSIGN_TO_PERSON.to_h[:label]).click

fill_in "taskInstructions", with: "Review the quality"
click_on "Submit"
click_on "Assign"

expect(page).to have_content("Task assigned to #{qr_user_name}")

Expand All @@ -101,7 +101,7 @@
expect(dropdown_selected_value(find(".cf-modal-body"))).to eq judge_user.full_name
fill_in "taskInstructions", with: qr_instructions

click_on "Submit"
click_on "Assign"

expect(page).to have_content("On hold (1)")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/queue/task_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def validate_pulac_cerullo_tasks_created(task_class, label)
expect(dropdown_selected_value(find(".cf-modal-body"))).to eq attorney_user.full_name
fill_in "taskInstructions", with: "Please fix this"

click_on COPY::MODAL_SUBMIT_BUTTON
click_on COPY::MODAL_ASSIGN_BUTTON

expect(page).to have_content(COPY::ASSIGN_TASK_SUCCESS_MESSAGE % attorney_user.full_name)

Expand Down
6 changes: 3 additions & 3 deletions spec/models/legacy_tasks/judge_legacy_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@
it "returns only case movement actions" do
expect(subject).to match_array [
Constants.TASK_ACTIONS.REASSIGN_TO_LEGACY_JUDGE.to_h,
Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY.to_h
Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY_LEGACY.to_h
]
end
end
end

context "when the user is on the special case movement team" do
let(:user) { create(:user).tap { |scm_user| SpecialCaseMovementTeam.singleton.add_user(scm_user) } }

it "returns only case movement actions" do
expect(subject).to match_array [
Constants.TASK_ACTIONS.REASSIGN_TO_LEGACY_JUDGE.to_h,
Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY.to_h
Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY_LEGACY.to_h
]
end
end
Expand Down

0 comments on commit cf1ea25

Please sign in to comment.