Hide fieldsets without visible fields, and support dynamic fieldsets.

Review Request #12291 — Created May 20, 2022 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

Registered fieldsets with registered fields were always being shown,
even if none of the fields inside were visible. This was because we only
determined visibility based on registered classes, and didn't even
instantiate fields until we had begun rendering the fieldset template.

This was prominent when installing Power Pack 5, which registers a
fieldset for SOS. This is shown but empty on any review request not
backed by SOS.

This change moves field construction out of the template rendering and
into the fieldset itself. A new build_fields() method is responsible
for instantiating all the fields, and a fields property returns a
cached view of that. This is combined with a new should_render
property, which considers visibility of the contained fields.

That simplifies templates and fixes visibility, but it also opens the
door to dynamic fields/fieldsets. A long-term project we've had is a
field editor for Power Pack, and that requires a way to dynamically
create new fieldsets and fields without first registering them globally.
This change enables the dynamic fields part, leaving only dynamic
fieldset generation remaining.

There are also some documentation fixes and a few fixes for state
assumptions noticed during testing.

Verified that the SOS fieldset wasn't being shown outside of SOS-based
review requests.

Added new unit tests, which all pass.

Tested all the current fields we show on review requests.

Commits

Files

    Loading...