[enhancement] added image_field so image will appear in the sidebar
This commit is contained in:
parent
fc5155c2fb
commit
90fb3ebcb9
19 changed files with 274 additions and 106 deletions
|
|
@ -444,33 +444,6 @@
|
|||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:!doc.istable",
|
||||
"description": "Comments and Communications will be associated with this linked document",
|
||||
"fieldname": "timeline_field",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Timeline Field",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
|
|
@ -498,6 +471,32 @@
|
|||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"description": "Must be of type \"Attach Image\"",
|
||||
"fieldname": "image_field",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Image Field",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
|
|
@ -552,6 +551,33 @@
|
|||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:!doc.istable",
|
||||
"description": "Comments and Communications will be associated with this linked document",
|
||||
"fieldname": "timeline_field",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Timeline Field",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
|
|
@ -1013,14 +1039,14 @@
|
|||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"icon": "icon-bolt",
|
||||
"idx": 1,
|
||||
"idx": 6,
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-03-30 01:36:35.902766",
|
||||
"modified": "2016-04-04 06:38:29.598545",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "DocType",
|
||||
|
|
|
|||
|
|
@ -402,6 +402,18 @@ def validate_fields(meta):
|
|||
_validate_title_field_pattern(df.options)
|
||||
_validate_title_field_pattern(df.default)
|
||||
|
||||
def check_image_field(meta):
|
||||
'''check image_field exists and is of type "Attach Image"'''
|
||||
if not meta.image_field:
|
||||
return
|
||||
|
||||
df = meta.get("fields", {"fieldname": meta.image_field})
|
||||
if not df:
|
||||
frappe.throw(_("Image field must be a valid fieldname"), InvalidFieldNameError)
|
||||
if df[0].fieldtype != 'Attach Image':
|
||||
frappe.throw(_("Image field must be of type Attach Image"), InvalidFieldNameError)
|
||||
|
||||
|
||||
def check_timeline_field(meta):
|
||||
if not meta.timeline_field:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -215,31 +215,6 @@
|
|||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "username",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Username",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
|
|
@ -317,6 +292,31 @@
|
|||
"unique": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "username",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Username",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
|
|
@ -375,7 +375,7 @@
|
|||
"description": "Get your globally recognized avatar from Gravatar.com",
|
||||
"fieldname": "user_image",
|
||||
"fieldtype": "Attach Image",
|
||||
"hidden": 0,
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
|
|
@ -384,7 +384,7 @@
|
|||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
|
|
@ -1508,7 +1508,8 @@
|
|||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"icon": "icon-user",
|
||||
"idx": 403,
|
||||
"idx": 413,
|
||||
"image_field": "user_image",
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
|
|
@ -1516,7 +1517,7 @@
|
|||
"istable": 0,
|
||||
"max_attachments": 5,
|
||||
"menu_index": 0,
|
||||
"modified": "2016-04-01 07:23:20.806153",
|
||||
"modified": "2016-04-04 06:45:42.330517",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "User",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
|
|||
ignore_links=False, pre_process=None, via_console=False):
|
||||
"""upload data"""
|
||||
frappe.flags.mute_emails = True
|
||||
frappe.flags.in_upload = True
|
||||
|
||||
# extra input params
|
||||
params = json.loads(frappe.form_dict.get("params") or '{}')
|
||||
|
||||
|
|
@ -275,6 +277,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
|
|||
frappe.db.commit()
|
||||
|
||||
frappe.flags.mute_emails = False
|
||||
frappe.flags.in_upload = False
|
||||
|
||||
return {"messages": ret, "error": error}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Document",
|
||||
"fields": [
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
|
|
@ -16,13 +17,16 @@
|
|||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 1,
|
||||
"label": "Enter Form Type",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "DocType",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -39,12 +43,15 @@
|
|||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -60,13 +67,16 @@
|
|||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 1,
|
||||
"label": "Default Print Format",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Print Format",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -83,12 +93,15 @@
|
|||
"fieldtype": "Int",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Max Attachments",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -104,12 +117,15 @@
|
|||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Hide Copy",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -125,12 +141,15 @@
|
|||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -147,13 +166,42 @@
|
|||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Title Field",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"description": "Must be of type \"Attach Image\"",
|
||||
"fieldname": "image_field",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Image Field",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -170,12 +218,15 @@
|
|||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 1,
|
||||
"label": "Search Fields",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -192,12 +243,15 @@
|
|||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -213,12 +267,15 @@
|
|||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Sort Field",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -234,12 +291,15 @@
|
|||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -255,13 +315,16 @@
|
|||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Sort Order",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "ASC\nDESC",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -279,12 +342,15 @@
|
|||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Fields",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -300,13 +366,16 @@
|
|||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Fields",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Customize Form Field",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
|
|
@ -324,7 +393,8 @@
|
|||
"is_submittable": 0,
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"modified": "2015-10-21 08:11:19.151364",
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-04-04 06:39:02.555760",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Custom",
|
||||
"name": "Customize Form",
|
||||
|
|
@ -353,5 +423,7 @@
|
|||
],
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"search_fields": "doc_type"
|
||||
"search_fields": "doc_type",
|
||||
"sort_order": "DESC",
|
||||
"track_seen": 0
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ from frappe.core.doctype.doctype.doctype import validate_fields_for_doctype
|
|||
doctype_properties = {
|
||||
'search_fields': 'Data',
|
||||
'title_field': 'Data',
|
||||
'image_field': 'Data',
|
||||
'sort_field': 'Data',
|
||||
'sort_order': 'Data',
|
||||
'default_print_format': 'Data',
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ CREATE TABLE `tabDocType` (
|
|||
`autoname` varchar(255) DEFAULT NULL,
|
||||
`name_case` varchar(255) DEFAULT NULL,
|
||||
`title_field` varchar(255) DEFAULT NULL,
|
||||
`image_field` varchar(255) DEFAULT NULL,
|
||||
`timeline_field` varchar(255) DEFAULT NULL,
|
||||
`sort_field` varchar(255) DEFAULT NULL,
|
||||
`sort_order` varchar(255) DEFAULT NULL,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
execute:frappe.db.sql("""update `tabPatch Log` set patch=replace(patch, '.4_0.', '.v4_0.')""") #2014-05-12
|
||||
frappe.patches.v5_0.convert_to_barracuda_and_utf8mb4
|
||||
frappe.patches.v6_1.rename_file_data
|
||||
execute:frappe.reload_doc('core', 'doctype', 'doctype', force=True) #2016-03-25
|
||||
execute:frappe.reload_doc('core', 'doctype', 'doctype', force=True) #2016-04-04
|
||||
execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2016-02-26
|
||||
execute:frappe.reload_doc('core', 'doctype', 'docperm') #2014-06-24
|
||||
execute:frappe.reload_doc('custom', 'doctype', 'custom_field') #2015-10-19
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@
|
|||
"public/js/frappe/form/print_layout.html",
|
||||
"public/js/frappe/form/print.js",
|
||||
"public/js/frappe/form/sidebar.js",
|
||||
"public/js/frappe/form/user_image.js",
|
||||
"public/js/frappe/form/users_in_sidebar.html",
|
||||
"public/js/frappe/form/share.js",
|
||||
"public/js/frappe/form/set_sharing.html",
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
padding-bottom: 100%;
|
||||
}
|
||||
.avatar-frame {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
padding: 50% 0px;
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ body[data-route^="Module"] .main-menu .form-sidebar {
|
|||
.form-sidebar .sidebar-image-section {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 0px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.form-sidebar .sidebar-image-section .sidebar-image {
|
||||
width: 100%;
|
||||
|
|
@ -182,6 +183,21 @@ body[data-route^="Module"] .main-menu .form-sidebar {
|
|||
font-size: 72px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.form-sidebar .sidebar-image-section .sidebar-image-wrapper:after {
|
||||
content: '\A';
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #fff;
|
||||
opacity: 0;
|
||||
transition: all 0.5s;
|
||||
-webkit-transition: all 0.6s;
|
||||
}
|
||||
.form-sidebar .sidebar-image-section .sidebar-image-wrapper:hover:after {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.form-sidebar .form-shared .share-doc-btn:hover,
|
||||
.form-sidebar .form-shared .share-doc-btn:focus,
|
||||
.form-sidebar .form-shared .share-doc-btn:active {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<ul class="list-unstyled sidebar-menu sidebar-image-section hidden-xs hidden-sm hide">
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<li class="sidebar-image-wrapper">
|
||||
<div class="sidebar-image"></div>
|
||||
<div class="sidebar-standard-image">
|
||||
<div class="standard-image"></div>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ frappe.provide("frappe.ui.form");
|
|||
frappe.ui.form.Sidebar = Class.extend({
|
||||
init: function(opts) {
|
||||
$.extend(this, opts);
|
||||
this.make();
|
||||
},
|
||||
|
||||
make: function() {
|
||||
|
|
@ -17,6 +16,7 @@ frappe.ui.form.Sidebar = Class.extend({
|
|||
this.comments = this.sidebar.find(".sidebar-comments");
|
||||
this.user_actions = this.sidebar.find(".user-actions");
|
||||
this.image_section = this.sidebar.find(".sidebar-image-section");
|
||||
this.image_wrapper = this.image_section.find('.sidebar-image-wrapper');
|
||||
|
||||
this.make_assignments();
|
||||
this.make_attachments();
|
||||
|
|
@ -65,7 +65,7 @@ frappe.ui.form.Sidebar = Class.extend({
|
|||
"<br>" + comment_when(this.frm.doc.creation)]));
|
||||
|
||||
this.refresh_like();
|
||||
this.refresh_image();
|
||||
frappe.ui.form.set_user_image(this.frm);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -148,46 +148,5 @@ frappe.ui.form.Sidebar = Class.extend({
|
|||
},
|
||||
|
||||
refresh_image: function() {
|
||||
if (this.frm.image_field===undefined) {
|
||||
for (var i in this.frm.fields) {
|
||||
var df = this.frm.fields[i].df;
|
||||
if (df.fieldtype == "Attach Image") {
|
||||
this.frm.image_field = df.fieldname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var image_field = this.frm.image_field;
|
||||
var image = this.frm.doc[image_field];
|
||||
|
||||
|
||||
this.image_section.toggleClass('hide', image_field ? false : true);
|
||||
// if image field has value
|
||||
if (image) {
|
||||
this.image_section
|
||||
.find(".sidebar-image")
|
||||
.css("background-image", 'url("' + image + '")')
|
||||
.removeClass("hide");
|
||||
|
||||
this.image_section
|
||||
.find('.sidebar-standard-image')
|
||||
.addClass('hide');
|
||||
|
||||
} else {
|
||||
this.image_section
|
||||
.find(".sidebar-image")
|
||||
.css("background-image", null)
|
||||
.addClass("hide");
|
||||
|
||||
var title = this.frm.get_title();
|
||||
|
||||
this.image_section
|
||||
.find('.sidebar-standard-image')
|
||||
.removeClass('hide')
|
||||
.find('.standard-image')
|
||||
.css({'background-color': frappe.get_palette(title)})
|
||||
.html(frappe.get_abbr(title));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
49
frappe/public/js/frappe/form/user_image.js
Normal file
49
frappe/public/js/frappe/form/user_image.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
frappe.ui.form.set_user_image = function(frm) {
|
||||
|
||||
var image_section = frm.sidebar.image_section;
|
||||
var image_field = frm.meta.image_field;
|
||||
var image = frm.doc[image_field];
|
||||
|
||||
|
||||
image_section.toggleClass('hide', image_field ? false : true);
|
||||
|
||||
if(!image_field) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if image field has value
|
||||
if (image) {
|
||||
image_section
|
||||
.find(".sidebar-image")
|
||||
.css("background-image", 'url("' + image + '")')
|
||||
.removeClass("hide");
|
||||
|
||||
image_section
|
||||
.find('.sidebar-standard-image')
|
||||
.addClass('hide');
|
||||
|
||||
} else {
|
||||
image_section
|
||||
.find(".sidebar-image")
|
||||
.css("background-image", null)
|
||||
.addClass("hide");
|
||||
|
||||
var title = frm.get_title();
|
||||
|
||||
image_section
|
||||
.find('.sidebar-standard-image')
|
||||
.removeClass('hide')
|
||||
.find('.standard-image')
|
||||
.css({'background-color': frappe.get_palette(title)})
|
||||
.html(frappe.get_abbr(title));
|
||||
}
|
||||
|
||||
frm.sidebar.image_wrapper.on('click', function() {
|
||||
var field = frm.get_field(frm.meta.image_field);
|
||||
if(!field.$input) {
|
||||
field.make_input();
|
||||
}
|
||||
field.$input.trigger('click');
|
||||
})
|
||||
|
||||
}
|
||||
|
|
@ -25,7 +25,8 @@ frappe.avatar = function(user, css_class, title) {
|
|||
|
||||
if(user_info.image) {
|
||||
return repl('<span class="avatar %(css_class)s" title="%(title)s">\
|
||||
<img src="%(image)s" alt="%(title)s"></span>', {
|
||||
<span class="avatar-frame" style="background-image: url(%(image)s)"\
|
||||
title="%(title)s"></span></span>', {
|
||||
image: image,
|
||||
title: title,
|
||||
abbr: user_info.abbr,
|
||||
|
|
|
|||
|
|
@ -458,6 +458,7 @@ _f.Frm.prototype.render_form = function(is_a_different_doc) {
|
|||
frm: this,
|
||||
page: this.page
|
||||
});
|
||||
this.sidebar.make();
|
||||
|
||||
// header must be refreshed before client methods
|
||||
// because add_custom_button
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@
|
|||
}
|
||||
|
||||
.avatar-frame {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
padding: 50% 0px;
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ body[data-route^="Module"] .main-menu {
|
|||
.sidebar-image-section {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 0px;
|
||||
cursor: pointer;
|
||||
|
||||
.sidebar-image {
|
||||
width: 100%;
|
||||
|
|
@ -170,6 +171,22 @@ body[data-route^="Module"] .main-menu {
|
|||
font-size: 72px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.sidebar-image-wrapper:after {
|
||||
content: '\A';
|
||||
position: absolute;
|
||||
width: 100%; height:100%;
|
||||
top:0; left:0;
|
||||
background: #fff;
|
||||
opacity: 0;
|
||||
transition: all 0.5s;
|
||||
-webkit-transition: all 0.6s;
|
||||
}
|
||||
|
||||
.sidebar-image-wrapper:hover:after {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,12 @@ def random_string(length):
|
|||
return ''.join([choice(string.letters + string.digits) for i in range(length)])
|
||||
|
||||
def has_gravatar(email):
|
||||
'''Returns gravatar url if user has set an avatar at gravatar.com'''
|
||||
if frappe.flags.in_upload:
|
||||
# no gravatar if via upload
|
||||
# since querying gravatar for every item will be slow
|
||||
return
|
||||
|
||||
gravatar_url = "https://secure.gravatar.com/avatar/{hash}?d=404&s=200".format(hash=md5.md5(email).hexdigest())
|
||||
if requests.get(gravatar_url).status_code==404:
|
||||
return ''
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue