Skip to content

Commit

Permalink
refactor(step-duration): clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenijesavic committed Sep 12, 2023
1 parent 158bd2c commit 157f888
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 191 deletions.
48 changes: 24 additions & 24 deletions src/pages/proposals/ProposalDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ export default {
// },
result (data) {
if ((data.data.getDocument.dao[0].details_daoName_n !== this.selectedDao.name) && !this.isBadge) {
if ((data?.data?.getDocument?.dao[0]?.details_daoName_n !== this?.selectedDao?.name) && !this.isBadge) {
this.$router.push({ name: '404-not-found' })
}
}
Expand Down Expand Up @@ -1054,7 +1054,7 @@ export default {
commentSectionId () { return this?.proposal?.cmntsect[0].docId },
ownAssignment () {
return (this.proposal.__typename === PROPOSAL_TYPE.ROLE || this.proposal.__typename === PROPOSAL_TYPE.ABILITY) &&
return (this?.proposal?.__typename === PROPOSAL_TYPE.ROLE || this?.proposal?.__typename === PROPOSAL_TYPE.ABILITY) &&
this.proposal.details_assignee_n === this.account &&
proposalParsing.status(this.proposal) !== PROPOSAL_STATE.PROPOSED &&
proposalParsing.status(this.proposal) !== PROPOSAL_STATE.REJECTED &&
Expand Down Expand Up @@ -1089,7 +1089,7 @@ export default {
loading () { return this.$apollo.queries.proposal.loading },
isBadge () { return this.proposal.__typename === PROPOSAL_TYPE.BADGE },
isBadge () { return this.proposal?.__typename === PROPOSAL_TYPE.BADGE },
badgeHolders () {
const uniqueHolders = lodash.uniqBy(this.proposal.assignment, 'details_assignee_n')
Expand Down Expand Up @@ -1177,7 +1177,7 @@ export default {
},
onApply (proposal) {
if (proposal.__typename === PROPOSAL_TYPE.BADGE) {
if (proposal?.__typename === PROPOSAL_TYPE.BADGE) {
proposal.type = PROPOSAL_TYPE.BADGE
// this.$store.commit('proposals/setNext', true)
Expand All @@ -1199,7 +1199,7 @@ export default {
this.saveDraft()
this.$router.push({ name: 'proposal-create', params: { draftId } })
}
if (proposal.__typename === PROPOSAL_TYPE.ARCHETYPE) {
if (proposal?.__typename === PROPOSAL_TYPE.ARCHETYPE) {
proposal.type = PROPOSAL_TYPE.ARCHETYPE
// this.$store.commit('proposals/setNext', true)
this.$store.commit('proposals/setType', CONFIG.options.recurring.options.assignment.type)
Expand Down Expand Up @@ -1286,41 +1286,40 @@ export default {
Policy: { key: 'policy', title: 'Policy' },
Quest: { 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/setStepIndex', 0)
this.$store.commit('proposals/setCategory', category)
this.$store.commit('proposals/setType', this.proposal.__typename)
this.$store.commit('proposals/setType', this.proposal?.__typename)
this.$store.commit('proposals/setState', this.proposal?.details_state_s)
this.$store.commit('proposals/setProposalId', this.proposal?.docId)
this.$store.commit('proposals/setTitle', this.proposal?.details_title_s)
this.$store.commit('proposals/setDescription', this.proposal?.details_description_s)
// this.$store.commit('proposals/setCircle', this.proposal?.details_description_s)
this.$store.commit('proposals/setUsdAmount', parseFloat(this?.proposal?.details_usdAmount_a))
this.$store.commit('proposals/setCommitment', parseFloat(this?.proposal?.details_timeShareX100_i))
this.$store.commit('proposals/setDeferred', parseFloat(this?.proposal?.details_deferredPercX100_i))
if (this.proposal.__typename === PROPOSAL_TYPE.CIRCLE) {
this.$store.commit('proposals/setUrl', this.proposal?.details_url_s)
if (this.proposal?.__typename === PROPOSAL_TYPE.CIRCLE) {
this.$store.commit('proposals/setCircle', {
label: this.proposal?.parentcircle[0]?.name,
value: this.proposal?.parentcircle[0]?.id
})
}
if (this.proposal.__typename === PROPOSAL_TYPE.POLICY) {
if (this.proposal?.__typename === PROPOSAL_TYPE.POLICY) {
this.$store.commit('proposals/setCircle', {
label: this.proposal?.parentcircle[0]?.name,
value: this.proposal?.parentcircle[0]?.id
})
}
if (this.proposal.__typename === PROPOSAL_TYPE.PAYOUT) {
this.$store.commit('proposals/setUrl', this.proposal?.details_url_s)
}
if (this.proposal.__typename === PROPOSAL_TYPE.ROLE) { // Role Assignment
if (this.proposal?.__typename === PROPOSAL_TYPE.ROLE) { // Role Assignment
const tier = this.tiers.find(tier => tier.label === this.proposal?.salaryband?.[0]?.details_name_s)
const archetype = this.archetypes.find(archetype => archetype.label === this.proposal?.salaryband?.[0]?.assignment?.[0]?.role?.[0]?.system_nodeLabel_s)
this.$store.commit('proposals/setRole', archetype)
Expand All @@ -1330,26 +1329,27 @@ export default {
this.$store.commit('proposals/setMinDeferred', tier?.value?.minDeferred || 0)
this.$store.commit('proposals/setMinCommitment', 0)
this.$store.commit('proposals/setCommitment', parseFloat(1))
this.$store.commit('proposals/setDeferred', parseFloat(tier.value.minDeferred))
this.$store.commit('proposals/setCommitment', this.proposal?.details_timeShareX100_i)
this.$store.commit('proposals/setDeferred', parseFloat(this.proposal?.details_deferredPercX100_i))
this.$store.commit('proposals/setStartPeriod', this.proposal?.start[0])
// this.$store.commit('proposals/setStartDate', this.proposal?.start[0]?.details_startTime_t)
this.$store.commit('proposals/setPeriodCount', this.proposal?.details_periodCount_i)
// this.$store.commit('proposals/setMinDeferred', this.proposal?.role[0]?.details_minDeferredX100_i)
}
if (this.proposal.__typename === PROPOSAL_TYPE.ABILITY || this.proposal.__typename === PROPOSAL_TYPE.ASSIGNBADGE) { // Badge Assignment
if (this.proposal?.__typename === PROPOSAL_TYPE.ABILITY || this.proposal?.__typename === PROPOSAL_TYPE.ASSIGNBADGE) { // Badge Assignment
this.$store.commit('proposals/setBadge', this?.proposal.badge?.[0])
this.$store.commit('proposals/setStartPeriod', this.proposal?.start[0])
this.$store.commit('proposals/setPeriodCount', this.proposal?.details_periodCount_i)
}
if (this.proposal.__typename === PROPOSAL_TYPE.ARCHETYPE) {
if (this.proposal?.__typename === PROPOSAL_TYPE.ARCHETYPE) {
this.$store.commit('proposals/setAnnualUsdSalary', parseInt(this.proposal?.details_annualUsdSalary_a.split(' ').shift()))
this.$store.commit('proposals/setRoleCapacity', this.proposal?.details_fulltimeCapacityX100_i)
this.$store.commit('proposals/setMinDeferred', this.proposal?.details_minDeferredX100_i)
}
if (this.proposal.__typename === PROPOSAL_TYPE.BADGE) {
if (this.proposal?.__typename === PROPOSAL_TYPE.BADGE) {
this.$store.commit('proposals/setBadge', this?.proposal)
this.$store.commit('proposals/setPurpose', this.proposal?.details_purpose_s)
this.$store.commit('proposals/setIcon', this.proposal?.details_icon_s)
Expand Down Expand Up @@ -1410,7 +1410,7 @@ export default {
await this.$forceUpdate()
},
toggle (proposal) {
return proposal.__typename === PROPOSAL_TYPE.ROLE || proposal.__typename === PROPOSAL_TYPE.ARCHETYPE || (proposal.__typename === PROPOSAL_TYPE.EDIT && proposal.original?.[0].role)
return proposal?.__typename === PROPOSAL_TYPE.ROLE || proposal?.__typename === PROPOSAL_TYPE.ARCHETYPE || (proposal?.__typename === PROPOSAL_TYPE.EDIT && proposal.original?.[0].role)
},
async fetchComment (commentId) {
Expand Down Expand Up @@ -1501,7 +1501,7 @@ export default {
proposal-item.bottom-no-rounded(v-if="ownAssignment" background="white" :proposal="proposal" :clickable="ownAssignment" :expandable="true" :owner="true" :moons="true" @claim-all="$emit('claim-all')" @change-deferred="(val) => $emit('change-deferred', val)" :selectedDao="selectedDao" :daoSettings="daoSettings" :votingPercentages="votingPercentages")
.separator-container(v-if="ownAssignment")
q-separator(color="grey-3" inset)
proposal-view(:proposal="optimisticProposal ? optimisticProposal : proposal" :ownAssignment="ownAssignment" :class="{'top-no-rounded': ownAssignment}" :withToggle="toggle(proposal)" :created="proposalParsing.created(proposal)" :restrictions="proposalParsing.restrictions(proposal)" :status="proposalParsing.status(proposal)" :docId="proposalParsing.docId(proposal)" :creator="proposalParsing.creator(proposal)" :capacity="proposalParsing.capacity(proposal)" :deferred="proposalParsing.deferred(proposal)" :description="proposalParsing.description(proposal)" :periodCount="proposalParsing.periodCount(proposal)" :salary="proposalParsing.salary(proposal)" :start="proposalParsing.start(proposal)" :subtitle="!ownAssignment ? proposalParsing.subtitle(proposal) : undefined" :title="!ownAssignment ? proposalParsing.title(proposal) : undefined" :type="proposal.__typename === 'Suspend' ? proposal.suspend[0].__typename : proposal.__typename" :url="proposalParsing.url(proposal)" :icon="proposalParsing.icon(proposal)" :commit="proposalParsing.commit(optimisticProposal ? optimisticProposal : proposal)" :compensation="proposalParsing.compensation(optimisticProposal ? optimisticProposal : proposal, daoSettings)" :tokens="proposalParsing.tokens(optimisticProposal ? optimisticProposal : proposal, periodsOnCycle, daoSettings, isDefaultBadgeMultiplier)" :isBadge="isBadge" :pastQuorum="proposalParsing.pastQuorum(proposal)" :pastUnity="proposalParsing.pastUnity(proposal)" :votingMethod="proposalParsing.votingMethod(proposal)" :parentCircle="proposalParsing.parentCircle(proposal)" @change-deferred="onDeferredUpdate" @change-commit="onCommitUpdate")
proposal-view(:proposal="optimisticProposal ? optimisticProposal : proposal" :ownAssignment="ownAssignment" :class="{'top-no-rounded': ownAssignment}" :withToggle="toggle(proposal)" :created="proposalParsing.created(proposal)" :restrictions="proposalParsing.restrictions(proposal)" :status="proposalParsing.status(proposal)" :docId="proposalParsing.docId(proposal)" :creator="proposalParsing.creator(proposal)" :capacity="proposalParsing.capacity(proposal)" :deferred="proposalParsing.deferred(proposal)" :description="proposalParsing.description(proposal)" :periodCount="proposalParsing.periodCount(proposal)" :salary="proposalParsing.salary(proposal)" :start="proposalParsing.start(proposal)" :subtitle="!ownAssignment ? proposalParsing.subtitle(proposal) : undefined" :title="!ownAssignment ? proposalParsing.title(proposal) : undefined" :type="proposal?.__typename === 'Suspend' ? proposal.suspend[0].__typename : proposal?.__typename" :url="proposalParsing.url(proposal)" :icon="proposalParsing.icon(proposal)" :commit="proposalParsing.commit(optimisticProposal ? optimisticProposal : proposal)" :compensation="proposalParsing.compensation(optimisticProposal ? optimisticProposal : proposal, daoSettings)" :tokens="proposalParsing.tokens(optimisticProposal ? optimisticProposal : proposal, periodsOnCycle, daoSettings, isDefaultBadgeMultiplier)" :isBadge="isBadge" :pastQuorum="proposalParsing.pastQuorum(proposal)" :pastUnity="proposalParsing.pastUnity(proposal)" :votingMethod="proposalParsing.votingMethod(proposal)" :parentCircle="proposalParsing.parentCircle(proposal)" @change-deferred="onDeferredUpdate" @change-commit="onCommitUpdate")
comments-widget(v-if="!isBadge" :comments="comments" :disable="expired" @create="createComment" @update="updateComment" @delete="deleteComment" @like="likeComment" @unlike="unlikeComment" @load-comment="fetchComment")
.col-12.col-lg-3(v-if="!isBadge" :class="{ 'q-pl-md': $q.screen.gt.md }")
widget.bg-primary(v-if="proposalParsing.status(proposal) === PROPOSAL_STATE.DRAFTED && isCreator && state === 'WAITING'")
Expand Down Expand Up @@ -1559,10 +1559,10 @@ export default {
)
.separator-container(v-if="ownAssignment")
q-separator(color="grey-3" inset)
proposal-view(:proposal="optimisticProposal ? optimisticProposal : proposal" :ownAssignment="ownAssignment" :class="{'top-no-rounded': ownAssignment}" :withToggle="toggle(proposal)" :created="proposalParsing.created(proposal)" :restrictions="proposalParsing.restrictions(proposal)" :status="proposalParsing.status(proposal)" :docId="proposalParsing.docId(proposal)" :creator="proposalParsing.creator(proposal)" :capacity="proposalParsing.capacity(proposal)" :deferred="proposalParsing.deferred(proposal)" :description="proposalParsing.description(proposal)" :periodCount="proposalParsing.periodCount(proposal)" :salary="proposalParsing.salary(proposal)" :start="proposalParsing.start(proposal)" :subtitle="!ownAssignment ? proposalParsing.subtitle(proposal) : undefined" :title="!ownAssignment ? proposalParsing.title(proposal) : undefined" :type="proposal.__typename === 'Suspend' ? proposal.suspend[0].__typename : proposal.__typename" :url="proposalParsing.url(proposal)" :icon="proposalParsing.icon(proposal)" :commit="proposalParsing.commit(optimisticProposal ? optimisticProposal : proposal)" :compensation="proposalParsing.compensation(optimisticProposal ? optimisticProposal : proposal, daoSettings)" :tokens="proposalParsing.tokens(optimisticProposal ? optimisticProposal : proposal, periodsOnCycle, daoSettings, isDefaultBadgeMultiplier)" :isBadge="isBadge" :pastQuorum="proposalParsing.pastQuorum(proposal)" :pastUnity="proposalParsing.pastUnity(proposal)" :purpose="proposalParsing.purpose(proposal)" :votingMethod="proposalParsing.votingMethod(proposal)" :parentCircle="proposalParsing.parentCircle(proposal)" @change-deferred="onDeferredUpdate" @change-commit="onCommitUpdate")
proposal-view(:proposal="optimisticProposal ? optimisticProposal : proposal" :ownAssignment="ownAssignment" :class="{'top-no-rounded': ownAssignment}" :withToggle="toggle(proposal)" :created="proposalParsing.created(proposal)" :restrictions="proposalParsing.restrictions(proposal)" :status="proposalParsing.status(proposal)" :docId="proposalParsing.docId(proposal)" :creator="proposalParsing.creator(proposal)" :capacity="proposalParsing.capacity(proposal)" :deferred="proposalParsing.deferred(proposal)" :description="proposalParsing.description(proposal)" :periodCount="proposalParsing.periodCount(proposal)" :salary="proposalParsing.salary(proposal)" :start="proposalParsing.start(proposal)" :subtitle="!ownAssignment ? proposalParsing.subtitle(proposal) : undefined" :title="!ownAssignment ? proposalParsing.title(proposal) : undefined" :type="proposal?.__typename === 'Suspend' ? proposal.suspend[0].__typename : proposal?.__typename" :url="proposalParsing.url(proposal)" :icon="proposalParsing.icon(proposal)" :commit="proposalParsing.commit(optimisticProposal ? optimisticProposal : proposal)" :compensation="proposalParsing.compensation(optimisticProposal ? optimisticProposal : proposal, daoSettings)" :tokens="proposalParsing.tokens(optimisticProposal ? optimisticProposal : proposal, periodsOnCycle, daoSettings, isDefaultBadgeMultiplier)" :isBadge="isBadge" :pastQuorum="proposalParsing.pastQuorum(proposal)" :pastUnity="proposalParsing.pastUnity(proposal)" :purpose="proposalParsing.purpose(proposal)" :votingMethod="proposalParsing.votingMethod(proposal)" :parentCircle="proposalParsing.parentCircle(proposal)" @change-deferred="onDeferredUpdate" @change-commit="onCommitUpdate")
comments-widget(v-if="!isBadge" :comments="comments" :disable="expired" @create="createComment" @update="updateComment" @delete="deleteComment" @like="likeComment" @unlike="unlikeComment" @load-comment="fetchComment")
.col-12.col-sm-3(:class="{ 'q-pl-md': $q.screen.gt.sm }")
widget.q-mb-md.position-relative(v-if="proposalParsing.status(proposal) === PROPOSAL_STATE.APPROVED && proposal.__typename === PROPOSAL_TYPE.QUEST_START && !claimPayments.length" :title="$t('pages.proposals.proposaldetail.questCompletion')")
widget.q-mb-md.position-relative(v-if="proposalParsing.status(proposal) === PROPOSAL_STATE.APPROVED && proposal?.__typename === PROPOSAL_TYPE.QUEST_START && !claimPayments.length" :title="$t('pages.proposals.proposaldetail.questCompletion')")
.text-ellipsis.text-body.q-my-xl {{ $t('pages.proposals.proposaldetail.didYouFinish') }}
q-btn.full-width.q-mt-xl.q-px-lg(rounded color="primary" no-caps @click="onQuestPayout") {{ $t('pages.proposals.proposaldetail.claimYourPayment') }}
widget.bg-primary(v-if="proposalParsing.status(proposal) === PROPOSAL_STATE.DRAFTED && isCreator && state === 'WAITING'")
Expand Down
Loading

0 comments on commit 157f888

Please sign in to comment.