Skip to content

Commit

Permalink
feat: add option to set default email recipients (#25555)
Browse files Browse the repository at this point in the history
* feat: add option to set default email recipients

* fix: don't crash if no events

communication.js:206 Uncaught TypeError: Cannot read properties of undefined (reading 'events')
    at frappe.views.CommunicationComposer.get_default_recipients (communication.js:206:16)
    at frappe.views.CommunicationComposer.get_fields (communication.js:57:19)
    at frappe.views.CommunicationComposer.make (communication.js:25:17)
    at new frappe.views.CommunicationComposer (communication.js:16:8)
    at Object.primary_action (communication__list_js:34:3)
    at HTMLButtonElement.<anonymous> (list_view.js:1432:19)
    at HTMLButtonElement.dispatch (jquery.js:5135:27)
    at elemData.handle (jquery.js:4939:28)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
(cherry picked from commit 4c85626)

# Conflicts:
#	frappe/public/js/frappe/views/communication.js
  • Loading branch information
barredterra authored and mergify[bot] committed Apr 11, 2024
1 parent af33091 commit dc070a4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions frappe/public/js/frappe/views/communication.js
Expand Up @@ -53,6 +53,7 @@ frappe.views.CommunicationComposer = class {
fieldtype: "MultiSelect",
reqd: 0,
fieldname: "recipients",
default: this.get_default_recipients("recipients"),
},
{
fieldtype: "Button",
Expand All @@ -71,11 +72,13 @@ frappe.views.CommunicationComposer = class {
label: __("CC"),
fieldtype: "MultiSelect",
fieldname: "cc",
default: this.get_default_recipients("cc"),
},
{
label: __("BCC"),
fieldtype: "MultiSelect",
fieldname: "bcc",
default: this.get_default_recipients("bcc"),
},
{
fieldtype: "Section Break",
Expand Down Expand Up @@ -187,6 +190,42 @@ frappe.views.CommunicationComposer = class {
return fields;
}

<<<<<<< HEAD
=======
get_default_recipients(fieldname) {
if (this.frm?.events.get_email_recipients) {
return (this.frm.events.get_email_recipients(this.frm, fieldname) || []).join(", ");
} else {
return "";
}
}

guess_language() {
// when attach print for print format changes try to guess language
// if print format has language then set that else boot lang.

// Print language resolution:
// 1. Document's print_language field
// 2. print format's default field
// 3. user lang
// 4. system lang
// 3 and 4 are resolved already in boot
let document_lang = this.frm?.doc?.language;
let print_format = this.dialog.get_value("select_print_format");

let print_format_lang;
if (print_format != "Standard") {
print_format_lang = frappe.get_doc(
"Print Format",
print_format
)?.default_print_language;
}

let lang = document_lang || print_format_lang || frappe.boot.lang;
this.dialog.set_value("print_language", lang);
}

>>>>>>> 4c8562687f (feat: add option to set default email recipients (#25555))
toggle_more_options(show_options) {
show_options = show_options || this.dialog.fields_dict.more_options.df.hidden;
this.dialog.set_df_property("more_options", "hidden", !show_options);
Expand Down

0 comments on commit dc070a4

Please sign in to comment.