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

Slot field options #5

Open
sveetch opened this issue Apr 15, 2024 · 2 comments
Open

Slot field options #5

sveetch opened this issue Apr 15, 2024 · 2 comments
Labels
feature For new feature development

Comments

@sveetch
Copy link
Member

sveetch commented Apr 15, 2024

Canopy stands on internal slot definitions to build the form fields.

We don't want to be like django-fobi that did have too many options for each field types but we will probably needs a little bit of options, like with an Integer field, you would expect to set a minimum and a maximum limit from the Slot options.

Since there would be too many options to modelize from various Django form field or widget, we just can not add them all to the Slot model, so it will need to be stored as JSON.

This leads to a problem, editing JSON is not user friendly at all so we would need something to turn the JSON to virtual fields that can be humanly edited.

There is a very nice frontend module for this with json-editor library. However, it needs to be implemented properly in the Slot form.

There was a Django app for this before with django-admin-json-editor but it is stale since some years, however it may helps to implement again.

@sveetch sveetch added the idea Idea about feature or new concept label Apr 15, 2024
@sveetch
Copy link
Member Author

sveetch commented May 7, 2024

We will avoid to procrastinate on this feature because of the front question since it is an important feature. Let's start with JSON edition for now, we will see further to improve its usage.

@sveetch sveetch added feature For new feature development and removed idea Idea about feature or new concept labels May 7, 2024
@sveetch
Copy link
Member Author

sveetch commented May 14, 2024

The 'Schema' way may not be the best choice. It is more difficult to write slot definition and more complicated to validate and use.

What if instead, we simply use a Django form for each definition, since its field are naturally validated, easier to define and may even be used to simply render its fields instead of using a frontend library like json-editor to render the options JSON and manage it in the Slot form.

The idea would be to define a form for each definition, this form will contains an input field for each option element from the JSON structure. Option form field to manage the choices attribute won't be trivial to implement, since it involves dynamic fields and surely some JS (to reproduce the InlineFormSet behaviors), we will avoid it for this PoC since it should not guide how we do this PoC.

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

No branches or pull requests

1 participant