2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

More refactoring

This commit is contained in:
Oliver Walters 2022-05-03 17:27:21 +10:00
parent f3e8edaf1f
commit f0e8e32c8a
3 changed files with 25 additions and 18 deletions

View File

@ -754,12 +754,18 @@
$("#part-order2").click(function() { $("#part-order2").click(function() {
launchModalForm("{% url 'order-parts' %}", { inventreeGet(
data: { '{% url "api-part-detail" part.pk %}',
part: {{ part.id }}, {},
}, {
reload: true, success: function(part) {
}); orderParts(
[part],
{}
);
}
}
);
}); });
onPanelLoad("test-templates", function() { onPanelLoad("test-templates", function() {

View File

@ -549,15 +549,6 @@
} }
} }
); );
return;
launchModalForm("{% url 'order-parts' %}", {
data: {
part: {{ part.id }},
},
reload: true,
});
}); });
{% if roles.part.add %} {% if roles.part.add %}

View File

@ -603,6 +603,17 @@ function orderParts(parts_list, options={}) {
return html; return html;
} }
// Remove a single row form this dialog
function removeRow(pk, opts) {
// Remove the row
$(opts.modal).find(`#order_row_${pk}`).remove();
// If the modal is now "empty", dismiss it
if (!($(opts.modal).find('.part-order-row').exists())) {
closeModal(opts.modal);
}
}
var table_entries = ''; var table_entries = '';
parts.forEach(function(part) { parts.forEach(function(part) {
@ -727,8 +738,7 @@ function orderParts(parts_list, options={}) {
{ {
method: 'POST', method: 'POST',
success: function(response) { success: function(response) {
// Remove the row removeRow(pk, opts);
$(opts.modal).find(`#order_row_${pk}`).remove();
}, },
error: function(xhr) { error: function(xhr) {
switch (xhr.status) { switch (xhr.status) {
@ -749,7 +759,7 @@ function orderParts(parts_list, options={}) {
$(opts.modal).find('.button-row-remove').click(function() { $(opts.modal).find('.button-row-remove').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
$(opts.modal).find(`#order_row_${pk}`).remove(); removeRow(pk, opts);
}); });
// Add callback for "new supplier part" button // Add callback for "new supplier part" button