From ca639d5c68097461acd3a85c151f434dd72c2bf6 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 10 Oct 2023 14:00:01 +0100 Subject: [PATCH] fixup! [SLWP] Add js to add message dependent on item count --- templates/web/base/waste/bulky/items.html | 11 +---- web/js/waste.js | 57 ++++++++++++----------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/templates/web/base/waste/bulky/items.html b/templates/web/base/waste/bulky/items.html index e92393a37fb..b840a73be42 100644 --- a/templates/web/base/waste/bulky/items.html +++ b/templates/web/base/waste/bulky/items.html @@ -9,16 +9,7 @@ [% IF property %] [% INCLUDE 'waste/_address_display.html' %] [% END %] -[% IF cobrand.moniker == 'sutton' || cobrand.moniker == 'kingston' %] -[% SET cfg = c.cobrand.wasteworks_config %] -
-
-[% END %] +
diff --git a/web/js/waste.js b/web/js/waste.js index 872e1a49bbd..4e6f03d7caf 100644 --- a/web/js/waste.js +++ b/web/js/waste.js @@ -82,6 +82,16 @@ $(function() { } } + function numberOfItems() { + var count = 0; + $('.govuk-select[name^="item_"] option:selected').each(function(i, e) { + if ($(this).val()) { + count++; + } + }); + return count; + } + function updateTotal() { var totalId = $('#js-bulky-total'); var pricing = totalId.data('pricing'); @@ -97,12 +107,7 @@ $(function() { }); totalId.text((total / 100).toFixed(2)); } else if (pricing.strategy === 'banded') { - var count = 0; - $('.govuk-select[name^="item_"] option:selected').each(function(i, e) { - if ($(this).val()) { - count++; - } - }); + var count = numberOfItems(); for (var i=0; i band1_max && current_selection <= base_max)) { - message = current_selection + ' items selected - you can add up to ' + - (base_max - current_selection) + ' more items.'; - } - else { - message = ''; - } - $('#band-pricing-info').text(message); + message = ''; } + $('#band-pricing-info').text(message); } $(function() {