Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Widgets/PaymentLog.vue
Show All 11 Lines | <div> | ||||
<tbody> | <tbody> | ||||
<tr v-for="payment in payments" :id="'log' + payment.id" :key="payment.id"> | <tr v-for="payment in payments" :id="'log' + payment.id" :key="payment.id"> | ||||
<td class="datetime">{{ payment.createdAt }}</td> | <td class="datetime">{{ payment.createdAt }}</td> | ||||
<td class="description">{{ payment.description }}</td> | <td class="description">{{ payment.description }}</td> | ||||
<td><a v-if="payment.checkoutUrl" :href="payment.checkoutUrl">{{ $t('form.details') }}</a></td> | <td><a v-if="payment.checkoutUrl" :href="payment.checkoutUrl">{{ $t('form.details') }}</a></td> | ||||
<td class="price text-success">{{ amount(payment) }}</td> | <td class="price text-success">{{ amount(payment) }}</td> | ||||
</tr> | </tr> | ||||
</tbody> | </tbody> | ||||
<tfoot class="table-fake-body"> | <list-foot :text="$t('wallet.pending-payments-none')" colspan="4"></list-foot> | ||||
<tr> | |||||
<td colspan="4">{{ $t('wallet.pending-payments-none') }}</td> | |||||
</tr> | |||||
</tfoot> | |||||
</table> | </table> | ||||
<div class="text-center p-3" id="payments-loader" v-if="hasMore"> | <list-more v-if="hasMore" :on-click="loadLog"></list-more> | ||||
<button class="btn btn-secondary" @click="loadLog(true)">{{ $t('nav.more') }}</button> | |||||
</div> | |||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
import ListTools from './ListTools' | |||||
export default { | export default { | ||||
props: { | mixins: [ ListTools ], | ||||
}, | |||||
data() { | data() { | ||||
return { | return { | ||||
payments: [], | payments: [] | ||||
hasMore: false, | |||||
page: 1 | |||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
this.loadLog() | this.loadLog({ reset: true }) | ||||
}, | }, | ||||
methods: { | methods: { | ||||
loadLog(more) { | loadLog(params) { | ||||
let loader = $(this.$el) | this.listSearch('payments', '/api/v4/payments/pending', params) | ||||
let param = '' | |||||
if (more) { | |||||
param = '?page=' + (this.page + 1) | |||||
loader = $('#payments-loader') | |||||
} | |||||
this.$root.addLoader(loader) | |||||
axios.get('/api/v4/payments/pending' + param) | |||||
.then(response => { | |||||
this.$root.removeLoader(loader) | |||||
// Note: In Vue we can't just use .concat() | |||||
for (let i in response.data.list) { | |||||
this.$set(this.payments, this.payments.length, response.data.list[i]) | |||||
} | |||||
this.hasMore = response.data.hasMore | |||||
this.page = response.data.page || 1 | |||||
}) | |||||
.catch(error => { | |||||
this.$root.removeLoader(loader) | |||||
}) | |||||
}, | }, | ||||
amount(payment) { | amount(payment) { | ||||
return this.$root.price(payment.amount, payment.currency) | return this.$root.price(payment.amount, payment.currency) | ||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |