Merge pull request #2131 from Luis-Fernando-Molina/develop

Contribution: Governance Bug Fixes
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-10-15 07:50:10 -04:00
commit cb0720f670
1 file changed
+67 -64
@@ -223,6 +223,10 @@ function newGovernanceFunctionLibraryVotingProgram() {
node.type === 'Asset' ||
node.type === 'Feature' ||
node.type === 'Pool' ||
node.type === 'Position Class' ||
node.type === 'Asset Class' ||
node.type === 'Feature Class' ||
node.type === 'Pool Class' ||
node.type === 'Position Contribution Claim' ||
node.type === 'Asset Contribution Claim' ||
node.type === 'Feature Contribution Claim'
@@ -285,7 +289,7 @@ function newGovernanceFunctionLibraryVotingProgram() {
/*
Setup the sign of the votes.
*/
let sign = 1
let sign = 1
let negative = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(node.payload, 'negative')
if (negative === true) {
sign = - 1
@@ -418,76 +422,75 @@ function newGovernanceFunctionLibraryVotingProgram() {
function drawVotes(node, votes, percentage, userProfile) {
if (node.payload !== undefined) {
if (node.type === 'User Profile') {
return
}
if (node.type === 'Voting Program') {
drawProgram(node, userProfile)
if (percentage !== undefined) {
node.payload.uiObject.setPercentage(percentage.toFixed(2),
UI.projects.governance.globals.designer.SET_PERCENTAGE_COUNTER
)
}
return
}
if (node.type === 'User Profile Vote') {
drawUserNode(node, votes, percentage)
return
}
if (
node.type === 'Position' ||
node.type === 'Position Class' ||
node.type === 'Pool' ||
node.type === 'Tokens Switch' ||
node.type === 'Asset' ||
node.type === 'Asset Class' ||
node.type === 'Feature' ||
node.type === 'Feature Class' ||
node.type === 'Position Contribution Claim' ||
node.type === 'Asset Contribution Claim' ||
node.type === 'Feature Contribution Claim'
) {
node.payload.uiObject.valueAngleOffset = 0
node.payload.uiObject.valueAtAngle = false
node.payload.uiObject.percentageAngleOffset = 0
node.payload.uiObject.percentageAtAngle = false
} else {
node.payload.uiObject.valueAngleOffset = 180
node.payload.uiObject.valueAtAngle = true
node.payload.uiObject.percentageAngleOffset = 180
node.payload.uiObject.percentageAtAngle = true
}
let voteType = 'Voting Power'
if (
node.type.indexOf('Weight') >= 0 ||
node.type.indexOf('Pool') >= 0 ||
node.type.indexOf('Feature') >= 0 ||
node.type.indexOf('Asset') >= 0
) {
voteType = 'Weight Power'
}
if (node.type.indexOf('Claim') >= 0) {
voteType = 'Claim Support Power'
}
const votesText = parseFloat(votes.toFixed(0)).toLocaleString('en') + ' ' + voteType
node.payload.uiObject.valueAngleOffset = 0
node.payload.uiObject.valueAtAngle = true
node.payload.uiObject.setValue(votesText, UI.projects.governance.globals.designer.SET_VALUE_COUNTER)
if (votes === undefined) { return }
if (isNaN(votes) === true) { return }
if (node.payload === undefined) { return }
if (node.type === 'User Profile') {
return
}
if (node.type === 'Voting Program') {
drawProgram(node, userProfile)
if (percentage !== undefined) {
node.payload.uiObject.setPercentage(percentage.toFixed(2),
UI.projects.governance.globals.designer.SET_PERCENTAGE_COUNTER
)
}
return
}
if (node.type === 'User Profile Vote') {
drawUserNode(node, votes, percentage)
return
}
if (
node.type === 'Position' ||
node.type === 'Position Class' ||
node.type === 'Pool' ||
node.type === 'Pool Class' ||
node.type === 'Tokens Switch' ||
node.type === 'Asset' ||
node.type === 'Asset Class' ||
node.type === 'Feature' ||
node.type === 'Feature Class' ||
node.type === 'Position Contribution Claim' ||
node.type === 'Asset Contribution Claim' ||
node.type === 'Feature Contribution Claim'
) {
return
}
node.payload.uiObject.valueAngleOffset = 180
node.payload.uiObject.valueAtAngle = true
node.payload.uiObject.percentageAngleOffset = 180
node.payload.uiObject.percentageAtAngle = true
let voteType = 'Voting Power'
if (
node.type.indexOf('Weight') >= 0 ||
node.type.indexOf('Pool') >= 0 ||
node.type.indexOf('Feature') >= 0 ||
node.type.indexOf('Asset') >= 0
) {
voteType = 'Weight Power'
}
if (node.type.indexOf('Claim') >= 0) {
voteType = 'Claim Support Power'
}
const votesText = parseFloat(votes.toFixed(0)).toLocaleString('en') + ' ' + voteType
node.payload.uiObject.setValue(votesText, UI.projects.governance.globals.designer.SET_VALUE_COUNTER)
if (percentage !== undefined) {
node.payload.uiObject.percentageAngleOffset = 180
node.payload.uiObject.percentageAtAngle = true
node.payload.uiObject.setPercentage(percentage.toFixed(2),
UI.projects.governance.globals.designer.SET_PERCENTAGE_COUNTER
)
}
function drawUserNode(node, votes, percentage) {
if (node.payload !== undefined) {