Skip to content

Conversation

@sea-kelp
Copy link
Collaborator

@sea-kelp sea-kelp commented Feb 23, 2025

Description of Changes

Fix bug where submit image page department selector was not submitting images to the correct department.

It looks like the current implementation was using selectedIndex (the index of the selected <option> element in the <select>) as the initial department id, which assumes the departments are loaded in order:

// Select user's preferred department by default
document.getElementById("department").selectedIndex = {{ preferred_dept_id }} - 1;
// Save the preferred department in dept_id
let dept_id = document.getElementById("department").selectedIndex + 1;

Notes for Deployment

None!

Screenshots (if appropriate)

N/A

Testing instructions

  1. Log in as admin user.
  2. Create a new department "Bellevue Police Department (BPD)" at http://localhost:3000/departments/new.
  3. Update the preferred department to BPD at http://localhost:3000/auth/change-dept/.
  4. Go to the Submit Image page (http://localhost:3000/submit) and confirm that the populated department is BPD.
  5. Upload an image.
  6. Verify in devtools that an image was submitted to http://localhost:3000/upload/departments/2.
  7. Update the department selector to SPD.
  8. Upload an image.
  9. Verify in devtools that an image was submitted to http://localhost:3000/upload/departments/1.
  10. Change the preferred department to SPD at http://localhost:3000/auth/change-dept/.
  11. Go to the Submit Image page (http://localhost:3000/submit) and confirm that the populated department is now SPD.
  12. Upload an image.
  13. Verify in devtools that an image was submitted to http://localhost:3000/upload/departments/1.

Checks

  • I have rebased my changes on main

  • just lint passes

  • just test passes

@sea-kelp sea-kelp requested a review from a team as a code owner February 23, 2025 12:21
Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for making this fix!

@sea-kelp
Copy link
Collaborator Author

sea-kelp commented Mar 3, 2025

Closing since this change was included in #534 to fix tests

@sea-kelp sea-kelp closed this Mar 3, 2025
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Orca Collective Task Tracker Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants