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

Fix department selector on submit image page #533

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

Successfully merging this pull request may close these issues.

1 participant