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

This commit is contained in:
Anand Doshi 2012-12-01 17:59:48 +05:30
commit 2551ecbb8e
5 changed files with 95 additions and 75 deletions

View file

@ -158,4 +158,66 @@ set_missing_values = function(doc, dict) {
$.each(dict, function(i, v) { if (!doc[i]) { fields_to_set[i] = v; } });
if (fields_to_set) { set_multiple(doc.doctype, doc.name, fields_to_set); }
}
}
_f.Frm.prototype.get_doc = function() {
return locals[this.doctype][this.docname];
}
_f.Frm.prototype.get_doclist = function() {
return make_doclist(this.doctype, this.docname);
}
_f.Frm.prototype.field_map = function(fnames, fn) {
if(typeof fnames=='string') {
if(fnames == '*') {
fnames = keys(this.fields_dict);
} else {
fnames = [fnames];
}
}
$.each(fnames, function(i,f) {
//var field = cur_frm.fields_dict[f]; - much better design
var field = wn.meta.get_docfield(cur_frm.doctype, f, cur_frm.docname)
if(field) {
fn(field);
cur_frm.refresh_field(f);
};
})
}
_f.Frm.prototype.set_df_property = function(fieldname, property, value) {
var field = wn.meta.get_docfield(cur_frm.doctype, fieldname, cur_frm.docname)
if(field) {
field[property] = value;
cur_frm.refresh_field(fieldname);
};
}
_f.Frm.prototype.toggle_enable = function(fnames, enable) {
cur_frm.field_map(fnames, function(field) { field.disabled = enable ? false : true; });
}
_f.Frm.prototype.toggle_reqd = function(fnames, mandatory) {
cur_frm.field_map(fnames, function(field) { field.reqd = mandatory ? true : false; });
}
_f.Frm.prototype.toggle_display = function(fnames, show) {
cur_frm.field_map(fnames, function(field) { field.hidden = show ? 0 : 1; });
}
_f.Frm.prototype.call_server = function(method, args, callback) {
$c_obj(cur_frm.get_doclist(), method, args, callback);
}
_f.Frm.prototype.get_files = function() {
return $.map((cur_frm.doc.file_list || "").split("\n"), function(f) {
return f.split(",")[0] || null;
});
}
_f.Frm.prototype.set_value = function(field, value) {
cur_frm.doc[field] = value;
cur_frm.fields_dict[field].refresh();
}

View file

@ -1085,66 +1085,4 @@ _f.Frm.prototype.show_comments = function() {
cur_frm.comments.list.dn = cur_frm.docname;
cur_frm.comments.show();
cur_frm.comments.list.run();
}
_f.Frm.prototype.get_doc = function() {
return locals[this.doctype][this.docname];
}
_f.Frm.prototype.get_doclist = function() {
return make_doclist(this.doctype, this.docname);
}
_f.Frm.prototype.field_map = function(fnames, fn) {
if(typeof fnames=='string') {
if(fnames == '*') {
fnames = keys(this.fields_dict);
} else {
fnames = [fnames];
}
}
$.each(fnames, function(i,f) {
//var field = cur_frm.fields_dict[f]; - much better design
var field = wn.meta.get_docfield(cur_frm.doctype, f, cur_frm.docname)
if(field) {
fn(field);
cur_frm.refresh_field(f);
};
})
}
_f.Frm.prototype.set_df_property = function(fieldname, property, value) {
var field = wn.meta.get_docfield(cur_frm.doctype, fieldname, cur_frm.docname)
if(field) {
field[property] = value;
cur_frm.refresh_field(fieldname);
};
}
_f.Frm.prototype.toggle_enable = function(fnames, enable) {
cur_frm.field_map(fnames, function(field) { field.disabled = enable ? false : true; });
}
_f.Frm.prototype.toggle_reqd = function(fnames, mandatory) {
cur_frm.field_map(fnames, function(field) { field.reqd = mandatory ? true : false; });
}
_f.Frm.prototype.toggle_display = function(fnames, show) {
cur_frm.field_map(fnames, function(field) { field.hidden = show ? 0 : 1; });
}
_f.Frm.prototype.call_server = function(method, args, callback) {
$c_obj(cur_frm.get_doclist(), method, args, callback);
}
_f.Frm.prototype.get_files = function() {
return $.map((cur_frm.doc.file_list || "").split("\n"), function(f) {
return f.split(",")[0] || null;
});
}
_f.Frm.prototype.set_value = function(field, value) {
cur_frm.doc[field] = value;
cur_frm.fields_dict[field].refresh();
}
}

