Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Admin/User.vue
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | <div class="container"> | ||||
</a> | </a> | ||||
</li> | </li> | ||||
</ul> | </ul> | ||||
<div class="tab-content"> | <div class="tab-content"> | ||||
<div class="tab-pane show active" id="user-finances" role="tabpanel" aria-labelledby="tab-finances"> | <div class="tab-pane show active" id="user-finances" role="tabpanel" aria-labelledby="tab-finances"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<h2 class="card-title"> | <h2 class="card-title"> | ||||
{{ $t('wallet.title') }} | {{ $t('wallet.title') }} | ||||
<span :class="wallet.balance < 0 ? 'text-danger' : 'text-success'"><strong>{{ $root.price(wallet.balance) }}</strong></span> | <span :class="wallet.balance < 0 ? 'text-danger' : 'text-success'"><strong>{{ $root.price(wallet.balance, wallet.currency) }}</strong></span> | ||||
</h2> | </h2> | ||||
<div class="card-text"> | <div class="card-text"> | ||||
<form class="read-only short"> | <form class="read-only short"> | ||||
<div class="form-group row"> | <div class="form-group row"> | ||||
<label class="col-sm-4 col-form-label">{{ $t('user.discount') }}</label> | <label class="col-sm-4 col-form-label">{{ $t('user.discount') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<span class="form-control-plaintext" id="discount"> | <span class="form-control-plaintext" id="discount"> | ||||
<span>{{ wallet.discount ? (wallet.discount + '% - ' + wallet.discount_description) : 'none' }}</span> | <span>{{ wallet.discount ? (wallet.discount + '% - ' + wallet.discount_description) : 'none' }}</span> | ||||
<button type="button" class="btn btn-secondary btn-sm" @click="discountEdit">{{ $t('btn.edit') }}</button> | <button type="button" class="btn btn-secondary btn-sm" @click="discountEdit">{{ $t('btn.edit') }}</button> | ||||
</span> | </span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row" v-if="wallet.mandate && wallet.mandate.id"> | <div class="form-group row" v-if="wallet.mandate && wallet.mandate.id"> | ||||
<label class="col-sm-4 col-form-label">{{ $t('user.auto-payment') }}</label> | <label class="col-sm-4 col-form-label">{{ $t('user.auto-payment') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<span id="autopayment" :class="'form-control-plaintext' + (wallet.mandateState ? ' text-danger' : '')" | <span id="autopayment" :class="'form-control-plaintext' + (wallet.mandateState ? ' text-danger' : '')" | ||||
v-html="$t('user.auto-payment-text', { | v-html="$t('user.auto-payment-text', { | ||||
amount: wallet.mandate.amount, | amount: wallet.mandate.amount + ' ' + wallet.currency, | ||||
balance: wallet.mandate.balance, | balance: wallet.mandate.balance + ' ' + wallet.currency, | ||||
method: wallet.mandate.method | method: wallet.mandate.method | ||||
})" | })" | ||||
> | > | ||||
<span v-if="wallet.mandateState">({{ wallet.mandateState }})</span>. | <span v-if="wallet.mandateState">({{ wallet.mandateState }})</span>. | ||||
</span> | </span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row" v-if="wallet.providerLink"> | <div class="form-group row" v-if="wallet.providerLink"> | ||||
▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | <div class="container"> | ||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
<form data-validation-prefix="oneoff_"> | <form data-validation-prefix="oneoff_"> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<label for="oneoff_amount" class="col-form-label">{{ $t('form.amount') }}</label> | <label for="oneoff_amount" class="col-form-label">{{ $t('form.amount') }}</label> | ||||
<div class="input-group"> | <div class="input-group"> | ||||
<input type="text" class="form-control" id="oneoff_amount" v-model="oneoff_amount" required> | <input type="text" class="form-control" id="oneoff_amount" v-model="oneoff_amount" required> | ||||
<span class="input-group-append"> | <span class="input-group-append"> | ||||
<span class="input-group-text">{{ oneoff_currency }}</span> | <span class="input-group-text">{{ wallet.currency }}</span> | ||||
</span> | </span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<label for="oneoff_description" class="col-form-label">{{ $t('form.description') }}</label> | <label for="oneoff_description" class="col-form-label">{{ $t('form.description') }}</label> | ||||
<input class="form-control" id="oneoff_description" v-model="oneoff_description" required> | <input class="form-control" id="oneoff_description" v-model="oneoff_description" required> | ||||
</div> | </div> | ||||
</form> | </form> | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | export default { | ||||
// but this component is reused in the new route. | // but this component is reused in the new route. | ||||
// Required to handle links from /user/XXX to /user/YYY | // Required to handle links from /user/XXX to /user/YYY | ||||
next() | next() | ||||
this.$parent.routerReload() | this.$parent.routerReload() | ||||
}, | }, | ||||
data() { | data() { | ||||
return { | return { | ||||
oneoff_amount: '', | oneoff_amount: '', | ||||
oneoff_currency: 'CHF', | |||||
oneoff_description: '', | oneoff_description: '', | ||||
oneoff_negative: false, | oneoff_negative: false, | ||||
discount: 0, | discount: 0, | ||||
discount_description: '', | discount_description: '', | ||||
discounts: [], | discounts: [], | ||||
external_email: '', | external_email: '', | ||||
has2FA: false, | has2FA: false, | ||||
wallet: {}, | wallet: {}, | ||||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | export default { | ||||
amount: this.oneoff_amount, | amount: this.oneoff_amount, | ||||
description: this.oneoff_description | description: this.oneoff_description | ||||
} | } | ||||
if (this.oneoff_negative && /^\d+(\.?\d+)?$/.test(post.amount)) { | if (this.oneoff_negative && /^\d+(\.?\d+)?$/.test(post.amount)) { | ||||
post.amount *= -1 | post.amount *= -1 | ||||
} | } | ||||
// TODO: We maybe should use system currency not wallet currency, | |||||
// or have a selector so the operator does not have to calculate | |||||
// exchange rates | |||||
this.$root.clearFormValidation(this.dialog) | this.$root.clearFormValidation(this.dialog) | ||||
axios.post('/api/v4/wallets/' + wallet_id + '/one-off', post) | axios.post('/api/v4/wallets/' + wallet_id + '/one-off', post) | ||||
.then(response => { | .then(response => { | ||||
if (response.data.status == 'success') { | if (response.data.status == 'success') { | ||||
this.dialog.modal('hide') | this.dialog.modal('hide') | ||||
this.$toast.success(response.data.message) | this.$toast.success(response.data.message) | ||||
this.wallet = Object.assign({}, this.wallet, {balance: response.data.balance}) | this.wallet = Object.assign({}, this.wallet, {balance: response.data.balance}) | ||||
Show All 27 Lines |