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

Allow filtering from columns #144

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

Conversation

elfjes
Copy link
Contributor

@elfjes elfjes commented Sep 24, 2024

Allow specifiying when a column may be "filterable" (by specifying the IncidentTableColumn.filter_field). This means:

  • a button will be attached to the column header
  • clicking that button will display an input element
  • typing into this element (ie change event) will fire an htmx request with the specified filter_field as the query param to filter incidents

image
image

TODO:

  • create the ui elements and activate this element when IncidentTableColumn.filter_field is set
  • wrap the column headers in a form and send this form as htmx request on change event
    • include filter-box form fields in the request
  • prefill input value based on current values

Limitations:

  • requires hyperscript
  • only support simple text input for now

@hmpf
Copy link
Collaborator

hmpf commented Sep 24, 2024

We should probably figure out how to do the bulk-selection first so the forms don't interfere with each other.

I assume the form will have hidden fields for the other values so we don't lose the existing GET-args?

@hmpf
Copy link
Collaborator

hmpf commented Sep 24, 2024

The icon needs be flatter =)

@elfjes
Copy link
Contributor Author

elfjes commented Sep 24, 2024

We should probably figure out how to do the bulk-selection first so the forms don't interfere with each other.

hmm perhaps, but I think the bulk selection will be a completely separate flow from the filtering, no? or is it the mass checkbox that you're concerned about?

I assume the form will have hidden fields for the other values so we don't lose the existing GET-args?

I was thinking to just cross hx-include the header-row form and the filterbox form for both forms (and also in the periodic refresh). Hidden inputs might also work but we need to be sure then to also add the header-row inputs in the filterbox form

The icon needs be flatter =)

I went with something that is in unicode. I could not find anything that worked better 😅. Maybe we need to think about adopting an icon pack (fontawesome?)

@hmpf
Copy link
Collaborator

hmpf commented Sep 24, 2024

We should probably figure out how to do the bulk-selection first so the forms don't interfere with each other.

hmm perhaps, but I think the bulk selection will be a completely separate flow from the filtering, no? or is it the mass checkbox that you're concerned about?

Yep. <input> has the form-attribute but there is more than one bulk form.

@hmpf
Copy link
Collaborator

hmpf commented Sep 24, 2024

As for supporting other types than text-input, we'd have to extend the column-objects.

@podliashanyk
Copy link
Contributor

We should probably figure out how to do the bulk-selection first so the forms don't interfere with each other.

hmm perhaps, but I think the bulk selection will be a completely separate flow from the filtering, no? or is it the mass checkbox that you're concerned about?

Yep. <input> has the form-attribute but there is more than one bulk form.

Haven't looked at code yet but in general multiple input tags with form is no problem. form exists for hooking inputs to any forms anywhere in DOM: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form.

@elfjes elfjes marked this pull request as ready for review November 11, 2024 10:46
@hmpf hmpf changed the title WIP: allow filtering from columns Allow filtering from columns Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

3 participants