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

Add 'selected' option to Select field and update specs #2676

Closed
wants to merge 2 commits into from

Conversation

Thrizian
Copy link

@Thrizian Thrizian commented Oct 6, 2024

Introduced a 'selected' option in the Select field to specify a default value when no data is available. Updated the form partial to prioritize 'selected' over data and added related test cases to ensure correct behavior. Updated .gitignore and added .tool-versions for environment settings.

Introduced a 'selected' option in the Select field to specify a default value when no data is available. Updated the form partial to prioritize 'selected' over data and added related test cases to ensure correct behavior. Updated .gitignore and added .tool-versions for environment settings.
@Thrizian
Copy link
Author

Thrizian commented Oct 6, 2024

This is my first ever open source commit, So if i'm slacking somewhere. Let me know. Also i'm having trouble testing this myself because the 1.0.0.beta1 blows up for me. sassc-rails, i've created an issue for it here #2677.

Also, can i run the demo app locally to test it?

@Thrizian
Copy link
Author

I've had another go at this. Since i figured out how to get the application up and running locally, #rtfm. I'm pretty bad at writing tests so perhaps someone can help me with writing some better coverage. But this should get us a nice start to get some more selectize functionality.

I've used the selectcontroller stimuluscontroller to handle this. We are using data attributes to get the message passed across.

This PR now adds:

  • selected
  • multiple
  • max_items
  • include_blank

Max items. Allows for selecting items up to max_items.

    kind: Field::Select.with_options(
      collection: [1,2,3,4],
      max_items: 2
    )

Multiple selecting multiple options.

    kind: Field::Select.with_options(
      collection: [1,2,3,4],
      selected: 4,
      max_items: 2
    )

Selected, allows for the selection of a specific element or multiple elements.

    kind: Field::Select.with_options(
      collection: [1,2,3,4],
      selected: 4,
    )
   kind: Field::Select.with_options(
     collection: [1,2,3,4],
     selected: [2,4],
   )

This also works with [[1, 2],[3,4],[5,6]]

   kind: Field::Select.with_options(
     collection: [[1, 2],[3,4],[5,6]],
     selected: [2,4],
   )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant