Fixed test cases and allow dict to be passed to frappe.ui.form.on(doctype, {})

This commit is contained in:
Anand Doshi 2015-02-25 14:04:40 +05:30
parent 75881851bc
commit bfdfcac1ed
5 changed files with 31 additions and 8 deletions

View file

@ -4,7 +4,8 @@ a {
a,
a:hover,
a:active,
a:focus {
a:focus,
.btn {
outline: 0;
}
img {

View file

@ -4,13 +4,27 @@
frappe.provide("frappe.ui.form.handlers");
frappe.ui.form.on = frappe.ui.form.on_change = function(doctype, fieldname, handler) {
if(!frappe.ui.form.handlers[doctype]) {
frappe.ui.form.handlers[doctype] = {};
var add_handler = function(fieldname, handler) {
if(!frappe.ui.form.handlers[doctype]) {
frappe.ui.form.handlers[doctype] = {};
}
if(!frappe.ui.form.handlers[doctype][fieldname]) {
frappe.ui.form.handlers[doctype][fieldname] = [];
}
frappe.ui.form.handlers[doctype][fieldname].push(handler);
}
if(!frappe.ui.form.handlers[doctype][fieldname]) {
frappe.ui.form.handlers[doctype][fieldname] = [];
if (!handler && $.isPlainObject(fieldname)) {
// a dict of handlers {fieldname: handler, ...}
for (var key in fieldname) {
var fn = fieldname[key];
if (typeof fn === "function") {
add_handler(key, fn);
}
}
} else {
add_handler(fieldname, handler);
}
frappe.ui.form.handlers[doctype][fieldname].push(handler)
}
frappe.ui.form.trigger = function(doctype, fieldname, callback) {
@ -70,6 +84,7 @@ frappe.ui.form.ScriptManager = Class.extend({
// css
doctype.__css && frappe.dom.set_style(doctype.__css);
},
log_error: function(caller, e) {
show_alert("Error in Client Script.");

View file

@ -403,5 +403,9 @@ frappe.utils = {
// Return the parsed data.
return( arrData );
}
},
warn_page_name_change: function(frm) {
frappe.msgprint("Note: Changing the Page Name will break previous URL to this page.");
},
};

View file

@ -5,7 +5,7 @@ a {
cursor: pointer;
}
a, a:hover, a:active, a:focus {
a, a:hover, a:active, a:focus, .btn {
outline: 0;
}

View file

@ -135,6 +135,9 @@ def build_json(path):
return get_context(path).data
def build_page(path):
if not hasattr(frappe.local, "path"):
frappe.local.path = path
context = get_context(path)
html = frappe.get_template(context.base_template_path).render(context)