Merge pull request #1704 from gradido/1686-When-sending-takes-longer-no-twice-results

add extra disabled variable for send emit, disabled send by emit
This commit is contained in:
Alexander Friedland 2022-03-31 23:12:59 +02:00 committed by GitHub
commit 90bafd462a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 7 deletions

View File

@ -60,7 +60,6 @@ export default {
amount: { type: Number, required: true },
memo: { type: String, required: true },
loading: { type: Boolean, required: true },
selected: { type: String, required: true },
},
}
</script>

View File

@ -45,6 +45,33 @@ describe('GddSend confirm', () => {
it('renders the component div.confirm-box-send', () => {
expect(wrapper.find('div.confirm-box-send').exists()).toBeTruthy()
})
describe('send now button', () => {
beforeEach(() => {
jest.clearAllMocks()
})
describe('single click', () => {
beforeEach(async () => {
await wrapper.find('button.btn-success').trigger('click')
})
it('emits send transaction one time', () => {
expect(wrapper.emitted('send-transaction')).toHaveLength(1)
})
})
describe('double click', () => {
beforeEach(async () => {
await wrapper.find('button.btn-success').trigger('click')
await wrapper.find('button.btn-success').trigger('click')
})
it('emits send transaction one time', () => {
expect(wrapper.emitted('send-transaction')).toHaveLength(1)
})
})
})
})
})
})

View File

@ -58,7 +58,11 @@
<b-button @click="$emit('on-reset')">{{ $t('form.cancel') }}</b-button>
</b-col>
<b-col class="text-right">
<b-button variant="success" :disabled="loading" @click="$emit('send-transaction')">
<b-button
variant="success"
:disabled="disabled"
@click="$emit('send-transaction'), (disabled = true)"
>
{{ $t('form.send_now') }}
</b-button>
</b-col>
@ -73,8 +77,11 @@ export default {
email: { type: String, required: false, default: '' },
amount: { type: Number, required: true },
memo: { type: String, required: true },
loading: { type: Boolean, required: true },
selected: { type: String, required: true },
},
data() {
return {
disabled: false,
}
},
}
</script>

View File

@ -12,11 +12,9 @@
<template #transactionConfirmationSend>
<transaction-confirmation-send
:balance="balance"
:selected="transactionData.selected"
:email="transactionData.email"
:amount="transactionData.amount"
:memo="transactionData.memo"
:loading="loading"
@send-transaction="sendTransaction"
@on-reset="onReset"
></transaction-confirmation-send>
@ -24,7 +22,6 @@
<template #transactionConfirmationLink>
<transaction-confirmation-link
:balance="balance"
:selected="transactionData.selected"
:email="transactionData.email"
:amount="transactionData.amount"
:memo="transactionData.memo"