diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs index c9e6c4c65f..daf18914af 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs @@ -50,7 +50,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared "/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js", "/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js", "/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/modal-manager.js", - "/libs/abp/aspnetcore.mvc.ui.theme.shared/datatables/datatables-extensions.js" + "/libs/abp/aspnetcore.mvc.ui.theme.shared/datatables/datatables-extensions.js", + "/libs/abp/aspnetcore.mvc.ui.theme.shared/sweetalert/abp-sweetalert.js" }); }); diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj index 27faf4e7cf..e846856456 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj @@ -22,4 +22,8 @@ + + + + \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js index efcc636b44..fb1036a588 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js @@ -9,9 +9,14 @@ var options = $.extend({}, $.fn.abpAjaxForm.defaults, userOptions); options.beforeSubmit = function (arr, $form) { - userOptions.beforeSubmit && userOptions.beforeSubmit.apply(this, arguments); - $form.find("button[type='submit']").buttonBusy(true); - //TODO: Disable other buttons..? + var retVal = userOptions.beforeSubmit && userOptions.beforeSubmit.apply(this, arguments); + + if (retVal !== false) { + $form.find("button[type='submit']").buttonBusy(true); + //TODO: Disable other buttons..? + } + + return retVal; }; options.error = function (jqXhr) { diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/sweetalert/abp-sweetalert.js b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/sweetalert/abp-sweetalert.js new file mode 100644 index 0000000000..c96f836f0d --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/sweetalert/abp-sweetalert.js @@ -0,0 +1,109 @@ +var abp = abp || {}; +(function ($) { + if (!sweetAlert || !$) { + return; + } + + /* DEFAULTS *************************************************/ + + abp.libs = abp.libs || {}; + abp.libs.sweetAlert = { + config: { + 'default': { + + }, + info: { + icon: 'info' + }, + success: { + icon: 'success' + }, + warn: { + icon: 'warning' + }, + error: { + icon: 'error' + }, + confirm: { + icon: 'warning', + title: 'Are you sure?', + buttons: ['Cancel', 'Yes'] + } + } + }; + + /* MESSAGE **************************************************/ + + var showMessage = function (type, message, title) { + if (!title) { + title = message; + message = undefined; + } + + var opts = $.extend( + {}, + abp.libs.sweetAlert.config['default'], + abp.libs.sweetAlert.config[type], + { + title: title, + text: message + } + ); + + return $.Deferred(function ($dfd) { + sweetAlert(opts).then(function () { + $dfd.resolve(); + }); + }); + }; + + abp.message.info = function (message, title) { + return showMessage('info', message, title); + }; + + abp.message.success = function (message, title) { + return showMessage('success', message, title); + }; + + abp.message.warn = function (message, title) { + return showMessage('warn', message, title); + }; + + abp.message.error = function (message, title) { + return showMessage('error', message, title); + }; + + abp.message.confirm = function (message, titleOrCallback, callback) { + var userOpts = { + text: message + }; + + if ($.isFunction(titleOrCallback)) { + callback = titleOrCallback; + } else if (titleOrCallback) { + userOpts.title = titleOrCallback; + }; + + var opts = $.extend( + {}, + abp.libs.sweetAlert.config['default'], + abp.libs.sweetAlert.config.confirm, + userOpts + ); + + return $.Deferred(function ($dfd) { + sweetAlert(opts).then(function (isConfirmed) { + callback && callback(isConfirmed); + $dfd.resolve(isConfirmed); + }); + }); + }; + + abp.event.on('abp.configurationInitialized', function () { + var l = abp.localization.getResource('AbpUi'); + + abp.libs.sweetAlert.config.confirm.title = l('AreYouSure'); + abp.libs.sweetAlert.config.confirm.buttons = [l('Cancel'), l('Yes')]; + }); + +})(jQuery); \ No newline at end of file