Add preview popover on hover to all link fields
This commit is contained in:
parent
8609b5b103
commit
f2391ff87a
7 changed files with 376 additions and 2 deletions
|
|
@ -371,4 +371,22 @@ def check_parent_permission(parent, child_doctype):
|
|||
if frappe.permissions.has_permission(parent):
|
||||
return
|
||||
# Either parent not passed or the user doesn't have permission on parent doctype of child table!
|
||||
raise frappe.PermissionError
|
||||
raise frappe.PermissionError
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_preview_data(doctype, docname, fields):
|
||||
fields = json.loads(fields)
|
||||
preview_data = frappe.cache().hget('preview_data', (doctype, docname))
|
||||
print('abcde')
|
||||
if preview_data == None:
|
||||
print('nimu')
|
||||
preview_data = frappe.get_all(doctype, filters={
|
||||
'name': docname
|
||||
}, fields=fields, limit=1)
|
||||
if preview_data: preview_data = preview_data[0]
|
||||
frappe.cache().hset('preview_data', (doctype, docname), preview_data)
|
||||
|
||||
return preview_data
|
||||
|
||||
def clear_preview_cache(doc, method):
|
||||
frappe.cache().delete_value('preview_data', (doc.get('doctype', doc.get('name'))))
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_preview": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "",
|
||||
"length": 0,
|
||||
|
|
@ -62,6 +63,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Label",
|
||||
"length": 0,
|
||||
|
|
@ -99,13 +104,21 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Type",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "fieldtype",
|
||||
"oldfieldtype": "Select",
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
"options": "Attach\nAttach Image\nBarcode\nButton\nCheck\nCode\nColor\nColumn Break\nCurrency\nData\nDate\nDatetime\nDynamic Link\nFloat\nFold\nGeolocation\nHeading\nHTML\nHTML Editor\nImage\nInt\nLink\nLong Text\nMarkdown Editor\nPassword\nPercent\nRating\nRead Only\nSection Break\nSelect\nSmall Text\nTable\nTable MultiSelect\nText\nText Editor\nTime\nSignature",
|
||||
=======
|
||||
"options": "Attach\nAttach Image\nBarcode\nButton\nCheck\nCode\nColor\nColumn Break\nCurrency\nData\nDate\nDatetime\nDynamic Link\nFloat\nFold\nGeolocation\nHeading\nHTML\nHTML Editor\nImage\nInt\nLink\nLong Text\nMarkdown Editor\nPassword\nPercent\nRead Only\nSection Break\nSelect\nSmall Text\nTable\nTable MultiSelect\nText\nText Editor\nTime\nSignature",
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
|
|
@ -134,6 +147,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Name",
|
||||
"length": 0,
|
||||
|
|
@ -168,6 +185,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Mandatory",
|
||||
"length": 0,
|
||||
|
|
@ -206,6 +227,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Precision",
|
||||
"length": 0,
|
||||
|
|
@ -240,6 +265,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Length",
|
||||
"length": 0,
|
||||
|
|
@ -273,6 +302,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Index",
|
||||
"length": 0,
|
||||
|
|
@ -309,6 +342,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "In List View",
|
||||
"length": 0,
|
||||
|
|
@ -343,6 +380,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "In Standard Filter",
|
||||
"length": 0,
|
||||
|
|
@ -377,6 +418,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "In Global Search",
|
||||
"length": 0,
|
||||
|
|
@ -402,6 +447,43 @@
|
|||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"fieldname": "in_preview",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_preview": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "In Preview",
|
||||
"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,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"fieldname": "allow_in_quick_entry",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
|
|
@ -410,6 +492,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Allow in Quick Entry",
|
||||
"length": 0,
|
||||
|
|
@ -443,6 +529,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Bold",
|
||||
"length": 0,
|
||||
|
|
@ -478,6 +568,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Translatable",
|
||||
"length": 0,
|
||||
|
|
@ -512,6 +606,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Collapsible",
|
||||
"length": 255,
|
||||
|
|
@ -546,6 +644,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Collapsible Depends On",
|
||||
"length": 0,
|
||||
|
|
@ -580,6 +682,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
|
|
@ -612,6 +718,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Options",
|
||||
"length": 0,
|
||||
|
|
@ -646,6 +756,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Default",
|
||||
"length": 0,
|
||||
|
|
@ -680,6 +794,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Fetch From",
|
||||
"length": 0,
|
||||
|
|
@ -714,6 +832,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Fetch If Empty",
|
||||
"length": 0,
|
||||
|
|
@ -747,6 +869,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Permissions",
|
||||
"length": 0,
|
||||
|
|
@ -779,6 +905,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Display Depends On",
|
||||
"length": 255,
|
||||
|
|
@ -814,6 +944,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Hidden",
|
||||
"length": 0,
|
||||
|
|
@ -850,6 +984,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Read Only",
|
||||
"length": 0,
|
||||
|
|
@ -884,6 +1022,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Unique",
|
||||
"length": 0,
|
||||
|
|
@ -918,6 +1060,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Set Only Once",
|
||||
"length": 0,
|
||||
|
|
@ -951,6 +1097,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Allow Bulk Edit",
|
||||
"length": 0,
|
||||
|
|
@ -984,6 +1134,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
|
|
@ -1016,6 +1170,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Perm Level",
|
||||
"length": 0,
|
||||
|
|
@ -1053,6 +1211,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Ignore User Permissions",
|
||||
"length": 0,
|
||||
|
|
@ -1086,6 +1248,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Allow on Submit",
|
||||
"length": 0,
|
||||
|
|
@ -1122,6 +1288,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Report Hide",
|
||||
"length": 0,
|
||||
|
|
@ -1159,6 +1329,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Remember Last Selected Value",
|
||||
"length": 0,
|
||||
|
|
@ -1193,6 +1367,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Ignore XSS Filter",
|
||||
"length": 0,
|
||||
|
|
@ -1226,6 +1404,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Display",
|
||||
"length": 0,
|
||||
|
|
@ -1258,6 +1440,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "In Filter",
|
||||
"length": 0,
|
||||
|
|
@ -1294,6 +1480,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "No Copy",
|
||||
"length": 0,
|
||||
|
|
@ -1330,6 +1520,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Print Hide",
|
||||
"length": 0,
|
||||
|
|
@ -1367,6 +1561,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Print Hide If No Value",
|
||||
"length": 0,
|
||||
|
|
@ -1400,6 +1598,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Print Width",
|
||||
"length": 0,
|
||||
|
|
@ -1432,6 +1634,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Width",
|
||||
"length": 0,
|
||||
|
|
@ -1470,6 +1676,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Columns",
|
||||
"length": 0,
|
||||
|
|
@ -1503,6 +1713,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
|
|
@ -1534,6 +1748,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"label": "Description",
|
||||
"length": 0,
|
||||
|
|
@ -1570,6 +1788,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
|
|
@ -1603,6 +1825,10 @@
|
|||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
=======
|
||||
"in_preview": 0,
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
|
|
@ -1631,7 +1857,11 @@
|
|||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
<<<<<<< bb1d5f7107c860375dcdf38e5aadebea7122c31e
|
||||
"modified": "2019-03-18 17:59:57.873790",
|
||||
=======
|
||||
"modified": "2019-03-20 14:30:21.672655",
|
||||
>>>>>>> Add preview popover on hover to all link fields
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "DocField",
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ CREATE TABLE `tabDocField` (
|
|||
`description` text,
|
||||
`in_list_view` int(1) NOT NULL DEFAULT 0,
|
||||
`in_standard_filter` int(1) NOT NULL DEFAULT 0,
|
||||
`in_preview` int(1) NOT NULL DEFAULT 0,
|
||||
`read_only` int(1) NOT NULL DEFAULT 0,
|
||||
`precision` varchar(255) DEFAULT NULL,
|
||||
`length` int(11) NOT NULL DEFAULT 0,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ CREATE TABLE "tabDocField" (
|
|||
"description" text,
|
||||
"in_list_view" smallint NOT NULL DEFAULT 0,
|
||||
"in_standard_filter" smallint NOT NULL DEFAULT 0,
|
||||
"in_preview" smallint NOT NULL DEFAULT 0,
|
||||
"read_only" smallint NOT NULL DEFAULT 0,
|
||||
"precision" varchar(255) DEFAULT NULL,
|
||||
"length" bigint NOT NULL DEFAULT 0,
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@
|
|||
"public/js/frappe/ui/keyboard.js",
|
||||
"public/js/frappe/ui/colors.js",
|
||||
"public/js/frappe/ui/sidebar.js",
|
||||
"public/js/frappe/ui/link_preview.js",
|
||||
|
||||
"public/js/frappe/request.js",
|
||||
"public/js/frappe/socketio_client.js",
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ frappe.Application = Class.extend({
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.link_preview = new frappe.ui.LinkPreview();
|
||||
},
|
||||
|
||||
setup_frappe_vue() {
|
||||
|
|
|
|||
123
frappe/public/js/frappe/ui/link_preview.js
Normal file
123
frappe/public/js/frappe/ui/link_preview.js
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
frappe.provide('frappe.pages');
|
||||
|
||||
frappe.ui.LinkPreview = class {
|
||||
|
||||
constructor() {
|
||||
this.$links = [];
|
||||
this.popover_timeout = null
|
||||
this.get_links();
|
||||
}
|
||||
|
||||
get_links() {
|
||||
$(document.body).on('mouseover', 'a[href*="/"]', (e) => {
|
||||
this.link_hovered = true;
|
||||
let link = $(e.currentTarget).attr('href');
|
||||
let link_arr = link.split('/');
|
||||
const link_element = $(e.currentTarget);
|
||||
let popover = link_element.data("bs.popover");
|
||||
this.setup_popover_control(popover, link_arr, link_element);
|
||||
});
|
||||
}
|
||||
|
||||
setup_popover_control(popover, link_arr, $link) {
|
||||
if(!popover) {
|
||||
if(link_arr.length > 2) {
|
||||
let name = decodeURI(link_arr[link_arr.length - 1]);
|
||||
let doctype = decodeURI(link_arr[link_arr.length -2]);
|
||||
let preview_fields = this.get_preview_fields(doctype);
|
||||
if(preview_fields.length) {
|
||||
this.data_timeout = setTimeout(() => {
|
||||
this.get_preview_fields_value(doctype, name, preview_fields).then((preview_data)=> {
|
||||
if(preview_data) {
|
||||
if (this.popover_timeout) {
|
||||
clearTimeout(this.popover_timeout)
|
||||
}
|
||||
this.popover_timeout = setTimeout(() => {
|
||||
this.init_preview_popover($link, preview_data, doctype);
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.popover_timeout = setTimeout(() => {
|
||||
popover.show();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
$(document.body).on('mouseout', 'a[href*="/"]', () => {
|
||||
this.link_hovered = false;
|
||||
if(this.data_timeout) {
|
||||
clearTimeout(this.data_timeout)
|
||||
}
|
||||
if (this.popover_timeout) {
|
||||
clearTimeout(this.popover_timeout)
|
||||
}
|
||||
})
|
||||
$(document.body).on('mousemove', () => {
|
||||
if (!this.link_hovered) {
|
||||
this.$links.forEach($link => $link.popover('hide'));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
get_preview_fields(dt) {
|
||||
let fields = []
|
||||
frappe.model.with_doctype(dt, () => {
|
||||
frappe.get_meta(dt).fields.filter((field) => {
|
||||
if(field.in_preview) fields.push(field.fieldname);
|
||||
})
|
||||
});
|
||||
return fields;
|
||||
}
|
||||
|
||||
get_preview_fields_value(dt, field_name, field_list) {
|
||||
return frappe.xcall('frappe.client.get_preview_data', {
|
||||
'doctype': dt,
|
||||
'docname': field_name,
|
||||
'fields': field_list
|
||||
});
|
||||
}
|
||||
|
||||
init_preview_popover($link, preview_data, dt) {
|
||||
console.log('create popover')
|
||||
let content_html = '';
|
||||
console.log('preview_data', preview_data);
|
||||
|
||||
Object.keys(preview_data).forEach(key => {
|
||||
content_html += `
|
||||
<p class="link-preview-field text-regular">
|
||||
<b> ${frappe.meta.get_label(dt, key)} </b>: ${preview_data[key]}
|
||||
</p>
|
||||
`;
|
||||
})
|
||||
|
||||
$link.popover({
|
||||
container: 'body',
|
||||
html: true,
|
||||
content: content_html,
|
||||
trigger: 'manual',
|
||||
animation: false
|
||||
// delay: {'show':show_delay,'hide':hide_delay}
|
||||
});
|
||||
this.$links.push($link);
|
||||
$link.popover('show');
|
||||
|
||||
// $link.data('bs.popover').options.content = content_html;
|
||||
// $link.popover('show');
|
||||
// setTimeout(() => {
|
||||
// $link.popover('show')
|
||||
// }, 1000);
|
||||
|
||||
|
||||
// $link.mouseleave(() => {
|
||||
// $link.popover('hide')
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue