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

Make a reusable range input template. #93

Open
hmpf opened this issue Sep 2, 2024 · 3 comments
Open

Make a reusable range input template. #93

hmpf opened this issue Sep 2, 2024 · 3 comments
Labels
polish Nice to have

Comments

@hmpf
Copy link
Collaborator

hmpf commented Sep 2, 2024

In order for any tick marks the widget must have a range to paint them in a for-loop. This is normally done via the context so we might have to sneak in something iterable into the form field that is automatically put in the context. Smells like a new FormField, frankly.

@hmpf hmpf added after-demo Need not work for demo polish Nice to have labels Sep 2, 2024
@podliashanyk
Copy link
Contributor

podliashanyk commented Sep 2, 2024

I don't think we necessarily need a separate form field for this. We could use the original ChoiceFiled and pass choices=INCIDENT_LEVEL_CHOICES, with it. And then render those choices as a <datalist> of <option> below the range slider (to replace the hardcoded "12345").

@hmpf
Copy link
Collaborator Author

hmpf commented Sep 2, 2024

But then we need to override the html type to "range". So either way it's extra work.

@podliashanyk
Copy link
Contributor

No extra work if this issue depends on #87, where you already render IntegerField as a NumberInput with a type set to range:

  maxlevel = forms.IntegerField(
        widget=forms.NumberInput(attrs={
            'type': 'range', 'step': '1', 'min': '1', 'max': MAX_INCIDENT_LEVEL
        }),
...

@hmpf hmpf removed the after-demo Need not work for demo label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polish Nice to have
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants