Skip to content

Commit

Permalink
add the ability to search for files and geom that have or don't have …
Browse files Browse the repository at this point in the history
…values, re #11179, re #11180
  • Loading branch information
apeters committed Aug 1, 2024
1 parent 4141350 commit c7d4d02
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 241 deletions.
25 changes: 25 additions & 0 deletions arches/app/datatypes/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,24 @@ def append_to_document(self, document, nodevalue, nodeid, tile, provisional=Fals
}
)

def append_search_filters(self, value, node, query, request):
try:
if value["op"] == "null" or value["op"] == "not_null":
self.append_null_search_filters(value, node, query, request)
elif (
value["op"] == "Point"
or value["op"] == "LineString"
or value["op"] == "Polygon"
):
match_query = Match(
field="tiles.data.%s.features.geometry.type" % (str(node.pk)),
query=value["op"],
type="phrase",
)
query.must(match_query)
except KeyError as e:
pass

def split_geom(self, feature, max_feature_in_bytes=32766):
geom = feature["geometry"]
coordinates = (
Expand Down Expand Up @@ -2049,6 +2067,13 @@ def append_to_document(self, document, nodevalue, nodeid, tile, provisional=Fals
}
document["strings"].append(val)

def append_search_filters(self, value, node, query, request):
try:
if value["op"] == "null" or value["op"] == "not_null":
self.append_null_search_filters(value, node, query, request)
except KeyError as e:
pass

def get_search_terms(self, nodevalue, nodeid):
terms = []
for file_obj in nodevalue:
Expand Down
35 changes: 26 additions & 9 deletions arches/app/media/js/views/components/datatypes/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,33 @@ define([
this.config = params.config;
this.search = params.search;

this.maxFiles = ko.observable(params.config.maxFiles());
this.maxFiles.subscribe(function(val) {
var int = parseInt(val);
if(int > 0) { params.config.maxFiles(int); }
else { self.maxFiles(1); }
});
if (this.search) {
var filter = params.filterValue();
this.op = ko.observable(filter.op || '~');
this.node = params.node;
this.searchValue = ko.observable(filter.val || '');
this.filterValue = ko.computed(function() {
return {
op: self.op(),
val: self.searchValue()
};
}).extend({ throttle: 750 });
params.filterValue(this.filterValue());
this.filterValue.subscribe(function(val) {
params.filterValue(val);
});
} else {
this.maxFiles = ko.observable(params.config.maxFiles());
this.maxFiles.subscribe(function(val) {
var int = parseInt(val);
if(int > 0) { params.config.maxFiles(int); }
else { self.maxFiles(1); }
});

this.imagesOnly = params.config.imagesOnly;
params.config.maxFiles.subscribe((val) => self.maxFiles(val));
this.activated = params.config.activateMax;
this.imagesOnly = params.config.imagesOnly;
params.config.maxFiles.subscribe((val) => self.maxFiles(val));
this.activated = params.config.activateMax;
}
};

ko.components.register(name, {
Expand Down
Loading

0 comments on commit c7d4d02

Please sign in to comment.