mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds custom filters for AJAX queries
This commit is contained in:
parent
e2942238a9
commit
41539b75db
@ -261,6 +261,15 @@ function constructFormBody(fields, options) {
|
|||||||
// Provide each field object with its own name
|
// Provide each field object with its own name
|
||||||
for(field in fields) {
|
for(field in fields) {
|
||||||
fields[field].name = field;
|
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
|
// Construct an ordered list of field names
|
||||||
@ -596,12 +605,15 @@ function initializeRelatedField(name, field, options) {
|
|||||||
offset = (params.page - 1) * pageSize;
|
offset = (params.page - 1) * pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-format search term into InvenTree API style
|
// Custom query filters can be specified against each field
|
||||||
return {
|
var query = field.filters || {};
|
||||||
search: params.term,
|
|
||||||
offset: offset,
|
// Add search and pagination options
|
||||||
limit: pageSize,
|
query.search = params.term;
|
||||||
};
|
query.offset = offset;
|
||||||
|
query.limit = pageSize;
|
||||||
|
|
||||||
|
return query;
|
||||||
},
|
},
|
||||||
processResults: function(response) {
|
processResults: function(response) {
|
||||||
// Convert the returned InvenTree data into select2-friendly format
|
// Convert the returned InvenTree data into select2-friendly format
|
||||||
|
Loading…
x
Reference in New Issue
Block a user