improve proposal display

This commit is contained in:
liangping 2022-10-08 09:31:15 +08:00
parent 99cb79e0cd
commit 6225c1b66f
2 changed files with 11 additions and 18 deletions

View File

@ -49,14 +49,7 @@
> >
<tbody> <tbody>
<b-tr> <b-tr>
<b-td <b-td style="text-transform: capitalize; vertical-align: top; width:200px">
style="text-transform: capitalize; vertical-align: top; width:200px"
>
{{ $t('proposal_id') }}
</b-td><b-td>{{ proposal.id }}</b-td>
</b-tr>
<b-tr>
<b-td>
{{ $t('proposal_proposer') }} {{ $t('proposal_proposer') }}
</b-td><b-td><router-link :to="`../account/${proposer.proposer}`"> </b-td><b-td><router-link :to="`../account/${proposer.proposer}`">
{{ formatAddress(proposer.proposer) }} {{ formatAddress(proposer.proposer) }}

View File

@ -15,7 +15,7 @@
<b-td <b-td
style="text-transform: capitalize; vertical-align: top;" style="text-transform: capitalize; vertical-align: top;"
> >
{{ name }} {{ formatTitle(name) }}
</b-td> </b-td>
<b-td v-if="isTokenField(value)"> <b-td v-if="isTokenField(value)">
{{ formatTokens( value ) }} {{ formatTokens( value ) }}
@ -37,13 +37,12 @@
<b-tabs <b-tabs
v-if="value" v-if="value"
small small
class="overflow-hidden"
> >
<b-tab <b-tab
v-for="key in Object.keys(value)" v-for="key in Object.keys(value)"
:key="key" :key="key"
:title="key" :title="formatTitle(key)"
class="p-0 overflow-hidden" class="p-0 text-capitalize"
title-item-class="bg-light-primary" title-item-class="bg-light-primary"
> >
<array-field-component <array-field-component
@ -60,7 +59,7 @@
/> />
<div <div
v-else v-else
style="max-width: 800px; overflow: auto;" style="max-width: 800px; max-height: 300px; overflow: auto;"
>{{ value[key] }}</div> >{{ value[key] }}</div>
</b-tab> </b-tab>
</b-tabs> </b-tabs>
@ -71,7 +70,7 @@
</VueMarkdown> </VueMarkdown>
<div <div
v-else v-else
style="max-width: 800px; word-wrap:normal" style="max-width: 800px; max-height: 300px; overflow: auto;"
>{{ value }}</div> >{{ value }}</div>
</b-td> </b-td>
</b-tr> </b-tr>
@ -135,6 +134,7 @@ export default {
// } // }
return value return value
}, },
formatTitle: v => v.replaceAll('_', ' '),
isObjectText(v) { isObjectText(v) {
return String(v).startsWith('{') && String(v).endsWith('}') return String(v).startsWith('{') && String(v).endsWith('}')
}, },
@ -146,16 +146,16 @@ export default {
return Array.from(value) return Array.from(value)
}, },
isTokenField(value) { isTokenField(value) {
return isToken(value) return value ? isToken(value) : false
}, },
isHex(value) { isHex(value) {
return isHexAddress(value) return value ? isHexAddress(value) : false
}, },
formatHexAddress(v) { formatHexAddress(v) {
return getStakingValidatorByHex(this.$http.config.chain_name, v) return getStakingValidatorByHex(this.$http.config.chain_name, v)
}, },
isArrayText(value) { isArrayText(value) {
return isStringArray(value) return value ? isStringArray(value) : false
}, },
formatTokens(value) { formatTokens(value) {
return tokenFormatter(value) return tokenFormatter(value)
@ -165,7 +165,7 @@ export default {
if (percentage.test(value)) { if (percentage.test(value)) {
return `${percent(value)}%` return `${percent(value)}%`
} }
return value.replace(/(?:\\[rn])+/g, '\n') return value ? value.replace(/(?:\\[rn])+/g, '\n') : '-'
}, },
}, },
} }