diff --git a/Site/Controls/v5/Base/FileUpload.ascx b/Site/Controls/v5/Base/FileUpload.ascx index 1e1b630f..1c1ccc7c 100644 --- a/Site/Controls/v5/Base/FileUpload.ascx +++ b/Site/Controls/v5/Base/FileUpload.ascx @@ -75,8 +75,22 @@ <%= this.ClientUploadStartedCallback %>("<%= GuidString%>", "<%= Cookie%>"); + <% } %> + }, + send: function(e, data) { + // call when upload actually begins -- for notify + }, + fail: function(e, data) { + // called on upload fail or upload abort -- for notify + + <% if (!String.IsNullOrEmpty(this.ClientUploadFailedCallback)) + { %> + + <%= this.ClientUploadFailedCallback %>("<%= GuidString%>", "<%= Cookie%>"); + <% } %> } + }); diff --git a/Site/Controls/v5/Base/FileUpload.ascx.cs b/Site/Controls/v5/Base/FileUpload.ascx.cs index 4d1db30a..9506b1d1 100644 --- a/Site/Controls/v5/Base/FileUpload.ascx.cs +++ b/Site/Controls/v5/Base/FileUpload.ascx.cs @@ -36,6 +36,7 @@ namespace Swarmops.Controls.Base public bool HideTrigger { get; set; } public string ClientUploadCompleteCallback { get; set; } public string ClientUploadStartedCallback { get; set; } + public string ClientUploadFailedCallback { get; set; } public string Cookie { get; set; } public string GuidToken diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 2f635191..f7e9f9a8 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -131,17 +131,27 @@ var itemId = $(this).attr('data-item'); var callbackFunction = $(this).attr('data-callback'); - $('img.action-icon[data-item="' + itemId + '"]').hide(); - $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); - if ($(this).hasClass('is-upload')) { + // Trigger upload, then trigger ajax call on complete + if (triggeredUpload != null) { + // upload is already in progress; don't allow two concurrent uploads since we're using one control + // todo: error message or some UX to explain this? + + return; + } + + triggeredUpload = this; <%=this.UploadControl.ClientID%>_triggerUpload(); } else { + // Ajax call right away + $('img.action-icon[data-item="' + itemId + '"]').hide(); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); + SwarmopsJS.ajaxCall( "/Pages/v5/Ledgers/EndOfMonth.aspx/" + callbackFunction, {}, @@ -179,12 +189,44 @@ }); - function clientPostUpload(callbackFunction, cookie) { - + function clientStartUpload() { + if (triggeredUpload == null) { + // invalid state + return; + } + + var itemId = $(triggeredUpload).attr('data-item'); + $('img.action-icon[data-item="' + itemId + '"]').hide(); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); + } + + function clientFailUpload() { + if (triggeredUpload == null) { + // invalid state + return; + } + + var itemId = $(triggeredUpload).attr('data-item'); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); + $('img.action-icon[data-item="' + itemId + '"]').show(); + + triggeredUpload = null; + } + + function clientFinishUpload() { + if (triggeredUpload == null) { + // invalid state + return; + } + + triggeredUpload = null; } var uploadGuid = '<%=this.UploadControl.GuidString%>'; + var triggeredUpload = null; + + // Function: Match all mismatched transactions // Function: Upload bank statement PDF for accountId x