Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(quest-proposal): editing v2 #2464

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/proposals/proposal-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ widget.proposal-view.q-mb-sm
.column
.text-h5.text-bold {{ title }}
.text-italic.text-body {{ subtitle }}
version-history(v-if="type === PROPOSAL_TYPE.POLICY && !hidePolicyHistory" :proposalId="proposal?.docId ? proposal.docId : docId")
quest-progression(v-if="type === PROPOSAL_TYPE.QUEST_START" :proposalId="proposal?.docId ? proposal.docId : docId")
version-history(v-if="type === PROPOSAL_TYPE.POLICY && !hidePolicyHistory" :proposalId="proposal?.docId ? proposal?.docId : docId")
quest-progression(v-if="type === PROPOSAL_TYPE.QUEST_START && status === PROPOSAL_STATE.APPROVED" :proposalId="proposal?.docId ? proposal?.docId : docId")
.q-my-sm(:class="{ 'row':$q.screen.gt.md }" v-if="type === PROPOSAL_TYPE.ROLE || type === PROPOSAL_TYPE.EDIT || type === PROPOSAL_TYPE.PAYOUT || type === PROPOSAL_TYPE.ABILITY || type === PROPOSAL_TYPE.BADGE")
.col.bg-internal-bg.rounded-border(:class="{ 'q-mr-xs':$q.screen.gt.md, 'q-mb-sm':$q.screen.lt.md || $q.screen.md }" v-if="icon")
.row.full-width.q-pt-md.q-px-md.q-ml-xs(:class="{ 'q-pb-md':$q.screen.lt.md || $q.screen.md }" v-if="iconDetails")
Expand Down
16 changes: 8 additions & 8 deletions src/components/proposals/quest-progression.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ export default {
return status
},
completionCardTitle () {
return this.currentQuest.status === PROPOSAL_STATE.PROPOSED ? 'Not available yet' : 'Create now!'
return this.currentQuest?.status === PROPOSAL_STATE.PROPOSED ? 'Not available yet' : 'Create now!'
}
}
}
</script>
<template lang="pug">
.quest-progression(v-if="currentQuest.status !== PROPOSAL_STATE.DRAFTED")
.quest-progression(v-if="currentQuest?.status !== PROPOSAL_STATE.DRAFTED")
.text-grey.text-italic.q-mb-sm(:style="{ 'font-size': '12px' }") {{ $t('proposals.quest-progression.questProgression') }}
.row
.q-mr-md.q-mb-md.rounded-border.q-pa-md(:style="{ 'min-width': '160px', 'max-width': '160px' }" :class="cardColor(currentQuest.status)")
.icon-container(:class="{ 'bg-primary': currentQuest.status === PROPOSAL_STATE.PENDING }")
q-icon(name="fa fa-map-marker" :color="iconColor(currentQuest.status)")
.h-h5.text-white(:style="{ 'white-space': 'nowrap', 'text-overflow': 'ellipsis', 'overflow': 'hidden' }") {{ currentQuest.title }}
.q-mr-md.q-mb-md.rounded-border.q-pa-md(:style="{ 'min-width': '160px', 'max-width': '160px' }" :class="cardColor(currentQuest?.status)")
.icon-container(:class="{ 'bg-primary': currentQuest?.status === PROPOSAL_STATE.PENDING }")
q-icon(name="fa fa-map-marker" :color="iconColor(currentQuest?.status)")
.h-h5.text-white(:style="{ 'white-space': 'nowrap', 'text-overflow': 'ellipsis', 'overflow': 'hidden' }") {{ currentQuest?.title }}

