From 96046b8d0cd459ca7bf54cd13b3b74398c737f94 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Fri, 14 Oct 2022 21:59:28 +0100 Subject: [PATCH 1/7] add default tip by rounding to value --- .../extensions/tpos/templates/tpos/tpos.html | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index 0f9620a96..4b1b0ad3c 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -17,6 +17,7 @@
{% raw %}{{ fsat }}{% endraw %} sat
+

{% raw %}{{ parseFloat(roundToSugestion) }}{% endraw %}

@@ -214,14 +215,37 @@ style="padding: 10px; margin: 3px" unelevated @click="processTipSelection(tip)" - size="xl" + size="lg" :outline="!($q.dark.isActive)" rounded color="primary" - v-for="tip in this.tip_options" + v-for="tip in tip_options.filter(f => f != 'Round')" :key="tip" >{% raw %}{{ tip }}{% endraw %}% + + + +

No, thanks

@@ -336,6 +360,7 @@ exchangeRate: null, stack: [], tipAmount: 0.0, + tipRounding: null, hasNFC: false, nfcTagReading: false, lastPaymentsDialog: { @@ -356,7 +381,8 @@ }, complete: { show: false - } + }, + rounding: false } }, computed: { @@ -389,9 +415,36 @@ }, fsat: function () { 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: { + setRounding(){ + this.rounding = true + this.tipRounding = this.roundToSugestion + this.$nextTick(() => this.$refs.inputRounding.focus()) + }, closeInvoiceDialog: function () { this.stack = [] this.tipAmount = 0.0 @@ -589,6 +642,10 @@ '{{ tpos.tip_options | tojson }}' == 'null' ? null : JSON.parse('{{ tpos.tip_options }}') + + if('{{ tpos.tip_wallet }}') { + this.tip_options.push("Round") + } setInterval(function () { getRates() }, 120000) From 9430aa28c7cb68c014076aaace4cf30827e08a4c Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Mon, 17 Oct 2022 11:40:30 +0100 Subject: [PATCH 2/7] add rounding tip option --- .../extensions/tpos/templates/tpos/index.html | 8 +++- .../extensions/tpos/templates/tpos/tpos.html | 47 ++++++++++++------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/index.html b/lnbits/extensions/tpos/templates/tpos/index.html index 3c4fa24f8..1aa75fcf1 100644 --- a/lnbits/extensions/tpos/templates/tpos/index.html +++ b/lnbits/extensions/tpos/templates/tpos/index.html @@ -139,8 +139,12 @@ input-debounce="0" new-value-mode="add-unique" label="Tip % Options (hit enter to add values)" - >Hit enter to add values + >Hit enter to add values + +
{% raw %}{{ fsat }}{% endraw %} sat -

{% raw %}{{ parseFloat(roundToSugestion) }}{% endraw %}

@@ -232,9 +231,9 @@ rounded color="primary" label="Round" - > + > - - - -
-

No, thanks

+ +
+ No, thanks Close
@@ -416,12 +415,12 @@ fsat: function () { return LNbits.utils.formatSat(this.sat) }, - isRoundValid(){ + isRoundValid() { return this.tipRounding > this.amount }, - roundToSugestion(){ + roundToSugestion() { //let toNext = 1 - switch(true){ + switch (true) { case this.amount > 50: toNext = 10 break @@ -435,16 +434,28 @@ toNext = 0.5 break } - - return Math.ceil(this.amount/toNext)*toNext + + return Math.ceil(this.amount / toNext) * toNext } }, methods: { - setRounding(){ + setRounding() { this.rounding = true this.tipRounding = this.roundToSugestion 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 () { this.stack = [] this.tipAmount = 0.0 @@ -643,8 +654,8 @@ ? null : JSON.parse('{{ tpos.tip_options }}') - if('{{ tpos.tip_wallet }}') { - this.tip_options.push("Round") + if ('{{ tpos.tip_wallet }}') { + this.tip_options.push('Round') } setInterval(function () { getRates() From f4c0c92655ac0373d8e98d36313134f6fd85c8f8 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Mon, 24 Oct 2022 14:09:40 +0200 Subject: [PATCH 3/7] strings --- lnbits/extensions/tpos/templates/tpos/tpos.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index 6a74d95b3..f432901a3 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -230,7 +230,7 @@ :outline="!($q.dark.isActive)" rounded color="primary" - label="Round" + label="Custom" > @@ -449,7 +449,7 @@ if (change < 0) { this.$q.notify({ type: 'warning', - message: 'Value must be greater than initial amount' + message: 'Amount with tip must be greater than initial amount.' }) this.tipRounding = this.roundToSugestion return From 12b69a7f826a178ba2ee7d30141266295d4cf1f3 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 17 Nov 2022 15:13:21 +0000 Subject: [PATCH 4/7] fix reseting rounding and better UX --- .../extensions/tpos/templates/tpos/tpos.html | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index f432901a3..3be6d4a52 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -230,21 +230,25 @@ :outline="!($q.dark.isActive)" rounded color="primary" - label="Custom" + label="Round to" > - + + + + Ok - - +
Date: Thu, 17 Nov 2022 15:14:53 +0000 Subject: [PATCH 5/7] format --- lnbits/extensions/tpos/templates/tpos/tpos.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index 3be6d4a52..c0adfca49 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -245,9 +245,13 @@ --> - Ok + Ok
From edf76ad7cc7d34165c5034fdab573ee7041ab2fb Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 17 Nov 2022 15:32:20 +0000 Subject: [PATCH 6/7] add input number --- lnbits/extensions/tpos/templates/tpos/tpos.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index c0adfca49..6c56b8fb7 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -238,6 +238,7 @@ ref="inputRounding" v-model.number="tipRounding" :placeholder="roundToSugestion" + type="number" hint="Total amount including tip" :prefix="currency" > @@ -673,4 +674,18 @@ } }) + {% endblock %} From d64e960ef67990b143ed951a0a9d5920091f0eb7 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Fri, 18 Nov 2022 13:58:56 +0200 Subject: [PATCH 7/7] chore: code clean-up and formatting --- lnbits/extensions/tpos/templates/tpos/tpos.html | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index 6c56b8fb7..c38862341 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -242,9 +242,6 @@ hint="Total amount including tip" :prefix="currency" > - this.amount }, roundToSugestion() { - //let toNext = 1 switch (true) { case this.amount > 50: toNext = 10 @@ -675,17 +671,15 @@ }) {% endblock %}