@@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json | |||||
from .exceptions import * | from .exceptions import * | ||||
from .utils.jinja import get_jenv, get_template, render_template | from .utils.jinja import get_jenv, get_template, render_template | ||||
__version__ = '8.3.2' | |||||
__version__ = '8.3.3' | |||||
__title__ = "Frappe Framework" | __title__ = "Frappe Framework" | ||||
local = Local() | local = Local() | ||||
@@ -119,7 +119,8 @@ frappe.ui.form.on("Email Account", { | |||||
}, | }, | ||||
show_gmail_message_for_less_secure_apps: function(frm) { | show_gmail_message_for_less_secure_apps: function(frm) { | ||||
if(frm.doc.service==="Gmail") { | |||||
frm.dashboard.clear_headline(); | |||||
if(frm.doc.service==="GMail") { | |||||
frm.dashboard.set_headline_alert('Gmail will only work if you allow access for less secure \ | frm.dashboard.set_headline_alert('Gmail will only work if you allow access for less secure \ | ||||
apps in Gmail settings. <a target="_blank" \ | apps in Gmail settings. <a target="_blank" \ | ||||
href="https://support.google.com/accounts/answer/6010255?hl=en">Read this for details</a>'); | href="https://support.google.com/accounts/answer/6010255?hl=en">Read this for details</a>'); | ||||
@@ -18,6 +18,7 @@ frappe.email_alert = { | |||||
// set value changed options | // set value changed options | ||||
frm.set_df_property("value_changed", "options", [""].concat(options)); | frm.set_df_property("value_changed", "options", [""].concat(options)); | ||||
frm.set_df_property("set_property_after_alert", "options", [""].concat(options)); | |||||
// set date changed options | // set date changed options | ||||
frm.set_df_property("date_changed", "options", $.map(fields, | frm.set_df_property("date_changed", "options", $.map(fields, | ||||
@@ -1,5 +1,6 @@ | |||||
{ | { | ||||
"allow_copy": 0, | "allow_copy": 0, | ||||
"allow_guest_to_view": 0, | |||||
"allow_import": 0, | "allow_import": 0, | ||||
"allow_rename": 1, | "allow_rename": 1, | ||||
"autoname": "Prompt", | "autoname": "Prompt", | ||||
@@ -13,6 +14,7 @@ | |||||
"engine": "InnoDB", | "engine": "InnoDB", | ||||
"fields": [ | "fields": [ | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -24,6 +26,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Enabled", | "label": "Enabled", | ||||
@@ -41,6 +44,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -51,6 +55,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Filters", | "label": "Filters", | ||||
@@ -68,6 +73,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -79,6 +85,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 1, | "ignore_xss_filter": 1, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 1, | "in_list_view": 1, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Subject", | "label": "Subject", | ||||
@@ -96,6 +103,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -106,6 +114,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 1, | "in_list_view": 1, | ||||
"in_standard_filter": 1, | "in_standard_filter": 1, | ||||
"label": "Document Type", | "label": "Document Type", | ||||
@@ -124,6 +133,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -134,6 +144,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Is Standard", | "label": "Is Standard", | ||||
@@ -152,6 +163,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -163,6 +175,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 1, | "in_standard_filter": 1, | ||||
"label": "Module", | "label": "Module", | ||||
@@ -182,6 +195,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -192,6 +206,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"length": 0, | "length": 0, | ||||
@@ -209,6 +224,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -219,6 +235,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 1, | "in_list_view": 1, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Send Alert On", | "label": "Send Alert On", | ||||
@@ -237,6 +254,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -249,6 +267,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Trigger Method", | "label": "Trigger Method", | ||||
@@ -267,6 +286,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -279,6 +299,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Reference Date", | "label": "Reference Date", | ||||
@@ -296,6 +317,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -309,6 +331,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Days Before or After", | "label": "Days Before or After", | ||||
@@ -326,6 +349,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -338,6 +362,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Value Changed", | "label": "Value Changed", | ||||
@@ -355,6 +380,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -365,6 +391,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"length": 0, | "length": 0, | ||||
@@ -382,6 +409,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -394,6 +422,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 1, | "ignore_xss_filter": 1, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 1, | "in_list_view": 1, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Condition", | "label": "Condition", | ||||
@@ -411,6 +440,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -421,6 +451,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"length": 0, | "length": 0, | ||||
@@ -437,6 +468,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -447,6 +479,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"length": 0, | "length": 0, | ||||
@@ -464,6 +497,97 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 1, | |||||
"columns": 0, | |||||
"fieldname": "property_section", | |||||
"fieldtype": "Section Break", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_global_search": 0, | |||||
"in_list_view": 0, | |||||
"in_standard_filter": 0, | |||||
"label": "Set Property After Alert", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"remember_last_selected_value": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | |||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 0, | |||||
"columns": 0, | |||||
"fieldname": "set_property_after_alert", | |||||
"fieldtype": "Select", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_global_search": 0, | |||||
"in_list_view": 0, | |||||
"in_standard_filter": 0, | |||||
"label": "Set Property After Alert", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"remember_last_selected_value": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | |||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 0, | |||||
"columns": 0, | |||||
"fieldname": "property_value", | |||||
"fieldtype": "Data", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_global_search": 0, | |||||
"in_list_view": 0, | |||||
"in_standard_filter": 0, | |||||
"label": "Value To Be Set", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"remember_last_selected_value": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | |||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -474,6 +598,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Recipients", | "label": "Recipients", | ||||
@@ -491,6 +616,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -501,6 +627,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Recipients", | "label": "Recipients", | ||||
@@ -519,6 +646,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -529,6 +657,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Message", | "label": "Message", | ||||
@@ -546,18 +675,20 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | "columns": 0, | ||||
"default": "Add your message here", | "default": "Add your message here", | ||||
"depends_on": "", | |||||
"depends_on": "eval:!doc.is_standard", | |||||
"fieldname": "message", | "fieldname": "message", | ||||
"fieldtype": "Code", | "fieldtype": "Code", | ||||
"hidden": 0, | "hidden": 0, | ||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 1, | "ignore_xss_filter": 1, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Message", | "label": "Message", | ||||
@@ -575,6 +706,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -585,6 +717,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Attach Print", | "label": "Attach Print", | ||||
@@ -603,6 +736,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -613,6 +747,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "Message Examples", | "label": "Message Examples", | ||||
@@ -631,6 +766,7 @@ | |||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | { | ||||
"allow_bulk_edit": 0, | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
@@ -641,6 +777,7 @@ | |||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_global_search": 0, | |||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"in_standard_filter": 0, | "in_standard_filter": 0, | ||||
"label": "View Properties (via Customize Form)", | "label": "View Properties (via Customize Form)", | ||||
@@ -659,19 +796,19 @@ | |||||
"unique": 0 | "unique": 0 | ||||
} | } | ||||
], | ], | ||||
"has_web_view": 0, | |||||
"hide_heading": 0, | "hide_heading": 0, | ||||
"hide_toolbar": 0, | "hide_toolbar": 0, | ||||
"icon": "fa fa-envelope", | "icon": "fa fa-envelope", | ||||
"idx": 0, | "idx": 0, | ||||
"image_view": 0, | "image_view": 0, | ||||
"in_create": 0, | "in_create": 0, | ||||
"in_dialog": 0, | |||||
"is_submittable": 0, | "is_submittable": 0, | ||||
"issingle": 0, | "issingle": 0, | ||||
"istable": 0, | "istable": 0, | ||||
"max_attachments": 0, | "max_attachments": 0, | ||||
"menu_index": 0, | "menu_index": 0, | ||||
"modified": "2016-12-29 14:40:25.782293", | |||||
"modified": "2017-07-07 16:09:48.804218", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Email", | "module": "Email", | ||||
"name": "Email Alert", | "name": "Email Alert", | ||||
@@ -688,7 +825,6 @@ | |||||
"export": 1, | "export": 1, | ||||
"if_owner": 0, | "if_owner": 0, | ||||
"import": 0, | "import": 0, | ||||
"is_custom": 0, | |||||
"permlevel": 0, | "permlevel": 0, | ||||
"print": 0, | "print": 0, | ||||
"read": 1, | "read": 1, | ||||
@@ -703,6 +839,7 @@ | |||||
"quick_entry": 0, | "quick_entry": 0, | ||||
"read_only": 0, | "read_only": 0, | ||||
"read_only_onload": 0, | "read_only_onload": 0, | ||||
"show_name_in_global_search": 0, | |||||
"sort_field": "modified", | "sort_field": "modified", | ||||
"sort_order": "DESC", | "sort_order": "DESC", | ||||
"title_field": "subject", | "title_field": "subject", | ||||
@@ -159,6 +159,11 @@ def get_context(context): | |||||
reference_name = doc.name, | reference_name = doc.name, | ||||
attachments = attachments) | attachments = attachments) | ||||
if self.set_property_after_alert: | |||||
frappe.db.set_value(doc.doctype, doc.name, self.set_property_after_alert, | |||||
self.property_value, update_modified = False) | |||||
doc.set(self.set_property_after_alert, self.property_value) | |||||
def load_standard_properties(self, context): | def load_standard_properties(self, context): | ||||
module = get_doc_module(self.module, self.doctype, self.name) | module = get_doc_module(self.module, self.doctype, self.name) | ||||
if module: | if module: | ||||
@@ -7,6 +7,8 @@ import unittest | |||||
test_records = frappe.get_test_records('Email Alert') | test_records = frappe.get_test_records('Email Alert') | ||||
test_dependencies = ["User"] | |||||
class TestEmailAlert(unittest.TestCase): | class TestEmailAlert(unittest.TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
frappe.db.sql("""delete from `tabEmail Queue`""") | frappe.db.sql("""delete from `tabEmail Queue`""") | ||||
@@ -32,6 +34,9 @@ class TestEmailAlert(unittest.TestCase): | |||||
self.assertTrue(frappe.db.get_value("Email Queue", {"reference_doctype": "Communication", | self.assertTrue(frappe.db.get_value("Email Queue", {"reference_doctype": "Communication", | ||||
"reference_name": communication.name, "status":"Not Sent"})) | "reference_name": communication.name, "status":"Not Sent"})) | ||||
self.assertEquals(frappe.db.get_value('Communication', | |||||
communication.name, 'subject'), '__testing__') | |||||
def test_condition(self): | def test_condition(self): | ||||
event = frappe.new_doc("Event") | event = frappe.new_doc("Event") | ||||
event.subject = "test", | event.subject = "test", | ||||
@@ -137,7 +142,7 @@ class TestEmailAlert(unittest.TestCase): | |||||
event.save() | event.save() | ||||
# Value Change email alert alert will be trigger as description is not changed | # Value Change email alert alert will be trigger as description is not changed | ||||
# mail will not be sent | |||||
# mail will not be sent | |||||
self.assertFalse(frappe.db.get_value("Email Queue", {"reference_doctype": "Event", | self.assertFalse(frappe.db.get_value("Email Queue", {"reference_doctype": "Event", | ||||
"reference_name": event.name, "status":"Not Sent"})) | "reference_name": event.name, "status":"Not Sent"})) | ||||
@@ -21,7 +21,9 @@ | |||||
"condition": "doc.communication_type=='Comment'", | "condition": "doc.communication_type=='Comment'", | ||||
"recipients": [ | "recipients": [ | ||||
{ "email_by_document_field": "owner" } | { "email_by_document_field": "owner" } | ||||
] | |||||
], | |||||
"set_property_after_alert": "subject", | |||||
"property_value": "__testing__" | |||||
}, | }, | ||||
{ | { | ||||
"doctype": "Email Alert", | "doctype": "Email Alert", | ||||
@@ -28,7 +28,8 @@ | |||||
border-top: 1px solid #d1d8dd; | border-top: 1px solid #d1d8dd; | ||||
} | } | ||||
.form-message { | .form-message { | ||||
padding: 15px; | |||||
padding: 15px 30px; | |||||
border-bottom: 1px solid #d1d8dd; | |||||
} | } | ||||
.document-flow-wrapper { | .document-flow-wrapper { | ||||
padding: 40px 15px 30px; | padding: 40px 15px 30px; | ||||
@@ -73,21 +74,24 @@ | |||||
} | } | ||||
.form-dashboard { | .form-dashboard { | ||||
background-color: #fafbfc; | background-color: #fafbfc; | ||||
border-bottom: 1px solid #d1d8dd; | |||||
} | |||||
.form-dashboard-wrapper { | |||||
margin: -15px 0px; | |||||
} | } | ||||
.form-documents h6 { | .form-documents h6 { | ||||
margin-top: 15px; | margin-top: 15px; | ||||
} | } | ||||
.form-dashboard-section { | .form-dashboard-section { | ||||
margin: 0px -15px; | |||||
padding: 15px 30px; | padding: 15px 30px; | ||||
border-bottom: 1px solid #EBEFF2; | border-bottom: 1px solid #EBEFF2; | ||||
} | } | ||||
.form-dashboard-section:first-child { | |||||
padding-top: 0px; | |||||
} | |||||
.form-dashboard-section:last-child { | .form-dashboard-section:last-child { | ||||
border-bottom: none; | border-bottom: none; | ||||
} | } | ||||
.form-heatmap { | |||||
padding-top: 30px; | |||||
} | |||||
.form-heatmap .heatmap-message { | .form-heatmap .heatmap-message { | ||||
margin-top: 10px; | margin-top: 10px; | ||||
} | } | ||||
@@ -543,20 +547,6 @@ select.form-control { | |||||
.password-strength-message { | .password-strength-message { | ||||
margin-top: -10px; | margin-top: -10px; | ||||
} | } | ||||
.form-headline { | |||||
padding: 0px 15px; | |||||
margin: 0px; | |||||
} | |||||
.form-headline .alert { | |||||
font-size: 12px; | |||||
background-color: #fffce7; | |||||
font-weight: normal !important; | |||||
border: 0px; | |||||
border-radius: 0px; | |||||
margin-bottom: 0px; | |||||
margin: 0px -15px; | |||||
padding: 10px 30px; | |||||
} | |||||
.delivery-status-indicator { | .delivery-status-indicator { | ||||
display: inline-block; | display: inline-block; | ||||
margin-top: -3px; | margin-top: -3px; | ||||
@@ -86,7 +86,8 @@ frappe.ui.form.Control = Class.extend({ | |||||
this.disp_status = this.get_status(); | this.disp_status = this.get_status(); | ||||
this.$wrapper | this.$wrapper | ||||
&& this.$wrapper.toggleClass("hide-control", this.disp_status=="None") | && this.$wrapper.toggleClass("hide-control", this.disp_status=="None") | ||||
&& this.$wrapper.trigger("refresh"); | |||||
&& this.refresh_input | |||||
&& this.refresh_input(); | |||||
}, | }, | ||||
get_doc: function() { | get_doc: function() { | ||||
return this.doctype && this.docname | return this.doctype && this.docname | ||||
@@ -108,34 +109,33 @@ frappe.ui.form.Control = Class.extend({ | |||||
}, | }, | ||||
validate_and_set_in_model: function(value, e) { | validate_and_set_in_model: function(value, e) { | ||||
var me = this; | var me = this; | ||||
return new Promise(resolve => { | |||||
if(this.inside_change_event) { | |||||
resolve(); | |||||
return; | |||||
} | |||||
this.inside_change_event = true; | |||||
var set = function(value) { | |||||
me.inside_change_event = false; | |||||
me.set_model_value(value) | |||||
.then(() => { | |||||
me.set_mandatory && me.set_mandatory(value); | |||||
if(me.df.change || me.df.onchange) { | |||||
// onchange event specified in df | |||||
let _promise = (me.df.change || me.df.onchange).apply(me, [e]); | |||||
if(_promise && _promise.then) { | |||||
_promise.then(() => { resolve(); }); | |||||
} else { | |||||
resolve(); | |||||
} | |||||
} else { | |||||
resolve(); | |||||
} | |||||
}); | |||||
} | |||||
if(this.inside_change_event) { | |||||
return new Promise.resolve(); | |||||
} | |||||
this.inside_change_event = true; | |||||
var set = function(value) { | |||||
me.inside_change_event = false; | |||||
return frappe.run_serially([ | |||||
() => me.set_model_value(value), | |||||
() => { | |||||
me.set_mandatory && me.set_mandatory(value); | |||||
if(me.df.change || me.df.onchange) { | |||||
// onchange event specified in df | |||||
return (me.df.change || me.df.onchange).apply(me, [e]); | |||||
} | |||||
} | |||||
]); | |||||
}; | |||||
this.validate ? this.validate(value, set) : set(value); | |||||
}); | |||||
value = this.validate(value); | |||||
if (value.then) { | |||||
// got a promise | |||||
return value.then((value) => set(value)); | |||||
} else { | |||||
// all clear | |||||
return set(value); | |||||
} | |||||
}, | }, | ||||
get_value: function() { | get_value: function() { | ||||
if(this.get_status()==='Write') { | if(this.get_status()==='Write') { | ||||
@@ -149,20 +149,17 @@ frappe.ui.form.Control = Class.extend({ | |||||
} | } | ||||
}, | }, | ||||
set_model_value: function(value) { | set_model_value: function(value) { | ||||
return new Promise(resolve => { | |||||
if(this.doctype && this.docname) { | |||||
frappe.model.set_value(this.doctype, this.docname, this.df.fieldname, | |||||
value, this.df.fieldtype) | |||||
.then(() => resolve()); | |||||
this.last_value = value; | |||||
} else { | |||||
if(this.doc) { | |||||
this.doc[this.df.fieldname] = value; | |||||
} | |||||
this.set_input(value); | |||||
resolve(); | |||||
if(this.doctype && this.docname) { | |||||
this.last_value = value; | |||||
return frappe.model.set_value(this.doctype, this.docname, this.df.fieldname, | |||||
value, this.df.fieldtype); | |||||
} else { | |||||
if(this.doc) { | |||||
this.doc[this.df.fieldname] = value; | |||||
} | } | ||||
}); | |||||
this.set_input(value); | |||||
return Promise.resolve(); | |||||
} | |||||
}, | }, | ||||
set_focus: function() { | set_focus: function() { | ||||
if(this.$input) { | if(this.$input) { | ||||
@@ -175,13 +172,11 @@ frappe.ui.form.Control = Class.extend({ | |||||
frappe.ui.form.ControlHTML = frappe.ui.form.Control.extend({ | frappe.ui.form.ControlHTML = frappe.ui.form.Control.extend({ | ||||
make: function() { | make: function() { | ||||
this._super(); | this._super(); | ||||
var me = this; | |||||
this.disp_area = this.wrapper; | this.disp_area = this.wrapper; | ||||
this.$wrapper.on("refresh", function() { | |||||
var content = me.get_content(); | |||||
if(content) me.$wrapper.html(content); | |||||
return false; | |||||
}); | |||||
}, | |||||
refresh_input: function() { | |||||
var content = this.get_content(); | |||||
if(content) this.$wrapper.html(content); | |||||
}, | }, | ||||
get_content: function() { | get_content: function() { | ||||
return this.df.options || ""; | return this.df.options || ""; | ||||
@@ -214,20 +209,20 @@ frappe.ui.form.ControlImage = frappe.ui.form.Control.extend({ | |||||
this.$wrapper.css({"margin": "0px"}); | this.$wrapper.css({"margin": "0px"}); | ||||
this.$body = $("<div></div>").appendTo(this.$wrapper) | this.$body = $("<div></div>").appendTo(this.$wrapper) | ||||
.css({"margin-bottom": "10px"}) | .css({"margin-bottom": "10px"}) | ||||
this.$wrapper.on("refresh", function() { | |||||
me.$body.empty(); | |||||
var doc = me.get_doc(); | |||||
if(doc && me.df.options && doc[me.df.options]) { | |||||
me.$img = $("<img src='"+doc[me.df.options]+"' class='img-responsive'>") | |||||
.appendTo(me.$body); | |||||
} else { | |||||
me.$buffer = $("<div class='missing-image'><i class='octicon octicon-circle-slash'></i></div>") | |||||
.appendTo(me.$body) | |||||
} | |||||
return false; | |||||
}); | |||||
$('<div class="clearfix"></div>').appendTo(this.$wrapper); | $('<div class="clearfix"></div>').appendTo(this.$wrapper); | ||||
}, | |||||
refresh_input: function() { | |||||
this.$body.empty(); | |||||
var doc = this.get_doc(); | |||||
if(doc && this.df.options && doc[this.df.options]) { | |||||
this.$img = $("<img src='"+doc[this.df.options]+"' class='img-responsive'>") | |||||
.appendTo(this.$body); | |||||
} else { | |||||
this.$buffer = $("<div class='missing-image'><i class='octicon octicon-circle-slash'></i></div>") | |||||
.appendTo(this.$body) | |||||
} | |||||
return false; | |||||
} | } | ||||
}); | }); | ||||
@@ -240,7 +235,6 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({ | |||||
// set description | // set description | ||||
this.set_max_width(); | this.set_max_width(); | ||||
this.setup_update_on_refresh(); | |||||
}, | }, | ||||
make_wrapper: function() { | make_wrapper: function() { | ||||
if(this.only_input) { | if(this.only_input) { | ||||
@@ -286,7 +280,7 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({ | |||||
// update input value, label, description | // update input value, label, description | ||||
// display (show/hide/read-only), | // display (show/hide/read-only), | ||||
// mandatory style on refresh | // mandatory style on refresh | ||||
setup_update_on_refresh: function() { | |||||
refresh_input: function() { | |||||
var me = this; | var me = this; | ||||
var make_input = function() { | var make_input = function() { | ||||
@@ -306,40 +300,37 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({ | |||||
} | } | ||||
} | } | ||||
this.$wrapper.on("refresh", function() { | |||||
if(me.disp_status != "None") { | |||||
// refresh value | |||||
if(me.doctype && me.docname) { | |||||
me.value = frappe.model.get_value(me.doctype, me.docname, me.df.fieldname); | |||||
} | |||||
if(me.disp_status != "None") { | |||||
// refresh value | |||||
if(me.doctype && me.docname) { | |||||
me.value = frappe.model.get_value(me.doctype, me.docname, me.df.fieldname); | |||||
} | |||||
if(me.disp_status=="Write") { | |||||
me.disp_area && $(me.disp_area).toggle(false); | |||||
$(me.input_area).toggle(true); | |||||
me.$input && me.$input.prop("disabled", false); | |||||
if(me.disp_status=="Write") { | |||||
me.disp_area && $(me.disp_area).toggle(false); | |||||
$(me.input_area).toggle(true); | |||||
me.$input && me.$input.prop("disabled", false); | |||||
make_input(); | |||||
update_input(); | |||||
} else { | |||||
if(me.only_input) { | |||||
make_input(); | make_input(); | ||||
update_input(); | update_input(); | ||||
} else { | } else { | ||||
if(me.only_input) { | |||||
make_input(); | |||||
update_input(); | |||||
} else { | |||||
$(me.input_area).toggle(false); | |||||
if (me.disp_area) { | |||||
me.set_disp_area(); | |||||
$(me.disp_area).toggle(true); | |||||
} | |||||
$(me.input_area).toggle(false); | |||||
if (me.disp_area) { | |||||
me.set_disp_area(); | |||||
$(me.disp_area).toggle(true); | |||||
} | } | ||||
me.$input && me.$input.prop("disabled", true); | |||||
} | } | ||||
me.set_description(); | |||||
me.set_label(); | |||||
me.set_mandatory(me.value); | |||||
me.set_bold(); | |||||
me.$input && me.$input.prop("disabled", true); | |||||
} | } | ||||
return false; | |||||
}); | |||||
me.set_description(); | |||||
me.set_label(); | |||||
me.set_mandatory(me.value); | |||||
me.set_bold(); | |||||
} | |||||
}, | }, | ||||
set_disp_area: function() { | set_disp_area: function() { | ||||
@@ -471,11 +462,10 @@ frappe.ui.form.ControlData = frappe.ui.form.ControlInput.extend({ | |||||
format_for_input: function(val) { | format_for_input: function(val) { | ||||
return val==null ? "" : val; | return val==null ? "" : val; | ||||
}, | }, | ||||
validate: function(v, callback) { | |||||
validate: function(v) { | |||||
if(this.df.options == 'Phone') { | if(this.df.options == 'Phone') { | ||||
if(v+''=='') { | if(v+''=='') { | ||||
callback(""); | |||||
return; | |||||
return ''; | |||||
} | } | ||||
var v1 = '' | var v1 = '' | ||||
// phone may start with + and must only have numbers later, '-' and ' ' are stripped | // phone may start with + and must only have numbers later, '-' and ' ' are stripped | ||||
@@ -492,18 +482,16 @@ frappe.ui.form.ControlData = frappe.ui.form.ControlInput.extend({ | |||||
v1 += '0'; v = v.substr(1); | v1 += '0'; v = v.substr(1); | ||||
} | } | ||||
v1 += cint(v) + ''; | v1 += cint(v) + ''; | ||||
callback(v1); | |||||
return v1; | |||||
} else if(this.df.options == 'Email') { | } else if(this.df.options == 'Email') { | ||||
if(v+''=='') { | if(v+''=='') { | ||||
callback(""); | |||||
return; | |||||
return ''; | |||||
} | } | ||||
var email_list = frappe.utils.split_emails(v); | var email_list = frappe.utils.split_emails(v); | ||||
if (!email_list) { | if (!email_list) { | ||||
// invalid email | // invalid email | ||||
callback(""); | |||||
return ''; | |||||
} else { | } else { | ||||
var invalid_email = false; | var invalid_email = false; | ||||
email_list.forEach(function(email) { | email_list.forEach(function(email) { | ||||
@@ -515,15 +503,15 @@ frappe.ui.form.ControlData = frappe.ui.form.ControlInput.extend({ | |||||
if (invalid_email) { | if (invalid_email) { | ||||
// at least 1 invalid email | // at least 1 invalid email | ||||
callback(""); | |||||
return ''; | |||||
} else { | } else { | ||||
// all good | // all good | ||||
callback(v); | |||||
return v; | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
callback(v); | |||||
return v; | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
@@ -604,19 +592,15 @@ frappe.ui.form.ControlInt = frappe.ui.form.ControlData.extend({ | |||||
.on("focus", function() { | .on("focus", function() { | ||||
setTimeout(function() { | setTimeout(function() { | ||||
if(!document.activeElement) return; | if(!document.activeElement) return; | ||||
me.validate(document.activeElement.value, function(val) { | |||||
document.activeElement.value = val; | |||||
}); | |||||
document.activeElement.select() | |||||
document.activeElement.value | |||||
= me.validate(document.activeElement.value); | |||||
document.activeElement.select(); | |||||
}, 100); | }, 100); | ||||
return false; | return false; | ||||
}) | |||||
}); | |||||
}, | }, | ||||
parse: function(value) { | parse: function(value) { | ||||
return cint(value, null); | return cint(value, null); | ||||
}, | |||||
validate: function(value, callback) { | |||||
return callback(value); | |||||
} | } | ||||
}); | }); | ||||
@@ -733,13 +717,12 @@ frappe.ui.form.ControlDate = frappe.ui.form.ControlData.extend({ | |||||
} | } | ||||
return ""; | return ""; | ||||
}, | }, | ||||
validate: function(value, callback) { | |||||
validate: function(value) { | |||||
if(value && !frappe.datetime.validate(value)) { | if(value && !frappe.datetime.validate(value)) { | ||||
frappe.msgprint(__("Date must be in format: {0}", [frappe.sys_defaults.date_format || "yyyy-mm-dd"])); | frappe.msgprint(__("Date must be in format: {0}", [frappe.sys_defaults.date_format || "yyyy-mm-dd"])); | ||||
callback(""); | |||||
return; | |||||
return ''; | |||||
} | } | ||||
return callback(value); | |||||
return value; | |||||
} | } | ||||
}); | }); | ||||
@@ -855,9 +838,6 @@ frappe.ui.form.ControlDateRange = frappe.ui.form.ControlData.extend({ | |||||
return value + " to " + value2 | return value + " to " + value2 | ||||
} | } | ||||
return ""; | return ""; | ||||
}, | |||||
validate: function(value, callback) { | |||||
return callback(value); | |||||
} | } | ||||
}); | }); | ||||
@@ -908,8 +888,8 @@ frappe.ui.form.ControlCheck = frappe.ui.form.ControlData.extend({ | |||||
get_input_value: function() { | get_input_value: function() { | ||||
return this.input.checked ? 1 : 0; | return this.input.checked ? 1 : 0; | ||||
}, | }, | ||||
validate: function(value, callback) { | |||||
return callback(cint(value)); | |||||
validate: function(value) { | |||||
return cint(value); | |||||
}, | }, | ||||
set_input: function(value) { | set_input: function(value) { | ||||
if(this.input) { | if(this.input) { | ||||
@@ -1184,16 +1164,15 @@ frappe.ui.form.ControlAttachImage = frappe.ui.form.ControlAttach.extend({ | |||||
this.img_container.on("click", function() { me.$input.click(); }); | this.img_container.on("click", function() { me.$input.click(); }); | ||||
this.remove_image_link.on("click", function() { me.$value.find(".close").click(); }); | this.remove_image_link.on("click", function() { me.$value.find(".close").click(); }); | ||||
this.$wrapper.on("refresh", function() { | |||||
$(me.wrapper).find('.btn-attach').addClass('hidden'); | |||||
me.set_image(); | |||||
if(me.get_status()=="Read") { | |||||
$(me.disp_area).toggle(false); | |||||
} | |||||
}); | |||||
this.set_image(); | this.set_image(); | ||||
}, | }, | ||||
refresh_input: function() { | |||||
$(this.wrapper).find('.btn-attach').addClass('hidden'); | |||||
this.set_image(); | |||||
if(this.get_status()=="Read") { | |||||
$(this.disp_area).toggle(false); | |||||
} | |||||
}, | |||||
set_image: function() { | set_image: function() { | ||||
if(this.get_value()) { | if(this.get_value()) { | ||||
$(this.img_wrapper).find(".missing-image").toggle(false); | $(this.img_wrapper).find(".missing-image").toggle(false); | ||||
@@ -1608,50 +1587,47 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({ | |||||
$.extend(args.filters, this.df.filters); | $.extend(args.filters, this.df.filters); | ||||
} | } | ||||
}, | }, | ||||
validate: function(value, callback) { | |||||
validate: function(value) { | |||||
// validate the value just entered | // validate the value just entered | ||||
var me = this; | |||||
if(this.df.options=="[Select]" || this.df.ignore_link_validation) { | if(this.df.options=="[Select]" || this.df.ignore_link_validation) { | ||||
callback(value); | |||||
return; | return; | ||||
} | } | ||||
this.validate_link_and_fetch(this.df, this.get_options(), | |||||
this.docname, value, callback); | |||||
return this.validate_link_and_fetch(this.df, this.get_options(), | |||||
this.docname, value); | |||||
}, | }, | ||||
validate_link_and_fetch: function(df, doctype, docname, value, callback) { | |||||
validate_link_and_fetch: function(df, doctype, docname, value) { | |||||
var me = this; | var me = this; | ||||
if(value) { | if(value) { | ||||
var fetch = ''; | |||||
return new Promise((resolve) => { | |||||
var fetch = ''; | |||||
if(this.frm && this.frm.fetch_dict[df.fieldname]) { | |||||
fetch = this.frm.fetch_dict[df.fieldname].columns.join(', '); | |||||
} | |||||
if(this.frm && this.frm.fetch_dict[df.fieldname]) { | |||||
fetch = this.frm.fetch_dict[df.fieldname].columns.join(', '); | |||||
} | |||||
return frappe.call({ | |||||
method:'frappe.desk.form.utils.validate_link', | |||||
type: "GET", | |||||
args: { | |||||
'value': value, | |||||
'options': doctype, | |||||
'fetch': fetch | |||||
}, | |||||
no_spinner: true, | |||||
callback: function(r) { | |||||
if(r.message=='Ok') { | |||||
if(r.fetch_values && docname) { | |||||
me.set_fetch_values(df, docname, r.fetch_values); | |||||
return frappe.call({ | |||||
method:'frappe.desk.form.utils.validate_link', | |||||
type: "GET", | |||||
args: { | |||||
'value': value, | |||||
'options': doctype, | |||||
'fetch': fetch | |||||
}, | |||||
no_spinner: true, | |||||
callback: function(r) { | |||||
if(r.message=='Ok') { | |||||
if(r.fetch_values && docname) { | |||||
me.set_fetch_values(df, docname, r.fetch_values); | |||||
} | |||||
resolve(r.valid_value); | |||||
} else { | |||||
resolve(""); | |||||
} | } | ||||
if(callback) callback(r.valid_value); | |||||
} else { | |||||
if(callback) callback(""); | |||||
} | } | ||||
} | |||||
}); | |||||
}); | }); | ||||
} else if(callback) { | |||||
callback(value); | |||||
} | } | ||||
}, | }, | ||||
set_fetch_values: function(df, docname, fetch_values) { | set_fetch_values: function(df, docname, fetch_values) { | ||||
@@ -1997,12 +1973,9 @@ frappe.ui.form.ControlTable = frappe.ui.form.Control.extend({ | |||||
$('<p class="text-muted small">' + __(this.df.description) + '</p>') | $('<p class="text-muted small">' + __(this.df.description) + '</p>') | ||||
.appendTo(this.wrapper); | .appendTo(this.wrapper); | ||||
} | } | ||||
var me = this; | |||||
this.$wrapper.on("refresh", function() { | |||||
me.grid.refresh(); | |||||
return false; | |||||
}); | |||||
}, | |||||
refresh_input: function() { | |||||
this.grid.refresh(); | |||||
}, | }, | ||||
get_value: function() { | get_value: function() { | ||||
if(this.grid) { | if(this.grid) { | ||||
@@ -2041,10 +2014,8 @@ frappe.ui.form.ControlSignature = frappe.ui.form.ControlData.extend({ | |||||
me.on_reset_sign(); | me.on_reset_sign(); | ||||
return false; | return false; | ||||
}); | }); | ||||
// handle refresh by reloading the pad | |||||
this.$wrapper.on("refresh", this.on_refresh.bind(this)); | |||||
}, | }, | ||||
on_refresh: function(e) { | |||||
refresh_input: function(e) { | |||||
// prevent to load the second time | // prevent to load the second time | ||||
this.$wrapper.find(".control-input").toggle(false); | this.$wrapper.find(".control-input").toggle(false); | ||||
this.set_editable(this.get_status()=="Write"); | this.set_editable(this.get_status()=="Write"); | ||||
@@ -4,10 +4,11 @@ | |||||
frappe.ui.form.Dashboard = Class.extend({ | frappe.ui.form.Dashboard = Class.extend({ | ||||
init: function(opts) { | init: function(opts) { | ||||
$.extend(this, opts); | $.extend(this, opts); | ||||
this.section = this.frm.fields_dict._form_dashboard.wrapper; | |||||
this.parent = this.section.find('.section-body'); | |||||
this.wrapper = $(frappe.render_template('form_dashboard', | this.wrapper = $(frappe.render_template('form_dashboard', | ||||
{frm: this.frm})).prependTo(this.frm.layout.wrapper); | |||||
{frm: this.frm})).appendTo(this.parent); | |||||
this.headline = this.wrapper.find('.form-headline'); | |||||
this.progress_area = this.wrapper.find(".progress-area"); | this.progress_area = this.wrapper.find(".progress-area"); | ||||
this.heatmap_area = this.wrapper.find('.form-heatmap'); | this.heatmap_area = this.wrapper.find('.form-heatmap'); | ||||
this.chart_area = this.wrapper.find('.form-chart'); | this.chart_area = this.wrapper.find('.form-chart'); | ||||
@@ -18,7 +19,7 @@ frappe.ui.form.Dashboard = Class.extend({ | |||||
}, | }, | ||||
reset: function() { | reset: function() { | ||||
this.wrapper.addClass('hidden'); | |||||
this.section.addClass('hidden'); | |||||
this.clear_headline(); | this.clear_headline(); | ||||
// clear progress | // clear progress | ||||
@@ -36,13 +37,10 @@ frappe.ui.form.Dashboard = Class.extend({ | |||||
this.wrapper.find('.custom').remove(); | this.wrapper.find('.custom').remove(); | ||||
}, | }, | ||||
set_headline: function(html) { | set_headline: function(html) { | ||||
this.headline.html(html).removeClass('hidden'); | |||||
this.show(); | |||||
this.frm.layout.show_message(html); | |||||
}, | }, | ||||
clear_headline: function() { | clear_headline: function() { | ||||
if(this.headline) { | |||||
this.headline.empty().addClass('hidden'); | |||||
} | |||||
this.frm.layout.show_message(); | |||||
}, | }, | ||||
add_comment: function(text, permanent) { | add_comment: function(text, permanent) { | ||||
@@ -59,13 +57,12 @@ frappe.ui.form.Dashboard = Class.extend({ | |||||
this.clear_headline(); | this.clear_headline(); | ||||
}, | }, | ||||
set_headline_alert: function(text, alert_class) { | |||||
set_headline_alert: function(text, indicator_color) { | |||||
if (!indicator_color) { | |||||
indicator_color = 'orange'; | |||||
} | |||||
if(text) { | if(text) { | ||||
if(!alert_class) alert_class = "alert-warning"; | |||||
this.set_headline(repl('<div class="alert %(alert_class)s">%(text)s</div>', { | |||||
"alert_class": alert_class || "", | |||||
"text": text | |||||
})); | |||||
this.set_headline(`<div><span class="indicator ${indicator_color}">${text}</span></div>`); | |||||
} else { | } else { | ||||
this.clear_headline(); | this.clear_headline(); | ||||
} | } | ||||
@@ -406,6 +403,6 @@ frappe.ui.form.Dashboard = Class.extend({ | |||||
} | } | ||||
}, | }, | ||||
show: function() { | show: function() { | ||||
this.wrapper.removeClass('hidden'); | |||||
this.section.removeClass('hidden'); | |||||
} | } | ||||
}); | }); |
@@ -19,12 +19,14 @@ frappe.ui.form.Layout = Class.extend({ | |||||
$.extend(this, opts); | $.extend(this, opts); | ||||
}, | }, | ||||
make: function() { | make: function() { | ||||
if(!this.parent && this.body) | |||||
if(!this.parent && this.body) { | |||||
this.parent = this.body; | this.parent = this.body; | ||||
} | |||||
this.wrapper = $('<div class="form-layout">').appendTo(this.parent); | this.wrapper = $('<div class="form-layout">').appendTo(this.parent); | ||||
this.message = $('<div class="form-message text-muted small hidden"></div>').appendTo(this.wrapper); | this.message = $('<div class="form-message text-muted small hidden"></div>').appendTo(this.wrapper); | ||||
if(!this.fields) | |||||
if(!this.fields) { | |||||
this.fields = frappe.meta.sort_docfields(frappe.meta.docfield_map[this.doctype]); | this.fields = frappe.meta.sort_docfields(frappe.meta.docfield_map[this.doctype]); | ||||
} | |||||
this.setup_tabbing(); | this.setup_tabbing(); | ||||
this.render(); | this.render(); | ||||
}, | }, | ||||
@@ -46,11 +48,16 @@ frappe.ui.form.Layout = Class.extend({ | |||||
}, | }, | ||||
render: function(new_fields) { | render: function(new_fields) { | ||||
var me = this; | var me = this; | ||||
var fields = new_fields || this.fields; | var fields = new_fields || this.fields; | ||||
this.section = null; | this.section = null; | ||||
this.column = null; | this.column = null; | ||||
if((fields[0] && fields[0].fieldtype!="Section Break") || !fields.length) { | |||||
if (this.with_dashboard) { | |||||
this.setup_dashboard_section(); | |||||
} | |||||
if (this.no_opening_section()) { | |||||
this.make_section(); | this.make_section(); | ||||
} | } | ||||
$.each(fields, function(i, df) { | $.each(fields, function(i, df) { | ||||
@@ -70,6 +77,26 @@ frappe.ui.form.Layout = Class.extend({ | |||||
}); | }); | ||||
}, | }, | ||||
no_opening_section: function() { | |||||
return (this.fields[0] && this.fields[0].fieldtype!="Section Break") || !this.fields.length; | |||||
}, | |||||
setup_dashboard_section: function() { | |||||
if (this.no_opening_section()) { | |||||
this.fields.unshift({fieldtype: 'Section Break'}); | |||||
} | |||||
this.fields.unshift({ | |||||
fieldtype: 'Section Break', | |||||
fieldname: '_form_dashboard', | |||||
label: __('Dashboard'), | |||||
cssClass: 'form-dashboard', | |||||
collapsible: 1, | |||||
//hidden: 1 | |||||
}); | |||||
}, | |||||
make_field: function(df, colspan, render = false) { | make_field: function(df, colspan, render = false) { | ||||
!this.section && this.make_section(); | !this.section && this.make_section(); | ||||
!this.column && this.make_column(); | !this.column && this.make_column(); | ||||
@@ -176,13 +203,14 @@ frappe.ui.form.Layout = Class.extend({ | |||||
var $this = $(this).removeClass("empty-section") | var $this = $(this).removeClass("empty-section") | ||||
.removeClass("visible-section") | .removeClass("visible-section") | ||||
.removeClass("shaded-section"); | .removeClass("shaded-section"); | ||||
if(!$(this).find(".frappe-control:not(.hide-control)").length) { | |||||
if(!$this.find(".frappe-control:not(.hide-control)").length | |||||
&& !$this.hasClass('form-dashboard')) { | |||||
// nothing visible, hide the section | // nothing visible, hide the section | ||||
$(this).addClass("empty-section"); | |||||
$this.addClass("empty-section"); | |||||
} else { | } else { | ||||
$(this).addClass("visible-section"); | |||||
$this.addClass("visible-section"); | |||||
if(cnt % 2) { | if(cnt % 2) { | ||||
$(this).addClass("shaded-section"); | |||||
$this.addClass("shaded-section"); | |||||
} | } | ||||
cnt ++; | cnt ++; | ||||
} | } | ||||
@@ -206,6 +234,10 @@ frappe.ui.form.Layout = Class.extend({ | |||||
collapse = false; | collapse = false; | ||||
} | } | ||||
if(df.fieldname === '_form_dashboard') { | |||||
collapse = false; | |||||
} | |||||
section.collapse(collapse); | section.collapse(collapse); | ||||
} | } | ||||
} | } | ||||
@@ -258,7 +290,7 @@ frappe.ui.form.Layout = Class.extend({ | |||||
if(doctype) | if(doctype) | ||||
return me.handle_tab(doctype, fieldname, ev.shiftKey); | return me.handle_tab(doctype, fieldname, ev.shiftKey); | ||||
} | } | ||||
}) | |||||
}); | |||||
}, | }, | ||||
handle_tab: function(doctype, fieldname, shift) { | handle_tab: function(doctype, fieldname, shift) { | ||||
var me = this, | var me = this, | ||||
@@ -281,7 +313,7 @@ frappe.ui.form.Layout = Class.extend({ | |||||
if(fields[i].df.fieldname==fieldname) { | if(fields[i].df.fieldname==fieldname) { | ||||
if(shift) { | if(shift) { | ||||
if(prev) { | if(prev) { | ||||
this.set_focus(prev) | |||||
this.set_focus(prev); | |||||
} else { | } else { | ||||
$(this.primary_button).focus(); | $(this.primary_button).focus(); | ||||
} | } | ||||
@@ -307,7 +339,7 @@ frappe.ui.form.Layout = Class.extend({ | |||||
// last row, close it and find next field | // last row, close it and find next field | ||||
grid_row.toggle_view(false, function() { | grid_row.toggle_view(false, function() { | ||||
grid_row.grid.frm.layout.handle_tab(grid_row.grid.df.parent, grid_row.grid.df.fieldname); | grid_row.grid.frm.layout.handle_tab(grid_row.grid.df.parent, grid_row.grid.df.fieldname); | ||||
}) | |||||
}); | |||||
} else { | } else { | ||||
// next row | // next row | ||||
grid_row.grid.grid_rows[grid_row.doc.idx].toggle_view(true); | grid_row.grid.grid_rows[grid_row.doc.idx].toggle_view(true); | ||||
@@ -342,7 +374,7 @@ frappe.ui.form.Layout = Class.extend({ | |||||
} | } | ||||
}, | }, | ||||
is_visible: function(field) { | is_visible: function(field) { | ||||
return field.disp_status==="Write" && (field.$wrapper && field.$wrapper.is(":visible")) | |||||
return field.disp_status==="Write" && (field.$wrapper && field.$wrapper.is(":visible")); | |||||
}, | }, | ||||
set_focus: function(field) { | set_focus: function(field) { | ||||
// next is table, show the table | // next is table, show the table | ||||
@@ -467,17 +499,20 @@ frappe.ui.form.Section = Class.extend({ | |||||
.appendTo(this.layout.page); | .appendTo(this.layout.page); | ||||
this.layout.sections.push(this); | this.layout.sections.push(this); | ||||
var section = this.wrapper[0]; | |||||
if(this.df) { | if(this.df) { | ||||
if(this.df.label) { | if(this.df.label) { | ||||
this.make_head(); | this.make_head(); | ||||
} | } | ||||
if(this.df.description) { | if(this.df.description) { | ||||
$('<div class="col-sm-12 small text-muted form-section-description">' + __(this.df.description) + '</div>') | $('<div class="col-sm-12 small text-muted form-section-description">' + __(this.df.description) + '</div>') | ||||
.appendTo(this.wrapper); | |||||
.appendTo(this.wrapper); | |||||
} | |||||
if(this.df.cssClass) { | |||||
this.wrapper.addClass(this.df.cssClass); | |||||
} | } | ||||
} | } | ||||
// for bc | // for bc | ||||
this.body = $('<div class="section-body">').appendTo(this.wrapper); | this.body = $('<div class="section-body">').appendTo(this.wrapper); | ||||
}, | }, | ||||
@@ -486,7 +521,7 @@ frappe.ui.form.Section = Class.extend({ | |||||
if(!this.df.collapsible) { | if(!this.df.collapsible) { | ||||
$('<div class="col-sm-12"><h6 class="form-section-heading uppercase">' | $('<div class="col-sm-12"><h6 class="form-section-heading uppercase">' | ||||
+ __(this.df.label) + '</h6></div>') | + __(this.df.label) + '</h6></div>') | ||||
.appendTo(this.wrapper); | |||||
.appendTo(this.wrapper); | |||||
} else { | } else { | ||||
this.head = $('<div class="section-head"><a class="h6 uppercase">' | this.head = $('<div class="section-head"><a class="h6 uppercase">' | ||||
+__(this.df.label)+'</a><span class="octicon octicon-chevron-down collapse-indicator"></span></div>').appendTo(this.wrapper); | +__(this.df.label)+'</a><span class="octicon octicon-chevron-down collapse-indicator"></span></div>').appendTo(this.wrapper); | ||||
@@ -538,7 +573,7 @@ frappe.ui.form.Section = Class.extend({ | |||||
} | } | ||||
return missing_mandatory; | return missing_mandatory; | ||||
} | } | ||||
}) | |||||
}); | |||||
frappe.ui.form.Column = Class.extend({ | frappe.ui.form.Column = Class.extend({ | ||||
init: function(section, df) { | init: function(section, df) { | ||||
@@ -555,7 +590,7 @@ frappe.ui.form.Column = Class.extend({ | |||||
</form>\ | </form>\ | ||||
</div>').appendTo(this.section.body) | </div>').appendTo(this.section.body) | ||||
.find("form") | .find("form") | ||||
.on("submit", function() { return false; }) | |||||
.on("submit", function() { return false; }); | |||||
if(this.df.label) { | if(this.df.label) { | ||||
$('<label class="control-label">'+ __(this.df.label) | $('<label class="control-label">'+ __(this.df.label) | ||||
@@ -574,4 +609,4 @@ frappe.ui.form.Column = Class.extend({ | |||||
refresh: function() { | refresh: function() { | ||||
this.section.refresh(); | this.section.refresh(); | ||||
} | } | ||||
}) | |||||
}); |
@@ -71,47 +71,45 @@ frappe.ui.form.ScriptManager = Class.extend({ | |||||
// trigger all the form level events that | // trigger all the form level events that | ||||
// are bound to this event_name | // are bound to this event_name | ||||
let me = this; | let me = this; | ||||
return new Promise(resolve => { | |||||
doctype = doctype || this.frm.doctype; | |||||
name = name || this.frm.docname; | |||||
let tasks = []; | |||||
let handlers = this.get_handlers(event_name, doctype); | |||||
// helper for child table | |||||
this.frm.selected_doc = frappe.get_doc(doctype, name); | |||||
let runner = (_function, is_old_style) => { | |||||
let _promise = null; | |||||
if(is_old_style) { | |||||
// old style arguments (doc, cdt, cdn) | |||||
_promise = me.frm.cscript[_function](me.frm.doc, doctype, name); | |||||
} else { | |||||
// new style (frm, doctype, name) | |||||
_promise = _function(me.frm, doctype, name); | |||||
} | |||||
// if the trigger returns a promise, return it, | |||||
// or use the default promise frappe.after_ajax | |||||
if (_promise && _promise.then) { | |||||
return _promise; | |||||
} else { | |||||
return frappe.after_server_call(); | |||||
} | |||||
}; | |||||
// make list of functions to be run serially | |||||
handlers.new_style.forEach((_function) => { | |||||
tasks.push(() => runner(_function, false)); | |||||
}); | |||||
doctype = doctype || this.frm.doctype; | |||||
name = name || this.frm.docname; | |||||
handlers.old_style.forEach((_function) => { | |||||
tasks.push(() => runner(_function, true)); | |||||
}); | |||||
let tasks = []; | |||||
let handlers = this.get_handlers(event_name, doctype); | |||||
// run them serially | |||||
frappe.run_serially(tasks).then(resolve()); | |||||
// helper for child table | |||||
this.frm.selected_doc = frappe.get_doc(doctype, name); | |||||
let runner = (_function, is_old_style) => { | |||||
let _promise = null; | |||||
if(is_old_style) { | |||||
// old style arguments (doc, cdt, cdn) | |||||
_promise = me.frm.cscript[_function](me.frm.doc, doctype, name); | |||||
} else { | |||||
// new style (frm, doctype, name) | |||||
_promise = _function(me.frm, doctype, name); | |||||
} | |||||
// if the trigger returns a promise, return it, | |||||
// or use the default promise frappe.after_ajax | |||||
if (_promise && _promise.then) { | |||||
return _promise; | |||||
} else { | |||||
return frappe.after_server_call(); | |||||
} | |||||
}; | |||||
// make list of functions to be run serially | |||||
handlers.new_style.forEach((_function) => { | |||||
tasks.push(() => runner(_function, false)); | |||||
}); | }); | ||||
handlers.old_style.forEach((_function) => { | |||||
tasks.push(() => runner(_function, true)); | |||||
}); | |||||
// run them serially | |||||
return frappe.run_serially(tasks); | |||||
}, | }, | ||||
has_handlers: function(event_name, doctype) { | has_handlers: function(event_name, doctype) { | ||||
let handlers = this.get_handlers(event_name, doctype); | let handlers = this.get_handlers(event_name, doctype); | ||||
@@ -1,6 +1,4 @@ | |||||
<div class="form-dashboard hidden"> | |||||
<h4 class="form-headline hidden form-dashboard-section"> | |||||
</h4> | |||||
<div class="form-dashboard-wrapper"> | |||||
<div class="progress-area hidden form-dashboard-section"> | <div class="progress-area hidden form-dashboard-section"> | ||||
</div> | </div> | ||||
<div class="form-heatmap hidden form-dashboard-section"> | <div class="form-heatmap hidden form-dashboard-section"> | ||||
@@ -1,9 +1,8 @@ | |||||
<div class="form-documents"> | <div class="form-documents"> | ||||
<h5 style="margin: 5px 0px;">{{__("Related Documents")}}</h5> | |||||
{% for (var i=0; i < transactions.length; i++) { %} | {% for (var i=0; i < transactions.length; i++) { %} | ||||
{% if((i % 2)===0) { %}<div class="row">{% } %} | {% if((i % 2)===0) { %}<div class="row">{% } %} | ||||
<div class="col-xs-6"> | <div class="col-xs-6"> | ||||
<h6 class="uppercase">{{ transactions[i].label }}</h5> | |||||
<h6>{{ transactions[i].label }}</h6> | |||||
{% for (var j=0; j < transactions[i].items.length; j++) { | {% for (var j=0; j < transactions[i].items.length; j++) { | ||||
var doctype = transactions[i].items[j]; %} | var doctype = transactions[i].items[j]; %} | ||||
<div class="document-link" | <div class="document-link" | ||||
@@ -282,7 +282,6 @@ frappe.ui.form.Toolbar = Class.extend({ | |||||
if(status === "Edit") { | if(status === "Edit") { | ||||
this.page.set_primary_action(__("Edit"), function() { | this.page.set_primary_action(__("Edit"), function() { | ||||
me.frm.page.set_view('main'); | me.frm.page.set_view('main'); | ||||
me.frm.set_hidden(false); | |||||
}, 'octicon octicon-pencil'); | }, 'octicon octicon-pencil'); | ||||
} else if(status === "Cancel") { | } else if(status === "Cancel") { | ||||
this.page.set_secondary_action(__(status), function() { | this.page.set_secondary_action(__(status), function() { | ||||
@@ -398,11 +398,11 @@ $.extend(frappe.model, { | |||||
}); | }); | ||||
tasks.push(() => { | tasks.push(() => { | ||||
runner(frappe.model.events[doc.doctype]['*']); | |||||
return runner(frappe.model.events[doc.doctype]['*']); | |||||
}); | }); | ||||
} | } | ||||
frappe.run_serially(tasks); | |||||
return frappe.run_serially(tasks); | |||||
}, | }, | ||||
get_doc: function(doctype, name) { | get_doc: function(doctype, name) { | ||||
@@ -281,9 +281,9 @@ _f.Frm.prototype.set_value = function(field, value, if_missing) { | |||||
} | } | ||||
me.refresh_field(f); | me.refresh_field(f); | ||||
return Promise.resolve(); | |||||
} else { | } else { | ||||
frappe.model.set_value(me.doctype, me.doc.name, f, v); | |||||
return frappe.model.set_value(me.doctype, me.doc.name, f, v); | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
@@ -293,14 +293,16 @@ _f.Frm.prototype.set_value = function(field, value, if_missing) { | |||||
} | } | ||||
if(typeof field=="string") { | if(typeof field=="string") { | ||||
_set(field, value) | |||||
return _set(field, value) | |||||
} else if($.isPlainObject(field)) { | } else if($.isPlainObject(field)) { | ||||
for (var f in field) { | |||||
var v = field[f]; | |||||
let tasks = []; | |||||
for (let f in field) { | |||||
let v = field[f]; | |||||
if(me.get_field(f)) { | if(me.get_field(f)) { | ||||
_set(f, v); | |||||
tasks.push(() => _set(f, v)); | |||||
} | } | ||||
} | } | ||||
return frappe.run_serially(tasks); | |||||
} | } | ||||
} | } | ||||
@@ -53,14 +53,14 @@ _f.Frm = function(doctype, parent, in_form) { | |||||
var me = this; | var me = this; | ||||
$(document).on('rename', function(event, dt, old_name, new_name) { | $(document).on('rename', function(event, dt, old_name, new_name) { | ||||
if(dt==me.doctype) | if(dt==me.doctype) | ||||
me.rename_notify(dt, old_name, new_name) | |||||
me.rename_notify(dt, old_name, new_name); | |||||
}); | }); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.check_doctype_conflict = function(docname) { | _f.Frm.prototype.check_doctype_conflict = function(docname) { | ||||
var me = this; | var me = this; | ||||
if(this.doctype=='DocType' && docname=='DocType') { | if(this.doctype=='DocType' && docname=='DocType') { | ||||
frappe.msgprint(__('Allowing DocType, DocType. Be careful!')) | |||||
frappe.msgprint(__('Allowing DocType, DocType. Be careful!')); | |||||
} else if(this.doctype=='DocType') { | } else if(this.doctype=='DocType') { | ||||
if (frappe.views.formview[docname] || frappe.pages['List/'+docname]) { | if (frappe.views.formview[docname] || frappe.pages['List/'+docname]) { | ||||
window.location.reload(); | window.location.reload(); | ||||
@@ -74,7 +74,7 @@ _f.Frm.prototype.check_doctype_conflict = function(docname) { | |||||
// throw 'doctype open conflict' | // throw 'doctype open conflict' | ||||
} | } | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.setup = function() { | _f.Frm.prototype.setup = function() { | ||||
@@ -115,13 +115,13 @@ _f.Frm.prototype.setup = function() { | |||||
this.footer = new frappe.ui.form.Footer({ | this.footer = new frappe.ui.form.Footer({ | ||||
frm: this, | frm: this, | ||||
parent: $('<div>').appendTo(this.page.main.parent()) | parent: $('<div>').appendTo(this.page.main.parent()) | ||||
}) | |||||
}); | |||||
$("body").attr("data-sidebar", 1); | $("body").attr("data-sidebar", 1); | ||||
} | } | ||||
this.setup_drag_drop(); | this.setup_drag_drop(); | ||||
this.setup_done = true; | this.setup_done = true; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.setup_drag_drop = function() { | _f.Frm.prototype.setup_drag_drop = function() { | ||||
var me = this; | var me = this; | ||||
@@ -153,7 +153,7 @@ _f.Frm.prototype.setup_drag_drop = function() { | |||||
} | } | ||||
}); | }); | ||||
}); | }); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.setup_print_layout = function() { | _f.Frm.prototype.setup_print_layout = function() { | ||||
var me = this; | var me = this; | ||||
@@ -165,7 +165,7 @@ _f.Frm.prototype.setup_print_layout = function() { | |||||
this.page.wrapper.on('view-change', function() { | this.page.wrapper.on('view-change', function() { | ||||
me.toolbar.set_primary_action(); | me.toolbar.set_primary_action(); | ||||
}); | }); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.print_doc = function() { | _f.Frm.prototype.print_doc = function() { | ||||
if(this.print_preview.wrapper.is(":visible")) { | if(this.print_preview.wrapper.is(":visible")) { | ||||
@@ -180,32 +180,14 @@ _f.Frm.prototype.print_doc = function() { | |||||
this.print_preview.refresh_print_options().trigger("change"); | this.print_preview.refresh_print_options().trigger("change"); | ||||
this.page.set_view("print"); | this.page.set_view("print"); | ||||
this.print_preview.set_user_lang(); | this.print_preview.set_user_lang(); | ||||
} | |||||
_f.Frm.prototype.set_hidden = function(status) { | |||||
// set hidden if hide_first is set | |||||
this.hidden = status; | |||||
var form_page = this.page.wrapper.find('.form-page'); | |||||
form_page.toggleClass('hidden', this.hidden); | |||||
this.toolbar.refresh(); | |||||
if(status===true) { | |||||
var msg = __('Edit {0} properties', [__(this.doctype)]); | |||||
this.layout.show_message('<div style="padding-left: 15px; padding-right: 15px;">\ | |||||
<a class="text-muted" onclick="cur_frm.set_hidden(false)">' + msg + '</a></div>'); | |||||
} else { | |||||
// clear message | |||||
this.layout.show_message(); | |||||
frappe.utils.scroll_to(form_page); | |||||
} | |||||
} | |||||
}; | |||||
_f.Frm.prototype.hide_print = function() { | _f.Frm.prototype.hide_print = function() { | ||||
if(this.setup_done && this.page.current_view_name==="print") { | if(this.setup_done && this.page.current_view_name==="print") { | ||||
this.page.set_view(this.page.previous_view_name==="print" ? | this.page.set_view(this.page.previous_view_name==="print" ? | ||||
"main" : (this.page.previous_view_name || "main")); | "main" : (this.page.previous_view_name || "main")); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.watch_model_updates = function() { | _f.Frm.prototype.watch_model_updates = function() { | ||||
// watch model updates | // watch model updates | ||||
@@ -220,9 +202,9 @@ _f.Frm.prototype.watch_model_updates = function() { | |||||
&& me.fields_dict[fieldname].refresh(fieldname); | && me.fields_dict[fieldname].refresh(fieldname); | ||||
me.layout.refresh_dependency(); | me.layout.refresh_dependency(); | ||||
me.script_manager.trigger(fieldname, doc.doctype, doc.name); | |||||
return me.script_manager.trigger(fieldname, doc.doctype, doc.name); | |||||
} | } | ||||
}) | |||||
}); | |||||
// on table fields | // on table fields | ||||
var table_fields = frappe.get_children("DocType", me.doctype, "fields", {fieldtype:"Table"}); | var table_fields = frappe.get_children("DocType", me.doctype, "fields", {fieldtype:"Table"}); | ||||
@@ -237,7 +219,7 @@ _f.Frm.prototype.watch_model_updates = function() { | |||||
} | } | ||||
}); | }); | ||||
}); | }); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.setup_std_layout = function() { | _f.Frm.prototype.setup_std_layout = function() { | ||||
this.form_wrapper = $('<div></div>').appendTo(this.layout_main); | this.form_wrapper = $('<div></div>').appendTo(this.layout_main); | ||||
@@ -251,6 +233,7 @@ _f.Frm.prototype.setup_std_layout = function() { | |||||
parent: this.body, | parent: this.body, | ||||
doctype: this.doctype, | doctype: this.doctype, | ||||
frm: this, | frm: this, | ||||
with_dashboard: true | |||||
}); | }); | ||||
this.layout.make(); | this.layout.make(); | ||||
@@ -269,7 +252,7 @@ _f.Frm.prototype.setup_std_layout = function() { | |||||
this.states = new frappe.ui.form.States({ | this.states = new frappe.ui.form.States({ | ||||
frm: this | frm: this | ||||
}); | }); | ||||
} | |||||
}; | |||||
// email the form | // email the form | ||||
_f.Frm.prototype.email_doc = function(message) { | _f.Frm.prototype.email_doc = function(message) { | ||||
@@ -282,16 +265,16 @@ _f.Frm.prototype.email_doc = function(message) { | |||||
message: message, | message: message, | ||||
real_name: this.doc.real_name || this.doc.contact_display || this.doc.contact_name | real_name: this.doc.real_name || this.doc.contact_display || this.doc.contact_name | ||||
}); | }); | ||||
} | |||||
}; | |||||
// rename the form | // rename the form | ||||
_f.Frm.prototype.rename_doc = function() { | _f.Frm.prototype.rename_doc = function() { | ||||
frappe.model.rename_doc(this.doctype, this.docname); | frappe.model.rename_doc(this.doctype, this.docname); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.share_doc = function() { | _f.Frm.prototype.share_doc = function() { | ||||
this.shared.show(); | this.shared.show(); | ||||
} | |||||
}; | |||||
// notify this form of renamed records | // notify this form of renamed records | ||||
_f.Frm.prototype.rename_notify = function(dt, old, name) { | _f.Frm.prototype.rename_notify = function(dt, old, name) { | ||||
@@ -320,15 +303,15 @@ _f.Frm.prototype.rename_notify = function(dt, old, name) { | |||||
frappe.re_route[window.location.hash] = '#Form/' + encodeURIComponent(this.doctype) + '/' + encodeURIComponent(name); | frappe.re_route[window.location.hash] = '#Form/' + encodeURIComponent(this.doctype) + '/' + encodeURIComponent(name); | ||||
frappe.set_route('Form', this.doctype, name); | frappe.set_route('Form', this.doctype, name); | ||||
} | |||||
}; | |||||
// SETUP | // SETUP | ||||
_f.Frm.prototype.setup_meta = function(doctype) { | _f.Frm.prototype.setup_meta = function(doctype) { | ||||
this.meta = frappe.get_doc('DocType',this.doctype); | this.meta = frappe.get_doc('DocType',this.doctype); | ||||
this.perm = frappe.perm.get_perm(this.doctype); // for create | this.perm = frappe.perm.get_perm(this.doctype); // for create | ||||
if(this.meta.istable) { this.meta.in_dialog = 1 } | |||||
} | |||||
if(this.meta.istable) { this.meta.in_dialog = 1; } | |||||
}; | |||||
_f.Frm.prototype.refresh_header = function(is_a_different_doc) { | _f.Frm.prototype.refresh_header = function(is_a_different_doc) { | ||||
// set title | // set title | ||||
@@ -360,22 +343,22 @@ _f.Frm.prototype.refresh_header = function(is_a_different_doc) { | |||||
this.clear_custom_buttons(); | this.clear_custom_buttons(); | ||||
this.show_web_link(); | this.show_web_link(); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.show_web_link = function() { | _f.Frm.prototype.show_web_link = function() { | ||||
var doc = this.doc, me = this; | var doc = this.doc, me = this; | ||||
if(!doc.__islocal && doc.__onload && doc.__onload.is_website_generator) { | if(!doc.__islocal && doc.__onload && doc.__onload.is_website_generator) { | ||||
me.web_link && me.web_link.remove(); | me.web_link && me.web_link.remove(); | ||||
if(doc.__onload.published) { | if(doc.__onload.published) { | ||||
me.add_web_link("/" + doc.route) | |||||
me.add_web_link("/" + doc.route); | |||||
} | } | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.add_web_link = function(path) { | _f.Frm.prototype.add_web_link = function(path) { | ||||
this.web_link = this.sidebar.add_user_action(__("See on Website"), | this.web_link = this.sidebar.add_user_action(__("See on Website"), | ||||
function() {}).attr("href", path || this.doc.route).attr("target", "_blank"); | function() {}).attr("href", path || this.doc.route).attr("target", "_blank"); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.check_doc_perm = function() { | _f.Frm.prototype.check_doc_perm = function() { | ||||
// get perm | // get perm | ||||
@@ -385,8 +368,8 @@ _f.Frm.prototype.check_doc_perm = function() { | |||||
if(!this.perm[0].read) { | if(!this.perm[0].read) { | ||||
return 0; | return 0; | ||||
} | } | ||||
return 1 | |||||
} | |||||
return 1; | |||||
}; | |||||
_f.Frm.prototype.refresh = function(docname) { | _f.Frm.prototype.refresh = function(docname) { | ||||
var is_a_different_doc = docname ? true : false; | var is_a_different_doc = docname ? true : false; | ||||
@@ -460,14 +443,6 @@ _f.Frm.prototype.refresh = function(docname) { | |||||
if(this.show_print_first && this.doc.docstatus===1) { | if(this.show_print_first && this.doc.docstatus===1) { | ||||
// show print view | // show print view | ||||
this.print_doc(); | this.print_doc(); | ||||
} else { | |||||
if(this.hide_first && !this.doc.__unsaved && !this.doc.__islocal) { | |||||
this.set_hidden(true); | |||||
} else { | |||||
if(this.hidden) { | |||||
this.set_hidden(false); | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -479,7 +454,7 @@ _f.Frm.prototype.refresh = function(docname) { | |||||
this.show_if_needs_refresh(); | this.show_if_needs_refresh(); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.show_if_needs_refresh = function() { | _f.Frm.prototype.show_if_needs_refresh = function() { | ||||
if(this.doc.__needs_refresh) { | if(this.doc.__needs_refresh) { | ||||
@@ -491,12 +466,12 @@ _f.Frm.prototype.show_if_needs_refresh = function() { | |||||
this.reload_doc(); | this.reload_doc(); | ||||
} | } | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.render_form = function(is_a_different_doc) { | _f.Frm.prototype.render_form = function(is_a_different_doc) { | ||||
if(!this.meta.istable) { | if(!this.meta.istable) { | ||||
this.layout.doc = this.doc; | this.layout.doc = this.doc; | ||||
this.layout.attach_doc_and_docfields() | |||||
this.layout.attach_doc_and_docfields(); | |||||
this.sidebar = new frappe.ui.form.Sidebar({ | this.sidebar = new frappe.ui.form.Sidebar({ | ||||
frm: this, | frm: this, | ||||
@@ -504,13 +479,13 @@ _f.Frm.prototype.render_form = function(is_a_different_doc) { | |||||
}); | }); | ||||
this.sidebar.make(); | this.sidebar.make(); | ||||
// clear layout message | |||||
this.layout.show_message(); | |||||
// header must be refreshed before client methods | // header must be refreshed before client methods | ||||
// because add_custom_button | // because add_custom_button | ||||
this.refresh_header(is_a_different_doc); | this.refresh_header(is_a_different_doc); | ||||
// clear layout message | |||||
this.layout.show_message(); | |||||
// call trigger | // call trigger | ||||
this.script_manager.trigger("refresh"); | this.script_manager.trigger("refresh"); | ||||
@@ -549,14 +524,14 @@ _f.Frm.prototype.render_form = function(is_a_different_doc) { | |||||
} | } | ||||
this.scroll_to_element(); | this.scroll_to_element(); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.refresh_field = function(fname) { | _f.Frm.prototype.refresh_field = function(fname) { | ||||
if(this.fields_dict[fname] && this.fields_dict[fname].refresh) { | if(this.fields_dict[fname] && this.fields_dict[fname].refresh) { | ||||
this.fields_dict[fname].refresh(); | this.fields_dict[fname].refresh(); | ||||
this.layout.refresh_dependency(); | this.layout.refresh_dependency(); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.refresh_fields = function() { | _f.Frm.prototype.refresh_fields = function() { | ||||
this.layout.refresh(this.doc); | this.layout.refresh(this.doc); | ||||
@@ -564,7 +539,7 @@ _f.Frm.prototype.refresh_fields = function() { | |||||
// cleanup activities after refresh | // cleanup activities after refresh | ||||
this.cleanup_refresh(this); | this.cleanup_refresh(this); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.cleanup_refresh = function() { | _f.Frm.prototype.cleanup_refresh = function() { | ||||
@@ -598,7 +573,7 @@ _f.Frm.prototype.cleanup_refresh = function() { | |||||
if(me.meta.autoname=="naming_series:" && !me.doc.__islocal) { | if(me.meta.autoname=="naming_series:" && !me.doc.__islocal) { | ||||
me.toggle_display("naming_series", false); | me.toggle_display("naming_series", false); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.setnewdoc = function() { | _f.Frm.prototype.setnewdoc = function() { | ||||
// moved this call to refresh function | // moved this call to refresh function | ||||
@@ -616,14 +591,14 @@ _f.Frm.prototype.setnewdoc = function() { | |||||
me.trigger_link_fields(); | me.trigger_link_fields(); | ||||
}); | }); | ||||
frappe.breadcrumbs.add(me.meta.module, me.doctype) | |||||
frappe.breadcrumbs.add(me.meta.module, me.doctype); | |||||
}); | }); | ||||
// update seen | // update seen | ||||
if(this.meta.track_seen) { | if(this.meta.track_seen) { | ||||
$('.list-id[data-name="'+ me.docname +'"]').addClass('seen'); | $('.list-id[data-name="'+ me.docname +'"]').addClass('seen'); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.trigger_link_fields = function() { | _f.Frm.prototype.trigger_link_fields = function() { | ||||
// trigger link fields which have default values set | // trigger link fields which have default values set | ||||
@@ -637,7 +612,7 @@ _f.Frm.prototype.trigger_link_fields = function() { | |||||
delete this.doc.__run_link_triggers; | delete this.doc.__run_link_triggers; | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) { | _f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) { | ||||
var me = this; | var me = this; | ||||
@@ -661,7 +636,7 @@ _f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) { | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.copy_doc = function(onload, from_amend) { | _f.Frm.prototype.copy_doc = function(onload, from_amend) { | ||||
this.validate_form_action("Create"); | this.validate_form_action("Create"); | ||||
@@ -673,7 +648,7 @@ _f.Frm.prototype.copy_doc = function(onload, from_amend) { | |||||
onload(newdoc); | onload(newdoc); | ||||
} | } | ||||
frappe.set_route('Form', newdoc.doctype, newdoc.name); | frappe.set_route('Form', newdoc.doctype, newdoc.name); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.reload_doc = function() { | _f.Frm.prototype.reload_doc = function() { | ||||
this.check_doctype_conflict(this.docname); | this.check_doctype_conflict(this.docname); | ||||
@@ -681,15 +656,15 @@ _f.Frm.prototype.reload_doc = function() { | |||||
var me = this; | var me = this; | ||||
var onsave = function(r, rtxt) { | var onsave = function(r, rtxt) { | ||||
me.refresh(); | me.refresh(); | ||||
} | |||||
}; | |||||
if(!me.doc.__islocal) { | if(!me.doc.__islocal) { | ||||
frappe.model.remove_from_locals(me.doctype, me.docname); | frappe.model.remove_from_locals(me.doctype, me.docname); | ||||
frappe.model.with_doc(me.doctype, me.docname, function() { | frappe.model.with_doc(me.doctype, me.docname, function() { | ||||
me.refresh(); | me.refresh(); | ||||
}) | |||||
}); | |||||
} | } | ||||
} | |||||
}; | |||||
frappe.validated = 0; | frappe.validated = 0; | ||||
// Proxy for frappe.validated | // Proxy for frappe.validated | ||||
@@ -718,7 +693,7 @@ _f.Frm.prototype.save = function(save_action, callback, btn, on_error) { | |||||
me._save(save_action, callback, btn, on_error, resolve); | me._save(save_action, callback, btn, on_error, resolve); | ||||
}, 100); | }, 100); | ||||
}); | }); | ||||
} | |||||
}; | |||||
_f.Frm.prototype._save = function(save_action, callback, btn, on_error, resolve) { | _f.Frm.prototype._save = function(save_action, callback, btn, on_error, resolve) { | ||||
var me = this; | var me = this; | ||||
@@ -742,7 +717,7 @@ _f.Frm.prototype._save = function(save_action, callback, btn, on_error, resolve) | |||||
} | } | ||||
callback && callback(r); | callback && callback(r); | ||||
resolve(); | resolve(); | ||||
} | |||||
}; | |||||
if(save_action != "Update") { | if(save_action != "Update") { | ||||
// validate | // validate | ||||
@@ -767,7 +742,7 @@ _f.Frm.prototype._save = function(save_action, callback, btn, on_error, resolve) | |||||
} else { | } else { | ||||
frappe.ui.form.save(me, save_action, after_save, btn); | frappe.ui.form.save(me, save_action, after_save, btn); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.savesubmit = function(btn, callback, on_error) { | _f.Frm.prototype.savesubmit = function(btn, callback, on_error) { | ||||
@@ -814,19 +789,19 @@ _f.Frm.prototype.savecancel = function(btn, callback, on_error) { | |||||
} else { | } else { | ||||
on_error(); | on_error(); | ||||
} | } | ||||
} | |||||
}; | |||||
frappe.ui.form.save(me, "cancel", after_cancel, btn); | frappe.ui.form.save(me, "cancel", after_cancel, btn); | ||||
}); | }); | ||||
}, on_error); | }, on_error); | ||||
} | |||||
}; | |||||
// delete the record | // delete the record | ||||
_f.Frm.prototype.savetrash = function() { | _f.Frm.prototype.savetrash = function() { | ||||
this.validate_form_action("Delete"); | this.validate_form_action("Delete"); | ||||
frappe.model.delete_doc(this.doctype, this.docname, function(r) { | frappe.model.delete_doc(this.doctype, this.docname, function(r) { | ||||
window.history.back(); | window.history.back(); | ||||
}) | |||||
} | |||||
}); | |||||
}; | |||||
_f.Frm.prototype.amend_doc = function() { | _f.Frm.prototype.amend_doc = function() { | ||||
if(!this.fields_dict['amended_from']) { | if(!this.fields_dict['amended_from']) { | ||||
@@ -839,22 +814,22 @@ _f.Frm.prototype.amend_doc = function() { | |||||
newdoc.amended_from = me.docname; | newdoc.amended_from = me.docname; | ||||
if(me.fields_dict && me.fields_dict['amendment_date']) | if(me.fields_dict && me.fields_dict['amendment_date']) | ||||
newdoc.amendment_date = frappe.datetime.obj_to_str(new Date()); | newdoc.amendment_date = frappe.datetime.obj_to_str(new Date()); | ||||
} | |||||
}; | |||||
this.copy_doc(fn, 1); | this.copy_doc(fn, 1); | ||||
frappe.utils.play_sound("click"); | frappe.utils.play_sound("click"); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.disable_save = function() { | _f.Frm.prototype.disable_save = function() { | ||||
// IMPORTANT: this function should be called in refresh event | // IMPORTANT: this function should be called in refresh event | ||||
this.save_disabled = true; | this.save_disabled = true; | ||||
this.toolbar.current_status = null; | this.toolbar.current_status = null; | ||||
this.page.clear_primary_action(); | this.page.clear_primary_action(); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.enable_save = function() { | _f.Frm.prototype.enable_save = function() { | ||||
this.save_disabled = false; | this.save_disabled = false; | ||||
this.toolbar.set_primary_action(); | this.toolbar.set_primary_action(); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.save_or_update = function() { | _f.Frm.prototype.save_or_update = function() { | ||||
if(this.save_disabled) return; | if(this.save_disabled) return; | ||||
@@ -864,24 +839,24 @@ _f.Frm.prototype.save_or_update = function() { | |||||
} else if(this.doc.docstatus===1 && this.doc.__unsaved) { | } else if(this.doc.docstatus===1 && this.doc.__unsaved) { | ||||
this.save("Update"); | this.save("Update"); | ||||
} | } | ||||
} | |||||
}; | |||||
_f.Frm.prototype.dirty = function() { | _f.Frm.prototype.dirty = function() { | ||||
this.doc.__unsaved = 1; | this.doc.__unsaved = 1; | ||||
this.$wrapper.trigger('dirty'); | this.$wrapper.trigger('dirty'); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.get_docinfo = function() { | _f.Frm.prototype.get_docinfo = function() { | ||||
return frappe.model.docinfo[this.doctype][this.docname]; | return frappe.model.docinfo[this.doctype][this.docname]; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.is_dirty = function() { | _f.Frm.prototype.is_dirty = function() { | ||||
return this.doc.__unsaved; | return this.doc.__unsaved; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.is_new = function() { | _f.Frm.prototype.is_new = function() { | ||||
return this.doc.__islocal; | return this.doc.__islocal; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.reload_docinfo = function(callback) { | _f.Frm.prototype.reload_docinfo = function(callback) { | ||||
@@ -899,23 +874,23 @@ _f.Frm.prototype.reload_docinfo = function(callback) { | |||||
me.assign_to.refresh(); | me.assign_to.refresh(); | ||||
me.attachments.refresh(); | me.attachments.refresh(); | ||||
} | } | ||||
}) | |||||
} | |||||
}); | |||||
}; | |||||
_f.Frm.prototype.get_perm = function(permlevel, access_type) { | _f.Frm.prototype.get_perm = function(permlevel, access_type) { | ||||
return this.perm[permlevel] ? this.perm[permlevel][access_type] : null; | return this.perm[permlevel] ? this.perm[permlevel][access_type] : null; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.set_intro = function(txt, append) { | _f.Frm.prototype.set_intro = function(txt, append) { | ||||
this.dashboard.set_headline_alert(txt); | this.dashboard.set_headline_alert(txt); | ||||
//frappe.utils.set_intro(this, this.body, txt, append); | //frappe.utils.set_intro(this, this.body, txt, append); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.set_footnote = function(txt) { | _f.Frm.prototype.set_footnote = function(txt) { | ||||
this.footnote_area = frappe.utils.set_footnote(this.footnote_area, this.body, txt); | this.footnote_area = frappe.utils.set_footnote(this.footnote_area, this.body, txt); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.add_custom_button = function(label, fn, group) { | _f.Frm.prototype.add_custom_button = function(label, fn, group) { | ||||
@@ -924,25 +899,25 @@ _f.Frm.prototype.add_custom_button = function(label, fn, group) { | |||||
var btn = this.page.add_inner_button(label, fn, group); | var btn = this.page.add_inner_button(label, fn, group); | ||||
this.custom_buttons[label] = btn; | this.custom_buttons[label] = btn; | ||||
return btn; | return btn; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.clear_custom_buttons = function() { | _f.Frm.prototype.clear_custom_buttons = function() { | ||||
this.page.clear_inner_toolbar(); | this.page.clear_inner_toolbar(); | ||||
this.page.clear_user_actions(); | this.page.clear_user_actions(); | ||||
this.custom_buttons = {}; | this.custom_buttons = {}; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.add_fetch = function(link_field, src_field, tar_field) { | _f.Frm.prototype.add_fetch = function(link_field, src_field, tar_field) { | ||||
if(!this.fetch_dict[link_field]) { | if(!this.fetch_dict[link_field]) { | ||||
this.fetch_dict[link_field] = {'columns':[], 'fields':[]} | |||||
this.fetch_dict[link_field] = {'columns':[], 'fields':[]}; | |||||
} | } | ||||
this.fetch_dict[link_field].columns.push(src_field); | this.fetch_dict[link_field].columns.push(src_field); | ||||
this.fetch_dict[link_field].fields.push(tar_field); | this.fetch_dict[link_field].fields.push(tar_field); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.set_print_heading = function(txt) { | _f.Frm.prototype.set_print_heading = function(txt) { | ||||
this.pformat[this.docname] = txt; | this.pformat[this.docname] = txt; | ||||
} | |||||
}; | |||||
_f.Frm.prototype.action_perm_type_map = { | _f.Frm.prototype.action_perm_type_map = { | ||||
"Create": "create", | "Create": "create", | ||||
@@ -974,7 +949,7 @@ _f.Frm.prototype.validate_form_action = function(action) { | |||||
_f.Frm.prototype.has_perm = function(ptype) { | _f.Frm.prototype.has_perm = function(ptype) { | ||||
return frappe.perm.has_perm(this.doctype, 0, ptype, this.doc); | return frappe.perm.has_perm(this.doctype, 0, ptype, this.doc); | ||||
} | |||||
}; | |||||
_f.Frm.prototype.scroll_to_element = function() { | _f.Frm.prototype.scroll_to_element = function() { | ||||
if (frappe.route_options && frappe.route_options.scroll_to) { | if (frappe.route_options && frappe.route_options.scroll_to) { | ||||
@@ -992,4 +967,4 @@ _f.Frm.prototype.scroll_to_element = function() { | |||||
frappe.utils.scroll_to(selector); | frappe.utils.scroll_to(selector); | ||||
} | } | ||||
} | } | ||||
} | |||||
}; |
@@ -37,7 +37,8 @@ | |||||
} | } | ||||
.form-message { | .form-message { | ||||
padding: 15px; | |||||
padding: 15px 30px; | |||||
border-bottom: 1px solid @border-color; | |||||
} | } | ||||
.document-flow-wrapper { | .document-flow-wrapper { | ||||
@@ -102,7 +103,10 @@ | |||||
.form-dashboard { | .form-dashboard { | ||||
background-color: @light-bg; | background-color: @light-bg; | ||||
border-bottom: 1px solid @border-color; | |||||
} | |||||
.form-dashboard-wrapper { | |||||
margin: -15px 0px; | |||||
} | } | ||||
.form-documents h6 { | .form-documents h6 { | ||||
@@ -110,16 +114,20 @@ | |||||
} | } | ||||
.form-dashboard-section { | .form-dashboard-section { | ||||
margin: 0px -15px; | |||||
padding: 15px 30px; | padding: 15px 30px; | ||||
border-bottom: 1px solid @light-border-color; | border-bottom: 1px solid @light-border-color; | ||||
} | } | ||||
.form-dashboard-section:first-child { | |||||
padding-top: 0px; | |||||
} | |||||
.form-dashboard-section:last-child { | .form-dashboard-section:last-child { | ||||
border-bottom: none; | border-bottom: none; | ||||
} | } | ||||
.form-heatmap { | .form-heatmap { | ||||
padding-top: 30px; | |||||
.heatmap-message { | .heatmap-message { | ||||
margin-top: 10px; | margin-top: 10px; | ||||
@@ -682,22 +690,6 @@ select.form-control { | |||||
margin-top: -10px; | margin-top: -10px; | ||||
} | } | ||||
.form-headline { | |||||
padding: 0px 15px; | |||||
margin: 0px; | |||||
} | |||||
.form-headline .alert { | |||||
font-size: @text-medium; | |||||
background-color: @light-yellow; | |||||
font-weight: normal !important; | |||||
border: 0px; | |||||
border-radius: 0px; | |||||
margin-bottom: 0px; | |||||
margin: 0px -15px; | |||||
padding: 10px 30px; | |||||
} | |||||
.delivery-status-indicator { | .delivery-status-indicator { | ||||
display: inline-block; | display: inline-block; | ||||
margin-top: -3px; | margin-top: -3px; | ||||
@@ -132,6 +132,11 @@ def add_sidebar_data(context): | |||||
from frappe.utils.user import get_fullname_and_avatar | from frappe.utils.user import get_fullname_and_avatar | ||||
import frappe.www.list | import frappe.www.list | ||||
if context.show_sidebar and context.website_sidebar: | |||||
context.sidebar_items = frappe.get_all('Website Sidebar Item', | |||||
filters=dict(parent=context.website_sidebar), fields=['title', 'route', '`group`'], | |||||
order_by='idx asc') | |||||
if not context.sidebar_items: | if not context.sidebar_items: | ||||
sidebar_items = frappe.cache().hget('portal_menu_items', frappe.session.user) | sidebar_items = frappe.cache().hget('portal_menu_items', frappe.session.user) | ||||
if sidebar_items == None: | if sidebar_items == None: | ||||
@@ -42,11 +42,6 @@ class WebPage(WebsiteGenerator): | |||||
if not self.show_title: | if not self.show_title: | ||||
context["no_header"] = 1 | context["no_header"] = 1 | ||||
if self.show_sidebar and self.website_sidebar: | |||||
context.sidebar_items = frappe.get_all('Website Sidebar Item', | |||||
filters=dict(parent=self.website_sidebar), fields=['title', 'route', '`group`'], | |||||
order_by='idx asc') | |||||
self.set_metatags(context) | self.set_metatags(context) | ||||
self.set_breadcrumbs(context) | self.set_breadcrumbs(context) | ||||
self.set_title_and_header(context) | self.set_title_and_header(context) | ||||