Skip to content

Commit

Permalink
Merge branch 'develop' into peng/74-transactions-page
Browse files Browse the repository at this point in the history
  • Loading branch information
faboweb authored Nov 22, 2017
2 parents 670e2e2 + 591c205 commit e623cdc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 83 deletions.
130 changes: 51 additions & 79 deletions app/src/renderer/components/wallet/PageSend.vue
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
<template lang='pug'>
page(title='Send Coins')
form-struct(:submit='verifySend')
form-group(:error='$v.fields.denom.$error'
field-id='send-denomination' field-label='Denomination')
field-group#send-denomination.denoms
btn.denom(
v-for='balance in wallet.balances'
@click.native='setDenom(balance.denom, $event)'
:value="balance.denom.toUpperCase()")
btn.denom(v-if="wallet.balances.length == 0" value="N/A" disabled)
page(title='Send Tokens'): form-struct(:submit='onSubmit')
form-group(:error='$v.fields.denom.$error'
field-id='send-denomination' field-label='Denomination')
field-group
field#send-denomination(
type="select"
v-model="fields.denom"
:options="denominations"
@input="$v.fields.denom.$touch()"
placeholder="Select token...")
form-msg(name='Denomination' type='required' v-if='!$v.fields.denom.required')

// field#send-denomination(
type="select"
v-model="fields.denom"
@input="$v.fields.denom.$touch()"
placeholder="Denomination"
required)
form-msg(name='Denomination', type='required', v-if='!$v.fields.denom.required')
form-group(:error='$v.fields.address.$error'
field-id='send-address' field-label='Pay To')
field-group
field#send-address(
type='text'
v-model='fields.address'
@input='$v.fields.address.$touch()'
placeholder='Address')
form-msg(name='Address' type='required' v-if='!$v.fields.address.required')
form-msg(name='Address' type='exactLength' length='40'
v-if='!$v.fields.address.minLength || !$v.fields.address.maxLength')
form-msg(name='Address' type='alphaNum' v-if='!$v.fields.address.alphaNum')

form-group(:error='$v.fields.address.$error'
field-id='send-address' field-label='Pay To')
field-group
field#send-address(type='text', v-model='fields.address', @input='$v.fields.address.$touch()', placeholder='Address', required='')
form-msg(name='Address', type='required', v-if='!$v.fields.address.required')
form-msg(name='Address', type='exactLength', length='40', v-if='!$v.fields.address.minLength || !$v.fields.address.maxLength')
form-msg(name='Address', type='alphaNum', v-if='!$v.fields.address.alphaNum')
form-group(:error='$v.fields.amount.$error'
field-id='send-amount' field-label='Amount')
field-group
field#send-amount(
type='number'
v-model='fields.amount'
@input='$v.fields.amount.$touch()'
placeholder='Amount')
field-addon Coins
btn(value='Max')
form-msg(name='Amount' type='required' v-if='!$v.fields.amount.required')
form-msg(name='Amount' type='between' min='1' max='1000000'
v-if='!$v.fields.amount.between')

form-group(:error='$v.fields.amount.$error'
field-id='send-amount' field-label='Amount')
field-group
field#send-amount(type='number', v-model='fields.amount', @input='$v.fields.amount.$touch()', placeholder='Amount', required='')
field-addon Coins
btn(value='Max')
form-msg(name='Amount', type='required', v-if='!$v.fields.amount.required')
form-msg(name='Amount', type='between', min='1', max='1000000', v-if='!$v.fields.amount.between')

div(slot='footer')
// btn(value='Reset', @click.native='resetForm')
div
btn(v-if='sending', value='Sending...' disabled)
btn(v-else='', type='submit', value='Send Now')
div(slot='footer')
// btn(value='Reset' @click.native='resetForm')
div
btn(v-if='sending' value='Sending...' disabled)
btn(v-else @click='onSubmit' icon="check" value="Send Tokens")
</template>

<script>
Expand Down Expand Up @@ -67,34 +70,23 @@ export default {
ToolBar
},
computed: {
...mapGetters(['wallet'])
...mapGetters(['wallet']),
denominations () {
return this.wallet.balances.map(i =>
({ key: i.denom.toUpperCase(), value: i.denom }))
}
},
methods: {
setDenom (denom, $event) {
let denomEls = document.querySelectorAll('.denoms .denom')
// console.log('denomEls', denomEls)
Array.from(denomEls).map(el => el.classList.remove('active'))
let thisDenomEl = $event.target
// console.log('denom el', thisDenomEl)
thisDenomEl.classList.add('active')
this.fields.denom = denom
// console.log('setting denomination to', this.fields.denom)
},
trunc (value) {
if (value.length > 20) value = this.value.substring(0, 20) + '...'
return '' + value + ''
},
resetForm () {
this.fields.address = ''
this.fields.amount = null
this.sending = false
this.$v.$reset()
},
verifySend () {
onSubmit () {
this.$v.$touch()
if (this.$v.$error) return
this.sending = true
let amount = +this.fields.amount
let address = this.fields.address
Expand Down Expand Up @@ -129,7 +121,7 @@ export default {
},
sending: false
}),
validations: {
validations: () => ({
fields: {
address: {
required,
Expand All @@ -145,7 +137,7 @@ export default {
required
}
}
}
})
}
</script>

Expand All @@ -155,27 +147,7 @@ export default {
#send-address
#send-amount
mono()
&::-webkit-input-placeholder
&:placeholder
df()
color light
&::-moz-placeholder
df()
color light
&:-ms-input-placeholder
df()
color light
&:-moz-placeholder
df()
color light
.denoms
display flex
.denom
margin-right 0.5rem
&.active
border-color link
background lighten(link, 90%)
color link
&:last-of-type
margin-right 0
</style>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
},
"dependencies": {
"@nylira/vue-button": "^4.0.1",
"@nylira/vue-field": "^1.1.8",
"@nylira/vue-field": "1.1.9",
"@nylira/vue-form-msg": "^1.0.3",
"@nylira/vue-input": "^3.2.0",
"@nylira/vue-notifications": "^1.3.0",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
version "4.1.0"
resolved "https://registry.yarnpkg.com/@nylira/vue-button/-/vue-button-4.1.0.tgz#a63215722e7d8950e9f00b5e9c11b004561fdb16"

"@nylira/vue-field@^1.1.8":
version "1.1.8"
resolved "https://registry.yarnpkg.com/@nylira/vue-field/-/vue-field-1.1.8.tgz#16362526fcf07d537c95528ca91f7ee4cad37049"
"@nylira/[email protected].9":
version "1.1.9"
resolved "https://registry.yarnpkg.com/@nylira/vue-field/-/vue-field-1.1.9.tgz#44c1909db4d41e021f75e7e3f3aaf4028ce1e28f"

"@nylira/vue-form-msg@^1.0.3":
version "1.0.3"
Expand Down

0 comments on commit e623cdc

Please sign in to comment.