mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Remove launchDeleteForm JS function
- All should be consolidated upon launchModalForm - StockItem delete now uses this
This commit is contained in:
parent
e35a9284eb
commit
a78106526a
@ -345,68 +345,6 @@ function openModal(options) {
|
||||
}
|
||||
|
||||
|
||||
function launchDeleteForm(url, options = {}) {
|
||||
/* Launch a modal form to delete an object
|
||||
*/
|
||||
|
||||
var modal = options.modal || '#modal-delete';
|
||||
|
||||
$(modal).on('shown.bs.modal', function() {
|
||||
$(modal + ' .modal-form-content').scrollTop(0);
|
||||
});
|
||||
|
||||
// Un-bind any attached click listeners
|
||||
$(modal).off('click', '#modal-form-delete');
|
||||
|
||||
// Request delete form data
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
beforeSend: function() {
|
||||
openModal({modal: modal});
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.title) {
|
||||
modalSetTitle(modal, response.title);
|
||||
}
|
||||
if (response.html_data) {
|
||||
modalSetContent(modal, response.html_data);
|
||||
}
|
||||
else {
|
||||
|
||||
$(modal).modal('hide');
|
||||
showAlertDialog('Invalid form response', 'JSON response missing HTML data');
|
||||
}
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
$(modal).modal('hide');
|
||||
showAlertDialog('Error requesting form data', renderErrorMessage(xhr));
|
||||
}
|
||||
});
|
||||
|
||||
$(modal).on('click', '#modal-form-delete', function() {
|
||||
|
||||
var form = $(modal).find('#delete-form');
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: form.serialize(),
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
$(modal).modal('hide');
|
||||
afterForm(response, options);
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
$(modal).modal('hide');
|
||||
showAlertDialog('Error deleting item', renderErrorMessage(xhr));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function injectModalForm(modal, form_html) {
|
||||
/* Inject form content into the modal.
|
||||
* Updates the HTML of the form content, and then applies some other updates
|
||||
|
@ -194,7 +194,7 @@
|
||||
{% endif %}
|
||||
|
||||
$("#stock-delete").click(function () {
|
||||
launchDeleteForm(
|
||||
launchModalForm(
|
||||
"{% url 'stock-item-delete' item.id %}",
|
||||
{
|
||||
redirect: "{% url 'part-stock' item.part.id %}"
|
||||
|
@ -1,5 +1,11 @@
|
||||
{% extends "modal_delete_form.html" %}
|
||||
|
||||
{% block pre_form_content %}
|
||||
|
||||
<div class='alert alert-danger alert-block'>
|
||||
Are you sure you want to delete this stock item?
|
||||
|
||||
<br>
|
||||
|
||||
This will remove <b>{{ item.quantity }}</b> units of <b>{{ item.part.full_name }}</b> from stock.
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user