-
Notifications
You must be signed in to change notification settings - Fork 656
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
www/caddy: partials bootgrid example implementation #4388
base: master
Are you sure you want to change the base?
Conversation
$formDialogReverseProxy = $this->getForm("dialogReverseProxy"); | ||
$this->view->formDialogReverseProxy = $this->preprocessFields($formDialogReverseProxy, 'reverse.'); | ||
|
||
$formDialogSubdomain = $this->getForm("dialogSubdomain"); | ||
$this->view->formDialogSubdomain = $this->preprocessFields($formDialogSubdomain, 'subdomain.'); | ||
|
||
$formDialogHandle = $this->getForm("dialogHandle"); | ||
$this->view->formDialogHandle = $this->preprocessFields($formDialogHandle, 'handle.'); | ||
|
||
$formDialogAccessList = $this->getForm("dialogAccessList"); | ||
$this->view->formDialogAccessList = $this->preprocessFields($formDialogAccessList, 'accesslist.'); | ||
|
||
$formDialogBasicAuth = $this->getForm("dialogBasicAuth"); | ||
$this->view->formDialogBasicAuth = $this->preprocessFields($formDialogBasicAuth, 'basicauth.'); | ||
|
||
$formDialogHeader = $this->getForm("dialogHeader"); | ||
$this->view->formDialogHeader = $this->preprocessFields($formDialogHeader, 'header.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit too much boilerplate for my taste, but I'm sure this can be improved. Can't the form hold the additional argument too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main issue here was this:
<th data-column-id="enabled" data-width="6em" data-type="boolean" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th> |
data-column-id="enabled"
plugins/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/dialogReverseProxy.xml
Line 3 in dbe996b
<id>reverse.enabled</id> |
<id>reverse.enabled</id>
I need to split the id. I could not process that in the template due to restrictions.
Maybe this boilerplate can be centralized at a different spot so I can always receive a data-column-id
that has been generated from the id
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symbolic approval here, I think the approach is very nice 👍
a few design decisions regarding form xml need to be made but that's just optics
} | ||
|
||
// Sort fields by 'sequence', defaulting to 0 if not set | ||
usort($fields, function ($a, $b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This here has the side effect to also change the order in the form dialogue. If there should be a /different/ sequence for the columns and the form this solution has to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tried to do it like this in the .volt
template it always crashed. So there are very different possibilities between volt and jinja 2 it seems and I can not sort the same way in the template as e.g.: here:
plugins/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeLayer4
Lines 15 to 23 in dbe996b
{% set unsorted_layer4_configs = helpers.toList('Pischem.caddy.reverseproxy.layer4') %} | |
{# Ensure that 'Sequence' is present and converted to an integer in each item #} | |
{% for item in unsorted_layer4_configs %} | |
{% set _ = item.update({'Sequence': item.get('Sequence', '0') | int}) %} | |
{% endfor %} | |
{# Sort the configurations based on 'Sequence' #} | |
{% set layer4_configs = unsorted_layer4_configs | sort(attribute='Sequence') %} |
I was doubting a bit to offer feedback in the code, but it's probably easier to document my comments and concerns here. Although I don't mind combining grid fields in forms, we do need to seek a way to explain the fields properly and prevent cluttering functionality. Consider the following field (which my the way could also be positioned in a [sub]tab)
If we add a So how about positioning the grid properties inside a container, e.g.
My next issue is more or less a past sin, as Maybe if we add a
The Obviously we need to feed the output of I can take a look at building the |
This PR is not for merging but rather for discussion of the code.
It aims to generalize the bootgrid table setup.
If this approach seems valuable, I would like to add it to core in some way.
Current status: "Works for me"