Browse Source

Add prompt dialog support to abp.message

Introduces a new abp.message.prompt function using SweetAlert2 to display input dialogs. This allows developers to easily prompt users for text input with customizable options.
pull/23915/head
enisn 4 months ago
parent
commit
1a90ad4c8b
No known key found for this signature in database GPG Key ID: A052619F04155D1C
  1. 36
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/sweetalert2/abp-sweetalert2.js

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

@ -29,6 +29,12 @@ var abp = abp || {};
title: 'Are you sure?',
showCancelButton: true,
reverseButtons: true
},
prompt: {
icon: 'question',
input: 'text',
showCancelButton: true,
reverseButtons: true
}
}
};
@ -99,6 +105,36 @@ var abp = abp || {};
});
};
abp.message.prompt = function (message, titleOrOptionsOrCallback, callback) {
var userOpts = {
html: abp.utils.htmlEscape(message).replace(/\n/g, '<br>')
};
if ($.isFunction(titleOrOptionsOrCallback)) {
callback = titleOrOptionsOrCallback;
} else if (typeof titleOrOptionsOrCallback === 'string') {
userOpts.title = titleOrOptionsOrCallback;
} else if ($.isPlainObject(titleOrOptionsOrCallback)) {
userOpts = $.extend(userOpts, titleOrOptionsOrCallback);
}
var opts = $.extend(
{},
abp.libs.sweetAlert.config['default'],
abp.libs.sweetAlert.config.prompt,
userOpts
);
return $.Deferred(function ($dfd) {
Swal.fire(opts).then(function (result) {
var value = result && result.isConfirmed ? result.value : null;
callback && callback(value);
$dfd.resolve(value);
});
});
};
abp.event.on('abp.configurationInitialized', function () {
var l = abp.localization.getResource('AbpUi');

Loading…
Cancel
Save