Fix crowdfund perk support fixes #5013

This commit is contained in:
Kukks 2023-05-30 10:34:48 +02:00
parent 35dd580e74
commit 4a6d52f78e
No known key found for this signature in database
GPG Key ID: 8E5530D9D1C93097
4 changed files with 31 additions and 23 deletions

View File

@ -38,7 +38,7 @@
@Safe.Raw("or more")
}
}
else if (item.PriceType != ViewPointOfSaleViewModel.ItemPriceType.Fixed )
else if (item.PriceType == ViewPointOfSaleViewModel.ItemPriceType.Topup )
{
@Safe.Raw("Any amount")
}else if (item.PriceType == ViewPointOfSaleViewModel.ItemPriceType.Fixed)

View File

@ -318,15 +318,17 @@
<div class="card-title d-flex justify-content-between" :class="{ 'mb-0': !perk.description }">
<span class="h5" :class="{ 'mb-0': !perk.description }">{{perk.title ? perk.title : perk.id}}</span>
<span class="text-muted">
<template v-if="perk.price && perk.price.value">
{{formatAmount(perk.price.value.noExponents(), srvModel.currencyData.divisibility)}}
{{targetCurrency}}
<template v-if="perk.price.type == 1">or more</template>
</template>
<template v-else-if="perk.price.type === 2 && !perk.price.value">
<template v-if="perk.priceType === 'Fixed' && amount ==0">
Free
</template>
<template v-else-if="perk.price.type === 0 || (!perk.price.value && perk.price.type === 1)">
<template v-else-if="amount">
{{formatAmount(perk.price.noExponents(), srvModel.currencyData.divisibility)}}
{{targetCurrency}}
<template v-if="perk.price.type === 'Minimum'">or more</template>
</template>
<template v-else-if="perk.priceType === 'Topup' || (!amount && perk.priceType === 'Minimum')">
Any amount
</template>
</span>
@ -334,19 +336,18 @@
<p class="card-text overflow-hidden" v-if="perk.description" v-html="perk.description"></p>
<div class="input-group" style="max-width:500px;" v-if="expanded" :id="'perk-form'+ perk.id">
<template v-if="perk.price.type !== 0 && !(perk.price.type === 2 && !perk.price.value)">
<template v-if="perk.priceType !== 'Topup' && !(perk.priceType === 'Fixed' && amount == 0)">
<input
:disabled="!active"
:readonly="perk.price.type !== 1"
:readonly="perk.priceType === 'Fixed'"
class="form-control hide-number-spin"
type="number"
v-model="amount"
:min="perk.price.value"
:min="perk.price"
step="any"
placeholder="Contribution Amount"
required>
<span class="input-group-text" >{{targetCurrency}}</span>
<span class="input-group-text">{{targetCurrency}}</span>
</template>
<button
class="btn btn-primary d-flex align-items-center "

View File

@ -50,19 +50,22 @@ document.addEventListener("DOMContentLoaded",function (ev) {
}
},
setAmount: function (amount) {
this.amount = this.perk.price.type === 0? null : (amount || 0).noExponents();
if(typeof amount === "string"){
amount = parseFloat(amount);
}
this.amount = this.perk.priceType === "Topup"? null : (amount || 0).noExponents();
this.expanded = false;
}
},
mounted: function () {
this.setAmount(this.perk.price.value);
this.setAmount(this.perk.price);
},
watch: {
perk: function (newValue, oldValue) {
if(newValue.price.type ===0){
if(newValue.price.type === "Topup"){
this.setAmount();
}else if (newValue.price.value != oldValue.price.value) {
this.setAmount(newValue.price.value);
}else if (newValue.price != oldValue.price) {
this.setAmount(newValue.price);
}
}
}
@ -147,9 +150,9 @@ document.addEventListener("DOMContentLoaded",function (ev) {
return result;
},
perks: function(){
var result = [];
for (var i = 0; i < this.srvModel.perks.length; i++) {
var currentPerk = this.srvModel.perks[i];
const result = [];
for (let i = 0; i < this.srvModel.perks.length; i++) {
const currentPerk = this.srvModel.perks[i];
if(this.srvModel.perkCount.hasOwnProperty(currentPerk.id)){
currentPerk.sold = this.srvModel.perkCount[currentPerk.id];
}

View File

@ -1,5 +1,5 @@
Number.prototype.noExponents= function(){
var data= String(this).split(/[eE]/);
String.prototype.noExponents= function(){
const data = String(this).split(/[eE]/);
if(data.length== 1) return data[0];
var z= '', sign= this<0? '-':'',
@ -14,4 +14,8 @@ Number.prototype.noExponents= function(){
mag -= str.length;
while(mag--) z += '0';
return str + z;
}
Number.prototype.noExponents= function(){
return String(this).noExponents();
};