From c890a4a6d00ec5a909bd267e713744533aeb8674 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 13 Sep 2021 23:18:44 +0200 Subject: [PATCH 1/2] only add button per name once --- InvenTree/templates/js/translated/modals.js | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/InvenTree/templates/js/translated/modals.js b/InvenTree/templates/js/translated/modals.js index 5195c67b46..2a90a54324 100644 --- a/InvenTree/templates/js/translated/modals.js +++ b/InvenTree/templates/js/translated/modals.js @@ -793,14 +793,25 @@ function attachSecondaries(modal, secondaries) { function insertActionButton(modal, options) { /* Insert a custom submission button */ - var html = ` - - - `; + var element = $(modal).find('#modal-footer-buttons'); - $(modal).find('#modal-footer-buttons').append(html); + // check if button already present + var already_present = false; + for(var child=element[0].firstElementChild; child; child=child.nextElementSibling){ + if (item.firstElementChild.name == options.name) { + already_present = true; + } + } + + if (already_present == false) { + var html = ` + + + `; + element.append(html); + } } function attachButtons(modal, buttons) { From 847fb62ab55ee0c7b95b52d2f37545930c5df546 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 13 Sep 2021 23:25:13 +0200 Subject: [PATCH 2/2] js style --- InvenTree/templates/js/translated/modals.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/templates/js/translated/modals.js b/InvenTree/templates/js/translated/modals.js index 2a90a54324..96e41fd6ec 100644 --- a/InvenTree/templates/js/translated/modals.js +++ b/InvenTree/templates/js/translated/modals.js @@ -797,7 +797,7 @@ function insertActionButton(modal, options) { // check if button already present var already_present = false; - for(var child=element[0].firstElementChild; child; child=child.nextElementSibling){ + for (var child=element[0].firstElementChild; child; child=child.nextElementSibling) { if (item.firstElementChild.name == options.name) { already_present = true; }