Skip to content

Commit ea3aca6

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

File tree

4 files changed

+88
-29
lines changed

4 files changed

+88
-29
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: 42 additions & 9 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,13 @@ 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
1969+
option, default is False.
19651970
use_previously_cached_files (bool): Flag to use previously cached files (e.g., made in background) if defined. default is False.
19661971
include_full_pdf (bool): Flag to include a full PDF option, default is False.
19671972
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 +2076,7 @@ def download_list_html(
20712076
html += table_row(full_pdf_label, full_pdf_button)
20722077

20732078
if include_email:
2074-
html += self.send_email_table_row(key=key)
2079+
html += self.send_email_table_row(key=key, send_label=send_label, send_icon=send_icon)
20752080

20762081
html += "\n</div>"
20772082

@@ -2150,13 +2155,15 @@ def download_html(
21502155

21512156
return html
21522157

2153-
def send_email_table_row(self, key: str = "final") -> str:
2158+
def send_email_table_row(self, key: str = "final", send_label: str = "Send", send_icon: str = "envelope") -> str:
21542159
"""
21552160
Generate HTML doc table row for an input box and button that allows
21562161
someone to send the bundle to the specified email address.
21572162
21582163
Args:
21592164
key (str): A key used to identify which version of the ALDocument to send. Defaults to "final".
2165+
send_label (str): Label for the 'send' button. Default is "Send".
2166+
send_icon (str): Icon for the 'send' button. Default is "envelope".
21602167
21612168
Returns:
21622169
str: The generated HTML string for the table row.
@@ -2189,7 +2196,7 @@ def send_email_table_row(self, key: str = "final") -> str:
21892196
"""
21902197

21912198
# "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)}'
2199+
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)}'
21932200

21942201
# Whole row put together
21952202
html = f"""
@@ -2206,8 +2213,10 @@ def send_button_to_html(
22062213
email: str,
22072214
editable: bool = False,
22082215
template_name: str = "",
2209-
label: str = "Send",
2210-
icon: str = "envelope",
2216+
label: Optional[str] = None,
2217+
send_label: str = "Send",
2218+
icon: Optional[str] = None,
2219+
send_icon: str = "envelope",
22112220
color: str = "primary",
22122221
key: str = "final",
22132222
) -> str:
@@ -2220,14 +2229,23 @@ def send_button_to_html(
22202229
email (str): The recipient's email address.
22212230
editable (bool, optional): Flag indicating if the bundle is editable. Defaults to False.
22222231
template_name (str, optional): The name of the template to be used. Defaults to an empty string.
2223-
label (str, optional): The label for the button. Defaults to "Send".
2224-
icon (str, optional): The Fontawesome icon for the button. Defaults to "envelope".
2232+
label (Optional[str]): The label for the send button. Defaults to
2233+
`send_label`.
2234+
send_label (str): Alias for `label`. Matches other methods.
2235+
Defaults to "Send".
2236+
icon (Optional[str]): The Fontawesome icon for the send button.
2237+
Defaults to `send_icon`.
2238+
send_icon (str): Alias for `icon`. Matches other methods. Defaults
2239+
to "envelope".
22252240
color (str, optional): The Bootstrap color of the button. Defaults to "primary".
22262241
key (str, optional): A key used to identify which version of the ALDocument to send. Defaults to "final".
22272242
22282243
Returns:
22292244
str: The generated HTML string for the button.
22302245
"""
2246+
label = label or send_label
2247+
icon = icon or send_icon
2248+
22312249
if not self.has_enabled_documents():
22322250
return "" # Don't let people email an empty set of documents
22332251
if not hasattr(self, "_cached_get_email_copy"):
@@ -2261,6 +2279,10 @@ def send_button_html(
22612279
key: str = "final",
22622280
show_editable_checkbox: bool = True,
22632281
template_name: str = "",
2282+
label: Optional[str] = None,
2283+
send_label: str = "Send",
2284+
icon: Optional[str] = None,
2285+
send_icon: str = "envelope",
22642286
) -> str:
22652287
"""
22662288
Generate HTML for an input box and button that allows someone to send the bundle
@@ -2276,10 +2298,21 @@ def send_button_html(
22762298
Defaults to True.
22772299
template_name (str, optional): Name of the template variable that is used to fill
22782300
the email contents. By default, the `x.send_email_template` template will be used.
2301+
label (str, optional): The label for the send button. Defaults to
2302+
`send_label`. Matches other methods.
2303+
send_label (str): Alias for `label`. Matches other methods.
2304+
Defaults to "Send".
2305+
icon (str, optional): The Fontawesome icon for the send button.
2306+
Defaults to `send_icon`. Matches other methods.
2307+
send_icon (str): Alias for `icon`. Matches other methods. Defaults
2308+
to "envelope".
22792309
22802310
Returns:
22812311
str: The generated HTML string for the input box and button.
22822312
"""
2313+
label = label or send_label
2314+
icon = icon or send_icon
2315+
22832316
if not self.has_enabled_documents():
22842317
return "" # Don't let people email an empty set of documents
22852318
if not hasattr(self, "_cached_get_email_copy"):
@@ -2327,7 +2360,7 @@ def send_button_html(
23272360
<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}">
23282361
</span>
23292362
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)}
2363+
{action_button_html(javascript_string, label=label, icon=icon, color="primary", size="md", classname="al_send_email_button", id_tag=al_send_button_id)}
23312364
23322365
</div>
23332366
"""

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, send_label="Custom send label", send_icon="search" )
342+
343+
${ multi_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, send_label="Custom send label", send_icon="search" ) }
344+
345+
---
346+
single_pdf_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, send_label="Custom send label", send_icon="search" )
347+
348+
${ single_pdf_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, send_label="Custom send label", send_icon="search" ) }
349+
350+
---
351+
single_docx_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, send_label="Custom send label", send_icon="search" )
352+
353+
${ single_docx_bundle_1.send_button_html( key="test_key", show_editable_checkbox=False, send_label="Custom send label", send_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", send_label="Custom send label", send_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", send_label="Custom send label", send_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", send_label="Custom send label", send_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", send_label="Custom send label", send_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", send_label="Custom send label", send_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", send_label="Custom send label", send_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)