q-tooltip {{ currentQuest.title }}
.h-h7.text-white.q-mt-md(:class="{ 'text-grey': currentQuest.status === PROPOSAL_STATE.PENDING}") {{ cardStatus(currentQuest) }}
q-tooltip {{ currentQuest?.title }}
.h-h7.text-white.q-mt-md(:class="{ 'text-grey': currentQuest?.status === PROPOSAL_STATE.PENDING}") {{ cardStatus(currentQuest) }}
template(v-if="claimPayments?.length" v-for="card in claimPayments")
.q-mr-md.q-mb-md.rounded-border.q-pa-md(:style="{ 'min-width': '160px', 'max-width': '160px' }" :class="cardColor(card.status)")
.icon-container(:class="{ 'bg-primary': card.status === PROPOSAL_STATE.PENDING }")
Expand Down
27 changes: 25 additions & 2 deletions src/pages/proposals/ProposalDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ const PROPOSAL_QUERY = `
details_ballotAlignment_i
details_url_s

start {
details_startTime_t
}

details_periodCount_i

lockedby {
docId
}
Expand Down Expand Up @@ -224,6 +230,11 @@ const PROPOSAL_QUERY = `
details_pegAmount_a
details_rewardAmount_a
details_voiceAmount_a
start {
details_startTime_t
}

details_periodCount_i
}

dao {
Expand Down Expand Up @@ -1285,9 +1296,10 @@ export default {
Circle: { key: 'circle', title: 'Circle' },
Policy: { key: 'policy', title: 'Policy' },
Quest: { key: 'quest', title: 'Quest' },
Queststart: { key: 'quest', title: 'Quest' },
Questcomplet: { key: 'quest', title: 'Quest' },
Budget: { key: 'circlebudget', title: 'Budget' }
}[this.proposal?.__typename]

}[this.proposal.__typename]
this.$store.commit('proposals/setStepIndex', 1)
this.$store.commit('proposals/setCategory', category)
this.$store.commit('proposals/setType', this.proposal?.__typename)
Expand Down Expand Up @@ -1361,6 +1373,17 @@ export default {
this.$store.commit('proposals/setPegCoefficient', this?.proposal?.details_pegCoefficientX10000_i)
}

if (this.proposal.__typename === PROPOSAL_TYPE.QUEST_START || this.proposal.__typename === PROPOSAL_TYPE.QUEST_PAYOUT) {
this.$store.commit('proposals/setUrl', this.proposal?.details_url_s)
this.$store.commit('proposals/setStartPeriod', this.proposal?.start?.[0])
this.$store.commit('proposals/setPeriodCount', this.proposal?.details_periodCount_i)
this.$store.commit('proposals/setPeg', this.proposal?.details_pegAmount_a.split(' ')[0])
this.$store.commit('proposals/setReward', this.proposal?.details_rewardAmount_a.split(' ')[0])
this.$store.commit('proposals/setVoice', this.proposal?.details_voiceAmount_a.split(' ')[0])
this.$store.commit('proposals/setStartPeriod', this.proposal?.start[0])
this.$store.commit('proposals/setPeriodCount', this.proposal?.details_periodCount_i)
}

