supporters working

This commit is contained in:
Luis Fernando Molina committed 2021-07-16 10:32:23 +02:00
1 parent 726895214f
commit 6e72bf0ae9
6 files changed
+150 -88

No files matched your search

@@ -16,94 +16,10 @@ function newGovernanceReportsReferrals() {
}
function addHTML(tabIndex) {
let tableRecords = []
let table = 'referrals'
let tableRecordDefinition = {
"properties": [
{
"name": "name",
"label": "User Profile",
"type": "string",
"order": "ascending"
},
{
"name": "ownPower",
"label": "Own Power",
"type": "number",
"order": "descending"
},
{
"name": "incoming",
"label": "Incoming",
"type": "number",
"order": "descending"
},
{
"name": "tokensAwarded",
"label": "Awarded",
"type": "number",
"order": "descending"
},
{
"name": "decendants",
"label": "Descendants",
"type": "number",
"order": "descending"
},
{
"name": "tokensBonus",
"label": "Bonus",
"type": "number",
"order": "descending"
}
]
}
/*
Here we get from the workspace all User Profiles.
*/
let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile')
/*
Transform the result array into table records.
*/
for (let j = 0; j < userProfiles.length; j++) {
let userProfile = userProfiles[j]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, 'Referral Program')
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
let tableRecord = {
"name": userProfile.name,
"ownPower": program.payload.referralProgram.ownPower | 0,
"incoming": program.payload.referralProgram.incomingPower | 0,
"tokensAwarded": program.payload.referralProgram.awarded.tokens | 0,
"decendants": program.payload.referralProgram.awarded.count | 0,
"tokensBonus": program.payload.referralProgram.bonus.tokens | 0
}
tableRecords.push(tableRecord)
}
/*
Get the sorting order for this table.
*/
let sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
/*
Set the default sorting order for this table.
*/
if (sortingOrder === undefined) {
UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table] = {
property: 'tokensAwarded',
order: 'descending'
}
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
}
return UI.projects.governance.utilities.tables.addHTML(
table,
tableRecords,
tableRecordDefinition,
sortingOrder,
return UI.projects.governance.utilities.decendentTables.addHTML(
'referrals',
'Referral Program',
'referralProgram',
tabIndex
)
}
@@ -60,6 +60,12 @@ function newGovernanceReportsReportsPage() {
resultCounter = response.resultCounter
break
}
case 'Supporters': {
let response = UI.projects.governance.spaces.reportsSpace.supports.addHTML(3)
HTML = HTML + response.HTML
resultCounter = response.resultCounter
break
}
}
HTML = HTML + '</div>'
@@ -8,6 +8,7 @@ function newGobernanceReportsSpace() {
footer: undefined,
userProfiles: undefined,
referrals: undefined,
supports: undefined,
tablesSortingOrders: undefined,
changeTableSortingOrder,
physics: physics,
@@ -52,6 +53,9 @@ function newGobernanceReportsSpace() {
thisObject.referrals.finalize()
thisObject.referrals = undefined
thisObject.supports.finalize()
thisObject.supports = undefined
isInitialized = false
}
@@ -73,11 +77,13 @@ function newGobernanceReportsSpace() {
thisObject.footer = newGovernanceReportsFooter()
thisObject.userProfiles = newGovernanceReportsUserProfiles()
thisObject.referrals = newGovernanceReportsReferrals()
thisObject.supports = newGovernanceReportsSupports()
thisObject.reportsPage.initialize()
thisObject.footer.initialize()
thisObject.userProfiles.initialize()
thisObject.referrals.initialize()
thisObject.supports.initialize()
setupSidePanelTab()
@@ -0,0 +1,26 @@
function newGovernanceReportsSupports() {
let thisObject = {
addHTML: addHTML,
initialize: initialize,
finalize: finalize
}
return thisObject
function initialize() {
}
function finalize() {
}
function addHTML(tabIndex) {
return UI.projects.governance.utilities.decendentTables.addHTML(
'supports',
'Support Program',
'supportProgram',
tabIndex
)
}
}
@@ -0,0 +1,103 @@
function newGovernanceUtilitiesDecendentTables() {
let thisObject = {
addHTML: addHTML
}
return thisObject
function addHTML(
table,
programName,
programPropertyName,
tabIndex
) {
let tableRecords = []
let tableRecordDefinition = {
"properties": [
{
"name": "name",
"label": "User Profile",
"type": "string",
"order": "ascending"
},
{
"name": "ownPower",
"label": "Own Power",
"type": "number",
"order": "descending"
},
{
"name": "incoming",
"label": "Incoming",
"type": "number",
"order": "descending"
},
{
"name": "tokensAwarded",
"label": "Awarded",
"type": "number",
"order": "descending"
},
{
"name": "decendants",
"label": "Descendants",
"type": "number",
"order": "descending"
},
{
"name": "tokensBonus",
"label": "Bonus",
"type": "number",
"order": "descending"
}
]
}
/*
Here we get from the workspace all User Profiles.
*/
let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile')
/*
Transform the result array into table records.
*/
for (let j = 0; j < userProfiles.length; j++) {
let userProfile = userProfiles[j]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programName)
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
let tableRecord = {
"name": userProfile.name,
"ownPower": program.payload[programPropertyName].ownPower | 0,
"incoming": program.payload[programPropertyName].incomingPower | 0,
"tokensAwarded": program.payload[programPropertyName].awarded.tokens | 0,
"decendants": program.payload[programPropertyName].awarded.count | 0,
"tokensBonus": program.payload[programPropertyName].bonus.tokens | 0
}
tableRecords.push(tableRecord)
}
/*
Get the sorting order for this table.
*/
let sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
/*
Set the default sorting order for this table.
*/
if (sortingOrder === undefined) {
UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table] = {
property: 'tokensAwarded',
order: 'descending'
}
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
}
return UI.projects.governance.utilities.tables.addHTML(
table,
tableRecords,
tableRecordDefinition,
sortingOrder,
tabIndex
)
}
}
+5
View File
@@ -1073,6 +1073,11 @@
"name": "Tables",
"propertyName": "tables",
"functionName": "newGovernanceUtilitiesTables"
},
{
"name": "Decendent Tables",
"propertyName": "decendentTables",
"functionName": "newGovernanceUtilitiesDecendentTables"
}
],
"spaces": [