Merge branch 'master' of github.com:webnotes/wnframework

This commit is contained in:
Rushabh Mehta 2012-12-31 10:51:54 +05:30
commit 60d3c7a550
6 changed files with 44 additions and 37 deletions

View file

@ -313,31 +313,11 @@ _f.Frm.prototype.setup_footer = function() {
}
_f.Frm.prototype.set_intro = function(txt) {
if(!this.intro_area) {
this.intro_area = $('<div class="alert form-intro-area" style="margin-top: 20px;">')
.insertBefore(this.page_layout.body.firstChild);
}
if(txt) {
if(txt.search(/<p>/)==-1) txt = '<p>' + txt + '</p>';
this.intro_area.html(txt);
} else {
this.intro_area.remove();
this.intro_area = null;
}
wn.utils.set_intro(this, this.page_layout.body, txt);
}
_f.Frm.prototype.set_footnote = function(txt) {
if(!this.footnote_area) {
this.footnote_area = $('<div class="alert form-intro-area">')
.insertAfter(this.page_layout.body.lastChild);
}
if(txt) {
if(txt.search(/<p>/)==-1) txt = '<p>' + txt + '</p>';
this.footnote_area.html(txt);
} else {
this.footnote_area.remove();
this.footnote_area = null;
}
wn.utils.set_footnote(this, this.page_layout.body, txt);
}
@ -350,7 +330,7 @@ _f.Frm.prototype.setup_fields_std = function() {
this.layout.addrow(); // default section break
if(fl[0].fieldtype!="Column Break") {// without column too
var c = this.layout.addcell();
$y(c.wrapper, {padding: '8px'});
$y(c.wrapper, {padding: '8px'});
}
}

View file

@ -50,5 +50,32 @@ wn.utils = {
} else {
return list;
}
}
},
set_intro: function(me, wrapper, txt) {
if(!me.intro_area) {
me.intro_area = $('<div class="alert form-intro-area" style="margin-top: 20px;">')
.insertBefore(wrapper.firstChild);
}
if(txt) {
if(txt.search(/<p>/)==-1) txt = '<p>' + txt + '</p>';
me.intro_area.html(txt);
} else {
me.intro_area.remove();
me.intro_area = null;
}
},
set_footnote: function(me, wrapper, txt) {
if(!me.footnote_area) {
me.footnote_area = $('<div class="alert form-intro-area" style="margin-top: 20px;">')
.insertAfter(wrapper.lastChild);
}
if(txt) {
if(txt.search(/<p>/)==-1) txt = '<p>' + txt + '</p>';
me.footnote_area.html(txt);
} else {
me.footnote_area.remove();
me.footnote_area = null;
}
},
}

View file

@ -72,7 +72,7 @@ wn.get_route_str = function(route) {
}
wn.set_route = function() {
route = $.map(arguments, function(a) { return encodeURIComponent(a) }).join('/');
route = $.map(arguments, function(a) { return a ? encodeURIComponent(a) : null; }).join('/');
window.location.hash = route;
// Set favicon (app.js)

View file

@ -268,7 +268,7 @@ wn.views.GridReport = Class.extend({
if (col.formatter==me.currency_formatter) {
item[col.id] = 0;
}
});
});
},
refresh: function() {
@ -302,15 +302,13 @@ wn.views.GridReport = Class.extend({
// print / export
$('<div style="text-align: right;"> \
<div class="processing" style="background-color: #fec; display: none; float: left; margin: 2px"> \
Updated! </div>\
<a href="#" class="grid-report-print"><i class="icon icon-print"></i> Print</a> \
<span style="color: #aaa; margin: 0px 10px;"> | </span> \
<a href="#" class="grid-report-export"><i class="icon icon-download-alt"></i> Export</a> \
<div class="processing" style="background-color: #fec; display: none; \
float: left; margin: 2px">Updated! </div> \
<a href="#" class="grid-report-export"> \
<i class="icon icon-download-alt"></i> Export</a> \
</div>').appendTo(this.wrapper);
this.wrapper.find(".grid-report-export").click(function() { return me.export(); });
this.wrapper.find(".grid-report-print").click(function() { msgprint("Coming Soon"); return false; });
// grid wrapper
this.grid_wrapper = $("<div style='height: 500px; border: 1px solid #aaa; \

View file

@ -739,14 +739,15 @@ def comma_and(some_list):
return comma_sep(some_list, " and ")
def comma_sep(some_list, sep):
if isinstance(some_list, list):
# ([] + some_list) is done to preserve the existing list
some_list = [unicode(s) for s in ([] + some_list)]
if isinstance(some_list, (list, tuple)):
# list(some_list) is done to preserve the existing list
some_list = [unicode(s) for s in list(some_list)]
if not some_list:
return ""
elif len(some_list) == 1:
return some_list[0]
else:
some_list = ["'%s'" % s for s in some_list]
return ", ".join(some_list[:-1]) + sep + some_list[-1]
else:
return some_list

View file

@ -41,11 +41,12 @@ def get_data():
conditions += " where " + " and ".join(args["conditions"])
if args.get("order_by"):
order_by = " order by " + args["order_by"]
table = args.get("from") or ("`tab%s`" % d)
out[d] = {}
start = datetime.datetime.now()
out[d]["data"] = [list(t) for t in webnotes.conn.sql("""select %s from `tab%s` %s %s""" % (",".join(args["columns"]),
d, conditions, order_by))]
out[d]["data"] = [list(t) for t in webnotes.conn.sql("""select %s from %s %s %s""" \
% (",".join(args["columns"]), table, conditions, order_by))]
out[d]["time"] = str(datetime.datetime.now() - start)
out[d]["columns"] = map(lambda c: c.split(" as ")[-1], args["columns"])