2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 12:10:59 +00:00

Refactor "showQuestionDialog" function

This commit is contained in:
Oliver
2021-07-12 21:03:01 +10:00
parent a1579eecfd
commit edf4aab063
2 changed files with 5 additions and 42 deletions

View File

@ -12,7 +12,6 @@
*/
function createNewModal(options={}) {
var id = 1;
// Check out what modal forms are already being displayed
@ -588,22 +587,15 @@ function showQuestionDialog(title, content, options={}) {
* cancel - Functino to run if the user presses 'Cancel'
*/
var modal = options.modal || '#modal-question-dialog';
$(modal).on('shown.bs.modal', function() {
$(modal + ' .modal-form-content').scrollTop(0);
var modal = createNewModal({
title: title,
submitText: options.accept_text || '{% trans "Accept" %}',
cancelText: options.cancel_text || '{% trans "Cancel" %}',
});
modalSetTitle(modal, title);
modalSetContent(modal, content);
var accept_text = options.accept_text || '{% trans "Accept" %}';
var cancel_text = options.cancel_text || '{% trans "Cancel" %}';
$(modal).find('#modal-form-cancel').html(cancel_text);
$(modal).find('#modal-form-accept').html(accept_text);
$(modal).on('click', '#modal-form-accept', function() {
$(modal).on('click', "#modal-form-submit", function() {
$(modal).modal('hide');
if (options.accept) {
@ -611,14 +603,6 @@ function showQuestionDialog(title, content, options={}) {
}
});
$(modal).on('click', 'modal-form-cancel', function() {
$(modal).modal('hide');
if (options.cancel) {
options.cancel();
}
});
$(modal).modal('show');
}