Skip to content

Conversation

@JoshDevHub
Copy link
Contributor

Because

We need a multi select form on interview surveys.

Note that this intentionally has a fairly constrained scope just to make sure we have the general behavior down for what we want. The form still looks kind of bad because little attention was paid to styling, validations aren't completely ironed out, and the feature is still hidden behind a feature flag.

This PR

  • Adds form for filling our the interview survey
  • Includes multi select form for interview concepts. Multi select uses tom-select library (wrapped in a Stimulus controller)
  • Includes new system specs to check core flow of submitting an interview survey form

Issue

Closes #4966

Additional Information

This ended up being more than a spike lol. Might change the branch name later.

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the keyword: brief description of change format, using one of the following keywords:
    • Feature - adds new or amends existing user-facing behavior
    • Chore - changes that have no user-facing value, refactors, dependency bumps, etc
    • Fix - bug fixes
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • I have verified all tests and linters pass after making these changes.
  • If this PR addresses an open issue, it is linked in the Issue section
  • If applicable, this PR includes new or updated automated tests

}
}

@import 'tom-select/dist/css/tom-select'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For whatever reason, this import was only working for me when placed at the bottom of the file. Maybe something to play around with later.

@@ -1,12 +1,31 @@
class InterviewSurveysController < ApplicationController
before_action :authenticate_user!
# TODO: merge feature flag stuff in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After #5164 is merged, I'll be able to clean some of this stuff up.

Comment on lines +5 to +10
connect () {
this.tomSelect = new TomSelect(
this.element,
{ create: true }
)
}
Copy link
Contributor Author

@JoshDevHub JoshDevHub Nov 13, 2025

Choose a reason for hiding this comment

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

Potentially going to be more to do here. Kind of depends on how the feature scales up. One problem might be that if there are hundreds of concepts, loading them upfront to be searched through might have performance issues. We'd have to probably create a rails controller for searching concepts and then configure tom-select's search input hit that controller. That's doable of course, but it'd mean adjusting more of this config.

Comment on lines +9 to +11
attribute :interview_concept_names, :string, array: true, default: -> { [] }

after_save :create_concepts
Copy link
Contributor Author

@JoshDevHub JoshDevHub Nov 13, 2025

Choose a reason for hiding this comment

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

Willing to accept some feedback on how this is wired up. I generally don't like using AR callbacks much, and it might be better to just call something from the controller.

I do like this virtual attribute though, and the way this is done ensures that if validation fails for some reason (like the user enters a bad date or doesn't enter a date at all), the multi select will still be populated with the items they selected.

Comment on lines +35 to +38
find('div[class="ts-control"]').click
find('input[id="interview_survey_interview_concept_names-ts-control"]')
.set("React props")
.send_keys(:return)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe a page object could help with some of this test readability.

validates :name, presence: true
validates :name, length: { minimum: 2, maximum: 25 }

normalizes :name, with: ->(name) { name.downcase }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a new way to solve the problem given in this comment of the previous PR: #5018 (comment)

Basically this just means that every concept will have its name case normalized to lowercase on saving. I think this is likely a good idea to combat duplicates. We might also want to make this field unique (it's not currently)?

@JoshDevHub
Copy link
Contributor Author

TODO:

  • Fix tests and lint
  • Explore validation of the concept names
  • Merge feature flag stuff in after it's merged to main
  • Put up a video or two of the current flow
  • Give some manual QA instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋 Backlog / Ideas

Development

Successfully merging this pull request may close these issues.

Post-Interview Survey Feature: Build form for filling out the survey using multi-select solution

1 participant