diff --git a/crm/hooks.py b/crm/hooks.py index 8e703a15..c60beac0 100644 --- a/crm/hooks.py +++ b/crm/hooks.py @@ -76,7 +76,7 @@ after_install = "crm.install.after_install" # Uninstallation # ------------ -# before_uninstall = "crm.uninstall.before_uninstall" +before_uninstall = "crm.uninstall.before_uninstall" # after_uninstall = "crm.uninstall.after_uninstall" # Integration Setup @@ -118,7 +118,8 @@ after_install = "crm.install.after_install" # Override standard doctype classes override_doctype_class = { - "Contact": "crm.overrides.contact.CustomContact" + "Contact": "crm.overrides.contact.CustomContact", + "Email Template": "crm.overrides.email_template.CustomEmailTemplate", } # Document Events diff --git a/crm/install.py b/crm/install.py index ff8a914d..351dd8ce 100644 --- a/crm/install.py +++ b/crm/install.py @@ -1,9 +1,11 @@ # Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt - from __future__ import unicode_literals +import click import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_fields + def before_install(): pass @@ -12,6 +14,7 @@ def after_install(): add_default_deal_statuses() add_default_communication_statuses() add_property_setter() + add_email_template_custom_fields() frappe.db.commit() def add_default_lead_statuses(): @@ -113,4 +116,31 @@ def add_property_setter(): doc.property = "search_fields" doc.property_type = "Data" doc.value = "email_id" - doc.insert() \ No newline at end of file + doc.insert() + +def add_email_template_custom_fields(): + if not frappe.get_meta("Email Template").has_field("enabled"): + click.secho("* Installing Custom Fields in Email Template") + + create_custom_fields( + { + "Email Template": [ + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled", + "insert_after": "", + }, + { + "fieldname": "reference_doctype", + "fieldtype": "Link", + "label": "Doctype", + "options": "DocType", + "insert_after": "enabled", + }, + ] + } + ) + + frappe.clear_cache(doctype="Email Template") diff --git a/crm/overrides/email_template.py b/crm/overrides/email_template.py new file mode 100644 index 00000000..da14c714 --- /dev/null +++ b/crm/overrides/email_template.py @@ -0,0 +1,49 @@ +# import frappe +from frappe import _ +from frappe.email.doctype.email_template.email_template import EmailTemplate + + +class CustomEmailTemplate(EmailTemplate): + @staticmethod + def default_list_data(): + columns = [ + { + 'label': 'Name', + 'type': 'Data', + 'key': 'name', + 'width': '17rem', + }, + { + 'label': 'Subject', + 'type': 'Data', + 'key': 'subject', + 'width': '12rem', + }, + { + 'label': 'Enabled', + 'type': 'Check', + 'key': 'enabled', + 'width': '6rem', + }, + { + 'label': 'Doctype', + 'type': 'Link', + 'key': 'reference_doctype', + 'width': '12rem', + }, + { + 'label': 'Last Modified', + 'type': 'Datetime', + 'key': 'modified', + 'width': '8rem', + }, + ] + rows = [ + "name", + "enabled", + "reference_doctype", + "subject", + "response", + "modified", + ] + return {'columns': columns, 'rows': rows} diff --git a/crm/uninstall.py b/crm/uninstall.py new file mode 100644 index 00000000..34622d0b --- /dev/null +++ b/crm/uninstall.py @@ -0,0 +1,22 @@ +# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt +from __future__ import unicode_literals +import click +import frappe + +def before_uninstall(): + delete_email_template_custom_fields() + +def delete_email_template_custom_fields(): + if frappe.get_meta("Email Template").has_field("enabled"): + click.secho("* Uninstalling Custom Fields from Email Template") + + fieldnames = ( + "enabled", + "reference_doctype", + ) + + for fieldname in fieldnames: + frappe.db.delete("Custom Field", {"name": "Email Template-" + fieldname}) + + frappe.clear_cache(doctype="Email Template") \ No newline at end of file diff --git a/frontend/src/components/CommentBox.vue b/frontend/src/components/CommentBox.vue index 2f3ea28c..b74d82ec 100644 --- a/frontend/src/components/CommentBox.vue +++ b/frontend/src/components/CommentBox.vue @@ -2,8 +2,8 @@ @@ -84,26 +86,32 @@ class="-ml-1" :buttons="textEditorMenuButtons" /> - - - +
+ + + + +
+ diff --git a/frontend/src/components/Modals/EmailTemplateModal.vue b/frontend/src/components/Modals/EmailTemplateModal.vue new file mode 100644 index 00000000..c8b009ce --- /dev/null +++ b/frontend/src/components/Modals/EmailTemplateModal.vue @@ -0,0 +1,199 @@ + + + diff --git a/frontend/src/components/Modals/EmailTemplateSelectorModal.vue b/frontend/src/components/Modals/EmailTemplateSelectorModal.vue new file mode 100644 index 00000000..616a45e8 --- /dev/null +++ b/frontend/src/components/Modals/EmailTemplateSelectorModal.vue @@ -0,0 +1,86 @@ + + + diff --git a/frontend/src/pages/EmailTemplate.vue b/frontend/src/pages/EmailTemplate.vue new file mode 100644 index 00000000..72571af1 --- /dev/null +++ b/frontend/src/pages/EmailTemplate.vue @@ -0,0 +1,6 @@ + diff --git a/frontend/src/pages/EmailTemplates.vue b/frontend/src/pages/EmailTemplates.vue new file mode 100644 index 00000000..3dea1ea4 --- /dev/null +++ b/frontend/src/pages/EmailTemplates.vue @@ -0,0 +1,107 @@ + + + diff --git a/frontend/src/router.js b/frontend/src/router.js index 9ee28274..73f733bb 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -73,6 +73,18 @@ const routes = [ component: () => import('@/pages/CallLog.vue'), props: true, }, + { + path: '/email-templates', + name: 'Email Templates', + component: () => import('@/pages/EmailTemplates.vue'), + meta: { scrollPos: { top: 0, left: 0 } }, + }, + { + path: '/email-templates/:emailTemplateId', + name: 'Email Template', + component: () => import('@/pages/EmailTemplate.vue'), + props: true, + }, { path: '/dashboard', name: 'Dashboard',