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

Conversation

Projects
None yet
3 participants
@prssanna
Copy link
Contributor

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.

@prssanna prssanna force-pushed the prssanna:link-preview branch 2 times, most recently from ceb0349 to 7325fdc Apr 15, 2019

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'):

This comment has been minimized.

Copy link
@rmehta

rmehta Apr 22, 2019

Member

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={

This comment has been minimized.

Copy link
@rmehta

rmehta Apr 22, 2019

Member

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))

This comment has been minimized.

Copy link
@rmehta

rmehta Apr 22, 2019

Member

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

}


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

This comment has been minimized.

Copy link
@rmehta

rmehta Apr 22, 2019

Member

break into smaller functions

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

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

This comment has been minimized.

Copy link
@rmehta

rmehta Apr 22, 2019

Member

too much horizontal indenting makes it hard to read!

@prssanna prssanna force-pushed the prssanna:link-preview branch from 25a143b to 482ebe4 Apr 23, 2019

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'):

This comment has been minimized.

Copy link
@rmehta

rmehta Apr 24, 2019

Member

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

@prssanna prssanna force-pushed the prssanna:link-preview branch from 482ebe4 to 2c1e204 Apr 24, 2019

@rmehta rmehta merged commit 6157ebb into frappe:develop May 3, 2019

5 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
Semantic Pull Request ready to be squashed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
security/snyk - package.json (frappe) No manifest changes detected
security/snyk - requirements.txt (frappe) No manifest changes detected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.