commit
55dc1d18d6
2 changed files with 33 additions and 14 deletions
|
|
@ -115,7 +115,6 @@ frappe.ui.form.LinkSelector = Class.extend({
|
|||
if(this.qty_fieldname) {
|
||||
frappe.prompt({fieldname:"qty", fieldtype:"Float", label:"Qty",
|
||||
"default": 1, reqd: 1}, function(data) {
|
||||
console.log(data);
|
||||
$.each(me.target.frm.doc[me.target.df.fieldname] || [], function(i, d) {
|
||||
if(d[me.fieldname]===value) {
|
||||
frappe.model.set_value(d.doctype, d.name, me.qty_fieldname, data.qty);
|
||||
|
|
@ -126,9 +125,13 @@ frappe.ui.form.LinkSelector = Class.extend({
|
|||
});
|
||||
if(!updated) {
|
||||
var d = me.target.add_new_row();
|
||||
frappe.model.set_value(d.doctype, d.name, me.qty_fieldname, data.qty);
|
||||
frappe.model.set_value(d.doctype, d.name, me.fieldname, value);
|
||||
show_alert(__("Added {0} ({1})", [value, data.qty]));
|
||||
frappe.after_ajax(function() {
|
||||
setTimeout(function() {
|
||||
frappe.model.set_value(d.doctype, d.name, me.qty_fieldname, data.qty);
|
||||
show_alert(__("Added {0} ({1})", [value, data.qty]));
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
}, __("Set Quantity"), __("Set"));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
frappe.provide('frappe.request');
|
||||
frappe.request.url = '/';
|
||||
frappe.request.ajax_count = 0;
|
||||
frappe.request.waiting_for_ajax = [];
|
||||
|
||||
// generic server call (call page, object)
|
||||
frappe.call = function(opts) {
|
||||
|
|
@ -110,7 +112,9 @@ frappe.request.call = function(opts) {
|
|||
data = JSON.parse(data.responseText);
|
||||
}
|
||||
frappe.request.cleanup(opts, data);
|
||||
if(opts.always) opts.always(data);
|
||||
if(opts.always) {
|
||||
opts.always(data);
|
||||
}
|
||||
})
|
||||
.done(function(data, textStatus, xhr) {
|
||||
var status_code_handler = statusCode[xhr.statusCode().status];
|
||||
|
|
@ -131,6 +135,8 @@ frappe.request.call = function(opts) {
|
|||
|
||||
// call execute serverside request
|
||||
frappe.request.prepare = function(opts) {
|
||||
frappe.request.ajax_count++;
|
||||
|
||||
$("body").attr("data-ajax-state", "triggered");
|
||||
|
||||
// btn indicator
|
||||
|
|
@ -200,22 +206,16 @@ frappe.request.cleanup = function(opts, r) {
|
|||
|
||||
// debug messages
|
||||
if(r._debug_messages) {
|
||||
console.log("-")
|
||||
console.log("-")
|
||||
console.log("-")
|
||||
if(opts.args) {
|
||||
console.log("<<<< arguments ");
|
||||
console.log("======== arguments ========");
|
||||
console.log(opts.args);
|
||||
console.log(">>>>")
|
||||
console.log("========")
|
||||
}
|
||||
$.each(JSON.parse(r._debug_messages), function(i, v) { console.log(v); });
|
||||
console.log("<<<< response");
|
||||
console.log("======== response ========");
|
||||
delete r._debug_messages;
|
||||
console.log(r);
|
||||
console.log(">>>>")
|
||||
console.log("-")
|
||||
console.log("-")
|
||||
console.log("-")
|
||||
console.log("========");
|
||||
}
|
||||
|
||||
if(r.docs || r.docinfo) {
|
||||
|
|
@ -226,6 +226,22 @@ frappe.request.cleanup = function(opts, r) {
|
|||
}
|
||||
|
||||
frappe.last_response = r;
|
||||
|
||||
frappe.request.ajax_count--;
|
||||
if(!frappe.request.ajax_count) {
|
||||
$.each(frappe.request.waiting_for_ajax || [], function(i, fn) {
|
||||
fn();
|
||||
});
|
||||
frappe.request.waiting_for_ajax = [];
|
||||
}
|
||||
}
|
||||
|
||||
frappe.after_ajax = function(fn) {
|
||||
if(frappe.request.ajax_count) {
|
||||
frappe.request.waiting_for_ajax.push(fn);
|
||||
} else {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
frappe.request.report_error = function(xhr, request_opts) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue