From 8546cdf52b7d2573f8ee04f19e7a6846f0a291d8 Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Sun, 31 Aug 2014 10:29:59 -0700 Subject: [PATCH] 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 --- src/od_action.coffee | 7 ++----- src/od_api.coffee | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) 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 -> -- 2.11.0