[desktop] [fix] ordering bug, fixes frappe/erpnext#5012, also copy module icon and color for doctype icon

This commit is contained in:
Rushabh Mehta 2016-03-19 11:23:21 +05:30
parent 05895f2883
commit 0f62fb1440
7 changed files with 45 additions and 35 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -7,11 +7,11 @@
<div class="small form-clickable-section grid-footer">
<div class="row">
<div class="col-sm-6">
<a href="#" class="grid-add-multiple-rows btn btn-xs btn-default hide"
style="margin-right: 10px;">
{%= __("Add multiple rows") %}</a>
<a href="#" class="btn btn-xs btn-default grid-add-row">
{%= __("Add new row") %}</a>
<a href="#" class="grid-add-multiple-rows btn btn-xs btn-default hide"
style="margin-left: 10px;">
{%= __("Add multiple rows") %}</a>
</div>
<div class="col-sm-6 text-right">
<a href="#" class="grid-download btn btn-xs btn-default hide"

View file

@ -44,8 +44,9 @@ frappe.ui.form.LinkSelector = Class.extend({
}
});
this.dialog.show();
this.search();
},
search: function(btn) {
search: function() {
var args = {
txt: this.dialog.fields_dict.txt.get_value(),
doctype: this.doctype,
@ -73,8 +74,12 @@ frappe.ui.form.LinkSelector = Class.extend({
parent.empty();
if(r.values.length) {
$.each(r.values, function(i, v) {
var row = $(repl('<p><b><a href="#" data-value="%(name)s">%(name)s</a></b> \
<span class="text-muted">%(values)s</span></p>', {
var row = $(repl('<div class="row link-select-row">\
<div class="col-xs-4">\
<b><a href="#" data-value="%(name)s">%(name)s</a></b></div>\
<div class="col-xs-8">\
<span class="text-muted">%(values)s</span></div>\
</div>', {
name: v[0],
values: v.splice(1).join(", ")
})).appendTo(parent);

View file

@ -121,16 +121,11 @@ textarea.form-control {
height: 120px;
}
ul.linked-with-list {
list-style: none;
margin: 0 0 20px 0;
padding: 0 0 0 0;
.link-select-row {
padding: 5px;
border-bottom: 1px solid @light-border-color;
}
ul.linked-with-list li {
padding: 5px 0px;
border-bottom: 1px solid @border-color;
}
/* jquery ui */