fixes to reportview and mapper
This commit is contained in:
parent
8b69aa038d
commit
6c79e85e8c
8 changed files with 105 additions and 94 deletions
|
|
@ -38,7 +38,7 @@ cur_frm.cscript.refresh = function(doc) {
|
|||
msgprint("Refreshing...");
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
|
||||
cur_frm.toggle_display('change_password', !doc.__islocal);
|
||||
|
||||
cur_frm.toggle_display(['sb1', 'sb3'], false);
|
||||
|
|
@ -55,9 +55,9 @@ cur_frm.cscript.refresh = function(doc) {
|
|||
cur_frm.toggle_display(['sb1', 'sb3'], true);
|
||||
}
|
||||
cur_frm.cscript.enabled(doc);
|
||||
|
||||
|
||||
cur_frm.roles_editor && cur_frm.roles_editor.show();
|
||||
|
||||
|
||||
if(user==doc.name) {
|
||||
// update display settings
|
||||
if(doc.background_image) {
|
||||
|
|
@ -72,11 +72,11 @@ cur_frm.cscript.refresh = function(doc) {
|
|||
|
||||
cur_frm.cscript.enabled = function(doc) {
|
||||
if(!doc.__islocal && has_common(user_roles, ["Administrator", "System Manager"])) {
|
||||
cur_frm.toggle_display(['sb1', 'sb3'], doc.enabled);
|
||||
cur_frm.toggle_display(['sb1', 'sb3'], doc.enabled);
|
||||
cur_frm.toggle_enable('*', doc.enabled);
|
||||
cur_frm.set_df_property('enabled', 'read_only', 0);
|
||||
}
|
||||
|
||||
|
||||
if(user!="Administrator") {
|
||||
cur_frm.toggle_enable('email', doc.__islocal);
|
||||
}
|
||||
|
|
@ -98,8 +98,8 @@ frappe.RoleEditor = Class.extend({
|
|||
callback: function(r) {
|
||||
me.roles = r.message;
|
||||
me.show_roles();
|
||||
|
||||
// refresh call could've already happened
|
||||
|
||||
// refresh call could've already happened
|
||||
// when all role checkboxes weren't created
|
||||
if(cur_frm.doc) {
|
||||
cur_frm.roles_editor.show();
|
||||
|
|
@ -127,14 +127,14 @@ frappe.RoleEditor = Class.extend({
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
for(var i in this.roles) {
|
||||
|
||||
$.each(this.roles, function(i, role) {
|
||||
$(this.wrapper).append(repl('<div class="user-role" \
|
||||
data-user-role="%(role)s">\
|
||||
<input type="checkbox" style="margin-top:0px;"> \
|
||||
<a href="#">%(role)s</a>\
|
||||
</div>', {role: this.roles[i]}));
|
||||
}
|
||||
</div>', {role: role}));
|
||||
})
|
||||
$(this.wrapper).find('input[type="checkbox"]').change(function() {
|
||||
cur_frm.dirty();
|
||||
});
|
||||
|
|
@ -145,11 +145,11 @@ frappe.RoleEditor = Class.extend({
|
|||
},
|
||||
show: function() {
|
||||
var me = this;
|
||||
|
||||
|
||||
// uncheck all roles
|
||||
$(this.wrapper).find('input[type="checkbox"]')
|
||||
.each(function(i, checkbox) { checkbox.checked = false; });
|
||||
|
||||
|
||||
// set user roles as checked
|
||||
$.each((cur_frm.doc.user_roles || []), function(i, user_role) {
|
||||
var checkbox = $(me.wrapper)
|
||||
|
|
@ -161,19 +161,19 @@ frappe.RoleEditor = Class.extend({
|
|||
var opts = this.get_roles();
|
||||
var existing_roles_map = {};
|
||||
var existing_roles_list = [];
|
||||
|
||||
$.each((cur_frm.doc.user_roles || []), function(i, user_role) {
|
||||
|
||||
$.each((cur_frm.doc.user_roles || []), function(i, user_role) {
|
||||
existing_roles_map[user_role.role] = user_role.name;
|
||||
existing_roles_list.push(user_role.role);
|
||||
});
|
||||
|
||||
|
||||
// remove unchecked roles
|
||||
$.each(opts.unchecked_roles, function(i, role) {
|
||||
if(existing_roles_list.indexOf(role)!=-1) {
|
||||
frappe.model.clear_doc("UserRole", existing_roles_map[role]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// add new roles that are checked
|
||||
$.each(opts.checked_roles, function(i, role) {
|
||||
if(existing_roles_list.indexOf(role)==-1) {
|
||||
|
|
@ -181,7 +181,7 @@ frappe.RoleEditor = Class.extend({
|
|||
user_role.role = role;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
refresh_field("user_roles");
|
||||
},
|
||||
get_roles: function() {
|
||||
|
|
@ -194,7 +194,7 @@ frappe.RoleEditor = Class.extend({
|
|||
unchecked_roles.push($(this).attr('data-user-role'));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
checked_roles: checked_roles,
|
||||
unchecked_roles: unchecked_roles
|
||||
|
|
@ -221,7 +221,7 @@ frappe.RoleEditor = Class.extend({
|
|||
<th>Amend</th></tr></tbody></table>');
|
||||
for(var i in r.message) {
|
||||
var perm = r.message[i];
|
||||
|
||||
|
||||
// if permission -> icon
|
||||
for(key in perm) {
|
||||
if(key!='parent' && key!='permlevel') {
|
||||
|
|
@ -229,10 +229,10 @@ frappe.RoleEditor = Class.extend({
|
|||
perm[key] = '<i class="icon-ok"></i>';
|
||||
} else {
|
||||
perm[key] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$body.find('tbody').append(repl('<tr>\
|
||||
<td style="text-align: left">%(parent)s</td>\
|
||||
<td>%(permlevel)s</td>\
|
||||
|
|
@ -243,11 +243,11 @@ frappe.RoleEditor = Class.extend({
|
|||
<td>%(amend)s</td>\
|
||||
</tr>', perm))
|
||||
}
|
||||
|
||||
|
||||
me.perm_dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
make_perm_dialog: function() {
|
||||
this.perm_dialog = new frappe.ui.Dialog({
|
||||
|
|
@ -255,4 +255,4 @@ frappe.RoleEditor = Class.extend({
|
|||
width: 500
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#icon-grid {
|
||||
padding-bottom: 30px;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
.case-wrapper {
|
||||
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
.case-label {
|
||||
color: white;
|
||||
padding-top: 5px;
|
||||
font-size: 90%;
|
||||
line-height: 1.1;
|
||||
text-align: center;
|
||||
text-shadow: 1px 1px 3px rgba(0, 0, 0, 1), 0px 3px 15px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
|
@ -76,4 +77,4 @@
|
|||
padding-top: 14px;
|
||||
padding-bottom: 50px;
|
||||
margin-bottom: -50px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,6 +150,9 @@ class BaseDocument(object):
|
|||
if doc[k] is None:
|
||||
del doc[k]
|
||||
|
||||
if self.get("__islocal"):
|
||||
doc["__islocal"] = 1
|
||||
|
||||
return doc
|
||||
|
||||
def get_table_field_doctype(self, fieldname):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// MIT License. See license.txt
|
||||
// MIT License. See license.txt
|
||||
|
||||
// add a new dom element
|
||||
frappe.provide('frappe.dom');
|
||||
|
|
@ -33,7 +33,7 @@ frappe.dom = {
|
|||
} else {
|
||||
se.appendChild(document.createTextNode(txt));
|
||||
}
|
||||
document.getElementsByTagName('head')[0].appendChild(se);
|
||||
document.getElementsByTagName('head')[0].appendChild(se);
|
||||
},
|
||||
add: function(parent, newtag, className, cs, innerHTML, onclick) {
|
||||
if(parent && parent.substr)parent = frappe.dom.by_id(parent);
|
||||
|
|
@ -46,17 +46,17 @@ frappe.dom = {
|
|||
if(newtag.toLowerCase()=='img')
|
||||
c.src = className
|
||||
else
|
||||
c.className = className;
|
||||
c.className = className;
|
||||
}
|
||||
if(cs) frappe.dom.css(c,cs);
|
||||
if(innerHTML) c.innerHTML = innerHTML;
|
||||
if(onclick) c.onclick = onclick;
|
||||
return c;
|
||||
},
|
||||
css: function(ele, s) {
|
||||
if(ele && s) {
|
||||
for(var i in s) ele.style[i]=s[i];
|
||||
};
|
||||
css: function(ele, s) {
|
||||
if(ele && s) {
|
||||
$.extend(ele.style, s);
|
||||
};
|
||||
return ele;
|
||||
},
|
||||
freeze: function() {
|
||||
|
|
@ -72,7 +72,7 @@ frappe.dom = {
|
|||
frappe.dom.freeze_count--;
|
||||
if(!frappe.dom.freeze_count) {
|
||||
$('#freeze').toggle(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
save_selection: function() {
|
||||
// via http://stackoverflow.com/questions/5605401/insert-link-in-contenteditable-element
|
||||
|
|
@ -102,7 +102,7 @@ frappe.dom = {
|
|||
savedSel.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
frappe.get_modal = function(title, body_html) {
|
||||
|
|
@ -119,7 +119,7 @@ frappe.get_modal = function(title, body_html) {
|
|||
</div>\
|
||||
</div>\
|
||||
</div>').appendTo(document.body);
|
||||
|
||||
|
||||
return modal;
|
||||
};
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ frappe.get_shade = function(color, factor) {
|
|||
}
|
||||
|
||||
var get_int = function(hex) {
|
||||
return parseInt(hex,16);
|
||||
return parseInt(hex,16);
|
||||
}
|
||||
return get_hex(get_int(color.substr(0,2)) + factor)
|
||||
+ get_hex(get_int(color.substr(2,2)) + factor)
|
||||
|
|
@ -189,7 +189,7 @@ $.fn.gradientify = function(col) {
|
|||
if(!col) col = this.css("background-color");
|
||||
var col1 = frappe.get_shade(col, 1.05);
|
||||
var col2 = frappe.get_shade(col, 0.95);
|
||||
|
||||
|
||||
this.css({
|
||||
"background": "-moz-linear-gradient(top, #"+col1+" 0%, #"+col2+" 99%)"
|
||||
});
|
||||
|
|
@ -230,7 +230,7 @@ frappe.dom.set_box_shadow = function(ele, spread) {
|
|||
$(ele).css('-moz-box-shadow', '0px 0px '+ spread +'px rgba(0,0,0,0.3);')
|
||||
$(ele).css('-webkit-box-shadow', '0px 0px '+ spread +'px rgba(0,0,0,0.3);')
|
||||
$(ele).css('-box-shadow', '0px 0px '+ spread +'px rgba(0,0,0,0.3);')
|
||||
|
||||
|
||||
};
|
||||
|
||||
// add <option> list to <select>
|
||||
|
|
@ -250,7 +250,7 @@ frappe.dom.set_box_shadow = function(ele, spread) {
|
|||
$.fn.set_working = function() {
|
||||
var ele = this.get(0);
|
||||
$(ele).prop('disabled', true);
|
||||
if(ele.loading_img) {
|
||||
if(ele.loading_img) {
|
||||
$(ele.loading_img).toggle(true);
|
||||
} else {
|
||||
ele.loading_img = $('<img src="assets/frappe/images/ui/button-load.gif" \
|
||||
|
|
@ -261,8 +261,8 @@ frappe.dom.set_box_shadow = function(ele, spread) {
|
|||
$.fn.done_working = function() {
|
||||
var ele = this.get(0);
|
||||
$(ele).prop('disabled', false);
|
||||
if(ele.loading_img) {
|
||||
$(ele.loading_img).toggle(false);
|
||||
if(ele.loading_img) {
|
||||
$(ele.loading_img).toggle(false);
|
||||
};
|
||||
}
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
|
|
|||
|
|
@ -172,8 +172,8 @@ $.extend(frappe.model, {
|
|||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
var doclist = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||
var doc = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", r.message.doctype, r.message.name);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -313,9 +313,11 @@ $.extend(frappe.model, {
|
|||
},
|
||||
|
||||
clear_doc: function(doctype, name) {
|
||||
var doc = locals[doctype][name];
|
||||
var doc = locals[doctype] && locals[doctype][name];
|
||||
if(!doc) return;
|
||||
|
||||
if(doc && doc.parenttype) {
|
||||
var parent = null;
|
||||
if(doc.parenttype) {
|
||||
var parent = doc.parent,
|
||||
parenttype = doc.parenttype,
|
||||
parentfield = doc.parentfield;
|
||||
|
|
|
|||
|
|
@ -11,20 +11,22 @@ $.extend(frappe.model, {
|
|||
|
||||
if(!r.docs && !r.docinfo) r = {docs:r};
|
||||
|
||||
if($.isPlainObject(r.docs)) r.docs = [r.docs];
|
||||
|
||||
if(r.docs) {
|
||||
var last_parent_name = null;
|
||||
var dirty = [];
|
||||
|
||||
$.each(r.docs, function(i, d) {
|
||||
if(!d.name && d.__islocal) { // get name (local if required)
|
||||
frappe.model.clear_doc(d)
|
||||
frappe.model.clear_doc(d);
|
||||
d.name = frappe.model.get_new_name(d.doctype);
|
||||
frappe.provide("frappe.model.docinfo." + d.doctype + "." + d.name);
|
||||
frappe.provide("frappe.model.docinfo." + d.doctype + "." + d.name);
|
||||
}
|
||||
|
||||
frappe.model.add_to_locals(d);
|
||||
d.__last_sync_on = new Date();
|
||||
|
||||
|
||||
if(d.doctype==="DocType") {
|
||||
frappe.meta.sync(d);
|
||||
}
|
||||
|
|
@ -37,7 +39,7 @@ $.extend(frappe.model, {
|
|||
frappe.model.new_names[d.localname] = d.name;
|
||||
$(document).trigger('rename', [d.doctype, d.localname, d.name]);
|
||||
delete locals[d.doctype][d.localname];
|
||||
|
||||
|
||||
// update docinfo to new dict keys
|
||||
if(i===0) {
|
||||
frappe.model.docinfo[d.doctype][d.name] = frappe.model.docinfo[d.doctype][d.localname];
|
||||
|
|
@ -45,11 +47,11 @@ $.extend(frappe.model, {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(cur_frm && dirty.indexOf(cur_frm.doctype)!==-1) cur_frm.dirty();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// set docinfo (comments, assign, attachments)
|
||||
if(r.docinfo) {
|
||||
if(r.docs) {
|
||||
|
|
@ -61,7 +63,7 @@ $.extend(frappe.model, {
|
|||
frappe.model.docinfo[doc.doctype] = {};
|
||||
frappe.model.docinfo[doc.doctype][doc.name] = r.docinfo;
|
||||
}
|
||||
|
||||
|
||||
return r.docs;
|
||||
},
|
||||
add_to_locals: function(doc) {
|
||||
|
|
@ -77,5 +79,5 @@ $.extend(frappe.model, {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ frappe.standard_pages["query-report"] = function() {
|
|||
frappe.query_report = new frappe.views.QueryReport({
|
||||
parent: wrapper,
|
||||
});
|
||||
|
||||
|
||||
$(wrapper).bind("show", function() {
|
||||
frappe.query_report.load();
|
||||
});
|
||||
|
|
@ -31,15 +31,14 @@ frappe.views.QueryReport = Class.extend({
|
|||
this.appframe = this.parent.appframe;
|
||||
this.parent.query_report = this;
|
||||
this.make();
|
||||
this.load();
|
||||
},
|
||||
slickgrid_options: {
|
||||
enableColumnReorder: false,
|
||||
showHeaderRow: true,
|
||||
headerRowHeight: 30,
|
||||
explicitInitialization: true,
|
||||
multiColumnSort: true
|
||||
},
|
||||
multiColumnSort: true
|
||||
},
|
||||
make: function() {
|
||||
this.wrapper = $("<div>").appendTo($(this.parent).find(".layout-main"));
|
||||
$('<div class="waiting-area" style="display: none;"></div>\
|
||||
|
|
@ -59,7 +58,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
make_toolbar: function() {
|
||||
var me = this;
|
||||
this.appframe.set_title_right(frappe._('Refresh'), function() { me.refresh(); });
|
||||
|
||||
|
||||
// Edit
|
||||
var edit_btn = this.appframe.add_primary_action(frappe._('Edit'), function() {
|
||||
if(!frappe.user.is_report_manager()) {
|
||||
|
|
@ -68,10 +67,10 @@ frappe.views.QueryReport = Class.extend({
|
|||
}
|
||||
frappe.set_route("Form", "Report", me.report_name);
|
||||
}, "icon-edit");
|
||||
|
||||
|
||||
this.appframe.add_primary_action(frappe._('Export'), function() { me.export_report(); },
|
||||
"icon-download");
|
||||
|
||||
|
||||
if(frappe.model.can_restrict("Report")) {
|
||||
this.appframe.add_primary_action(frappe._("User Restrictions"), function() {
|
||||
frappe.route_options = {
|
||||
|
|
@ -91,7 +90,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
me.report_name = route[1];
|
||||
this.wrapper.find(".no-report-area").toggle(false);
|
||||
me.appframe.set_title(frappe._("Query Report")+": " + frappe._(me.report_name));
|
||||
|
||||
|
||||
frappe.model.with_doc("Report", me.report_name, function() {
|
||||
me.report_doc = frappe.get_doc("Report", me.report_name);
|
||||
frappe.model.with_doctype(me.report_doc.ref_doctype, function() {
|
||||
|
|
@ -117,7 +116,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
}
|
||||
} else {
|
||||
var msg = frappe._("No Report Loaded. Please use query-report/[Report Name] to run a report.")
|
||||
this.wrapper.find(".no-report-area").html(msg).toggle(true);
|
||||
this.wrapper.find(".no-report-area").html(msg).toggle(true);
|
||||
}
|
||||
},
|
||||
setup_filters: function() {
|
||||
|
|
@ -133,7 +132,10 @@ frappe.views.QueryReport = Class.extend({
|
|||
if(df["default"]) {
|
||||
f.set_input(df["default"]);
|
||||
}
|
||||
|
||||
if(df.fieldtype=="Check") {
|
||||
$(f.wrapper).find("input[type='checkbox']").css({"float":"None"});
|
||||
}
|
||||
|
||||
if(df.get_query) f.get_query = df.get_query;
|
||||
}
|
||||
});
|
||||
|
|
@ -148,15 +150,16 @@ frappe.views.QueryReport = Class.extend({
|
|||
var me = this;
|
||||
if(frappe.route_options) {
|
||||
$.each(this.filters || [], function(i, f) {
|
||||
if(frappe.route_options[f.df.fieldname]!=null)
|
||||
if(frappe.route_options[f.df.fieldname]!=null) {
|
||||
f.set_input(frappe.route_options[f.df.fieldname]);
|
||||
}
|
||||
});
|
||||
}
|
||||
frappe.route_options = null;
|
||||
},
|
||||
set_filters_by_name: function() {
|
||||
this.filters_by_name = {};
|
||||
|
||||
|
||||
for(var i in this.filters) {
|
||||
this.filters_by_name[this.filters[i].df.fieldname] = this.filters[i];
|
||||
}
|
||||
|
|
@ -164,7 +167,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
refresh: function() {
|
||||
// Run
|
||||
var me =this;
|
||||
this.waiting = frappe.messages.waiting(this.wrapper.find(".waiting-area").empty().toggle(true),
|
||||
this.waiting = frappe.messages.waiting(this.wrapper.find(".waiting-area").empty().toggle(true),
|
||||
"Loading Report...");
|
||||
this.wrapper.find(".results").toggle(false);
|
||||
var filters = {};
|
||||
|
|
@ -183,7 +186,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
me.make_results(r.message.result, r.message.columns);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return this.report_ajax;
|
||||
},
|
||||
get_values: function() {
|
||||
|
|
@ -211,8 +214,8 @@ frappe.views.QueryReport = Class.extend({
|
|||
this.columnFilters = {};
|
||||
this.make_dataview();
|
||||
this.id = frappe.dom.set_unique_id(this.wrapper.find(".result-area").get(0));
|
||||
|
||||
this.grid = new Slick.Grid("#"+this.id, this.dataView, this.columns,
|
||||
|
||||
this.grid = new Slick.Grid("#"+this.id, this.dataView, this.columns,
|
||||
this.slickgrid_options);
|
||||
|
||||
this.grid.setSelectionModel(new Slick.CellSelectionModel());
|
||||
|
|
@ -228,8 +231,8 @@ frappe.views.QueryReport = Class.extend({
|
|||
},
|
||||
make_columns: function(columns) {
|
||||
this.columns = [{id: "_id", field: "_id", name: "Sr No", width: 60}]
|
||||
.concat($.map(columns, function(c) {
|
||||
var col = {name:c, id: c, field: c, sortable: true, width: 80}
|
||||
.concat($.map(columns, function(c) {
|
||||
var col = {name:c, id: c, field: c, sortable: true, width: 80}
|
||||
|
||||
if(c.indexOf(":")!=-1) {
|
||||
var opts = c.split(":");
|
||||
|
|
@ -238,8 +241,8 @@ frappe.views.QueryReport = Class.extend({
|
|||
fieldtype: opts.length<=2 ? opts[1] : opts[opts.length - 2],
|
||||
width: opts.length<=2 ? opts[2] : opts[opts.length - 1]
|
||||
}
|
||||
|
||||
if(!df.fieldtype)
|
||||
|
||||
if(!df.fieldtype)
|
||||
df.fieldtype="Data";
|
||||
|
||||
if(df.fieldtype.indexOf("/")!=-1) {
|
||||
|
|
@ -247,12 +250,12 @@ frappe.views.QueryReport = Class.extend({
|
|||
df.fieldtype = tmp[0];
|
||||
df.options = tmp[1];
|
||||
}
|
||||
|
||||
|
||||
col.df = df;
|
||||
col.formatter = function(row, cell, value, columnDef, dataContext) {
|
||||
return frappe.format(value, columnDef.df, null, dataContext);
|
||||
}
|
||||
|
||||
|
||||
// column parameters
|
||||
col.name = col.id = col.field = df.label;
|
||||
col.name = frappe._(df.label);
|
||||
|
|
@ -261,7 +264,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
// width
|
||||
if(df.width) {
|
||||
col.width=parseInt(df.width);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
col.df = {
|
||||
label: c,
|
||||
|
|
@ -293,7 +296,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
this.dataView.setItems(this.data);
|
||||
this.dataView.setFilter(this.inline_filter);
|
||||
this.dataView.endUpdate();
|
||||
|
||||
|
||||
var me = this;
|
||||
this.dataView.onRowCountChanged.subscribe(function (e, args) {
|
||||
me.grid.updateRowCount();
|
||||
|
|
@ -310,7 +313,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
for (var columnId in me.columnFilters) {
|
||||
if (columnId !== undefined && me.columnFilters[columnId] !== "") {
|
||||
var c = me.grid.getColumns()[me.grid.getColumnIndex(columnId)];
|
||||
if (!me.compare_values(item[c.field], me.columnFilters[columnId],
|
||||
if (!me.compare_values(item[c.field], me.columnFilters[columnId],
|
||||
me.columns[me.grid.getColumnIndex(columnId)])) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -320,16 +323,16 @@ frappe.views.QueryReport = Class.extend({
|
|||
},
|
||||
compare_values: function(value, filter, columnDef) {
|
||||
var invert = false;
|
||||
|
||||
|
||||
// check if invert
|
||||
if(filter[0]=="!") {
|
||||
invert = true;
|
||||
filter = filter.substr(1);
|
||||
}
|
||||
|
||||
|
||||
var out = false;
|
||||
var cond = "=="
|
||||
|
||||
|
||||
// parse condition
|
||||
if(filter[0]==">") {
|
||||
filter = filter.substr(1);
|
||||
|
|
@ -338,7 +341,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
filter = filter.substr(1);
|
||||
cond = "<"
|
||||
}
|
||||
|
||||
|
||||
if(in_list(['Float', 'Currency', 'Int', 'Date'], columnDef.df.fieldtype)) {
|
||||
// non strings
|
||||
if(filter.indexOf(":")==-1) {
|
||||
|
|
@ -350,7 +353,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
value = flt(value);
|
||||
filter = flt(filter);
|
||||
}
|
||||
|
||||
|
||||
out = eval("value" + cond + "filter");
|
||||
} else {
|
||||
// range
|
||||
|
|
@ -365,7 +368,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
filter[0] = flt(filter[0]);
|
||||
filter[1] = flt(filter[1]);
|
||||
}
|
||||
|
||||
|
||||
out = value >= filter[0] && value <= filter[1];
|
||||
}
|
||||
} else {
|
||||
|
|
@ -375,15 +378,15 @@ frappe.views.QueryReport = Class.extend({
|
|||
filter = filter.toLowerCase();
|
||||
out = value.indexOf(filter) != -1;
|
||||
}
|
||||
|
||||
if(invert)
|
||||
|
||||
if(invert)
|
||||
return !out;
|
||||
else
|
||||
else
|
||||
return out;
|
||||
},
|
||||
setup_header_row: function() {
|
||||
var me = this;
|
||||
|
||||
|
||||
$(this.grid.getHeaderRow()).delegate(":input", "change keyup", function (e) {
|
||||
var columnId = $(this).data("columnId");
|
||||
if (columnId != null) {
|
||||
|
|
@ -428,7 +431,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
msgprint(frappe._("You are not allowed to export this report."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var result = $.map(frappe.slickgrid_tools.get_view_data(this.columns, this.dataView),
|
||||
function(row) {
|
||||
return [row.splice(1)];
|
||||
|
|
@ -437,4 +440,4 @@ frappe.views.QueryReport = Class.extend({
|
|||
frappe.tools.downloadify(result, null, this);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue