Skip to content

Commit

Permalink
Merge pull request #2248 from bolatovumar/fix-2247
Browse files Browse the repository at this point in the history
Ensure "No" selection is maintained for custom price in POS app
  • Loading branch information
NicolasDorier committed Feb 10, 2021
2 parents 9c5f826 + 42de080 commit 5cb647e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions BTCPayServer/Views/Apps/TemplateEditor.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@
<div class="col-sm-3">
<label>Custom price</label>
<select class="form-control" v-model="editingItem.custom">
<option v-bind:value="false">No</option>
<option v-bind:value="true">Yes</option>
<option v-for="option in customPriceOptions" :value="option.value">{{option.text}}</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -134,6 +133,10 @@ $(function() {
errors: [],
items: [],
editingItem: null,
customPriceOptions: [
{ text: 'No', value: false },
{ text: 'Yes', value: true },
],
elementId: "@Model.templateId"
},
computed: {
Expand Down Expand Up @@ -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);
Expand All @@ -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
});
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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 $('<div/>').html(k).text();
}
}
Expand Down

0 comments on commit 5cb647e

Please sign in to comment.