Skip to content

Commit

Permalink
regenerate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpyle committed Jul 19, 2024
1 parent 53e067b commit 4565dc4
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 31 deletions.
2 changes: 2 additions & 0 deletions docassemble_base/docassemble/base/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def __str__(self):


def filename_invalid(filename):
logmessage("filename is " + repr(filename))
if '../' in filename or filename.startswith('/'):
logmessage("Returning invalid")
return True
if re.search(r'[^A-Za-z0-9\_\.\-\/ ]', filename):
return True
Expand Down
6 changes: 5 additions & 1 deletion docassemble_base/docassemble/base/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4647,6 +4647,10 @@ def __init__(self, orig_data, caller, **kwargs):
if 'extras' not in field_info:
field_info['extras'] = {}
field_info['extras'][key] = TextObject(definitions + str(field[key]), question=self)
elif key == 'css class':
if 'extras' not in field_info:
field_info['extras'] = {}
field_info['extras'][key] = TextObject(definitions + str(field[key]), question=self)
elif key == 'show if':
if not isinstance(field[key], list):
field_list = [field[key]]
Expand Down Expand Up @@ -6066,7 +6070,7 @@ def ask(self, user_dict, old_user_dict, the_x, iterators, sought, orig_sought, p
continue
else:
extras['field metadata'][field.number] = recursive_eval_textobject_or_primitive(field.extras['field metadata'], user_dict)
for key in ('note', 'html', 'raw html', 'min', 'max', 'minlength', 'maxlength', 'step', 'scale', 'inline', 'inline width', 'currency symbol', 'pen color', 'file css class'): # 'script', 'css',
for key in ('note', 'html', 'raw html', 'css class'):
if key in field.extras:
if key not in extras:
extras[key] = {}
Expand Down
29 changes: 20 additions & 9 deletions docassemble_base/docassemble/base/standardformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
continue_button_color = status.extras.get('continuecolor', None) or BUTTON_COLOR
back_button_val = status.extras.get('back_button', None)
if (back_button_val or (back_button_val is None and status.question.interview.question_back_button)) and status.question.can_go_back and steps > 1:
back_button = '\n <button type="button" class="btn ' + BUTTON_STYLE + (status.extras.get('back button color', None) or BUTTON_COLOR_BACK) + ' ' + BUTTON_CLASS + ' daquestionbackbutton danonsubmit" title=' + json.dumps(word("Go back to the previous question")) + '><i class="fa-solid fa-chevron-left"></i> '
back_button = '\n <button type="button" class="btn ' + BUTTON_STYLE + (status.extras.get('back button color', None) or BUTTON_COLOR_BACK) + ' ' + BUTTON_CLASS + ' daquestionbackbutton danonsubmit" title=' + json.dumps(word("Go back to the previous question")) + '><i class="fa-solid fa-chevron-left me-1"></i>'
back_button += status.back
back_button += '</button>'
else:
Expand Down Expand Up @@ -1048,6 +1048,9 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
if hasattr(status.question, 'review_saveas'):
datatypes[safeid(status.question.review_saveas)] = "boolean"
for field in status.get_field_list():
extra_container_class = None
if 'css class' in status.extras and field.number in status.extras['css class']:
extra_container_class = ' ' + clean_whitespace(status.extras['css class'][field.number])
if 'html' in status.extras and field.number in status.extras['html']:
side_note_content = status.extras['html'][field.number].rstrip()
elif 'raw html' in status.extras and field.number in status.extras['raw html']:
Expand Down Expand Up @@ -1078,12 +1081,12 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
if tabular:
fieldlist.append(' <tr class="da-field-container da-field-container-note da-review"><td colspan="2">' + help_wrap(side_note_content, status.helptexts[field.number], status) + '</td></tr>\n')
else:
fieldlist.append(' <div class="da-form-group row da-field-container da-field-container-note da-review"><div class="col"><div>' + help_wrap(side_note_content, status.helptexts[field.number], status) + '</div></div></div>\n')
fieldlist.append(' <div class="row da-field-container da-field-container-note da-review da-review-button pt-2 my-2' + (extra_container_class if extra_container_class is not None else '') + '"><div class="col"><div>' + help_wrap(side_note_content, status.helptexts[field.number], status) + '</div></div></div>\n')
else:
if tabular:
fieldlist.append(' <tr class="da-field-container da-field-container-note da-review"><td colspan="2">' + side_note_content + '</td></tr>\n')
else:
fieldlist.append(' <div class="da-form-group row da-field-container da-field-container-note da-review"><div class="col"><div>' + side_note_content + '</div></div></div>\n')
fieldlist.append(' <div class="row da-field-container da-field-container-note da-review da-review-button pt-2 my-2' + (extra_container_class if extra_container_class is not None else '') + '"><div class="col"><div>' + side_note_content + '</div></div></div>\n')
continue
if field.datatype == 'raw html' and 'raw html' in status.extras and field.number in status.extras['raw html'] and side_note_content:
fieldlist.append(' ' + side_note_content + '\n')
Expand All @@ -1093,12 +1096,12 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
if tabular:
fieldlist.append(' <tr class="da-field-container da-field-container-note da-review"><td colspan="2">' + help_wrap(side_note_content, status.helptexts[field.number], status) + '</td></tr>\n')
else:
fieldlist.append(' <div class="da-form-group row da-field-container da-field-container-note da-review"><div class="col">' + help_wrap(side_note_content, status.helptexts[field.number], status) + '</div></div>\n')
fieldlist.append(' <div class="row da-field-container da-field-container-note da-review da-review-button pt-2 my-2' + (extra_container_class if extra_container_class is not None else '') + '"><div class="col">' + help_wrap(side_note_content, status.helptexts[field.number], status) + '</div></div>\n')
else:
if tabular:
fieldlist.append(' <tr class="da-field-container da-field-container-note da-review"><td colspan="2">' + side_note_content + '</td></tr>\n')
else:
fieldlist.append(' <div class="da-form-group row da-field-container da-field-container-note da-review"><div class="col">' + side_note_content + '</div></div>\n')
fieldlist.append(' <div class="row da-field-container da-field-container-note da-review da-review-button pt-2 my-2' + (extra_container_class if extra_container_class is not None else '') + '"><div class="col">' + side_note_content + '</div></div>\n')
continue
# elif field.datatype in ['script', 'css']:
# continue
Expand All @@ -1120,7 +1123,7 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
if tabular:
fieldlist.append(' <tr class="da-review da-review-button-tabular"><td>' + markdown_to_html(status.helptexts[field.number], status=status, strip_newlines=True) + '</td><td><a href="#" role="button" class="btn btn-sm ' + BUTTON_STYLE + color + ' da-review-action da-review-action-button" data-action=' + myb64doublequote(status.extras['action'][field.number]) + '>' + icon + markdown_to_html(status.labels[field.number], trim=True, status=status, strip_newlines=True) + '</a></td>' + side_note + '</tr>\n')
else:
fieldlist.append(' <div class="row' + side_note_parent + ' da-review da-review-button bg-light pt-2 my-2"><div class="col"><a href="#" role="button" class="btn btn-sm ' + BUTTON_STYLE + color + ' da-review-action da-review-action-button ms-2 mb-1" data-action=' + myb64doublequote(status.extras['action'][field.number]) + '>' + icon + markdown_to_html(status.labels[field.number], trim=True, status=status, strip_newlines=True) + '</a>' + markdown_to_html(status.helptexts[field.number], status=status, strip_newlines=True) + '</div>' + side_note + '</div>\n')
fieldlist.append(' <div class="row' + side_note_parent + ' da-review da-review-button' + (extra_container_class if extra_container_class is not None else ' bg-secondary-subtle') + ' pt-2 my-2"><div class="col"><a href="#" role="button" class="btn btn-sm ' + BUTTON_STYLE + color + ' da-review-action da-review-action-button ms-2 mb-1" data-action=' + myb64doublequote(status.extras['action'][field.number]) + '>' + icon + markdown_to_html(status.labels[field.number], trim=True, status=status, strip_newlines=True) + '</a>' + markdown_to_html(status.helptexts[field.number], status=status, strip_newlines=True) + '</div>' + side_note + '</div>\n')
continue
if hasattr(field, 'label'):
if tabular:
Expand Down Expand Up @@ -1352,6 +1355,10 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
else:
field_class = ' da-field-container da-field-container-datatype-' + field.datatype
if field.datatype == 'html':
if 'css class' in status.extras and field.number in status.extras['css class']:
note_css_class = ' ' + clean_whitespace(status.extras['css class'][field.number])
else:
note_css_class = ''
if hasattr(field, 'collect_type'):
if not seen_first:
if status.extras['list_collect_length'] <= 1:
Expand Down Expand Up @@ -1394,10 +1401,10 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
fieldlist.append(note_fields[field.number])
else:
if field.number in status.helptexts:
fieldlist.append(field_item(field, grid_info, pre=style_def + data_def, classes='da-field-container da-field-container-note' + class_def + extra_container_class, content_classes='col', content=help_wrap(note_fields[field.number], status.helptexts[field.number], status), under_text=under_text))
fieldlist.append(field_item(field, grid_info, pre=style_def + data_def, classes='da-field-container da-field-container-note' + note_css_class + class_def + extra_container_class, content_classes='col', content=help_wrap(note_fields[field.number], status.helptexts[field.number], status), under_text=under_text))
# fieldlist.append(' <div ' + style_def + data_def + 'class="da-form-group row da-field-container da-field-container-note' + class_def + extra_container_class + '"><div class="col">' + help_wrap(note_fields[field.number], status.helptexts[field.number], status) + '</div></div>\n')
else:
fieldlist.append(field_item(field, grid_info, pre=style_def + data_def, classes='da-field-container da-field-container-note' + class_def + extra_container_class, content_classes='col', content='<div>' + note_fields[field.number] + '</div>', under_text=under_text))
fieldlist.append(field_item(field, grid_info, pre=style_def + data_def, classes='da-field-container da-field-container-note' + note_css_class + class_def + extra_container_class, content_classes='col', content='<div>' + note_fields[field.number] + '</div>', under_text=under_text))
# fieldlist.append(' <div ' + style_def + data_def + 'class="da-form-group row da-field-container da-field-container-note' + class_def + extra_container_class + '"><div class="col"><div>' + note_fields[field.number] + '</div></div></div>\n')
# continue
elif field.datatype == 'raw html':
Expand All @@ -1406,7 +1413,11 @@ def as_html(status, debug, root, validation_rules, field_error, the_progress_bar
elif field.datatype == 'note':
if field.number in note_fields:
if field.number in status.helptexts:
fieldlist.append(field_item(field, grid_info, pre=style_def + data_def, classes='da-field-container da-field-container-note' + class_def + extra_container_class, content_classes='col', content=help_wrap(note_fields[field.number], status.helptexts[field.number], status), under_text=under_text))
if 'css class' in status.extras and field.number in status.extras['css class']:
note_css_class = ' ' + clean_whitespace(status.extras['css class'][field.number])
else:
note_css_class = ''
fieldlist.append(field_item(field, grid_info, pre=style_def + data_def, classes='da-field-container da-field-container-note' + note_css_class + class_def + extra_container_class, content_classes='col', content=help_wrap(note_fields[field.number], status.helptexts[field.number], status), under_text=under_text))
# fieldlist.append(' <div ' + style_def + data_def + 'class="da-form-group row da-field-container da-field-container-note' + class_def + extra_container_class + '"><div class="col">' + help_wrap(note_fields[field.number], status.helptexts[field.number], status) + '</div></div>\n')
else:
fieldlist.append(field_item(field, grid_info, pre=style_def + data_def, classes='da-field-container da-field-container-note' + class_def + extra_container_class, content_classes='col', content=note_fields[field.number], under_text=under_text))
Expand Down
2 changes: 2 additions & 0 deletions docassemble_base/docassemble/base/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,8 @@ def init(self, *pargs, **kwargs):
self.complete_attribute = None
if 'ask_object_type' in kwargs and kwargs['ask_object_type']:
self.ask_object_type = True
self.object_type = None
self.object_type_parameters = {}
del kwargs['ask_object_type']
if not hasattr(self, 'ask_object_type'):
self.ask_object_type = False
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
metadata:
title: Accordion Fields
short title: Accordion
documentation: "https://docassemble.org/docs/recipes.html#accordion"
example start: 1
example end: 4
---
modules:
- docassemble.demo.accordion
---
features:
css: docassemble.demo:data/static/accordion.css
---
question: |
Tell me about your preferences
fields:
- raw html: |
${ start_accordion('Pets', showing=True) }
- Favorite cat: favorite_cat
show if:
code: ask_about_pets
- Favorite dog: favorite_dog
show if:
code: ask_about_pets
- raw html: |
${ next_accordion('Food') }
- Favorite fruit: favorite_fruit
required: False
- Favorite vegetable: favorite_vegetable
required: False
- raw html: |
${ next_accordion('Aesthetics') }
- Fashion aesthetic: fashion_aesthetic
required: False
- Decor aesthetic: decor_aesthetic
required: False
- raw html: ${ end_accordion() }
---
code: |
ask_about_pets = False
---
mandatory: True
question: |
Your favorite vegetable is ${ favorite_vegetable } and
your fashion aesthetic is ${ fashion_aesthetic }.
8 changes: 8 additions & 0 deletions docassemble_demo/docassemble/demo/data/static/accordion.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
div.accordion-item:has(.accordion-body:empty) h2 {
display: none;
}

div.accordion-item:has(.accordion-body:empty) div {
display: none;
}

2 changes: 1 addition & 1 deletion docassemble_demo/docassemble/demo/progressivedisclosure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def prog_disclose(template, classname=None):
if classname is None:
classname = ' bg-light'
classname = ' bg-secondary-subtle'
else:
classname = ' ' + classname.strip()
the_id = re.sub(r'[^A-Za-z0-9]', '', template.instanceName)
Expand Down
9 changes: 7 additions & 2 deletions docassemble_webapp/docassemble/webapp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ def get_twilio_config():
else:
app.config['BUTTON_STYLE'] = 'btn-'
BUTTON_COLOR_NAV_LOGIN = daconfig['button colors'].get('navigation bar login', 'primary')
app.config['FOOTER_CLASS'] = str(daconfig.get('footer css class', 'bg-light')).strip() + ' dafooter'
app.config['FOOTER_CLASS'] = str(daconfig.get('footer css class', 'bg-secondary-subtle')).strip() + ' dafooter'


def get_page_parts():
Expand Down Expand Up @@ -3397,6 +3397,9 @@ def make_navbar(status, steps, show_login, chat_info, debug_mode, index_params,
navbar += '\n <a class="btn btn-' + BUTTON_COLOR_NAV_LOGIN + ' btn-sm mb-0 ms-3 d-none d-md-block" href="' + login_url + '">' + word('Sign in') + '</a>'
navbar += """
</div>"""
else:
if status.nav_item:
navbar += '<ul class="navbar-nav ms-auto">' + status.nav_item + '</ul>'
navbar += """
</div>
</div>
Expand Down Expand Up @@ -11454,6 +11457,8 @@ def index(action_argument=None, refer=None):
}
$(".da-to-labelauty").labelauty({ class: "labelauty da-active-invisible dafullwidth" });
$(".da-to-labelauty-icon").labelauty({ label: false });
$("input[type=radio].da-to-labelauty:checked").trigger('change');
$("input[type=radio].da-to-labelauty-icon:checked").trigger('change');
$("button").on('click', function(){
daWhichButton = this;
return true;
Expand Down Expand Up @@ -30400,7 +30405,7 @@ def manage_api():
flash(word("Could not create new key"), 'error')
return render_template('pages/manage_api.html', **argu)
argu['description'] = Markup(
"""<div class="card text-bg-light mb-3">
"""<div class="card bg-info-subtle mb-3">
<div class="card-body">
<p class="card-text">
""" + (word("Your new API key, known internally as <strong>%s</strong>, is:<br />%s<br />") % (form.name.data, '<br /><span class="text-success"><i class="fa-solid fa-check"></i></span> <code id="daApiKey">' + api_key + '</code><wbr /><button aria-label=' + json.dumps(word("Copy API key")) + ' onclick="daCopyToClipboard()" class="btn btn-link ps-1 pt-1" type="button"><i class="fa-regular fa-copy"></i></button>')) + """
Expand Down
Loading

0 comments on commit 4565dc4

Please sign in to comment.