Adds custom filters for AJAX queries

This commit is contained in:
Oliver 2021-06-28 14:19:05 +10:00
parent e2942238a9
commit 41539b75db

View File

@ -261,6 +261,15 @@ function constructFormBody(fields, options) {
// Provide each field object with its own name
for(field in fields) {
fields[field].name = field;
var field_options = displayed_fields[field];
// Copy custom options across to the fields object
if (field_options) {
// Query filters
fields[field].filters = field_options.filters;
}
}
// Construct an ordered list of field names
@ -596,12 +605,15 @@ function initializeRelatedField(name, field, options) {
offset = (params.page - 1) * pageSize;
}
// Re-format search term into InvenTree API style
return {
search: params.term,
offset: offset,
limit: pageSize,
};
// Custom query filters can be specified against each field
var query = field.filters || {};
// Add search and pagination options
query.search = params.term;
query.offset = offset;
query.limit = pageSize;
return query;
},
processResults: function(response) {
// Convert the returned InvenTree data into select2-friendly format