SuffolkLITLab / docassemble-AssemblyLine

Quickly go from a paper court form to a runnable, guided, step-by-step web application powered by Docassemble. Swap out branding and pre-built questions to meet your needs.
https://suffolklitlab.org/docassemble-AssemblyLine-documentation/
MIT License
41 stars 5 forks source link

Allow using 'data' rather than 'data from code' for al_nav_sections #844

Closed nonprofittechy closed 5 months ago

nonprofittechy commented 5 months ago

Currently, when you use the al_nav_sections method to declaratively define navigation, you need the longer and more verbose data from code because the hidden dictionary key is evaluated as a str.

For example:

---
reconsider: True
variable name: al_nav_sections
data from code:
  - section_intro: |
      "Introduction"
  - section_about_you: |
      "About you"
  - section_about_spouse: |
      "About your spouse"
    hidden: not is_married

works but

reconsider: True
variable name: al_nav_sections
variable name: al_nav_sections
data:
  - section_intro: Introduction
  - section_about_you: About you
  - section_about_spouse: About your spouse
    hidden: ${ not showifdef("is_married") }

does not.

Type coercion is safe here because structurally, hidden is only meant to ever be a boolean value. it's only acted on when the value is exactly True.