Skip to content

Commit

Permalink
Merge pull request #726 from SuffolkLITLab/flexible-menu-items
Browse files Browse the repository at this point in the history
More flexible API for menu items
  • Loading branch information
nonprofittechy authored Aug 11, 2023
2 parents 5d7d802 + 09edd7d commit c88f618
Showing 1 changed file with 59 additions and 45 deletions.
104 changes: 59 additions & 45 deletions docassemble/AssemblyLine/data/questions/al_visual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,54 +69,68 @@ features:
---
initial: True
code: |
# Set the dropdown/hamburger menu items
# by default we just add a "Start over" link
if _internal.get('steps') > 1:
menu_items = al_menu_items
else:
# Skip the "start over", download, and exit and erase menu item
if al_enable_incomplete_downloads:
menu_items = al_menu_items[3:]
else:
menu_items = al_menu_items[2:]
menu_items = [
item for item in al_menu_items if not item.get("hidden", False)
]
---
code: |
al_menu_items_custom_items = []
---
reconsider: True
code: |
al_menu_items_tmp = [
{"url": url_ask(['al_start_over_confirmation','al_start_over']),
"label": "Start over"
},
{
"url": url_ask(['al_exit_logout_confirmation', 'al_exit_logout']),
"label": "Exit and delete my answers"
},
]
if al_enable_incomplete_downloads:
al_menu_items_tmp.append({
"url": url_action('al_error_action_download_screen'),
"label": "Download current progress"
})
# Answer set feature is behind a server-wide configuration option
if get_config('assembly line',{}).get('enable answer sets'):
al_menu_items_tmp.extend([
{"url": url_ask(["al_sessions_snapshot_label", {"recompute": ["al_sessions_save_session_snapshot"]}, "al_sessions_save_status"]),
"label": "Save answer set"
},
action_menu_item("Load answer set", "al_load_saved_session"),
]
)
if get_config('assembly line',{}).get('enable answer set imports'):
al_menu_items_tmp.append(
{"url": url_ask(["al_sessions_json_file", {"recompute": ["al_sessions_import_json"]}, "al_sessions_load_status"]),
"label": "Import answer set"
}
)
al_menu_items = al_menu_items_tmp
del al_menu_items_tmp
al_menu_items = al_menu_items_custom_items + al_menu_items_default_items
---
reconsider: True
variable name: al_menu_items_default_items
data from code:
- url:
url_ask(['al_start_over_confirmation','al_start_over'])
label: str(al_start_over_string)
hidden: _internal.get('steps') < 2
- url: |
url_ask(['al_exit_logout_confirmation', 'al_exit_logout'])
label: str(al_exit_logout_string)
hidden: _internal.get('steps') < 2
- url: |
url_action('al_error_action_download_screen')
label: str(al_download_progress_string)
hidden: (not al_enable_incomplete_downloads) or (_internal.get('steps') < 2)
- url: |
url_ask(["al_sessions_snapshot_label", {"recompute": ["al_sessions_save_session_snapshot"]}, "al_sessions_save_status"])
label: str(al_save_answer_set_string)
hidden: (not get_config('assembly line',{}).get('enable answer sets')) or (_internal.get('steps') < 2)
- url: |
url_action('al_load_saved_session')
label: str(al_load_answer_set_string)
hidden: (not get_config('assembly line',{}).get('enable answer sets')) or (_internal.get('steps') < 2)
- url: |
url_action('al_error_action_download_screen')
label: str(al_download_answer_set_string)
hidden: (not get_config('assembly line',{}).get('enable answer set imports')) or (_internal.get('steps') < 2)
---
template: al_start_over_string
content: >-
Start over
---
template: al_exit_logout_string
content: >-
Exit and delete my answers
---
template: al_download_progress_string
content: >-
Download current progress
---
template: al_save_answer_set_string
content: >-
Save answer set
---
template: al_load_answer_set_string
content: >-
Load answer set
---
template: al_download_answer_set_string
content: >-
Download answer set
---
event: al_exit_logout
code: |
Expand Down

0 comments on commit c88f618

Please sign in to comment.