better format enum

This commit is contained in:
Pham Tu 2024-01-21 11:05:28 +07:00
parent 497dab0dcd
commit 81dc41652f
No known key found for this signature in database
GPG Key ID: 7460FD99133ADA1C
3 changed files with 27 additions and 17 deletions

View File

@ -136,10 +136,11 @@ function metaItem(metadata: string | undefined): {
item?.voterStatus !== VoteOption.VOTE_OPTION_NO_WITH_VETO
"
>{{
voteOptionToJSON(item?.voterStatus).replace(
'VOTE_OPTION_',
''
)
voteOptionToJSON(item?.voterStatus)
.toLowerCase()
.replace(/^vote_option/, '')
.replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase())
.trim()
}}</span
>
@ -237,10 +238,11 @@ function metaItem(metadata: string | undefined): {
<span
v-if="item?.voterStatus !== VoteOption.VOTE_OPTION_NO_WITH_VETO"
>{{
voteOptionToJSON(item?.voterStatus).replace(
'VOTE_OPTION_',
''
)
voteOptionToJSON(item?.voterStatus)
.toLowerCase()
.replace(/^vote_option/, '')
.replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase())
.trim()
}}</span
>

View File

@ -71,7 +71,13 @@ function myContracts() {
</td>
<td>{{ v.creator }}</td>
<td>
{{ accessTypeToJSON(v.instantiatePermission?.permission) }}
{{
accessTypeToJSON(v.instantiatePermission?.permission)
.toLowerCase()
.replace(/^access_type/, '')
.replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase())
.trim()
}}
<span
>{{ v.instantiatePermission?.address }}
{{ v.instantiatePermission?.addresses.join(', ') }}</span

View File

@ -103,10 +103,11 @@ const color = computed(() => {
});
const status = computed(() => {
if (proposal.value.status) {
return proposalStatusToJSON(proposal.value.status).replace(
'PROPOSAL_STATUS_',
''
);
return proposalStatusToJSON(proposal.value.status)
.toLowerCase()
.replace(/^proposal_status/, '')
.replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase())
.trim();
}
return '';
});
@ -440,10 +441,11 @@ function metaItem(metadata: string | undefined): {
item.options
.map(
(x) =>
`${voteOptionToJSON(x.option).replace(
'VOTE_OPTION_',
''
)}:${format.percent(x.weight)}`
`${voteOptionToJSON(x.option)
.toLowerCase()
.replace(/^vote_option/, '')
.replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase())
.trim()}:${format.percent(x.weight)}`
)
.join(', ')
}}