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

More flexible API for menu items #726

Merged
merged 1 commit into from
Aug 11, 2023
Merged

Conversation

nonprofittechy
Copy link
Member

@nonprofittechy nonprofittechy commented Aug 8, 2023

fix #723

Adds a new user-facing magic keyword: al_menu_items_custom_items which should be a list of menu items. Custom items are shown before default menu items.

Each menu items follows the Docassemble menu item format, which is a dictionary with the keys url and label. It can be convenient, and readable, to use a data from code block to define the menu items, but you can use any method to create the right Python datastructure.

Optionally, you can add a key hidden which contains a True/False value. If the value is True the menu item won't be shown. This can be used to dynamically show or hide the menu item on a given page. If the value is dynamic, you should add a reconsider modifier on the block that defines al_menu_items_custom_items.

E.g.,

reconsider: True
variable name: al_menu_items_custom_items
data from code:
  - url: |
      "http://example.com"
    label: |
       "Example link"
    hidden: user_turned_off_example_link

Note that if the visible state isn't dynamic, the author can use a data block instead of a data from code block. This will make the label translatable. Alternatively, the author can add a template for the label to make it available for translation.

Copy link
Contributor

@BryceStevenWilley BryceStevenWilley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Getting this in the docs would be great too

@nonprofittechy nonprofittechy merged commit c88f618 into main Aug 11, 2023
5 checks passed
@nonprofittechy
Copy link
Member Author

LGTM. Getting this in the docs would be great too

On it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants