浏览代码

[minor] dashboard fixes

version-14
Rushabh Mehta 9 年前
父节点
当前提交
9e305cc237
共有 3 个文件被更改,包括 42 次插入8 次删除
  1. +8
    -0
      frappe/public/css/desk.css
  2. +24
    -8
      frappe/public/js/frappe/form/dashboard.js
  3. +10
    -0
      frappe/public/less/desk.less

+ 8
- 0
frappe/public/css/desk.css 查看文件

@@ -231,6 +231,14 @@ a.form-link {
font-weight: bold;
font-size: 102%;
}
a[disabled="disabled"] {
color: #8D99A6;
text-decoration: none;
cursor: default;
}
a[disabled="disabled"]:hover {
text-decoration: none;
}
.link-btn {
position: absolute;
top: 2px;


+ 24
- 8
frappe/public/js/frappe/form/dashboard.js 查看文件

@@ -119,8 +119,7 @@ frappe.ui.form.Dashboard = Class.extend({
}

if(!this.data) {
this.data = this.frm.meta.__dashboard;
this.filter_permissions();
this.init_data();
}

var show = false;
@@ -145,6 +144,13 @@ frappe.ui.form.Dashboard = Class.extend({
}
},

init_data: function() {
this.data = this.frm.meta.__dashboard || {};
if(!this.data.transactions) this.data.transactions = [];
if(!this.data.internal_links) this.data.internal_links = {};
this.filter_permissions();
},

filter_permissions: function() {
// filter out transactions for which the user
// does not have permission
@@ -192,10 +198,14 @@ frappe.ui.form.Dashboard = Class.extend({
open_document_list: function($link, show_open) {
// show document list with filters
var doctype = $link.attr('data-doctype'),
names = $link.attr('data-names')
names = $link.attr('data-names') || [];

if(names) {
frappe.route_options = {'name': ['in', names]};
if(this.data.internal_links[doctype]) {
if(names.length) {
frappe.route_options = {'name': ['in', names]};
} else {
return false;
}
} else {
frappe.route_options = this.get_document_filter(doctype);
if(show_open) {
@@ -248,12 +258,12 @@ frappe.ui.form.Dashboard = Class.extend({
});

// update from internal links
$.each(me.data.internal_links || {}, function(doctype, link) {
$.each(me.data.internal_links, function(doctype, link) {
var table_fieldname = link[0], link_fieldname = link[1];
var names = [];
(me.frm.doc[table_fieldname] || []).forEach(function(d) {
var value = d[link_fieldname];
if(names.indexOf(value)===-1) {
if(value && names.indexOf(value)===-1) {
names.push(value);
}
});
@@ -282,7 +292,13 @@ frappe.ui.form.Dashboard = Class.extend({
.html((count > 9) ? '9+' : count);
}

$link.attr('data-names', names ? names.join(',') : '');
if(this.data.internal_links[doctype]) {
if(names && names.length) {
$link.attr('data-names', names ? names.join(',') : '');
} else {
$link.find('a').attr('disabled', true);
}
}
},

update_heatmap: function(data) {


+ 10
- 0
frappe/public/less/desk.less 查看文件

@@ -12,6 +12,16 @@ a.form-link {
font-size: 102%;
}

a[disabled="disabled"] {
color: @text-muted;
text-decoration: none;
cursor: default;

&:hover {
text-decoration: none;
}
}

.link-btn {
position: absolute;
top: 2px;


正在加载...
取消
保存