浏览代码

number format fix, permission fix in listview

version-14
Rushabh Mehta 12 年前
父节点
当前提交
4248761f7a
共有 3 个文件被更改,包括 26 次插入20 次删除
  1. +5
    -2
      public/js/wn/misc/number_format.js
  2. +1
    -0
      public/js/wn/misc/tests/test_number_format.js
  3. +20
    -18
      public/js/wn/views/listview.js

+ 5
- 2
public/js/wn/misc/number_format.js 查看文件

@@ -23,12 +23,15 @@ window.format_number = function(v, format, decimals){
if(isNaN(+v)) {
v=0;
};
// remove group separators (if any)
if(typeof v=="string") {
v = replace_all(info.group_sep, "");
}

if(v<0) var is_negative = true;
v = Math.abs(v);

//Fix the decimal first, toFixed will auto fill trailing zero.
decimals = decimals || info.precision;
@@ -66,7 +69,7 @@ window.format_number = function(v, format, decimals){
part[1] = part[1] ? (info.decimal_str + part[1]) : "";
// join
return part[0] + part[1];
return (is_negative ? "-" : "") + part[0] + part[1];
};

function format_currency(v, currency) {


+ 1
- 0
public/js/wn/misc/tests/test_number_format.js 查看文件

@@ -29,6 +29,7 @@ test("#.###", function() {
equal(format_number(100, "#.###"), "100");
equal(format_number(1000, "#.###"), "1.000");
equal(format_number(10000, "#.###"), "10.000");
equal(format_number(-100000, "#.###"), "-100.000");
equal(format_number(1000000, "#.###"), "1.000.000");
equal(format_number(1000000.345, "#.###"), "1.000.000");
});

+ 20
- 18
public/js/wn/views/listview.js 查看文件

@@ -32,27 +32,29 @@ wn.views.ListView = Class.extend({
this.fields = [t + 'name', t + 'owner', t + 'docstatus',
t + '_user_tags', t + 'modified', t + 'modified_by'];
this.stats = ['_user_tags'];
$.each(wn.model.get("DocField", {"parent":this.doctype, "in_list_view":1}), function(i,d) {
if(d.fieldtype=="Image" && d.options) {
me.fields.push(t + "`" + d.options + "`");
} else {
me.fields.push(t + "`" + d.fieldname + "`");
}
if(d.fieldtype=="Select") {
me.stats.push(d.fieldname);
}

// currency field for symbol (multi-currency)
if(d.fieldtype=="Currency" && d.options) {
if(d.options.indexOf(":")!=-1) {
me.fields.push(t + "`" + d.options.split(":")[1] + "`");
} else {
if(wn.perm.has_perm(me.doctype, d.permlevel, READ)) {
if(d.fieldtype=="Image" && d.options) {
me.fields.push(t + "`" + d.options + "`");
};
}
} else {
me.fields.push(t + "`" + d.fieldname + "`");
}

if(d.fieldtype=="Select") {
me.stats.push(d.fieldname);
}

// currency field for symbol (multi-currency)
if(d.fieldtype=="Currency" && d.options) {
if(d.options.indexOf(":")!=-1) {
me.fields.push(t + "`" + d.options.split(":")[1] + "`");
} else {
me.fields.push(t + "`" + d.options + "`");
};
}
}
});

// additional fields


正在加载...
取消
保存