Skip to content

Commit 4bafe6a

Browse files
committed
Add docs custom send button label & icon optional keyword args
1 parent 76ead20 commit 4bafe6a

File tree

4 files changed

+62
-25
lines changed

4 files changed

+62
-25
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2023 Suffolk Legal Innovation and Technology Lab
3+
Copyright (c) 2025 Suffolk Legal Innovation and Technology Lab
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docassemble/AssemblyLine/al_document.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,8 @@ def download_list_html(
19361936
view_icon: str = "eye",
19371937
download_label: str = "Download",
19381938
download_icon: str = "download",
1939+
send_label: str = "Send",
1940+
send_icon: str = "envelope",
19391941
zip_label: Optional[str] = None,
19401942
zip_icon: str = "file-archive",
19411943
append_matching_suffix: bool = True,
@@ -1958,10 +1960,12 @@ def download_list_html(
19581960
view_icon (str): Icon for the 'view' button, default is "eye".
19591961
download_label (str): Label for the 'download' button, default is "Download".
19601962
download_icon (str): Icon for the 'download' button, default is "download".
1963+
send_label (str): Label for the 'send' button. Default is "Send".
1964+
send_icon (str): Fontawesome icon for the 'send' button. Default is "envelope".
19611965
zip_label (Optional[str]): Label for the zip option. If not provided, uses the generic template for `self.zip_label` ("Download all").
19621966
zip_icon (str): Icon for the zip option, default is "file-archive".
19631967
append_matching_suffix (bool): Flag to determine if matching suffix should be appended to file name, default is True.
1964-
include_email (bool): Flag to include an email option, default is False.
1968+
include_email (bool): Flag to include an option, default is False.
19651969
use_previously_cached_files (bool): Flag to use previously cached files (e.g., made in background) if defined. default is False.
19661970
include_full_pdf (bool): Flag to include a full PDF option, default is False.
19671971
full_pdf_label (Optional[str]): Label for the full PDF option. If not provided, uses the generic template for `self.full_pdf_label` ("Download all").
@@ -2071,7 +2075,7 @@ def download_list_html(
20712075
html += table_row(full_pdf_label, full_pdf_button)
20722076

20732077
if include_email:
2074-
html += self.send_email_table_row(key=key)
2078+
html += self.send_email_table_row(key=key, send_label=send_label, send_icon=send_icon)
20752079

20762080
html += "\n</div>"
20772081

@@ -2150,13 +2154,15 @@ def download_html(
21502154

21512155
return html
21522156

2153-
def send_email_table_row(self, key: str = "final") -> str:
2157+
def send_email_table_row(self, key: str = "final", send_label: str = "Send", send_icon: str = "envelope") -> str:
21542158
"""
21552159
Generate HTML doc table row for an input box and button that allows
21562160
someone to send the bundle to the specified email address.
21572161
21582162
Args:
21592163
key (str): A key used to identify which version of the ALDocument to send. Defaults to "final".
2164+
send_label (str): Label for the 'send' button. Default is "Send".
2165+
send_icon (str): Icon for the 'send' button. Default is "envelope".
21602166
21612167
Returns:
21622168
str: The generated HTML string for the table row.
@@ -2189,7 +2195,7 @@ def send_email_table_row(self, key: str = "final") -> str:
21892195
"""
21902196

21912197
# "Send" button for the 2nd column of the table row
2192-
send_button = f'{action_button_html(javascript_string, label="Send", icon="envelope", color="primary", size="md", classname="al_send_email_button al_button", id_tag=al_send_button_id)}'
2198+
send_button = f'{action_button_html(javascript_string, label=send_label, icon=send_icon, color="primary", size="md", classname="al_send_email_button al_button", id_tag=al_send_button_id)}'
21932199

21942200
# Whole row put together
21952201
html = f"""
@@ -2261,6 +2267,8 @@ def send_button_html(
22612267
key: str = "final",
22622268
show_editable_checkbox: bool = True,
22632269
template_name: str = "",
2270+
label: str = "Send",
2271+
icon: str = "envelope",
22642272
) -> str:
22652273
"""
22662274
Generate HTML for an input box and button that allows someone to send the bundle
@@ -2276,6 +2284,9 @@ def send_button_html(
22762284
Defaults to True.
22772285
template_name (str, optional): Name of the template variable that is used to fill
22782286
the email contents. By default, the `x.send_email_template` template will be used.
2287+
label (str, optional): The label for the button. Defaults to "Send".
2288+
icon (str, optional): The Fontawesome icon for the button. Defaults
2289+
to "envelope".
22792290
22802291
Returns:
22812292
str: The generated HTML string for the input box and button.
@@ -2327,7 +2338,7 @@ def send_button_html(
23272338
<input value="{user_info().email if user_logged_in() else ''}" alt="Email address for document" class="form-control" type="email" size="35" name="{al_email_input_id}" id="{al_email_input_id}">
23282339
</span>
23292340
2330-
{action_button_html(javascript_string, label="Send", icon="envelope", color="primary", size="md", classname="al_send_email_button", id_tag=al_send_button_id)}
2341+
{action_button_html(javascript_string, label=label, icon=icon, color="primary", size="md", classname="al_send_email_button", id_tag=al_send_button_id)}
23312342
23322343
</div>
23332344
"""

docassemble/AssemblyLine/data/questions/test_aldocument.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,14 @@ comment: |
214214
format:str='pdf',
215215
view:bool=True,
216216
refresh:bool=True,
217-
include_zip:bool = True,
218-
view_label="View",
217+
include_zip:bool=True,
218+
view_label:str="View",
219219
view_icon:str="eye",
220220
download_label:str="Download",
221221
download_icon:str="download",
222+
include_email:bool=False,
223+
send_label:str="Send",
224+
send_icon:str="envelope",
222225
zip_label:str="Download zip",
223226
zip_icon:str="file-archive"
224227
id: download_list_html_custom_1
@@ -231,21 +234,21 @@ subquestion: |
231234
- Keep "view" as True
232235
- Keep "include_zip" as True
233236
234-
multi_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", zip_label="Custom zip label", zip_icon="clock" )
237+
multi_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", include_email=True, send_label="Custom send label", send_icon="search", zip_label="Custom zip label", zip_icon="clock" )
235238
236-
${ multi_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", zip_label="Custom zip label", zip_icon="clock" ) }
239+
${ multi_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", include_email=True, send_label="Custom send label", send_icon="search", zip_label="Custom zip label", zip_icon="clock" ) }
237240
238241
---
239242
240-
single_pdf_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", zip_label="Custom zip label", zip_icon="clock" )
243+
single_pdf_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", include_email=True, send_label="Custom send label", send_icon="search", zip_label="Custom zip label", zip_icon="clock" )
241244
242-
${ single_pdf_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", zip_label="Custom zip label", zip_icon="clock" ) }
245+
${ single_pdf_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", include_email=True, send_label="Custom send label", send_icon="search", zip_label="Custom zip label", zip_icon="clock" ) }
243246
244247
---
245248
246-
single_docx_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", zip_label="Custom zip label", zip_icon="clock" )
249+
single_docx_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", include_email=True, send_label="Custom send label", send_icon="search", zip_label="Custom zip label", zip_icon="clock" )
247250
248-
${ single_docx_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", zip_label="Custom zip label", zip_icon="clock" ) }
251+
${ single_docx_bundle_1.download_list_html( key="test_key", format="docx", refresh=False, view_label="Custom view label", view_icon="circle", download_label="Custom download label", download_icon="square", include_email=True, send_label="Custom send label", send_icon="search", zip_label="Custom zip label", zip_icon="clock" ) }
249252
250253
---
251254
---
@@ -329,21 +332,45 @@ subquestion: |
329332
id: email_custom
330333
continue button field: email_custom
331334
question: |
332-
send_button_html() with custom args
335+
send_button_html() and send_button_to_html() with custom args
333336
subquestion: |
334-
multi_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False )
337+
##### send_button_html()
338+
339+
Send button which allows the user to edit the email address.
340+
341+
multi_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, label="Custom send label", icon="search" )
342+
343+
${ multi_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, label="Custom send label", icon="search" ) }
344+
345+
---
346+
single_pdf_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, label="Custom send label", icon="search" )
347+
348+
${ single_pdf_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, label="Custom send label", icon="search" ) }
349+
350+
---
351+
single_docx_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, label="Custom send label", icon="search" )
352+
353+
${ single_docx_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, label="Custom send label", icon="search" ) }
354+
355+
---
356+
357+
##### send_button_to_html()
358+
359+
Send button that hides the recipient's email address.
360+
361+
multi_bundle_1.send_button_to_html( "happy_feet@example.com", key="test_key", label="Custom send label", icon="search" )
335362
336-
${ multi_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False ) }
363+
${ multi_bundle_1.send_button_to_html( "happy_feet@example.com", key="test_key", label="Custom send label", icon="search" ) }
337364
338365
---
339-
single_pdf_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False )
366+
single_pdf_bundle_1.send_button_to_html( "happy_feet@example.com", key="test_key", label="Custom send label", icon="search" )
340367
341-
${ single_pdf_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False ) }
368+
${ single_pdf_bundle_1.send_button_to_html( "happy_feet@example.com", key="test_key", label="Custom send label", icon="search" ) }
342369
343370
---
344-
single_docx_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False )
371+
single_docx_bundle_1.send_button_to_html( "happy_feet@example.com", key="test_key", label="Custom send label", icon="search" )
345372
346-
${ single_docx_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False ) }
373+
${ single_docx_bundle_1.send_button_to_html( "happy_feet@example.com", key="test_key", label="Custom send label", icon="search" ) }
347374
348375
---
349376
---

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import sys
3-
from setuptools import setup, find_packages
3+
from setuptools import setup, find_namespace_packages
44
from fnmatch import fnmatchcase
55
from distutils.util import convert_path
66

@@ -52,9 +52,8 @@ def find_package_data(where='.', package='', exclude=standard_exclude, exclude_d
5252
author_email='qsteenhuis@suffolk.edu',
5353
license='The MIT License (MIT)',
5454
url='https://courtformsonline.org',
55-
packages=find_packages(),
56-
namespace_packages=['docassemble'],
57-
install_requires=['docassemble.ALToolbox>=0.8.3', 'docassemble.GithubFeedbackForm>=0.2.1'],
55+
packages=find_namespace_packages(),
56+
install_requires=['docassemble.ALToolbox>=0.11.1', 'docassemble.GithubFeedbackForm>=0.4.1.1'],
5857
zip_safe=False,
5958
package_data=find_package_data(where='docassemble/AssemblyLine/', package='docassemble.AssemblyLine'),
6059
)

0 commit comments

Comments
 (0)