$hint => [{"column" => "id", "transform" => "distinct"}]
};
+ my $attr_from_filter;
if ($options->{"order_by"}) {
# What's the point of this block? When using ORDER BY in conjuction
# with SELECT DISTINCT, the fields present in ORDER BY have to also
q/order_by clause must be of the long form, like:
"order_by": [{"class": "foo", "field": "bar", "direction": "asc"}]/
);
+
} else {
+
+ # we can't combine distinct(id) with another select column,
+ # since the non-distinct column may arbitrarily (via hash keys)
+ # sort to the front of the final SQL, which PG will complain about.
+ $select_clause = { $hint => ["id"] };
$select_clause->{$class} ||= [];
- push @{$select_clause->{$class}}, $field;
+ push @{$select_clause->{$class}},
+ {column => $field, transform => 'first', aggregate => 1};
+
+ # when sorting by LI attr values, we have to limit
+ # to a specific type of attr value to sort on.
+ if ($class eq 'acqlia') {
+ $attr_from_filter = {
+ "fkey" => "id",
+ "filter" => {
+ "attr_type" => "lineitem_marc_attr_definition",
+ "attr_name" => $options->{"order_by_attr"} || "title"
+ },
+ "type" => "left",
+ "field" =>"lineitem"
+ };
+ }
}
}
return new OpenILS::Event("BAD_PARAMS", "desc" => "No usable terms");
}
+
+ # if ordering by acqlia, insert the from clause
+ # filter to limit to one type of attr.
+ if ($attr_from_filter) {
+ $query->{from}->{jub} = {} unless $query->{from}->{jub};
+ $query->{from}->{jub}->{acqlia} = $attr_from_filter;
+ }
+
my $results = $e->json_query($query) or return $e->die_event;
my @id_list = map { $_->{"id"} } (grep { $_->{"id"} } @$results);
}
}
+ if (dojo.byId('acq-invoice-search-sort-title').checked) {
+ uriManager.order_by =
+ [ {"class": "acqlia", "field":"attr_value", "transform":"first"} ];
+ }
+
resultManager.go(searchObject)
console.log('Lineitem Search: ' + js2JSON(searchObject));
focusLastSearchInput();
termManager = new TermManager();
resultManager = new ResultManager();
resultsLoader = new searchResultsLoader();
+ uriManager = new URIManager();
// define custom lineitem result handler
resultManager.result_types = {
if (window.unifiedSearchExternalMode) {
// assume for now that external mode implies inline results display
- uriManager = new URIManager();
+ uriManager = uriManager || new URIManager();
uriManager.search_object = search_object;
uriManager.result_type = dojo.byId("acq-unified-result-type").getValue();
uriManager.conjunction = dojo.byId("acq-unified-conjunction").getValue();