mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-26 16:51:42 +02:00
add default tip by rounding to value
This commit is contained in:
parent
0ab869e304
commit
96046b8d0c
@ -17,6 +17,7 @@
|
|||||||
<h5 class="q-mt-none q-mb-sm">
|
<h5 class="q-mt-none q-mb-sm">
|
||||||
{% raw %}{{ fsat }}{% endraw %} <small>sat</small>
|
{% raw %}{{ fsat }}{% endraw %} <small>sat</small>
|
||||||
</h5>
|
</h5>
|
||||||
|
<p>{% raw %}{{ parseFloat(roundToSugestion) }}{% endraw %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-page-sticky>
|
</q-page-sticky>
|
||||||
@ -214,14 +215,37 @@
|
|||||||
style="padding: 10px; margin: 3px"
|
style="padding: 10px; margin: 3px"
|
||||||
unelevated
|
unelevated
|
||||||
@click="processTipSelection(tip)"
|
@click="processTipSelection(tip)"
|
||||||
size="xl"
|
size="lg"
|
||||||
:outline="!($q.dark.isActive)"
|
:outline="!($q.dark.isActive)"
|
||||||
rounded
|
rounded
|
||||||
color="primary"
|
color="primary"
|
||||||
v-for="tip in this.tip_options"
|
v-for="tip in tip_options.filter(f => f != 'Round')"
|
||||||
:key="tip"
|
:key="tip"
|
||||||
>{% raw %}{{ tip }}{% endraw %}%</q-btn
|
>{% raw %}{{ tip }}{% endraw %}%</q-btn
|
||||||
>
|
>
|
||||||
|
<q-btn
|
||||||
|
style="padding: 10px; margin: 3px"
|
||||||
|
unelevated
|
||||||
|
@click="setRounding"
|
||||||
|
size="lg"
|
||||||
|
:outline="!($q.dark.isActive)"
|
||||||
|
rounded
|
||||||
|
color="primary"
|
||||||
|
label="Round"
|
||||||
|
></q-btn
|
||||||
|
>
|
||||||
|
<q-input
|
||||||
|
ref="inputRounding"
|
||||||
|
v-if="rounding"
|
||||||
|
filled
|
||||||
|
v-model.number="tipRounding"
|
||||||
|
:placeholder="roundToSugestion"
|
||||||
|
hint="Rounded amount"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon name="send" @click="processTipSelection((1 - (amount/tipRounding))*100)" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center q-mb-xl">
|
<div class="text-center q-mb-xl">
|
||||||
<p><a @click="processTipSelection(0)"> No, thanks</a></p>
|
<p><a @click="processTipSelection(0)"> No, thanks</a></p>
|
||||||
@ -336,6 +360,7 @@
|
|||||||
exchangeRate: null,
|
exchangeRate: null,
|
||||||
stack: [],
|
stack: [],
|
||||||
tipAmount: 0.0,
|
tipAmount: 0.0,
|
||||||
|
tipRounding: null,
|
||||||
hasNFC: false,
|
hasNFC: false,
|
||||||
nfcTagReading: false,
|
nfcTagReading: false,
|
||||||
lastPaymentsDialog: {
|
lastPaymentsDialog: {
|
||||||
@ -356,7 +381,8 @@
|
|||||||
},
|
},
|
||||||
complete: {
|
complete: {
|
||||||
show: false
|
show: false
|
||||||
}
|
},
|
||||||
|
rounding: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -389,9 +415,36 @@
|
|||||||
},
|
},
|
||||||
fsat: function () {
|
fsat: function () {
|
||||||
return LNbits.utils.formatSat(this.sat)
|
return LNbits.utils.formatSat(this.sat)
|
||||||
|
},
|
||||||
|
isRoundValid(){
|
||||||
|
return this.tipRounding > this.amount
|
||||||
|
},
|
||||||
|
roundToSugestion(){
|
||||||
|
//let toNext = 1
|
||||||
|
switch(true){
|
||||||
|
case this.amount > 50:
|
||||||
|
toNext = 10
|
||||||
|
break
|
||||||
|
case this.amount > 6:
|
||||||
|
toNext = 5
|
||||||
|
break
|
||||||
|
case this.amount > 2.5:
|
||||||
|
toNext = 1
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
toNext = 0.5
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.ceil(this.amount/toNext)*toNext
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setRounding(){
|
||||||
|
this.rounding = true
|
||||||
|
this.tipRounding = this.roundToSugestion
|
||||||
|
this.$nextTick(() => this.$refs.inputRounding.focus())
|
||||||
|
},
|
||||||
closeInvoiceDialog: function () {
|
closeInvoiceDialog: function () {
|
||||||
this.stack = []
|
this.stack = []
|
||||||
this.tipAmount = 0.0
|
this.tipAmount = 0.0
|
||||||
@ -589,6 +642,10 @@
|
|||||||
'{{ tpos.tip_options | tojson }}' == 'null'
|
'{{ tpos.tip_options | tojson }}' == 'null'
|
||||||
? null
|
? null
|
||||||
: JSON.parse('{{ tpos.tip_options }}')
|
: JSON.parse('{{ tpos.tip_options }}')
|
||||||
|
|
||||||
|
if('{{ tpos.tip_wallet }}') {
|
||||||
|
this.tip_options.push("Round")
|
||||||
|
}
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
getRates()
|
getRates()
|
||||||
}, 120000)
|
}, 120000)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user