casa icon indicating copy to clipboard operation
casa copied to clipboard

Bug: Case Contact Contact Type Selection

Open elasticspoon opened this issue 1 year ago • 6 comments

Can create contact types on a case contact that should not be allowed on it.

Steps: Volunteer manages cases A and B. Case A => Restrict contact types to just Casa Case B => Restrict contact types to just Judge.

As volunteer go to page for Case A, create new case contact. Available cases will be A and B with only A selected. Available contact types will be Casa and Judge.

Select Judge, complete form.

Case contact now has a contact type if should have been restricted from having. If you go to edit page for that case contact the contact type will not appear but it is on the record.

CaseContact.find(case_id).contact_types will include Judge.

https://www.loom.com/share/434f152958a5440c8bce9830c4c6f3b9?sid=bdf91748-7e24-4c47-9b71-098b8c91a83d

Possible Solutions / Considerations

  • volunteers are not super tech savy, if you use a validation they might miss that it happened and just leave the page incomplete, ideally we want to make this as easy for them as possible
  • a solution that filters down the available topics based on selected cases using Javascript seems like the best choice

elasticspoon avatar Apr 12 '24 19:04 elasticspoon

Can I grab this?

mgrigoriev8109 avatar Apr 17 '24 23:04 mgrigoriev8109

This seems pretty complex cause you're not going to want to break the existing behavior if the form allows you to select both.

schoork avatar May 20 '24 14:05 schoork

probably js make sure to write tests!

compwron avatar May 26 '24 20:05 compwron

This issue has been open without changes for a long time! What's up?

github-actions[bot] avatar Jul 27 '24 01:07 github-actions[bot]

I looked at this a bit during Case Contact Form Overhaul - current code is:

def get_contact_types
    case_contact_types = ContactType.includes(:contact_type_group)
      .joins(:casa_case_contact_types)
      .active
      .where(casa_case_contact_types: {casa_case_id: @casa_cases.pluck(:id)})

    if case_contact_types.present?
      case_contact_types
    else
      ContactType
        .includes(:contact_type_group)
        .joins(:contact_type_group)
        .active
        .where(contact_type_group: {casa_org: current_organization})
        .order("contact_type_group.name ASC", :name)
    end
  end

This should handle when the types are restricted for one of the cases -- even when there are other cases available in the selection... I may be wrong, I don't think it's tested. May want to start with view specs for which types are shown.

thejonroberts avatar Oct 21 '24 18:10 thejonroberts

This issue has been open without changes for a long time! What's up?

github-actions[bot] avatar Dec 22 '24 02:12 github-actions[bot]