Skip to content

Modal form framework #5354

Closed
Closed

Description

@SchrodingersGat

reimplement the existing "API forms" framework in react

### Tasks
- [x] Add framework for launching and rendering modal
- [x] Implement permission checks
- [x] Extract form data from API OPTIONS endpoint
- [x] Extract existing model data from API before rendering
- [x] Implement "string" input
- [x] Implement "number" input
- [x] Implement "select" (choice) input
- [x] Implement "date" input
- [x] Implement "API select" input
- [x] Implement "boolean" input
- [x] Allow icons to be added to fields
- [x] Validation based on metadata provided via API
- [x] Implement onChange callback
- [x] Handle form submission errors
- [x] Handle "processing" / "loading" states
- [x] Custom cancel / submit text
- [x] Handle initial value for related model fields
- [x] Implement custom render functions for related model fields
- [x] Handle "onSuccess" callback - redirect or reload, etc
- [x] Handle non-field errors
- [x] Handle file upload / image upload
- [ ] Implement "adjustFilters" callback for related model fields
- [ ] Allow form data to be passed separately to form (e.g. to "duplicate" and edit an existing item)
- [ ] Custom validation types (min / max / length / etc)
- [ ] Implement "datetime" input
- [ ] Handle different form upload modes (get / post / patch / delete)
- [ ] Implement "persistent" dialogs which remain after submission
- [ ] Handle creation of secondary modals
- [ ] allow "focus field" to be specified (or select first field)
- [ ] Support "groups" within each form
- [ ] Support "auto fill" for related fields with only one available item
- [ ] Make "footer" (buttons etc) stick to the bottom of the modal (no scroll) - https://github.com/orgs/mantinedev/discussions/1141

Activity

  1. added
    User Interface
    on Jul 27, 2023
  2. wolflu05 commented on Jul 27, 2023

    @wolflu05
    Member

    I would like to extend this a bit:

    • Add sub forms
    • Add a generic ApiView to the backend with some typing so the we can easily define such forms
    • Dependent settings
    • Input type: array list
    • Input Type: Date, time, datetime
    • validations: int, min, max, regex, ...
  3. SchrodingersGat commented on Jul 27, 2023

    @SchrodingersGat
    MemberAuthor

    I would like to extend this a bit:

    • Add sub forms - like, secondary forms which open from the first one?
    • Add a generic ApiView to the backend with some typing so the we can easily define such forms - example?
    • Dependent settings - example?
    • Input type: array list - example?
    • Input Type: Date, time, datetime
    • validations: int, min, max, regex, ...
  4. wolflu05 commented on Jul 27, 2023

    @wolflu05
    Member

    Sub forms

    They are an array of other form definitions that are rendered indented. Maybe also collapsable if they want to.

    Generic Django Views

    I tried to provide the idea a bit in #5295 . If I want to have a form defined from the backend I currently have no type hints and generic views to do so, I need to implement them again and again. I imagine having a View where I can define the form inputs somewhere in the class or via a getter and this view automatically handles advertisement via OPTIONS and calls a function like formSubmit. It should also handle api choices fields.

    Dependent settings

    This is for choices fields. Sometimes one choice field needs the value of other fields to calculate the choices. E.g. useful for providing the machine first and then conditionally get the specific machines printing form.

    Array list

    Just an input to provide a list. You start with one input, then there is a button + where you can add some inputs and each input has a delete button to remove it.

  5. SchrodingersGat commented on Jul 27, 2023

    @SchrodingersGat
    MemberAuthor

    If I want to have a form defined from the backend I currently have no type hints and generic views to do so, I need to implement them again and again.

    Use either a DRF serializer or Django model, and it will be taken care of for you. Check out metadata.py - this is where most of the magic happens. All of the current "front end" forms are constructed from that data.

  6. SchrodingersGat commented on Jul 27, 2023

    @SchrodingersGat
    MemberAuthor

    This is for choices fields. Sometimes one choice field needs the value of other fields to calculate the choices. E.g. useful for providing the machine first and then conditionally get the specific machines printing form.

    Choice fields can specify a "choicesFunc" method, which gets us some of the way there. However your advanced usage probably comes after this PR is merged in (as a starting point)

  7. wolflu05 commented on Jul 27, 2023

    @wolflu05
    Member

    Use either a DRF serializer or Django model, and it will be taken care of for you. Check out metadata.py - this is where most of the magic happens. All of the current "front end" forms are constructed from that data.

    I still think we need something generic with our own options. I don't think that DRF serializers have e.g. dependent options, sub forms, and also a lot of the stuff you Implement.

  8. matmair commented on Jul 27, 2023

    @matmair
    Member

    If it touches the python API I wold probaly move it to another PR as we probably need to bump the API version

  9. SchrodingersGat commented on Jul 27, 2023

    @SchrodingersGat
    MemberAuthor

    This issue (and linked PR) are only to re-implement functionality we already have in the "classic" UI

  10. wolflu05 commented on Sep 20, 2023

    @wolflu05
    Member

    We could probably implement an icon picker like the emoji keyboard on phones / the glyphs keyboard from iOS and maybe I bit more dense.

  11. github-actions commented on Nov 20, 2023

    @github-actions
    Contributor

    This issue seems stale. Please react to show this is still important.

  12. added
    inactive
    on Nov 20, 2023
  13. wolflu05 commented on Nov 20, 2023

    @wolflu05
    Member

    not stale

  14. removed
    inactive
    on Nov 21, 2023
  15. github-actions commented on Jan 20, 2024

    @github-actions
    Contributor

    This issue seems stale. Please react to show this is still important.

  16. added
    inactive
    on Jan 20, 2024
  17. SchrodingersGat commented on Jan 20, 2024

    @SchrodingersGat
    MemberAuthor

    Not stale, long running issue in progress

  18. removed
    inactive
    on Jan 21, 2024
  19. XanderLuciano commented on Mar 13, 2024

    @XanderLuciano
    Contributor

    Make "footer" (buttons etc) stick to the bottom of the modal (no scroll)

    Big +1 on this, the ability to click "submit" without having to scroll to the bottom is a killer advantage of the old UI vs. the new UI currently

    Also, I know the old UI also handles "enter" as a modal form submission. This behavior also should be kept / added to the new UI.

    This is a task I'm interested in submitting a PR for.

    EDIT: Related Issue: https://github.com/orgs/mantinedev/discussions/1141

  20. added this to the horizon milestone on Mar 13, 2024
  21. matmair commented on May 7, 2024

    @matmair
    Member

    @SchrodingersGat is this still open/relevant and are the action items on top all still valid?

  22. SchrodingersGat commented on May 7, 2024

    @SchrodingersGat
    MemberAuthor

    This is sufficiently advanced that we can close it out. Nice work everyone :)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    User Interface

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions