// for license information please see license.txt
wn.provide("wn.form.formatters")
wn.form.formatters = {
Data: function(value) {
return value==null ? "" : value
},
Float: function(value) {
return flt(value).toFixed(6);
},
Int: function(value) {
return cint(value);
},
Currency: function(value) {
return "
" + fmt_money(value) + "
";
},
Check: function(value) {
return value ? "" : "";
},
Link: function(value, docfield) {
if(!value) return "";
if(docfield.options) {
return repl('\
%(name)s', {
doctype: docfield.options,
name: value
});
} else {
return value;
}
},
Date: function(value) {
return dateutil.str_to_user(value);
},
Text: function(value) {
if(value && value.indexOf("
")==-1 && value.indexOf("")==-1 && value.indexOf("
'+v +'';
});
return html;
},
WorkflowState: function(value) {
workflow_state = wn.meta.get("Workflow State", value)[0];
if(workflow_state) {
return repl("\
%(value)s", {
value: value,
style: workflow_state.style.toLowerCase(),
icon: workflow_state.icon
});
} else {
return "" + value + "";
}
}
}
wn.form.get_formatter = function(fieldtype) {
return wn.form.formatters[fieldtype] || wn.form.formatters.Data;
}