Filters at Utilities
This commit is contained in:
1 parent
4aba44d87f
commit
072cca8e6b
3 files changed
+43
-28
No files matched your search
@@ -83,34 +83,7 @@ function newGovernanceReportsUserProfiles() {
|
|||||||
"tokenPower": userProfile.payload.tokenPower | 0
|
"tokenPower": userProfile.payload.tokenPower | 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply Filters */
|
if (UI.projects.governance.utilities.filters.applyFilters(filters, filtersObject, tableRecord) === true) {
|
||||||
let passedFilters = true
|
|
||||||
if (filtersObject !== undefined) {
|
|
||||||
for (var property in tableRecord) {
|
|
||||||
if (Object.prototype.hasOwnProperty.call(tableRecord, property)) {
|
|
||||||
let fiter = filtersObject[property]
|
|
||||||
if (fiter === undefined) { continue }
|
|
||||||
let value = tableRecord[property]
|
|
||||||
let condition = eval(fiter)
|
|
||||||
if (condition === false) {
|
|
||||||
passedFilters = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
We will assume the filter is a string and that needs to be applied to the property name.
|
|
||||||
*/
|
|
||||||
if (
|
|
||||||
filters !== undefined &&
|
|
||||||
filters !== "" &&
|
|
||||||
tableRecord.name.indexOf(filters) < 0
|
|
||||||
) {
|
|
||||||
passedFilters = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (passedFilters === true) {
|
|
||||||
tableRecords.push(tableRecord)
|
tableRecords.push(tableRecord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
function newGovernanceUtilitiesFilters() {
|
||||||
|
let thisObject = {
|
||||||
|
applyFilters: applyFilters
|
||||||
|
}
|
||||||
|
|
||||||
|
return thisObject
|
||||||
|
|
||||||
|
function applyFilters(filters, filtersObject, tableRecord) {
|
||||||
|
/* Apply Filters */
|
||||||
|
let passedFilters = true
|
||||||
|
if (filtersObject !== undefined) {
|
||||||
|
for (var property in tableRecord) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(tableRecord, property)) {
|
||||||
|
let fiter = filtersObject[property]
|
||||||
|
if (fiter === undefined) { continue }
|
||||||
|
let value = tableRecord[property]
|
||||||
|
let condition = eval(fiter)
|
||||||
|
if (condition === false) {
|
||||||
|
passedFilters = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
We will assume the filter is a string and that needs to be applied to the property name.
|
||||||
|
*/
|
||||||
|
if (
|
||||||
|
filters !== undefined &&
|
||||||
|
filters !== "" &&
|
||||||
|
tableRecord.name.indexOf(filters) < 0
|
||||||
|
) {
|
||||||
|
passedFilters = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return passedFilters
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1083,6 +1083,11 @@
|
|||||||
"name": "Common Tables",
|
"name": "Common Tables",
|
||||||
"propertyName": "commonTables",
|
"propertyName": "commonTables",
|
||||||
"functionName": "newGovernanceUtilitiesCommonTables"
|
"functionName": "newGovernanceUtilitiesCommonTables"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Filters",
|
||||||
|
"propertyName": "filters",
|
||||||
|
"functionName": "newGovernanceUtilitiesFilters"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"spaces": [
|
"spaces": [
|
||||||
|
|||||||
Reference in new issue
Block a user