@@ -359,15 +359,18 @@ def get_desktop_page(page): | |||||
Returns: | Returns: | ||||
dict: dictionary of cards, charts and shortcuts to be displayed on website | dict: dictionary of cards, charts and shortcuts to be displayed on website | ||||
""" | """ | ||||
wspace = Workspace(page) | |||||
wspace.build_workspace() | |||||
return { | |||||
'charts': wspace.charts, | |||||
'shortcuts': wspace.shortcuts, | |||||
'cards': wspace.cards, | |||||
'onboarding': wspace.onboarding, | |||||
'allow_customization': not wspace.doc.disable_user_customization | |||||
} | |||||
try: | |||||
wspace = Workspace(page) | |||||
wspace.build_workspace() | |||||
return { | |||||
'charts': wspace.charts, | |||||
'shortcuts': wspace.shortcuts, | |||||
'cards': wspace.cards, | |||||
'onboarding': wspace.onboarding, | |||||
'allow_customization': not wspace.doc.disable_user_customization | |||||
} | |||||
except DoesNotExistError: | |||||
return {} | |||||
@frappe.whitelist() | @frappe.whitelist() | ||||
def get_desk_sidebar_items(): | def get_desk_sidebar_items(): | ||||
@@ -608,3 +611,4 @@ def merge_cards_based_on_label(cards): | |||||
cards_dict[label] = card | cards_dict[label] = card | ||||
return list(cards_dict.values()) | return list(cards_dict.values()) | ||||
@@ -246,7 +246,7 @@ class DesktopPage { | |||||
this.page.appendTo(this.container); | this.page.appendTo(this.container); | ||||
this.get_data().then(() => { | this.get_data().then(() => { | ||||
if (!this.data) { | |||||
if (Object.keys(this.data).length == 0) { | |||||
delete localStorage.current_workspace; | delete localStorage.current_workspace; | ||||
frappe.set_route("workspace"); | frappe.set_route("workspace"); | ||||
return; | return; | ||||
@@ -274,7 +274,7 @@ class DesktopPage { | |||||
page: this.page_name | page: this.page_name | ||||
}).then(data => { | }).then(data => { | ||||
this.data = data; | this.data = data; | ||||
if (!this.data) return; | |||||
if (Object.keys(this.data).length == 0) return; | |||||
return frappe.dashboard_utils.get_dashboard_settings().then(settings => { | return frappe.dashboard_utils.get_dashboard_settings().then(settings => { | ||||
let chart_config = settings.chart_config ? JSON.parse(settings.chart_config) : {}; | let chart_config = settings.chart_config ? JSON.parse(settings.chart_config) : {}; | ||||
@@ -410,3 +410,5 @@ class DesktopPage { | |||||
this.sections["cards"] = cards; | this.sections["cards"] = cards; | ||||
} | } | ||||
} | } | ||||