From 77103ffcd53275579e7e1ebca2877f972734f4ab Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 30 Sep 2023 13:45:40 +0700 Subject: [PATCH 1/6] Add proposal edit --- src/components/SpaceProposalHeader.vue | 14 +++++---- src/composables/useClient.ts | 22 ++++++++++--- src/composables/useFormSpaceProposal.ts | 2 +- src/locales/default.json | 1 + src/views/SpaceCreate.vue | 41 ++++++++++++++++++++----- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/components/SpaceProposalHeader.vue b/src/components/SpaceProposalHeader.vue index 84fd9abd3ba8..0df21d259d81 100644 --- a/src/components/SpaceProposalHeader.vue +++ b/src/components/SpaceProposalHeader.vue @@ -19,10 +19,10 @@ const { web3Account } = useWeb3(); const isCreator = computed(() => props.proposal?.author === web3Account.value); const threeDotItems = computed(() => { - const items = [ - { text: t('duplicate'), action: 'duplicate' }, - { text: t('report'), action: 'report' } - ]; + const items: { text: string; action: string }[] = []; + if (isCreator.value) items.push({ text: t('edit'), action: 'edit' }); + items.push({ text: t('duplicate'), action: 'duplicate' }); + items.push({ text: t('report'), action: 'report' }); if (props.isAdmin || props.isModerator || isCreator.value) items.push({ text: t('delete'), action: 'delete' }); return items; @@ -55,14 +55,15 @@ function handleSelect(e) { if (!props.proposal) return; if (e === 'delete') deleteProposal(); if (e === 'report') window.open('https://tally.so/r/mDBEGb', '_blank'); - if (e === 'duplicate') { + if (e === 'duplicate' || e === 'edit') { resetForm(); router.push({ name: 'spaceCreate', params: { key: props.proposal.space.id, sourceProposal: props.proposal.id - } + }, + query: { editing: e === 'edit' ? 'true' : undefined } }); } } @@ -149,6 +150,7 @@ watch(