From 0f62fb144032df6a4b734dc9ba79fde6ea2bcb9c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 19 Mar 2016 11:23:21 +0530 Subject: [PATCH] [desktop] [fix] ordering bug, fixes frappe/erpnext#5012, also copy module icon and color for doctype icon --- .../core/page/modules_setup/modules_setup.py | 18 ++++++++++------- .../desk/doctype/desktop_icon/desktop_icon.py | 20 ++++++++++++++----- frappe/public/css/desk.css | 11 +++------- frappe/public/js/frappe/form/grid.js | 3 ++- frappe/public/js/frappe/form/grid_body.html | 6 +++--- frappe/public/js/frappe/form/link_selector.js | 11 +++++++--- frappe/public/less/desk.less | 11 +++------- 7 files changed, 45 insertions(+), 35 deletions(-) diff --git a/frappe/core/page/modules_setup/modules_setup.py b/frappe/core/page/modules_setup/modules_setup.py index 83892bd4a5..d0956cd1e3 100644 --- a/frappe/core/page/modules_setup/modules_setup.py +++ b/frappe/core/page/modules_setup/modules_setup.py @@ -48,17 +48,21 @@ def get_user_icons(user): icons = [] for icon in get_desktop_icons(user): + add = True if icon.hidden_in_standard: - continue + add = False + if not icon.custom: - if icon.type=="page" and icon.link not in allowed_pages: - continue + if icon.module_name=='Learn': + pass + + elif icon.type=="page" and icon.link not in allowed_pages: + add = False elif icon.type=="module" and icon.module_name not in user_perms.allow_modules: - continue + add = False - icons.append(icon) + if add: + icons.append(icon) return icons - - diff --git a/frappe/desk/doctype/desktop_icon/desktop_icon.py b/frappe/desk/doctype/desktop_icon/desktop_icon.py index 35958c272a..35a2a4e703 100644 --- a/frappe/desk/doctype/desktop_icon/desktop_icon.py +++ b/frappe/desk/doctype/desktop_icon/desktop_icon.py @@ -97,7 +97,15 @@ def add_user_icon(label, link, type, _doctype): frappe.session.user)[0][0] or \ frappe.db.sql('select count(*) from `tabDesktop Icon` where standard=1')[0][0] - color = random.choice(palette) + module = frappe.db.get_value('DocType', _doctype, 'module') + module_icon = frappe.get_value('Desktop Icon', {'standard':1, 'module_name':module}, + ['icon', 'color', 'reverse'], as_dict=True) + + if not module_icon: + module_icon = frappe._dict() + opts = random.choice(palette) + module_icon.color = opts[0] + module_icon.reverse = 0 if (len(opts) > 1) else 1 try: frappe.get_doc({ @@ -107,8 +115,9 @@ def add_user_icon(label, link, type, _doctype): 'link': link, 'type': type, '_doctype': _doctype, - 'color': color[0], - 'reverse': 0 if (len(color) > 1) else 1, + 'icon': module_icon.icon, + 'color': module_icon.color, + 'reverse': module_icon.reverse, 'idx': idx + 1, 'custom': 1, 'standard': 0 @@ -128,8 +137,9 @@ def set_order(new_order): if isinstance(new_order, basestring): new_order = json.loads(new_order) for i, module_name in enumerate(new_order): - icon = get_user_copy(module_name, frappe.session.user) - icon.db_set('idx', i) + if module_name not in ('Explore',): + icon = get_user_copy(module_name, frappe.session.user) + icon.db_set('idx', i) clear_desktop_icons_cache() diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css index a7be95bad8..e9c6d3d65f 100644 --- a/frappe/public/css/desk.css +++ b/frappe/public/css/desk.css @@ -317,14 +317,9 @@ a.form-link { textarea.form-control { height: 120px; } -ul.linked-with-list { - list-style: none; - margin: 0 0 20px 0; - padding: 0 0 0 0; -} -ul.linked-with-list li { - padding: 5px 0px; - border-bottom: 1px solid #d1d8dd; +.link-select-row { + padding: 5px; + border-bottom: 1px solid #EBEFF2; } /* jquery ui */ .ui-datepicker .ui-datepicker-header { diff --git a/frappe/public/js/frappe/form/grid.js b/frappe/public/js/frappe/form/grid.js index 48c3413b7e..ff269ded69 100644 --- a/frappe/public/js/frappe/form/grid.js +++ b/frappe/public/js/frappe/form/grid.js @@ -99,7 +99,8 @@ frappe.ui.form.Grid = Class.extend({ if(this.is_editable()) { this.wrapper.find(".grid-footer").toggle(true); - this.wrapper.find(".grid-add-row, .grid-add-multiple-rows").toggle(!this.cannot_add_rows); + this.wrapper.find(".grid-add-row, .grid-add-multiple-rows").toggleClass("hide", + this.cannot_add_rows ? true : false); this.make_sortable($rows); } else { this.wrapper.find(".grid-footer").toggle(false); diff --git a/frappe/public/js/frappe/form/grid_body.html b/frappe/public/js/frappe/form/grid_body.html index 55ebb86746..7b26b2a419 100644 --- a/frappe/public/js/frappe/form/grid_body.html +++ b/frappe/public/js/frappe/form/grid_body.html @@ -7,11 +7,11 @@