Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(desk): Link preview popover #7281

Merged
merged 7 commits into from May 3, 2019
Merged

feat(desk): Link preview popover #7281

merged 7 commits into from May 3, 2019

Conversation

@prssanna
Copy link
Collaborator

@prssanna prssanna commented Apr 15, 2019

Preview popover appears on hover of all link and control fields:
Screen Shot 2019-04-15 at 3 58 43 PM

By default all mandatory fields are shown in the preview. The fields can be manually selected by setting in_preview.

def get_preview_data(doctype, docname, fields):
fields = json.loads(fields)
preview_fields = [field['name'] for field in fields if field['type'] not in no_value_fields]
if 'title' not in fields and frappe.get_meta(doctype).has_field('title'):
Copy link
Member

@rmehta rmehta Apr 22, 2019

meta has a property get_title_field


preview_data = frappe.cache().hget('preview_data', (doctype, docname))
if preview_data == None:
preview_data = frappe.get_all(doctype, filters={
Copy link
Member

@rmehta rmehta Apr 22, 2019

use get_list as we also need to check permission

if frappe.get_meta(doctype).has_field('image'):
preview_fields.append('image')

preview_data = frappe.cache().hget('preview_data', (doctype, docname))
Copy link
Member

@rmehta rmehta Apr 22, 2019

don't cache this, data will keep on changing.

}


setup_popover_control(e, popover, name, doctype, $el, is_link, link) {
Copy link
Member

@rmehta rmehta Apr 22, 2019

break into smaller functions

});
content_html+=`</table>`;

let popover_content = `<div class="preview-popover-header">
Copy link
Member

@rmehta rmehta Apr 22, 2019

too much horizontal indenting makes it hard to read!

preview_fields.append(frappe.get_meta(doctype).get_title_field())
if 'name' not in fields:
preview_fields.append('name')
if frappe.get_meta(doctype).has_field('image'):
Copy link
Member

@rmehta rmehta Apr 24, 2019

there is a meta property called image_field too. Otherwise looks okay 👍

@rmehta rmehta merged commit 6157ebb into frappe:develop May 3, 2019
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants