Browse Source

Switch to SweetAlert2

pull/9607/head
liangshiwei 5 years ago
parent
commit
3b72a6a142
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/SweetAlert/SweetalertScriptContributor.cs
  2. 24
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/sweetalert/abp-sweetalert.js
  3. 2
      npm/packs/sweetalert/abp.resourcemapping.js
  4. 2
      npm/packs/sweetalert/package.json

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/SweetAlert/SweetalertScriptContributor.cs

@ -10,7 +10,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.SweetAlert
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/libs/sweetalert/sweetalert.min.js");
context.Files.AddIfNotContains("/libs/sweetalert2/sweetalert2.all.min.js");
}
}
}

24
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/sweetalert/abp-sweetalert.js

@ -1,6 +1,6 @@
var abp = abp || {};
(function ($) {
if (!sweetAlert || !$) {
if (!Swal || !$) {
return;
}
@ -27,7 +27,8 @@
confirm: {
icon: 'warning',
title: 'Are you sure?',
buttons: ['Cancel', 'Yes']
showCancelButton: true,
reverseButtons: true
}
}
};
@ -51,7 +52,7 @@
);
return $.Deferred(function ($dfd) {
sweetAlert(opts).then(function () {
Swal.fire(opts).then(function () {
$dfd.resolve();
});
});
@ -73,7 +74,7 @@
return showMessage('error', message, title);
};
abp.message.confirm = function (message, titleOrCallback, callback, closeOnEsc) {
abp.message.confirm = function (message, titleOrCallback, callback) {
var userOpts = {
text: message
@ -86,8 +87,6 @@
userOpts.title = titleOrCallback;
};
userOpts.closeOnEsc = closeOnEsc;
var opts = $.extend(
{},
abp.libs.sweetAlert.config['default'],
@ -96,10 +95,10 @@
);
return $.Deferred(function ($dfd) {
sweetAlert(opts).then(function (isConfirmed) {
callback && callback(isConfirmed);
$dfd.resolve(isConfirmed);
});
Swal.fire(opts).then(result => {
callback && callback(result.value);
$dfd.resolve(result.value);
})
});
};
@ -107,7 +106,8 @@
var l = abp.localization.getResource('AbpUi');
abp.libs.sweetAlert.config.confirm.title = l('AreYouSure');
abp.libs.sweetAlert.config.confirm.buttons = [l('Cancel'), l('Yes')];
abp.libs.sweetAlert.config.confirm.showCancelButton = true;
abp.libs.sweetAlert.config.confirm.reverseButtons = true;
});
})(jQuery);
})(jQuery);

2
npm/packs/sweetalert/abp.resourcemapping.js

@ -1,5 +1,5 @@
module.exports = {
mappings: {
"@node_modules/sweetalert/dist/*.*": "@libs/sweetalert/"
"@node_modules/sweetalert2/dist/*.*": "@libs/sweetalert2/"
}
}

2
npm/packs/sweetalert/package.json

@ -6,7 +6,7 @@
},
"dependencies": {
"@abp/core": "~4.4.0-rc.2",
"sweetalert": "^2.1.2"
"sweetalert2": "^11.0.18"
},
"gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431"
}

Loading…
Cancel
Save