add rounding tip option
This commit is contained in:
parent
96046b8d0c
commit
9430aa28c7
2 changed files with 35 additions and 20 deletions
|
|
@ -139,8 +139,12 @@
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
new-value-mode="add-unique"
|
new-value-mode="add-unique"
|
||||||
label="Tip % Options (hit enter to add values)"
|
label="Tip % Options (hit enter to add values)"
|
||||||
><q-tooltip>Hit enter to add values</q-tooltip></q-select
|
><q-tooltip>Hit enter to add values</q-tooltip>
|
||||||
>
|
<template v-slot:hint>
|
||||||
|
You can leave this blank. A default rounding option is available
|
||||||
|
(round amount to a value)
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
<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>
|
||||||
|
|
@ -232,9 +231,9 @@
|
||||||
rounded
|
rounded
|
||||||
color="primary"
|
color="primary"
|
||||||
label="Round"
|
label="Round"
|
||||||
></q-btn
|
></q-btn>
|
||||||
>
|
|
||||||
<q-input
|
<q-input
|
||||||
|
class="q-my-lg"
|
||||||
ref="inputRounding"
|
ref="inputRounding"
|
||||||
v-if="rounding"
|
v-if="rounding"
|
||||||
filled
|
filled
|
||||||
|
|
@ -243,14 +242,14 @@
|
||||||
hint="Rounded amount"
|
hint="Rounded amount"
|
||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon name="send" @click="processTipSelection((1 - (amount/tipRounding))*100)" />
|
<q-icon name="send" @click="calculatePercent" />
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center q-mb-xl">
|
|
||||||
<p><a @click="processTipSelection(0)"> No, thanks</a></p>
|
|
||||||
</div>
|
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
|
<q-btn flat color="primary" @click="processTipSelection(0)"
|
||||||
|
>No, thanks</q-btn
|
||||||
|
>
|
||||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
@ -416,12 +415,12 @@
|
||||||
fsat: function () {
|
fsat: function () {
|
||||||
return LNbits.utils.formatSat(this.sat)
|
return LNbits.utils.formatSat(this.sat)
|
||||||
},
|
},
|
||||||
isRoundValid(){
|
isRoundValid() {
|
||||||
return this.tipRounding > this.amount
|
return this.tipRounding > this.amount
|
||||||
},
|
},
|
||||||
roundToSugestion(){
|
roundToSugestion() {
|
||||||
//let toNext = 1
|
//let toNext = 1
|
||||||
switch(true){
|
switch (true) {
|
||||||
case this.amount > 50:
|
case this.amount > 50:
|
||||||
toNext = 10
|
toNext = 10
|
||||||
break
|
break
|
||||||
|
|
@ -436,15 +435,27 @@
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.ceil(this.amount/toNext)*toNext
|
return Math.ceil(this.amount / toNext) * toNext
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setRounding(){
|
setRounding() {
|
||||||
this.rounding = true
|
this.rounding = true
|
||||||
this.tipRounding = this.roundToSugestion
|
this.tipRounding = this.roundToSugestion
|
||||||
this.$nextTick(() => this.$refs.inputRounding.focus())
|
this.$nextTick(() => this.$refs.inputRounding.focus())
|
||||||
},
|
},
|
||||||
|
calculatePercent() {
|
||||||
|
let change = ((this.tipRounding - this.amount) / this.amount) * 100
|
||||||
|
if (change < 0) {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Value must be greater than initial amount'
|
||||||
|
})
|
||||||
|
this.tipRounding = this.roundToSugestion
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.processTipSelection(change)
|
||||||
|
},
|
||||||
closeInvoiceDialog: function () {
|
closeInvoiceDialog: function () {
|
||||||
this.stack = []
|
this.stack = []
|
||||||
this.tipAmount = 0.0
|
this.tipAmount = 0.0
|
||||||
|
|
@ -643,8 +654,8 @@
|
||||||
? null
|
? null
|
||||||
: JSON.parse('{{ tpos.tip_options }}')
|
: JSON.parse('{{ tpos.tip_options }}')
|
||||||
|
|
||||||
if('{{ tpos.tip_wallet }}') {
|
if ('{{ tpos.tip_wallet }}') {
|
||||||
this.tip_options.push("Round")
|
this.tip_options.push('Round')
|
||||||
}
|
}
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
getRates()
|
getRates()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue