mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add a callback to remove individual rows
This commit is contained in:
parent
8b41e68e6b
commit
0e1e8226b1
@ -162,7 +162,7 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) {
|
|||||||
|
|
||||||
// Render a single row
|
// Render a single row
|
||||||
var html = `
|
var html = `
|
||||||
<tr id='substitute-${pk}' class='substitute-row'>
|
<tr id='substitute-row-${pk}' class='substitute-row'>
|
||||||
<td id='part-${pk}'>${thumb} ${substitute.part_detail.full_name}</td>
|
<td id='part-${pk}'>${thumb} ${substitute.part_detail.full_name}</td>
|
||||||
<td id='description-${pk}'><em>${substitute.part_detail.description}</em></td>
|
<td id='description-${pk}'><em>${substitute.part_detail.description}</em></td>
|
||||||
<td>${buttons}</td>
|
<td>${buttons}</td>
|
||||||
@ -218,9 +218,30 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
preFormContent: html,
|
preFormContent: html,
|
||||||
|
submitText: '{% trans "Add Substitute" %}',
|
||||||
title: '{% trans "Edit BOM Item Substitutes" %}',
|
title: '{% trans "Edit BOM Item Substitutes" %}',
|
||||||
afterRender: function(fields, opts) {
|
afterRender: function(fields, opts) {
|
||||||
// TODO
|
|
||||||
|
// Add a callback to remove individual rows
|
||||||
|
$(opts.modal).find('.button-row-remove').click(function() {
|
||||||
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
|
var pre = `
|
||||||
|
<div class='alert alert-block alert-warning'>
|
||||||
|
{% trans "Are you sure you wish to remove this substitute part link?" %}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
constructForm(`/api/bom/substitute/${pk}/`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
title: '{% trans "Remove Substitute Part" %}',
|
||||||
|
preFormContent: pre,
|
||||||
|
confirm: true,
|
||||||
|
onSuccess: function() {
|
||||||
|
$(opts.modal).find(`#substitute-row-${pk}`).remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onSubmit: function(fields, opts) {
|
onSubmit: function(fields, opts) {
|
||||||
// TODO
|
// TODO
|
||||||
|
Loading…
Reference in New Issue
Block a user