From 42de0803c94b7731ccba871261f4222d8a8e30fe Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Tue, 2 Feb 2021 20:13:39 -0800 Subject: [PATCH] Ensure "No" selection is maintained for custom price in POS app --- BTCPayServer/Views/Apps/TemplateEditor.cshtml | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/BTCPayServer/Views/Apps/TemplateEditor.cshtml b/BTCPayServer/Views/Apps/TemplateEditor.cshtml index eecb5ff44..a7af71102 100644 --- a/BTCPayServer/Views/Apps/TemplateEditor.cshtml +++ b/BTCPayServer/Views/Apps/TemplateEditor.cshtml @@ -84,8 +84,7 @@
@@ -134,6 +133,10 @@ $(function() { errors: [], items: [], editingItem: null, + customPriceOptions: [ + { text: 'No', value: false }, + { text: 'Yes', value: true }, + ], elementId: "@Model.templateId" }, computed: { @@ -210,7 +213,7 @@ $(function() { image = productProperty.replace('image:', '').trim(); } if (productProperty.indexOf('custom:') !== -1) { - custom =productProperty.replace('custom:', '').trim(); + custom = productProperty.replace('custom:', '').trim(); } if (productProperty.indexOf('inventory:') !== -1) { inventory = parseInt(productProperty.replace('inventory:', '').trim(),10); @@ -228,7 +231,7 @@ $(function() { price: price, image: image || null, description: description || '', - custom: Boolean(custom), + custom: custom === "true", inventory: isNaN(inventory)? null: inventory, paymentMethods: paymentMethods }); @@ -263,8 +266,8 @@ $(function() { if (inventory) { template += ' inventory: ' + inventory + '\n'; } - if (custom) { - template += ' custom: true\n'; + if (custom != null) { + template += ' custom: ' + custom + '\n'; } if(paymentMethods != null && paymentMethods.length > 0){ template+= ' payment_methods:\n'; @@ -376,6 +379,11 @@ $(function() { return item; }, unEscapeKey : function(k){ + // Without this check a `false` boolean value will always be returned as an empty string + if (k === false) { + return "false"; + } + return $('
').html(k).text(); } }