Skip to content

Commit

Permalink
fix(proposal): edit assigment proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenijesavic committed Sep 26, 2023
1 parent 43f8148 commit 5d7b208
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 73 deletions.
155 changes: 86 additions & 69 deletions src/pages/proposals/ProposalDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mapActions, mapGetters } from 'vuex'
import gql from 'graphql-tag'

import CONFIG from './create/config.js'
import { PROPOSAL_STATE, PROPOSAL_TYPE } from '~/const'
import { PROPOSAL_STATE, PROPOSAL_TYPE, DEFAULT_TIER } from '~/const'
// import { calcVoicePercentage } from '~/utils/eosio'

import { format } from '~/mixins/format'
Expand Down Expand Up @@ -94,13 +94,13 @@ const PROPOSAL_QUERY = `
}

... on Budget {
ballot_expiration_t
details_title_s
details_description_s
details_state_s
details_ballotQuorum_i
details_ballotSupply_a
details_ballotAlignment_i
ballot_expiration_t
details_title_s
details_description_s
details_state_s
details_ballotQuorum_i
details_ballotSupply_a
details_ballotAlignment_i

votetally {
docId
Expand All @@ -112,68 +112,73 @@ const PROPOSAL_QUERY = `
}
}

circle {
... on Circle {
circle {
... on Circle {
id: docId
name: details_title_s
purpose: details_description_s
budget: details_purpose_s

applicant {
username: details_member_n
}

members: member {
username: details_member_n
}

subcircles: subcircle {
id: docId
name: details_title_s
purpose: details_description_s
budget: details_purpose_s

applicant {
username: details_member_n
}

members: member {
username: details_member_n
}

subcircles: subcircle {
id: docId
name: details_title_s
purpose: details_description_s
budget: details_purpose_s
}
}
}
details_pegAmount_a
details_voiceAmount_a
details_rewardAmount_a
creator
createdDate
}
details_pegAmount_a
details_voiceAmount_a
details_rewardAmount_a
creator
createdDate

cmntsect {
docId
cmntsect {
docId

comment {
id: docId
author: comment_author_n
content: comment_content_s
createdDate
deletedStatus: comment_deleted_i

reactions: reaction {
reactionlnkrAggregate {
count
}

reactionlnkr {
author: details_member_n
}
}
comment {
id: docId
author: comment_author_n
content: comment_content_s
createdDate
deletedStatus: comment_deleted_i

commentAggregate {
reactions: reaction {
reactionlnkrAggregate {
count
}

reactionlnkr {
author: details_member_n
}
}

commentAggregate {
count
}
}
}
}

... on Queststart {
ballot_expiration_t

details_title_s
details_description_s

# details_usdAmount_a
# details_deferredPercX100_i

details_annualUsdSalary_a

details_pegAmount_a
details_rewardAmount_a
details_voiceAmount_a
Expand Down Expand Up @@ -341,8 +346,8 @@ const PROPOSAL_QUERY = `
}

masterpolicy {
details_title_s
}
details_title_s
}

dao {
details_daoName_n
Expand Down Expand Up @@ -397,7 +402,7 @@ const PROPOSAL_QUERY = `
abstain_votePower_a
}
}

parentcircle {
... on Circle {
id: docId
Expand Down Expand Up @@ -617,14 +622,20 @@ const PROPOSAL_QUERY = `
}
}
... on Assignment {
details_usdSalaryValuePerPhase_a
ballot_expiration_t
details_assignee_n

details_title_s
details_description_s

details_periodCount_i
details_usdSalaryValuePerPhase_a
details_annualUsdSalary_a
details_pegSalaryPerPeriod_a
details_rewardSalaryPerPeriod_a
details_voiceSalaryPerPeriod_a
details_timeShareX100_i
details_approvedDeferredPercX100_i

details_ballotQuorum_i
details_ballotSupply_a
Expand All @@ -640,9 +651,16 @@ const PROPOSAL_QUERY = `
}
}

role {
id: docId
name: details_title_s
}
salaryband {
details_annualUsdSalary_a
details_name_s
id: docId
name: details_name_s
annualAmount: details_annualUsdSalary_a
minDeferred: details_minDeferredX100_i

assignment {
role {
system_nodeLabel_s
Expand All @@ -661,11 +679,7 @@ const PROPOSAL_QUERY = `
claimed {
docId
}
details_pegSalaryPerPeriod_a
details_rewardSalaryPerPeriod_a
details_voiceSalaryPerPeriod_a
details_timeShareX100_i
details_approvedDeferredPercX100_i

lastimeshare {
details_timeShareX100_i
}
Expand Down Expand Up @@ -980,10 +994,10 @@ const PROPOSAL_QUERY = `
}
... on Votable {
votetally {
docId
docId

... on VoteTally {
docId
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
Expand Down Expand Up @@ -1446,12 +1460,15 @@ export default {
}

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)
const tier = this.tiers.find(tier => tier.label === (this.proposal?.salaryband?.[0]?.details_name_s || DEFAULT_TIER))
// const archetype = this.archetypes.find(archetype => archetype.label === this.proposal?.salaryband?.[0]?.assignment?.[0]?.role?.[0]?.system_nodeLabel_s)

this.$store.commit('proposals/setRole', { value: this.proposal?.role[0] })

// this.$store.commit('proposals/setRole', archetype)
this.$store.commit('proposals/setTier', tier)

this.$store.commit('proposals/setAnnualUsdSalary', tier?.value?.annualAmount || 0)
this.$store.commit('proposals/setAnnualUsdSalary', this.proposal?.details_annualUsdSalary_a.split(' ')[0])
this.$store.commit('proposals/setMinDeferred', tier?.value?.minDeferred || 0)
this.$store.commit('proposals/setMinCommitment', 0)

Expand Down Expand Up @@ -1491,9 +1508,9 @@ export default {
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/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)
}
Expand Down
20 changes: 16 additions & 4 deletions src/store/proposals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export default {
{ label: 'time_share_x100', value: ['int64', draft.commitment] },
{ label: 'deferred_perc_x100', value: ['int64', draft.deferred] },

{ label: 'role', value: ['int64', draft.role.value.id] },
{ label: 'role', value: ['int64', draft.role.value ? draft.role.value.id : draft.role.id] },
{ label: 'start_period', value: ['int64', draft.startPeriod.docId] },
{ label: 'period_count', value: ['int64', draft.periodCount] }

Expand Down Expand Up @@ -728,18 +728,30 @@ export default {
// Role assignment
case PROPOSAL_TYPE.ROLE:
content = [

{ label: 'content_group_label', value: ['string', 'details'] },
{ label: 'assignee', value: ['name', rootState.accounts.account] },
{ 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`] },

...(draft.tier.value.name !== DEFAULT_TIER
? [
{ label: 'salary_band_id', value: ['int64', draft.tier.value.id] }
]
: [
{ 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: 'time_share_x100', value: ['int64', draft.commitment] },
{ label: 'deferred_perc_x100', value: ['int64', draft.deferred] },
{ label: 'salary_band_id', value: ['int64', draft.tier.value.id] },
{ label: 'role', value: ['int64', draft.role.value.id] },

{ label: 'role', value: ['int64', draft.role.value ? draft.role.value.id : draft.role.id] },
{ label: 'start_period', value: ['int64', draft.startPeriod.docId] },
{ label: 'period_count', value: ['int64', draft.periodCount] }

]
break

Expand Down

0 comments on commit 5d7b208

Please sign in to comment.