const draftId = Date.now()
this.$store.commit('proposals/setDraftId', draftId)
this.saveDraft()
Expand Down
2 changes: 1 addition & 1 deletion src/pages/proposals/create/StepDuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default {
<template lang="pug">
widget
label.h-h4 {{ fields.stepDurationTitle.label }}
label.h-h4 {{ fields.stepDurationTitle?.label }}
div
.q-mt-md
.q-gutter-sm(:class="{ 'row': $q.screen.gt.md }")
Expand Down
64 changes: 63 additions & 1 deletion src/store/proposals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ export default {
let content
let proposalType
let publishToStaging

if (draft.edit) {
proposalType = 'edit'
publishToStaging = false
Expand Down Expand Up @@ -842,6 +841,69 @@ export default {
...(draft.masterPolicy ? [{ label: 'master_policy', value: ['int64', draft.masterPolicy.value] }] : [])
]
break

case PROPOSAL_TYPE.QUEST_PAYOUT:
content = [
{ label: 'content_group_label', value: ['string', 'details'] },
{ label: 'title', value: ['string', draft.title] },
{ label: 'description', value: ['string', draft.description] },
{ label: 'url', value: ['string', draft.url] },
{ label: 'annual_usd_salary', value: ['asset', `${parseFloat(draft.annualUsdSalary).toFixed(2)} USD`] },
{ label: 'fulltime_capacity_x100', value: ['int64', Math.round(parseFloat(draft.roleCapacity) * 100)] },
{ label: 'min_deferred_x100', value: ['int64', Math.round(parseFloat(draft.minDeferred))] },

{ label: 'voice_amount', value: ['asset', `${parseFloat(draft.voice).toFixed(rootState.dao.settings.voiceTokenDecimals)} ${rootState.dao.settings.voiceToken}`] },
{ label: 'reward_amount', value: ['asset', `${parseFloat(draft.reward).toFixed(rootState.dao.settings.rewardTokenDecimals)} ${rootState.dao.settings.rewardToken}`] },
{ label: 'peg_amount', value: ['asset', `${parseFloat(draft.peg).toFixed(rootState.dao.settings.pegTokenDecimals)} ${rootState.dao.settings.pegToken}`] },

{ label: 'start_period', value: ['int64', draft.startPeriod.docId] },
{ label: 'period_count', value: ['int64', draft.periodCount] },
{ label: 'recipient', value: ['name', rootState.accounts.account] },
...(draft.parentId ? [{ label: 'quest_start', value: ['int64', draft.parentId] }] : [])
]
break

case PROPOSAL_TYPE.QUEST_START:
content = [
{ label: 'content_group_label', value: ['string', 'details'] },
{ label: 'title', value: ['string', draft.title] },
{ label: 'description', value: ['string', draft.description] },
{ label: 'url', value: ['string', draft.url] },
{ label: 'annual_usd_salary', value: ['asset', `${parseFloat(draft.annualUsdSalary).toFixed(2)} USD`] },
{ label: 'fulltime_capacity_x100', value: ['int64', Math.round(parseFloat(draft.roleCapacity) * 100)] },
{ label: 'min_deferred_x100', value: ['int64', Math.round(parseFloat(draft.minDeferred))] },

{ label: 'voice_amount', value: ['asset', `${parseFloat(draft.voice).toFixed(rootState.dao.settings.voiceTokenDecimals)} ${rootState.dao.settings.voiceToken}`] },
{ label: 'reward_amount', value: ['asset', `${parseFloat(draft.reward).toFixed(rootState.dao.settings.rewardTokenDecimals)} ${rootState.dao.settings.rewardToken}`] },
{ label: 'peg_amount', value: ['asset', `${parseFloat(draft.peg).toFixed(rootState.dao.settings.pegTokenDecimals)} ${rootState.dao.settings.pegToken}`] },

{ label: 'start_period', value: ['int64', draft.startPeriod.docId] },
{ label: 'period_count', value: ['int64', draft.periodCount] },
{ label: 'recipient', value: ['name', rootState.accounts.account] },
...(draft.parentId ? [{ label: 'quest_start', value: ['int64', draft.parentId] }] : [])
]
break

case PROPOSAL_TYPE.QUEST :
content = [
{ label: 'content_group_label', value: ['string', 'details'] },
{ label: 'title', value: ['string', draft.title] },
{ label: 'description', value: ['string', draft.description] },
{ label: 'url', value: ['string', draft.url] },
{ label: 'annual_usd_salary', value: ['asset', `${parseFloat(draft.annualUsdSalary).toFixed(2)} USD`] },
{ label: 'fulltime_capacity_x100', value: ['int64', Math.round(parseFloat(draft.roleCapacity) * 100)] },
{ label: 'min_deferred_x100', value: ['int64', Math.round(parseFloat(draft.minDeferred))] },

{ label: 'voice_amount', value: ['asset', `${parseFloat(draft.voice).toFixed(rootState.dao.settings.voiceTokenDecimals)} ${rootState.dao.settings.voiceToken}`] },
{ label: 'reward_amount', value: ['asset', `${parseFloat(draft.reward).toFixed(rootState.dao.settings.rewardTokenDecimals)} ${rootState.dao.settings.rewardToken}`] },
{ label: 'peg_amount', value: ['asset', `${parseFloat(draft.peg).toFixed(rootState.dao.settings.pegTokenDecimals)} ${rootState.dao.settings.pegToken}`] },

{ label: 'start_period', value: ['int64', draft.startPeriod.docId] },
{ label: 'period_count', value: ['int64', draft.periodCount] },
{ label: 'recipient', value: ['name', rootState.accounts.account] },
...(draft.parentId ? [{ label: 'quest_start', value: ['int64', draft.parentId] }] : [])
]
break
}
if (content) {
const actions = [{
Expand Down
Loading