Skip to content

Commit aa2f5ce

Browse files
Merge pull request #970 from SuffolkLITLab/copilot/fix-920
Add support for multiple email addresses in email button HTML
2 parents 4c9d1e1 + 1e28c9c commit aa2f5ce

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

docassemble/AssemblyLine/data/static/aldocument.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
/*
2-
* given a docassemble event name, and text ID containing email address and whether
2+
* Helper function to process multiple email addresses from a string
3+
* Splits on comma or semicolon and trims whitespace
4+
*/
5+
function process_multiple_emails(email_string) {
6+
if (!email_string || typeof email_string !== 'string') {
7+
return email_string;
8+
}
9+
10+
// Split on comma or semicolon, trim whitespace, and filter out empty strings
11+
var emails = email_string.split(/[,;]/).map(function(email) {
12+
return email.trim();
13+
}).filter(function(email) {
14+
return email.length > 0;
15+
});
16+
17+
// Return single string if only one email, array if multiple
18+
return emails.length === 1 ? emails[0] : emails;
19+
}
20+
21+
/*
22+
* given a docassemble event name, and text ID containing email address(es) and whether
323
* or not user wants to send editable files, trigger docassemble event to
4-
* email an ALDocumentBundle
24+
* email an ALDocumentBundle. Supports multiple email addresses separated by commas or semicolons.
525
*/
626
function aldocument_send_action(event_name, wants_editable_id, email_id, template_name="", key="final", preferred_formats=null) {
727
var editable = null;
@@ -18,7 +38,8 @@ function aldocument_send_action(event_name, wants_editable_id, email_id, templat
1838
}
1939
}
2040

21-
var email = $('#' + email_id)[0].value;
41+
var email_raw = $('#' + email_id)[0].value;
42+
var email = process_multiple_emails(email_raw);
2243
da_action_perform(event_name, {editable: editable, email: email, key:key, template_name: template_name, preferred_formats: final_formats});
2344
};
2445

0 commit comments

Comments
 (0)