')
.appendTo(this.wrapper);
- this.frm.sections.push(this.section);
+ this.sections.push(this.section);
var section = this.section[0];
section.df = df;
@@ -108,7 +119,7 @@ wn.ui.form.Layout = Class.extend({
"font-weight": "bold",
})
.appendTo(this.section);
- if(this.frm.sections.length > 1)
+ if(this.sections.length > 1)
this.section.css({
"margin-top": "15px",
"border-top": "1px solid #ddd"
@@ -125,8 +136,8 @@ wn.ui.form.Layout = Class.extend({
.appendTo(this.section)
.css({"height": "20px"});
}
- this.frm.fields_dict[df.fieldname] = section;
- this.frm.fields.push(section);
+ this.fields_dict[df.fieldname] = section;
+ this.fields_list.push(section);
}
// for bc
this.section.body = $('
').appendTo(this.section);
@@ -163,11 +174,11 @@ wn.ui.form.Layout = Class.extend({
var me = this,
grid_row = null;
prev = null,
- fields = me.frm.fields,
+ fields = me.fields,
in_grid = false;
// in grid
- if(doctype != me.frm.doctype) {
+ if(doctype != me.doctype) {
grid_row =me.get_open_grid_row()
fields = grid_row.fields;
}
@@ -178,7 +189,7 @@ wn.ui.form.Layout = Class.extend({
if(prev) {
this.set_focus(prev)
} else {
- $(cur_frm.wrapper).find(".btn-primary").focus();
+ $(this.primary_button).focus();
}
break;
}
@@ -196,7 +207,7 @@ wn.ui.form.Layout = Class.extend({
grid_row.grid.grid_rows[grid_row.doc.idx].toggle_view(true);
}
} else {
- $(cur_frm.wrapper).find(".btn-primary").focus();
+ $(this.primary_button).focus();
}
} else {
me.focus_on_next_field(i, fields);
@@ -238,37 +249,4 @@ wn.ui.form.Layout = Class.extend({
return $(".grid-row-open").data("grid_row");
},
- // dashboard
- clear_dashboard: function() {
- this.dashboard.empty();
- },
- add_doctype_badge: function(doctype, fieldname) {
- if(wn.model.can_read(doctype)) {
- this.add_badge(wn._(doctype), function() {
- wn.route_options = {};
- wn.route_options[fieldname] = cur_frm.doc.name;
- wn.set_route("List", doctype);
- }).attr("data-doctype", doctype);
- }
- },
- add_badge: function(label, onclick) {
- var badge = $(repl('
', {label:label}))
- .appendTo(this.dashboard)
-
- badge.find(".badge-link").click(onclick);
-
- return badge.find(".alert-badge");
- },
- set_badge_count: function(data) {
- var me = this;
- $.each(data, function(doctype, count) {
- $(me.dashboard)
- .find(".alert-badge[data-doctype='"+doctype+"'] .badge")
- .html(cint(count));
- });
- },
})
\ No newline at end of file
diff --git a/public/js/wn/misc/utils.js b/public/js/wn/misc/utils.js
index 5e5a0ec295..0583cd86a1 100644
--- a/public/js/wn/misc/utils.js
+++ b/public/js/wn/misc/utils.js
@@ -237,7 +237,7 @@ wn.utils = {
var ctx = canvas.getContext("2d");
ctx.drawImage(this, 0, 0, tempW, tempH);
var dataURL = canvas.toDataURL("image/jpeg");
- callback(dataURL);
+ setTimeout(function() { callback(dataURL); }, 10 );
}
}
};
\ No newline at end of file
diff --git a/public/js/wn/model/meta.js b/public/js/wn/model/meta.js
index 7c5b1c456a..1d706c4f60 100644
--- a/public/js/wn/model/meta.js
+++ b/public/js/wn/model/meta.js
@@ -64,7 +64,7 @@ $.extend(wn.meta, {
},
get_fieldnames: function(doctype, name, filters) {
- return $.map(wn.meta.get_docfields(doctype, name, filters),
+ return $.map(wn.utils.filter_dict(wn.meta.docfield_map[doctype], filters),
function(df) { return df.fieldname; });
},
diff --git a/public/js/wn/ui/dialog.js b/public/js/wn/ui/dialog.js
index 4cf9666f9b..6c7ae4b8e9 100644
--- a/public/js/wn/ui/dialog.js
+++ b/public/js/wn/ui/dialog.js
@@ -24,6 +24,7 @@ wn.ui.Dialog = wn.ui.FieldGroup.extend({
if(!opts.width) opts.width = 480;
$.extend(this, opts);
+ this._super();
this.make();
},
make: function() {
diff --git a/public/js/wn/ui/field_group.js b/public/js/wn/ui/field_group.js
index 9b4859d87d..86aeb13045 100644
--- a/public/js/wn/ui/field_group.js
+++ b/public/js/wn/ui/field_group.js
@@ -3,50 +3,53 @@
wn.provide('wn.ui');
-wn.ui.FieldGroup = Class.extend({
+wn.ui.FieldGroup = wn.ui.form.Layout.extend({
init: function(opts) {
$.extend(this, opts);
+ this._super();
},
make: function() {
if(this.fields) {
- this.make_fields();
- if(!this.no_submit_on_enter)
+ this._super();
+ this.refresh();
+ if(!this.no_submit_on_enter) {
+ $(this.body).find(".btn:first").removeClass("btn-default").addClass("btn-primary");
this.catch_enter_as_submit();
- }
- },
- first_button: false,
- make_fields: function() {
- $(this.body).css({padding:'25px'});
- this.fields_dict = {}; // reset
- for(var i=0; i< this.fields.length; i++) {
- var df = this.fields[i];
- if(!df.fieldname && df.label) {
- df.fieldname = df.label.replace(/ /g, '_').toLowerCase();
- }
- if(!df.fieldtype) df.fieldtype="Data";
-
- var div = $a(this.body, 'div');
- f = make_field(df, null, div, null);
- f.not_in_form = 1;
- f.dialog_wrapper = this.wrapper || null;
- this.fields_dict[df.fieldname] = f
- f.refresh();
-
- // first button primary ?
- if(df.fieldtype=='Button' && !this.first_button) {
- $(f.input).removeClass("btn-default").addClass('btn-info');
- this.first_button = true;
- }
- if(!df.description) {
- $(f.wrapper).find(".help-box").toggle(false);
}
}
},
+ first_button: false,
+ // make_fields: function() {
+ // this.fields_dict = {}; // reset
+ // for(var i=0; i< this.fields.length; i++) {
+ // var df = this.fields[i];
+ // if(!df.fieldname && df.label) {
+ // df.fieldname = df.label.replace(/ /g, '_').toLowerCase();
+ // }
+ // if(!df.fieldtype) df.fieldtype="Data";
+ //
+ // var div = $a(this.body, 'div');
+ // f = make_field(df, null, div, null);
+ // f.not_in_form = 1;
+ // f.dialog_wrapper = this.wrapper || null;
+ // this.fields_dict[df.fieldname] = f
+ // f.refresh();
+ //
+ // // first button primary ?
+ // if(df.fieldtype=='Button' && !this.first_button) {
+ // $(f.input).removeClass("btn-default").addClass('btn-info');
+ // this.first_button = true;
+ // }
+ // if(!df.description) {
+ // $(f.wrapper).find(".help-box").toggle(false);
+ // }
+ // }
+ // },
catch_enter_as_submit: function() {
var me = this;
$(this.body).find('input[type="text"], input[type="password"]').keypress(function(e) {
if(e.which==13) {
- $(me.body).find('.btn-info:first').click();
+ $(me.body).find('.btn-primary:first').click();
}
})
},
diff --git a/public/js/wn/upload.js b/public/js/wn/upload.js
index a5506912ae..96cc10801f 100644
--- a/public/js/wn/upload.js
+++ b/public/js/wn/upload.js
@@ -27,6 +27,7 @@ wn.upload = {
$upload.find(".action-link").addClass("disabled");
$upload.find(".action-attach-input").toggle(false);
$upload.find(".action-link-input").toggle(true);
+ $upload.find(".btn-upload").html('
' +wn._('Set Link'))
return false;
})
@@ -35,6 +36,7 @@ wn.upload = {
$upload.find(".action-attach").addClass("disabled");
$upload.find(".action-link-input").toggle(false);
$upload.find(".action-attach-input").toggle(true);
+ $upload.find(".btn-upload").html('
' +wn._('Upload'))
return false;
})
@@ -72,9 +74,10 @@ wn.upload = {
return;
}
+ var dataurl = null;
var _upload_file = function() {
if(opts.on_attach) {
- opts.on_attach(args)
+ opts.on_attach(args, dataurl)
} else {
var msgbox = msgprint(wn._("Uploading..."));
return wn.call({
@@ -104,12 +107,14 @@ wn.upload = {
freader.onload = function() {
args.filename = fileobj.name;
if((opts.max_width || opts.max_height) && (/\.(gif|jpg|jpeg|tiff|png)$/i).test(args.filename)) {
- wn.utils.resize_image(freader, function(dataurl) {
- args.filedata = dataurl.split(",")[1];
+ wn.utils.resize_image(freader, function(_dataurl) {
+ dataurl = _dataurl;
+ args.filedata = _dataurl.split(",")[1];
console.log("resized!")
_upload_file();
})
} else {
+ dataurl = freader.result;
args.filedata = freader.result.split(",")[1];
_upload_file();
}
diff --git a/website/templates/includes/comments.html b/website/templates/includes/comments.html
index 4535880132..b2229eab50 100644
--- a/website/templates/includes/comments.html
+++ b/website/templates/includes/comments.html
@@ -63,6 +63,7 @@ $(document).ready(function() {
}
wn.call({
+ btn: this,
type: "POST",
method: "website.templates.includes.comments.add_comment",
args: args,