Browse Source

Added "quick vouchers" option to withdraw ext

internalpayments
arcbtc 5 years ago
parent
commit
b97595b06d
  1. 32
      lnbits/extensions/withdraw/static/js/index.js
  2. 61
      lnbits/extensions/withdraw/templates/withdraw/index.html

32
lnbits/extensions/withdraw/static/js/index.js

@ -59,6 +59,15 @@ new Vue({
is_unique: false
}
},
simpleformDialog: {
show: false,
data: {
is_unique: false,
title: 'Vouchers',
min_withdrawable: 0,
wait_time: 1
}
},
qrCodeDialog: {
show: false,
data: null
@ -97,6 +106,11 @@ new Vue({
is_unique: false
}
},
simplecloseFormDialog: function () {
this.simpleformDialog.data = {
is_unique: false
}
},
openQrCodeDialog: function (linkId) {
var link = _.findWhere(this.withdrawLinks, {id: linkId})
this.qrCodeDialog.data = _.clone(link)
@ -127,6 +141,23 @@ new Vue({
this.createWithdrawLink(wallet, data)
}
},
simplesendFormData: function () {
var wallet = _.findWhere(this.g.user.wallets, {
id: this.simpleformDialog.data.wallet
})
var data = _.omit(this.simpleformDialog.data, 'wallet')
data.wait_time = 1
data.min_withdrawable = data.max_withdrawable
data.title = 'vouchers'
data.is_unique = true
if (data.id) {
this.updateWithdrawLink(wallet, data)
} else {
this.createWithdrawLink(wallet, data)
}
},
updateWithdrawLink: function (wallet, data) {
var self = this
@ -164,6 +195,7 @@ new Vue({
.then(function (response) {
self.withdrawLinks.push(mapWithdrawLink(response.data))
self.formDialog.show = false
self.simpleformDialog.show = false
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)

61
lnbits/extensions/withdraw/templates/withdraw/index.html

@ -9,8 +9,14 @@
<div class="col-12 col-md-7 q-gutter-y-md">
<q-card>
<q-card-section>
<q-btn
unelevated
color="deep-purple"
@click="simpleformDialog.show = true"
>Quick vouchers</q-btn
>
<q-btn unelevated color="deep-purple" @click="formDialog.show = true"
>New withdraw link</q-btn
>Advanced withdraw link(s)</q-btn
>
</q-card-section>
</q-card>
@ -229,6 +235,59 @@
</q-card>
</q-dialog>
<q-dialog
v-model="simpleformDialog.show"
position="top"
@hide="simplecloseFormDialog"
>
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
<q-form @submit="simplesendFormData" class="q-gutter-md">
<q-select
filled
dense
emit-value
v-model="simpleformDialog.data.wallet"
:options="g.user.walletOptions"
label="Wallet *"
>
</q-select>
<q-input
filled
dense
v-model.number="simpleformDialog.data.max_withdrawable"
type="number"
label="Withdraw amount"
></q-input>
<q-input
filled
dense
v-model.number="simpleformDialog.data.uses"
type="number"
:default="1"
label="Amount of uses *"
></q-input>
<div class="row q-mt-lg">
<q-btn
unelevated
color="deep-purple"
:disable="
simpleformDialog.data.wallet == null ||
simpleformDialog.data.max_withdrawable == null ||
simpleformDialog.data.max_withdrawable < 1 ||
simpleformDialog.data.uses == null"
type="submit"
>Create vouchers</q-btn
>
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
>Cancel</q-btn
>
</div>
</q-form>
</q-card>
</q-dialog>
<q-dialog v-model="qrCodeDialog.show" position="top">
<q-card v-if="qrCodeDialog.data" class="q-pa-lg lnbits__dialog-card">
{% raw %}

Loading…
Cancel
Save