From: Steven Chan Date: Sun, 31 Aug 2014 17:29:59 +0000 (-0700) Subject: Fix progress message in action dialogues X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8546cdf52b7d2573f8ee04f19e7a6846f0a291d8;p=contrib%2Foverdrive-eg-opac.git Fix progress message in action dialogues The jQuery ajax method does not implement the full promise interface; it does not call notify and so the progress callback cannot work. As a substitute, we pass the progress callback as the beforeSend callback, which is executed before an ajax send. Also, we use a progress bar instead of a progress text message. Signed-off-by: Steven Chan --- diff --git a/src/od_action.coffee b/src/od_action.coffee index e4bcada..e25361f 100644 --- a/src/od_action.coffee +++ b/src/od_action.coffee @@ -107,11 +107,8 @@ define [ # Make an API call action = @options._action - od.api action.href, action.method, fields: $('form', @element).serializeArray() - - # TODO progress message is not showing - # seems like the progress callback is never called - .progress => @set_message 'progress', true + progress = => @set_message 'progress', true + od.api action.href, action.method, fields: $('form', @element).serializeArray(), progress # Re-use the dialog to show notifications with a close button .then( diff --git a/src/od_api.coffee b/src/od_api.coffee index 6d4087d..9e09cd9 100644 --- a/src/od_api.coffee +++ b/src/od_api.coffee @@ -151,7 +151,7 @@ define [ # Customize the plain jQuery ajax method to handle a GET or POST method # for the Overdrive api. - api: (url, method, data) -> + api: (url, method, data, beforeSend) -> # Do some pre-processing of data before it is sent to server if method is 'post' @@ -177,6 +177,7 @@ define [ # A given data object is expected to be in JSON format contentType: 'application/json; charset=utf-8' data: json.stringify data + beforeSend: beforeSend .done ->