support metadata
This commit is contained in:
parent
2094c2c48d
commit
5ecba3b283
@ -9,7 +9,7 @@ import { select } from '@/components/dynamic/index';
|
|||||||
import type { PaginatedProposals } from '@/types';
|
import type { PaginatedProposals } from '@/types';
|
||||||
import ProposalProcess from './ProposalProcess.vue';
|
import ProposalProcess from './ProposalProcess.vue';
|
||||||
import type { PropType } from 'vue';
|
import type { PropType } from 'vue';
|
||||||
import { ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
const dialog = useTxDialog();
|
const dialog = useTxDialog();
|
||||||
defineProps({
|
defineProps({
|
||||||
proposals: { type: Object as PropType<PaginatedProposals> },
|
proposals: { type: Object as PropType<PaginatedProposals> },
|
||||||
@ -38,6 +38,11 @@ const voterStatusMap: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const proposalInfo = ref();
|
const proposalInfo = ref();
|
||||||
|
|
||||||
|
function metaItem(metadata: string|undefined): { title: string; summary: string } {
|
||||||
|
return metadata ? JSON.parse(metadata) : {}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-white dark:bg-[#28334e] rounded text-sm">
|
<div class="bg-white dark:bg-[#28334e] rounded text-sm">
|
||||||
@ -59,13 +64,13 @@ const proposalInfo = ref();
|
|||||||
:to="`/${chain.chainName}/gov/${item?.proposal_id}`"
|
:to="`/${chain.chainName}/gov/${item?.proposal_id}`"
|
||||||
class="text-main text-base mb-1 block hover:text-indigo-400 truncate"
|
class="text-main text-base mb-1 block hover:text-indigo-400 truncate"
|
||||||
>
|
>
|
||||||
{{ item?.content?.title || item?.title }}
|
{{ item?.content?.title || item?.title || metaItem(item?.metadata)?.title }}
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<div
|
<div
|
||||||
v-if="item.content"
|
v-if="item.content"
|
||||||
class="bg-[#f6f2ff] text-[#9c6cff] dark:bg-gray-600 dark:text-gray-300 inline-block rounded-full px-2 py-[1px] text-xs mb-1"
|
class="bg-[#f6f2ff] text-[#9c6cff] dark:bg-gray-600 dark:text-gray-300 inline-block rounded-full px-2 py-[1px] text-xs mb-1"
|
||||||
>
|
>
|
||||||
{{ showType(item.content['@type']) }}
|
{{ showType(item.content['@type']) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@ -144,7 +149,7 @@ const proposalInfo = ref();
|
|||||||
<RouterLink
|
<RouterLink
|
||||||
:to="`/${chain.chainName}/gov/${item?.proposal_id}`"
|
:to="`/${chain.chainName}/gov/${item?.proposal_id}`"
|
||||||
class="flex-1 w-0 truncate mr-4"
|
class="flex-1 w-0 truncate mr-4"
|
||||||
>{{ item?.content?.title || item?.title }}</RouterLink
|
>{{ item?.content?.title || item?.title || metaItem(item?.metadata)?.title }}</RouterLink
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
for="proposal-detail-modal"
|
for="proposal-detail-modal"
|
||||||
@ -237,9 +242,9 @@ const proposalInfo = ref();
|
|||||||
<h3 class="font-bold text-lg">Description</h3>
|
<h3 class="font-bold text-lg">Description</h3>
|
||||||
<p class="py-4">
|
<p class="py-4">
|
||||||
<Component
|
<Component
|
||||||
v-if="proposalInfo?.content?.description || proposalInfo?.summary"
|
v-if="proposalInfo?.content?.description || proposalInfo?.summary || metaItem(proposalInfo?.metadata)?.summary"
|
||||||
:is="select(proposalInfo?.content?.description || proposalInfo?.summary, 'horizontal')"
|
:is="select(proposalInfo?.content?.description || proposalInfo?.summary || metaItem(proposalInfo?.metadata)?.summary, 'horizontal')"
|
||||||
:value="proposalInfo?.content?.description || proposalInfo?.summary"
|
:value="proposalInfo?.content?.description || proposalInfo?.summary || metaItem(proposalInfo?.metadata)?.summary"
|
||||||
>
|
>
|
||||||
</Component>
|
</Component>
|
||||||
</p>
|
</p>
|
||||||
|
@ -185,14 +185,18 @@ function pageload(p: number) {
|
|||||||
pageResponse.value = x.pagination;
|
pageResponse.value = x.pagination;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function metaItem(metadata: string|undefined): { title: string; summary: string } {
|
||||||
|
return metadata ? JSON.parse(metadata) : {}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="bg-base-100 px-4 pt-3 pb-4 rounded mb-4 shadow">
|
<div class="bg-base-100 px-4 pt-3 pb-4 rounded mb-4 shadow">
|
||||||
<h2 class="card-title flex flex-col md:!justify-between md:!flex-row">
|
<h2 class="card-title flex flex-col md:!justify-between md:!flex-row mb-2">
|
||||||
<p class="truncate w-full">
|
<p class="truncate w-full">
|
||||||
{{ proposal_id }}. {{ proposal.title || proposal.content?.title }}
|
{{ proposal_id }}. {{ proposal.title || proposal.content?.title || metaItem(proposal?.metadata)?.title }}
|
||||||
</p>
|
</p>
|
||||||
<div
|
<div
|
||||||
class="badge badge-ghost"
|
class="badge badge-ghost"
|
||||||
@ -210,9 +214,9 @@ function pageload(p: number) {
|
|||||||
<div class="">
|
<div class="">
|
||||||
<ObjectElement :value="proposal.content" />
|
<ObjectElement :value="proposal.content" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="proposal.summary && !proposal.content?.description">
|
<div v-if="proposal.summary && !proposal.content?.description || metaItem(proposal?.metadata)?.summary ">
|
||||||
<MdEditor
|
<MdEditor
|
||||||
:model-value="format.multiLine(proposal.summary)"
|
:model-value="format.multiLine(proposal.summary || metaItem(proposal?.metadata)?.summary)"
|
||||||
previewOnly
|
previewOnly
|
||||||
class="md-editor-recover"
|
class="md-editor-recover"
|
||||||
></MdEditor>
|
></MdEditor>
|
||||||
|
@ -24,6 +24,7 @@ export interface GovProposal {
|
|||||||
title?: string;
|
title?: string;
|
||||||
summary?: string;
|
summary?: string;
|
||||||
proposal_id: string;
|
proposal_id: string;
|
||||||
|
metadata?: string;
|
||||||
content: {
|
content: {
|
||||||
'@type': string;
|
'@type': string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user