diff --git a/frappe/config/__init__.py b/frappe/config/__init__.py index a31febf6bc..262af8d994 100644 --- a/frappe/config/__init__.py +++ b/frappe/config/__init__.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from frappe import _ import frappe import json -from frappe.desk.moduleview import get_data, get_onboard_items, config_exists +from frappe.desk.moduleview import get_data, get_onboard_items, config_exists, get_module_link_items_from_list from six import iteritems def get_modules_from_all_apps_for_user(user=None): @@ -22,8 +22,14 @@ def get_modules_from_all_apps_for_user(user=None): module_name = module["module_name"] if module_name in empty_tables_by_module: module["onboard_present"] = 1 - if module_name not in home_settings[module["category"]]: + + category_settings = home_settings[module["category"]] + if module_name not in category_settings: module["hidden"] = 1 + else: + links = category_settings[module_name]["links"] + if links: + module["links"] = get_module_link_items_from_list(module["app"], module_name, links.split(",")) return allowed_modules_list @@ -71,7 +77,6 @@ def get_modules_from_app(app): to_add = False if to_add: - m["shortcuts"] = get_onboard_items(app, frappe.scrub(m["module_name"]))[:5] m["app"] = app active_modules_list.append(m) diff --git a/frappe/desk/moduleview.py b/frappe/desk/moduleview.py index d71dfe7352..d5b62d1406 100644 --- a/frappe/desk/moduleview.py +++ b/frappe/desk/moduleview.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe +import json from frappe import _ from frappe.boot import get_allowed_pages, get_allowed_reports from frappe.desk.doctype.desktop_icon.desktop_icon import set_hidden, clear_desktop_icons_cache @@ -296,13 +297,38 @@ def get_links(app, module): link_names = [] - for section in sections: for item in section["items"]: link_names.append(item.get("label")) print(link_names) return link_names + +@frappe.whitelist() +def get_module_link_items_from_dict(module_link_list_map): + module_link_list_map = json.loads(module_link_list_map) + module_links = {} + for module, data in module_link_list_map.items(): + print(data) + module_links[module] = get_module_link_items_from_list(data["app"], module, data["links"]) + return module_links + + +def get_module_link_items_from_list(app, module, list_of_link_names): + try: + sections = get_config(app, frappe.scrub(module)) + except ImportError: + return [] + + links = [] + for section in sections: + for item in section["items"]: + if item.get("label", "") in list_of_link_names: + links.append(item) + + return links + + def set_last_modified(data): for section in data: for item in section["items"]: diff --git a/frappe/patches/v12_0/init_desk_settings.py b/frappe/patches/v12_0/init_desk_settings.py index a6ad8da898..e339f2f4f9 100644 --- a/frappe/patches/v12_0/init_desk_settings.py +++ b/frappe/patches/v12_0/init_desk_settings.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe import json from frappe.config import get_modules_from_all_apps_for_user +from frappe.desk.moduleview import get_onboard_items def execute(): frappe.reload_doc("core", "doctype", "user") @@ -11,8 +12,9 @@ def execute(): settings = {} for idx, m in enumerate(all_modules): + links = get_onboard_items(m["app"], frappe.scrub(m["module_name"]))[:5] module_settings = { - "links": ",".join([d["label"] for d in m.get("shortcuts")]) + "links": ",".join([d["label"] for d in links]) } category_dict = settings.get(m.get("category", ""), None) if category_dict: diff --git a/frappe/public/js/frappe/views/components/DeskModuleBox.vue b/frappe/public/js/frappe/views/components/DeskModuleBox.vue index aebdc548dc..58c6e5c8e6 100644 --- a/frappe/public/js/frappe/views/components/DeskModuleBox.vue +++ b/frappe/public/js/frappe/views/components/DeskModuleBox.vue @@ -22,10 +22,10 @@

{{ shortcut.label }} @@ -38,7 +38,7 @@