diff --git a/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js b/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js index 2b979d977..0700b9625 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js @@ -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 } } diff --git a/Projects/Governance/UI/Spaces/Reports-Space/UserProfiles.js b/Projects/Governance/UI/Spaces/Reports-Space/UserProfiles.js index d9288273d..885c88fdf 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/UserProfiles.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/UserProfiles.js @@ -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 = '↑' - const downArrow = '↓' - - HTML = HTML + '
' - - HTML = HTML + '' - HTML = HTML + '' - HTML = HTML + '' - 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 + '' - } - HTML = HTML + '' - HTML = HTML + '' - HTML = HTML + '' - - for (let j = 0; j < tableRecords.length; j++) { - let tableRecord = tableRecords[j] - - if (odd === true) { - HTML = HTML + '' - odd = false - } else { - HTML = HTML + '' - odd = true - } - - /* - Iterate through tableRecord properties. - */ - for (var property in tableRecord) { - if (Object.prototype.hasOwnProperty.call(tableRecord, property)) { - HTML = HTML + '' - } - } - - thisObject.resultCounter++ - - HTML = HTML + '' - } - - HTML = HTML + '' - HTML = HTML + '
' + '' + property.label + ' ' + orderArrow +'' + '
' + tableRecord[property] + '
' - - HTML = HTML + '
' - - return HTML + return UI.projects.governance.utilities.tables.addHTML(table, tableRecords, tableRecordDefinition) } } \ No newline at end of file diff --git a/Projects/Governance/UI/Utilities/BonusProgram.js b/Projects/Governance/UI/Utilities/BonusProgram.js index 6e97ec814..16030d2a2 100644 --- a/Projects/Governance/UI/Utilities/BonusProgram.js +++ b/Projects/Governance/UI/Utilities/BonusProgram.js @@ -1,4 +1,4 @@ -function newFoundationsUtilitiesBonusProgram() { +function newGovernanceUtilitiesBonusProgram() { let thisObject = { run: run } diff --git a/Projects/Governance/UI/Utilities/DecendentProgram.js b/Projects/Governance/UI/Utilities/DecendentProgram.js index 63ebac828..dce2a35ac 100644 --- a/Projects/Governance/UI/Utilities/DecendentProgram.js +++ b/Projects/Governance/UI/Utilities/DecendentProgram.js @@ -1,4 +1,4 @@ -function newFoundationsUtilitiesDecendentProgram() { +function newGovernanceUtilitiesDecendentProgram() { let thisObject = { run: run } diff --git a/Projects/Governance/UI/Utilities/Pools.js b/Projects/Governance/UI/Utilities/Pools.js index f6c35a751..ead317a6b 100644 --- a/Projects/Governance/UI/Utilities/Pools.js +++ b/Projects/Governance/UI/Utilities/Pools.js @@ -1,4 +1,4 @@ -function newFoundationsUtilitiesPools() { +function newGovernanceUtilitiesPools() { let thisObject = { findPool: findPool } diff --git a/Projects/Governance/UI/Utilities/Tables.js b/Projects/Governance/UI/Utilities/Tables.js new file mode 100644 index 000000000..af9928cbd --- /dev/null +++ b/Projects/Governance/UI/Utilities/Tables.js @@ -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 = '↑' + const downArrow = '↓' + + HTML = HTML + '
' + + HTML = HTML + '' + HTML = HTML + '' + HTML = HTML + '' + 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 + '' + } + HTML = HTML + '' + HTML = HTML + '' + HTML = HTML + '' + + for (let j = 0; j < tableRecords.length; j++) { + let tableRecord = tableRecords[j] + + if (odd === true) { + HTML = HTML + '' + odd = false + } else { + HTML = HTML + '' + odd = true + } + + /* + Iterate through tableRecord properties. + */ + for (var property in tableRecord) { + if (Object.prototype.hasOwnProperty.call(tableRecord, property)) { + HTML = HTML + '' + } + } + + resultCounter++ + + HTML = HTML + '' + } + + HTML = HTML + '' + HTML = HTML + '
' + '' + property.label + ' ' + orderArrow + '' + '
' + tableRecord[property] + '
' + + HTML = HTML + '
' + + return { HTML: HTML, resultCounter: resultCounter } + } +} \ No newline at end of file diff --git a/Projects/Governance/UI/Utilities/Validations.js b/Projects/Governance/UI/Utilities/Validations.js index e369bcbaa..4b23c27ce 100644 --- a/Projects/Governance/UI/Utilities/Validations.js +++ b/Projects/Governance/UI/Utilities/Validations.js @@ -1,4 +1,4 @@ -function newFoundationsUtilitiesValidations() { +function newGovernanceUtilitiesValidations () { let thisObject = { onlyOneProgram: onlyOneProgram } diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 38bf41a33..7581a6108 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -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": [