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

Contribution: utilities table
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-07-15 05:49:45 -04:00
commit fb5244c0e6
8 files changed
+164 -150

No files matched your search

@@ -49,9 +49,9 @@ function newGovernanceReportsReportsPage() {
switch (tab) {
case 'Profiles': {
HTML = HTML + UI.projects.governance.spaces.reportsSpace.userProfiles.addHTML()
resultCounter = UI.projects.governance.spaces.reportsSpace.userProfiles.resultCounter
let response = UI.projects.governance.spaces.reportsSpace.userProfiles.addHTML()
HTML = HTML + response.HTML
resultCounter = response.resultCounter
break
}
}
@@ -1,6 +1,5 @@
function newGovernanceReportsUserProfiles() {
let thisObject = {
resultCounter: undefined,
addHTML: addHTML,
initialize: initialize,
finalize: finalize
@@ -18,8 +17,6 @@ function newGovernanceReportsUserProfiles() {
function addHTML() {
thisObject.resultCounter = 0
let HTML = ''
let tableRecords = []
let table = 'userProfiles'
let tableRecordDefinition = {
@@ -69,141 +66,6 @@ function newGovernanceReportsUserProfiles() {
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: 'name',
order: 'ascending'
}
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
}
/*
Get the property type for the current sorting order.
*/
let propertyType
for (let i = 0; i < tableRecordDefinition.properties.length; i++) {
let property = tableRecordDefinition.properties[i]
if (property.name === sortingOrder.property) {
propertyType = property.type
break
}
}
/*
Apply the sorting order for this table.
*/
switch (propertyType) {
case 'string': {
switch (sortingOrder.order) {
case 'ascending': {
tableRecords.sort((a, b) => (a[sortingOrder.property].toLowerCase() > b[sortingOrder.property].toLowerCase()) ? 1 : -1)
break
}
case 'descending': {
tableRecords.sort((a, b) => (a[sortingOrder.property].toLowerCase() > b[sortingOrder.property].toLowerCase()) ? -1 : 1)
break
}
}
break
}
case 'number': {
switch (sortingOrder.order) {
case 'ascending': {
tableRecords.sort((a, b) => (a[sortingOrder.property] > b[sortingOrder.property]) ? 1 : -1)
break
}
case 'descending': {
tableRecords.sort((a, b) => (a[sortingOrder.property] > b[sortingOrder.property]) ? -1 : 1)
break
}
}
break
}
}
/*
Build the HTML
*/
let odd = false
const upArrow = '&uarr;'
const downArrow = '&darr;'
HTML = HTML + '<section id="governance-report-page-div" class="governance-search-result-content">'
HTML = HTML + '<table class="governance-info-table">'
HTML = HTML + '<thead>'
HTML = HTML + '<tr>'
for (let i = 0; i < tableRecordDefinition.properties.length; i++) {
let property = tableRecordDefinition.properties[i]
let newOrder
let orderArrow
/*
If the property is the one defining the order, then the new order will be
the opossite order.
*/
if (property.name === sortingOrder.property) {
if (sortingOrder.order === 'ascending') {
newOrder = 'descending'
orderArrow = upArrow
} else {
newOrder = 'ascending'
orderArrow = downArrow
}
} else {
orderArrow = ""
/*
If the property is not the current defininf the order, then the new order will
be the default order for that property.
*/
for (let i = 0; i < tableRecordDefinition.properties.length; i++) {
let propertyDefinition = tableRecordDefinition.properties[i]
if (property.name === propertyDefinition.name) {
newOrder = propertyDefinition.order
break
}
}
}
HTML = HTML + '<th>' + '<a href="#" onClick="UI.projects.governance.spaces.reportsSpace.changeTableSortingOrder(\'' + table + '\',\'' + property.name + '\',\'' + newOrder + '\')">' + property.label + ' ' + orderArrow +'</a>' + '</th>'
}
HTML = HTML + '</tr>'
HTML = HTML + '<thead>'
HTML = HTML + '<tbody>'
for (let j = 0; j < tableRecords.length; j++) {
let tableRecord = tableRecords[j]
if (odd === true) {
HTML = HTML + '<tr class="governance-info-table-alt-bg">'
odd = false
} else {
HTML = HTML + '<tr>'
odd = true
}
/*
Iterate through tableRecord properties.
*/
for (var property in tableRecord) {
if (Object.prototype.hasOwnProperty.call(tableRecord, property)) {
HTML = HTML + '<td>' + tableRecord[property] + '</td>'
}
}
thisObject.resultCounter++
HTML = HTML + '</tr>'
}
HTML = HTML + '<tbody>'
HTML = HTML + '</table>'
HTML = HTML + '</section>'
return HTML
return UI.projects.governance.utilities.tables.addHTML(table, tableRecords, tableRecordDefinition)
}
}
@@ -1,4 +1,4 @@
function newFoundationsUtilitiesBonusProgram() {
function newGovernanceUtilitiesBonusProgram() {
let thisObject = {
run: run
}
@@ -1,4 +1,4 @@
function newFoundationsUtilitiesDecendentProgram() {
function newGovernanceUtilitiesDecendentProgram() {
let thisObject = {
run: run
}
+1 -1
View File
@@ -1,4 +1,4 @@
function newFoundationsUtilitiesPools() {
function newGovernanceUtilitiesPools() {
let thisObject = {
findPool: findPool
}
+147
View File
@@ -0,0 +1,147 @@
function newGovernanceUtilitiesTables() {
let thisObject = {
addHTML: addHTML
}
return thisObject
function addHTML(table, tableRecords, tableRecordDefinition) {
let HTML = ''
let resultCounter = 0
/*
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: 'name',
order: 'ascending'
}
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
}
/*
Get the property type for the current sorting order.
*/
let propertyType
for (let i = 0; i < tableRecordDefinition.properties.length; i++) {
let property = tableRecordDefinition.properties[i]
if (property.name === sortingOrder.property) {
propertyType = property.type
break
}
}
/*
Apply the sorting order for this table.
*/
switch (propertyType) {
case 'string': {
switch (sortingOrder.order) {
case 'ascending': {
tableRecords.sort((a, b) => (a[sortingOrder.property].toLowerCase() > b[sortingOrder.property].toLowerCase()) ? 1 : -1)
break
}
case 'descending': {
tableRecords.sort((a, b) => (a[sortingOrder.property].toLowerCase() > b[sortingOrder.property].toLowerCase()) ? -1 : 1)
break
}
}
break
}
case 'number': {
switch (sortingOrder.order) {
case 'ascending': {
tableRecords.sort((a, b) => (a[sortingOrder.property] > b[sortingOrder.property]) ? 1 : -1)
break
}
case 'descending': {
tableRecords.sort((a, b) => (a[sortingOrder.property] > b[sortingOrder.property]) ? -1 : 1)
break
}
}
break
}
}
/*
Build the HTML
*/
let odd = false
const upArrow = '&uarr;'
const downArrow = '&darr;'
HTML = HTML + '<section id="governance-report-page-div" class="governance-search-result-content">'
HTML = HTML + '<table class="governance-info-table">'
HTML = HTML + '<thead>'
HTML = HTML + '<tr>'
for (let i = 0; i < tableRecordDefinition.properties.length; i++) {
let property = tableRecordDefinition.properties[i]
let newOrder
let orderArrow
/*
If the property is the one defining the order, then the new order will be
the opossite order.
*/
if (property.name === sortingOrder.property) {
if (sortingOrder.order === 'ascending') {
newOrder = 'descending'
orderArrow = upArrow
} else {
newOrder = 'ascending'
orderArrow = downArrow
}
} else {
orderArrow = ""
/*
If the property is not the current defininf the order, then the new order will
be the default order for that property.
*/
for (let i = 0; i < tableRecordDefinition.properties.length; i++) {
let propertyDefinition = tableRecordDefinition.properties[i]
if (property.name === propertyDefinition.name) {
newOrder = propertyDefinition.order
break
}
}
}
HTML = HTML + '<th>' + '<a href="#" onClick="UI.projects.governance.spaces.reportsSpace.changeTableSortingOrder(\'' + table + '\',\'' + property.name + '\',\'' + newOrder + '\')">' + property.label + ' ' + orderArrow + '</a>' + '</th>'
}
HTML = HTML + '</tr>'
HTML = HTML + '<thead>'
HTML = HTML + '<tbody>'
for (let j = 0; j < tableRecords.length; j++) {
let tableRecord = tableRecords[j]
if (odd === true) {
HTML = HTML + '<tr class="governance-info-table-alt-bg">'
odd = false
} else {
HTML = HTML + '<tr>'
odd = true
}
/*
Iterate through tableRecord properties.
*/
for (var property in tableRecord) {
if (Object.prototype.hasOwnProperty.call(tableRecord, property)) {
HTML = HTML + '<td>' + tableRecord[property] + '</td>'
}
}
resultCounter++
HTML = HTML + '</tr>'
}
HTML = HTML + '<tbody>'
HTML = HTML + '</table>'
HTML = HTML + '</section>'
return { HTML: HTML, resultCounter: resultCounter }
}
}
@@ -1,4 +1,4 @@
function newFoundationsUtilitiesValidations() {
function newGovernanceUtilitiesValidations () {
let thisObject = {
onlyOneProgram: onlyOneProgram
}
+9 -4
View File
@@ -1052,22 +1052,27 @@
{
"name": "Pools",
"propertyName": "pools",
"functionName": "newFoundationsUtilitiesPools"
"functionName": "newGovernanceUtilitiesPools"
},
{
"name": "Decendent Program",
"propertyName": "decendentProgram",
"functionName": "newFoundationsUtilitiesDecendentProgram"
"functionName": "newGovernanceUtilitiesDecendentProgram"
},
{
"name": "Bonus Program",
"propertyName": "bonusProgram",
"functionName": "newFoundationsUtilitiesBonusProgram"
"functionName": "newGovernanceUtilitiesBonusProgram"
},
{
"name": "Validations",
"propertyName": "validations",
"functionName": "newFoundationsUtilitiesValidations"
"functionName": "newGovernanceUtilitiesValidations"
},
{
"name": "Tables",
"propertyName": "tables",
"functionName": "newGovernanceUtilitiesTables"
}
],
"spaces": [