From 0e1e8226b16fe14f09d32d82973ce1cbba4898a5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 13 Oct 2021 21:42:50 +1100 Subject: [PATCH] Add a callback to remove individual rows --- InvenTree/templates/js/translated/bom.js | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index 4f3ae912d5..a5e1153bad 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -162,7 +162,7 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) { // Render a single row var html = ` - + ${thumb} ${substitute.part_detail.full_name} ${substitute.part_detail.description} ${buttons} @@ -218,9 +218,30 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) { }, }, preFormContent: html, + submitText: '{% trans "Add Substitute" %}', title: '{% trans "Edit BOM Item Substitutes" %}', 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 = ` +
+ {% trans "Are you sure you wish to remove this substitute part link?" %} +
+ `; + + 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) { // TODO