Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong placement of ajax timeout option #1524

Merged
merged 1 commit into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bika/lims/browser/js/coffee/bika_widgets/remarkswidget.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,10 @@ class window.RemarksWidgetView
url: @get_portal_url() + "/@@API/update"
data:
obj_uid: widget.attr('data-uid')
timeout: 600000 # 10 minutes timeout
options.data[fieldname] = value
@ajax_submit options
.done (data) ->
return deferred.resolveWith this, [[]]
.fail (request, status, error) ->
msg = _("Sorry, an error occured: #{status}")
window.bika.lims.portalMessage msg
window.scroll 0, 0
return deferred.promise()

### EVENT HANDLERS ###
Expand Down Expand Up @@ -213,13 +208,18 @@ class window.RemarksWidgetView
options.context ?= this
options.dataType ?= "json"
options.data ?= {}
options.timeout ?= 600000 # 10 minutes timeout

console.debug ">>> ajax_submit::options=", options

$(this).trigger "ajax:submit:start"
done = ->
$(this).trigger "ajax:submit:end"
return $.ajax(options).done done
fail = (request, status, error) ->
msg = _("Sorry, an error occured: #{status}")
window.bika.lims.portalMessage msg
window.scroll 0, 0
return $.ajax(options).done(done).fail(fail)

get_portal_url: =>
###
Expand Down
21 changes: 12 additions & 9 deletions bika/lims/skins/bika/bika_widgets/remarkswidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,12 @@
options = {
url: this.get_portal_url() + "/@@API/update",
data: {
obj_uid: widget.attr('data-uid'),
timeout: 600000
obj_uid: widget.attr('data-uid')
}
};
options.data[fieldname] = value;
this.ajax_submit(options).done(function(data) {
return deferred.resolveWith(this, [[]]);
}).fail(function(request, status, error) {
var msg;
msg = _("Sorry, an error occured: " + status);
window.bika.lims.portalMessage(msg);
return window.scroll(0, 0);
});
return deferred.promise();
};
Expand Down Expand Up @@ -266,7 +260,7 @@
* jQuery ajax options
* @returns {Deferred} XHR request
*/
var done;
var done, fail;
console.debug("°°° ajax_submit °°°");
if (options == null) {
options = {};
Expand All @@ -286,12 +280,21 @@
if (options.data == null) {
options.data = {};
}
if (options.timeout == null) {
options.timeout = 600000;
}
console.debug(">>> ajax_submit::options=", options);
$(this).trigger("ajax:submit:start");
done = function() {
return $(this).trigger("ajax:submit:end");
};
return $.ajax(options).done(done);
fail = function(request, status, error) {
var msg;
msg = _("Sorry, an error occured: " + status);
window.bika.lims.portalMessage(msg);
return window.scroll(0, 0);
};
return $.ajax(options).done(done).fail(fail);
};

RemarksWidgetView.prototype.get_portal_url = function() {
Expand Down