View file

@ -351,6 +351,16 @@ $.extend(_p, {
+ stat
+ container.innerHTML.replace(/<div/g, '\n<div').replace(/<td/g, '\n<td')
+ footer;
// replace relative links by absolute links
var prefix = window.location.href.split("app.html")[0]
$.each(finished.match(/src=['"]([^'"]*)['"]/) || [], function(i, v) {
if(v.substr(0,4)!="src=") {
if(v.substr(0,4)!="http")
finished = finished.replace(v, prefix + v);
}
});
return finished;
},

View file

@ -74,16 +74,18 @@ wn.views.CommunicationList = Class.extend({
make_line: function(doc) {
var me = this;
var comm = $(repl('<tr><td title="Click to Expand / Collapse">\
<p><b>%(_sender)s on %(when)s</b> \
<a href="#Form/Communication/%(name)s" style="font-size: 90%">\
Show Details</a></p>\
<a href="#Form/Communication/%(name)s" style="font-size: 90%; float: right;">\
Show Details</a>\
<p class="comm-header"><b>%(_sender)s on %(when)s</b></p>\
<div class="comm-content" style="border-top: 1px solid #ddd; \
padding: 10px; overflow-x: auto; display: none;"></div>\
</td></tr>', doc))
.appendTo(this.body)
comm.find(".comm-header")
.css({"cursor":"pointer"})
.click(function() {
$(this).find(".comm-content").toggle();
$(this).parent().find(".comm-content").toggle();
});
this.comm_list.push(comm);
@ -106,8 +108,8 @@ wn.views.CommunicationComposer = Class.extend({
{label:"To", fieldtype:"Data", reqd: 1, fieldname:"recipients",
description:"Email addresses, separted by commas"},
{label:"Subject", fieldtype:"Data", reqd: 1},
{label:"Message", fieldtype:"Text Editor", reqd: 1, fieldname:"content"},
{label:"Add Reply", fieldtype:"Button"},
{label:"Message", fieldtype:"Text Editor", reqd: 1, fieldname:"content"},
{label:"Send Email", fieldtype:"Check"},
{label:"Send Me A Copy", fieldtype:"Check"},
{label:"Attach Document Print", fieldtype:"Check"},
@ -161,8 +163,10 @@ wn.views.CommunicationComposer = Class.extend({
var me = this;
var fields = this.dialog.fields_dict;
if(this.attach_document_print)
$(fields.attach_document_print.input).attr("checked", "checked")
if(this.attach_document_print) {
$(fields.send_me_a_copy.input).click();
$(fields.attach_document_print.input).click();
}
$(fields.send_email.input).attr("checked", "checked")
$(fields.add_reply.input).click(function() {
@ -174,8 +178,15 @@ wn.views.CommunicationComposer = Class.extend({
return $(element).attr("data-file-name");
})
_p.build(args.select_print_format || "", function(print_html) {
_p.build(form_values.select_print_format || "", function(print_format_html) {
me.dialog.hide();
if(form_values.attach_document_print) {
var print_html = print_format_html
form_values.content = form_values.content
+ "<p></p><hr>" + print_html;
} else {
print_html = "";
}
wn.call({
method:"core.doctype.communication.communication.make",
args: {
@ -189,8 +200,7 @@ wn.views.CommunicationComposer = Class.extend({
contact: me.doc.contact,
send_me_a_copy: form_values.send_me_a_copy,
send_email: form_values.send_email,
print_html: form_values.attach_document_print
? print_html : "",
print_html: print_html,
attachments: selected_attachments
},
callback: function(r) {

View file

@ -32,7 +32,7 @@ roles = []
@webnotes.whitelist()
def get(arg=None):
query = build_query(arg)
return compress(webnotes.conn.sql(query, as_dict=1, debug=1))
return compress(webnotes.conn.sql(query, as_dict=1))
def build_query(arg=None):
"""