Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions API/Backend/Geodatasets/routes/geodatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function get(reqtype, req, res, next) {
const filterSplit = req.query.filters.split(",");
filters = [];
filterSplit.forEach((f) => {
if (f === "OR" || f === "AND" || f === "NOT") {
if (f === "OR" || f === "AND" || f === "NOT_AND" || f === "NOT_OR") {
filters.push({
isGroup: true,
op: f,
Expand Down Expand Up @@ -257,9 +257,17 @@ function get(reqtype, req, res, next) {
) {
filterSQL.push(
`${
currentGroupOp == "NOT" ? "NOT " : ""
currentGroupOp == "NOT_AND" || currentGroupOp == "NOT_OR"
? "NOT "
: ""
}(${currentGroup.join(
` ${currentGroupOp == "NOT" ? "AND" : f.op} `
` ${
currentGroupOp == "NOT_AND"
? "AND"
: currentGroupOp == "NOT_OR"
? "OR"
: currentGroupOp
} `
)})`
);
currentGroup = [];
Expand All @@ -286,6 +294,12 @@ function get(reqtype, req, res, next) {
case "<":
op = "<";
break;
case ">=":
op = ">=";
break;
case "<=":
op = "<=";
break;
case "in":
op = "IN";
break;
Expand All @@ -294,6 +308,9 @@ function get(reqtype, req, res, next) {
case "endswith":
op = "LIKE";
break;
case "!=":
op = "!=";
break;
case "=":
default:
break;
Expand Down Expand Up @@ -342,9 +359,17 @@ function get(reqtype, req, res, next) {
// Final group
if (currentGroup.length > 0) {
filterSQL.push(
`${currentGroupOp == "NOT" ? "NOT " : ""}(${currentGroup.join(
`${
currentGroupOp == "NOT_AND" || currentGroupOp == "NOT_OR"
? "NOT "
: ""
}(${currentGroup.join(
` ${
currentGroupOp === "NOT" ? "AND" : currentGroupOp || "AND"
currentGroupOp === "NOT_AND"
? "AND"
: currentGroupOp === "NOT_OR"
? "OR"
: currentGroupOp || "AND"
} `
)})`
);
Expand Down
76 changes: 76 additions & 0 deletions configure/src/metaconfigs/layer-vector-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,82 @@
}
]
},
{
"name": "Filter",
"rows": [
{
"name": "Filters",
"components": [
{
"field": "variables.initialFilters",
"name": "Initial Filters",
"description": "Configures the layer's filters for displaying an initial custom subset of the data.",
"type": "objectarray",
"width": 12,
"object": [
{
"field": "type",
"name": "Type of Property",
"description": "If not a Group, whether the property's value should be treated as a string or as a number.",
"type": "dropdown",
"width": 2,
"options": ["string", "number"]
},
{
"field": "key",
"name": "Property",
"description": "If not a Group, a field name from the properties object of each feature of this layer to be to construct a filter. Supports dot.notation for nested properties.",
"type": "text",
"width": 4
},
{
"field": "op",
"name": "Operator",
"description": "If not a Group, the operator to use between the 'Property' and 'Value'.",
"type": "dropdown",
"width": 2,
"options": [
"=",
"!=",
",",
"<",
">",
"<=",
">=",
"contains",
"beginswith",
"endswith"
]
},
{
"field": "value",
"name": "Value",
"description": "If not a Group, a value for the equation to operate on.",
"type": "text",
"width": 4
},
{
"field": "isGroup",
"name": "Is A Group",
"description": "A group contains all property-value rows beneath this row and up until the next Group row or up until the end. Groups themselves are always ANDed together but enables member rows within them to abide by a different operator. If this entry 'Is A Group', then the type, property, operator and values fields are ignored.",
"type": "switch",
"width": 6,
"defaultChecked": false
},
{
"field": "groupOp",
"name": "Group Operator",
"description": "If 'Is A Group', the operator to use for members within the group. 'AND' ands all the group members together. 'OR' ors all the group members together. 'NOT_AND' ands all the group members together and then negates the evaluation. 'NOT_OR' ors all the group members together and then negates the evaluation.",
"type": "dropdown",
"width": 6,
"options": ["AND", "OR", "NOT_AND", "NOT_OR"]
}
]
}
]
}
]
},
{
"name": "Interface",
"rows": [
Expand Down
4 changes: 3 additions & 1 deletion src/essence/Ancillary/LocalFilterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,10 @@ const LocalFilterer = {
let result
if (group.op === 'OR') {
result = group.matches.some(Boolean)
} else if (group.op === 'NOT') {
} else if (group.op === 'NOT_AND') {
result = !group.matches.every(Boolean)
} else if (group.op === 'NOT_OR') {
result = !group.matches.some(Boolean)
} else {
// default to AND
result = group.matches.every(Boolean)
Expand Down
7 changes: 5 additions & 2 deletions src/essence/Basics/Layers_/Filtering/Filtering.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
font-size: 13px;
}
.layersTool_filtering_group_operator {
width: 190px;
width: 231px;
text-align: center;
}

Expand Down Expand Up @@ -257,7 +257,10 @@
.layersTool_filtering_group_operator_select.op_or {
background: var(--color-c2);
}
.layersTool_filtering_group_operator_select.op_not {
.layersTool_filtering_group_operator_select.op_not_and {
background: var(--color-orange2);
}
.layersTool_filtering_group_operator_select.op_not_or {
background: var(--color-p4);
}
.layersTool_filtering_group_operator_select .dropy__title span {
Expand Down
Loading
Loading