@@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json | |||||
from .exceptions import * | from .exceptions import * | ||||
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template | from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template | ||||
__version__ = '8.5.5' | |||||
__version__ = '8.5.6' | |||||
__title__ = "Frappe Framework" | __title__ = "Frappe Framework" | ||||
local = Local() | local = Local() | ||||
@@ -335,10 +335,10 @@ def build_match_conditions(doctype, as_condition=True): | |||||
return match_conditions | return match_conditions | ||||
def get_filters_cond(doctype, filters, conditions, ignore_permissions=None, with_match_conditions=False): | def get_filters_cond(doctype, filters, conditions, ignore_permissions=None, with_match_conditions=False): | ||||
if filters: | |||||
if isinstance(filters, basestring): | |||||
filters = json.loads(filters) | |||||
if isinstance(filters, basestring): | |||||
filters = json.loads(filters) | |||||
if filters: | |||||
flt = filters | flt = filters | ||||
if isinstance(filters, dict): | if isinstance(filters, dict): | ||||
filters = filters.items() | filters = filters.items() | ||||
@@ -363,4 +363,3 @@ def get_filters_cond(doctype, filters, conditions, ignore_permissions=None, with | |||||
else: | else: | ||||
cond = '' | cond = '' | ||||
return cond | return cond | ||||
@@ -89,6 +89,7 @@ kbd { | |||||
} | } | ||||
.dropdown-menu > li > a { | .dropdown-menu > li > a { | ||||
padding: 14px; | padding: 14px; | ||||
white-space: normal; | |||||
} | } | ||||
.dropdown-menu { | .dropdown-menu { | ||||
min-width: 200px; | min-width: 200px; | ||||
@@ -89,6 +89,7 @@ kbd { | |||||
} | } | ||||
.dropdown-menu > li > a { | .dropdown-menu > li > a { | ||||
padding: 14px; | padding: 14px; | ||||
white-space: normal; | |||||
} | } | ||||
.dropdown-menu { | .dropdown-menu { | ||||
min-width: 200px; | min-width: 200px; | ||||
@@ -89,6 +89,7 @@ kbd { | |||||
} | } | ||||
.dropdown-menu > li > a { | .dropdown-menu > li > a { | ||||
padding: 14px; | padding: 14px; | ||||
white-space: normal; | |||||
} | } | ||||
.dropdown-menu { | .dropdown-menu { | ||||
min-width: 200px; | min-width: 200px; | ||||
@@ -263,18 +263,6 @@ frappe.ui.form.Layout = Class.extend({ | |||||
} | } | ||||
}, | }, | ||||
refresh_fields: function(fields) { | |||||
let fieldnames = fields.map((field) => { | |||||
if(field.label) return field.label; | |||||
}); | |||||
this.fields_list.map(fieldobj => { | |||||
if(fieldnames.includes(fieldobj._label)) { | |||||
fieldobj.refresh(); | |||||
} | |||||
}); | |||||
}, | |||||
refresh_section_count: function() { | refresh_section_count: function() { | ||||
this.wrapper.find(".section-count-label:visible").each(function(i) { | this.wrapper.find(".section-count-label:visible").each(function(i) { | ||||
$(this).html(i+1); | $(this).html(i+1); | ||||
@@ -158,23 +158,29 @@ frappe.request.call = function(opts) { | |||||
return $.ajax(ajax_args) | return $.ajax(ajax_args) | ||||
.done(function(data, textStatus, xhr) { | .done(function(data, textStatus, xhr) { | ||||
if(typeof data === "string") data = JSON.parse(data); | |||||
try { | |||||
if(typeof data === "string") data = JSON.parse(data); | |||||
// sync attached docs | |||||
if(data.docs || data.docinfo) { | |||||
frappe.model.sync(data); | |||||
} | |||||
// sync attached docs | |||||
if(data.docs || data.docinfo) { | |||||
frappe.model.sync(data); | |||||
} | |||||
// sync translated messages | |||||
if(data.__messages) { | |||||
$.extend(frappe._messages, data.__messages); | |||||
} | |||||
// sync translated messages | |||||
if(data.__messages) { | |||||
$.extend(frappe._messages, data.__messages); | |||||
} | |||||
// callbacks | |||||
var status_code_handler = statusCode[xhr.statusCode().status]; | |||||
if (status_code_handler) { | |||||
status_code_handler(data, xhr); | |||||
// callbacks | |||||
var status_code_handler = statusCode[xhr.statusCode().status]; | |||||
if (status_code_handler) { | |||||
status_code_handler(data, xhr); | |||||
} | |||||
} catch(e) { | |||||
console.log("Unable to handle response"); | |||||
console.trace(e); | |||||
} | } | ||||
}) | }) | ||||
.always(function(data, textStatus, xhr) { | .always(function(data, textStatus, xhr) { | ||||
try { | try { | ||||
@@ -208,7 +214,7 @@ frappe.request.call = function(opts) { | |||||
// call execute serverside request | // call execute serverside request | ||||
frappe.request.prepare = function(opts) { | frappe.request.prepare = function(opts) { | ||||
frappe.request.ajax_count++; | frappe.request.ajax_count++; | ||||
$("body").attr("data-ajax-state", "triggered"); | $("body").attr("data-ajax-state", "triggered"); | ||||
// btn indicator | // btn indicator | ||||
@@ -247,53 +253,51 @@ frappe.request.cleanup = function(opts, r) { | |||||
// un-freeze page | // un-freeze page | ||||
if(opts.freeze) frappe.dom.unfreeze(); | if(opts.freeze) frappe.dom.unfreeze(); | ||||
if(r) { | |||||
if(!r) { | |||||
return; | |||||
} | |||||
// session expired? - Guest has no business here! | |||||
if(r.session_expired || frappe.get_cookie("sid")==="Guest") { | |||||
frappe.app.handle_session_expired(); | |||||
return; | |||||
} | |||||
// session expired? - Guest has no business here! | |||||
if(r.session_expired || frappe.get_cookie("sid")==="Guest") { | |||||
frappe.app.handle_session_expired(); | |||||
return; | |||||
} | |||||
// show messages | |||||
if(r._server_messages && !opts.silent) { | |||||
r._server_messages = JSON.parse(r._server_messages); | |||||
frappe.hide_msgprint(); | |||||
frappe.msgprint(r._server_messages); | |||||
} | |||||
// show messages | |||||
if(r._server_messages && !opts.silent) { | |||||
r._server_messages = JSON.parse(r._server_messages); | |||||
frappe.hide_msgprint(); | |||||
frappe.msgprint(r._server_messages); | |||||
} | |||||
// show errors | |||||
if(r.exc) { | |||||
r.exc = JSON.parse(r.exc); | |||||
if(r.exc instanceof Array) { | |||||
$.each(r.exc, function(i, v) { | |||||
if(v) { | |||||
console.log(v); | |||||
} | |||||
}) | |||||
} else { | |||||
console.log(r.exc); | |||||
// show errors | |||||
if(r.exc) { | |||||
r.exc = JSON.parse(r.exc); | |||||
if(r.exc instanceof Array) { | |||||
$.each(r.exc, function(i, v) { | |||||
if(v) { | |||||
console.log(v); | |||||
} | |||||
}) | |||||
} else { | |||||
console.log(r.exc); | |||||
} | |||||
} | } | ||||
} | |||||
// debug messages | |||||
if(r._debug_messages) { | |||||
if(opts.args) { | |||||
console.log("======== arguments ========"); | |||||
console.log(opts.args); | |||||
console.log("========") | |||||
// debug messages | |||||
if(r._debug_messages) { | |||||
if(opts.args) { | |||||
console.log("======== arguments ========"); | |||||
console.log(opts.args); | |||||
console.log("========") | |||||
} | |||||
$.each(JSON.parse(r._debug_messages), function(i, v) { console.log(v); }); | |||||
console.log("======== response ========"); | |||||
delete r._debug_messages; | |||||
console.log(r); | |||||
console.log("========"); | |||||
} | } | ||||
$.each(JSON.parse(r._debug_messages), function(i, v) { console.log(v); }); | |||||
console.log("======== response ========"); | |||||
delete r._debug_messages; | |||||
console.log(r); | |||||
console.log("========"); | |||||
} | } | ||||
frappe.last_response = r; | frappe.last_response = r; | ||||
frappe.request.ajax_count--; | frappe.request.ajax_count--; | ||||
@@ -45,6 +45,20 @@ frappe.ui.FieldGroup = frappe.ui.form.Layout.extend({ | |||||
this.render(fields); | this.render(fields); | ||||
this.refresh_fields(fields); | this.refresh_fields(fields); | ||||
}, | }, | ||||
refresh_fields: function(fields) { | |||||
let fieldnames = fields.map((field) => { | |||||
if(field.fieldname) return field.fieldname; | |||||
}); | |||||
this.fields_list.map(fieldobj => { | |||||
if(fieldnames.includes(fieldobj.df.fieldname)) { | |||||
fieldobj.refresh(); | |||||
if(fieldobj.df["default"]) { | |||||
fieldobj.set_input(fieldobj.df["default"]); | |||||
} | |||||
} | |||||
}); | |||||
}, | |||||
first_button: false, | first_button: false, | ||||
catch_enter_as_submit: function() { | catch_enter_as_submit: function() { | ||||
var me = this; | var me = this; | ||||
@@ -11,9 +11,7 @@ frappe.ui.FilterList = Class.extend({ | |||||
this.set_events(); | this.set_events(); | ||||
}, | }, | ||||
make: function() { | make: function() { | ||||
var me = this; | |||||
this.wrapper.find('.show_filters').remove(); | |||||
this.wrapper.find('.show_filters, .filter_area').remove(); | |||||
this.wrapper.append(` | this.wrapper.append(` | ||||
<div class="show_filters"> | <div class="show_filters"> | ||||
<div class="set-filters"> | <div class="set-filters"> | ||||
@@ -24,7 +24,7 @@ frappe.ui.notifications = { | |||||
this.boot_info = frappe.boot.notification_info; | this.boot_info = frappe.boot.notification_info; | ||||
let defaults = ["Comment", "ToDo", "Event"]; | let defaults = ["Comment", "ToDo", "Event"]; | ||||
this.get_counts(this.boot_info.open_count_doctype, 0, defaults); | |||||
this.get_counts(this.boot_info.open_count_doctype, 1, defaults); | |||||
this.get_counts(this.boot_info.open_count_other, 1); | this.get_counts(this.boot_info.open_count_other, 1); | ||||
// Target counts are stored for docs per doctype | // Target counts are stored for docs per doctype | ||||
@@ -49,16 +49,19 @@ frappe.ui.notifications = { | |||||
}, | }, | ||||
get_counts: function(map, divide, keys, excluded = [], target = false) { | get_counts: function(map, divide, keys, excluded = [], target = false) { | ||||
let empty_map = 1; | |||||
keys = keys ? keys | keys = keys ? keys | ||||
: Object.keys(map).sort().filter(e => !excluded.includes(e)); | : Object.keys(map).sort().filter(e => !excluded.includes(e)); | ||||
keys.map(key => { | keys.map(key => { | ||||
let doc_dt = (map.doctypes) ? map.doctypes[key] : undefined; | let doc_dt = (map.doctypes) ? map.doctypes[key] : undefined; | ||||
if(map[key] > 0) { | |||||
if(map[key] > 0 || target) { | |||||
this.add_notification(key, map[key], doc_dt, target); | this.add_notification(key, map[key], doc_dt, target); | ||||
empty_map = 0; | |||||
} | } | ||||
}); | }); | ||||
if(divide) | |||||
if(divide && !empty_map) { | |||||
this.dropdown.append($('<li class="divider"></li>')); | this.dropdown.append($('<li class="divider"></li>')); | ||||
} | |||||
}, | }, | ||||
add_notification: function(name, value, doc_dt, target = false) { | add_notification: function(name, value, doc_dt, target = false) { | ||||
@@ -68,7 +71,7 @@ frappe.ui.notifications = { | |||||
<span class="badge pull-right">${value}</span> | <span class="badge pull-right">${value}</span> | ||||
</a></li>`) | </a></li>`) | ||||
: $(`<li><a class="progress-small" data-doctype="${doc_dt}" | : $(`<li><a class="progress-small" data-doctype="${doc_dt}" | ||||
data-doc="${name}">${label} | |||||
data-doc="${name}"><span class="dropdown-item-label">${label}<span> | |||||
<div class="progress-chart"><div class="progress"> | <div class="progress-chart"><div class="progress"> | ||||
<div class="progress-bar" style="width: ${value}%"></div> | <div class="progress-bar" style="width: ${value}%"></div> | ||||
</div></div> | </div></div> | ||||
@@ -101,6 +101,7 @@ kbd { | |||||
// dropdowns | // dropdowns | ||||
.dropdown-menu > li > a { | .dropdown-menu > li > a { | ||||
padding: 14px; | padding: 14px; | ||||
white-space: normal; | |||||
} | } | ||||
.dropdown-menu { | .dropdown-menu { | ||||