2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 12:35:46 +00:00

Filter build orders by responsible owner (#4383) (#4408)

* add assigned_to filter to Build API

* extend API to filter build orders by assigned owner

* rename API filter to 'responsible'

* add 'Responsible' filter to build oders table

* add user/group icon to owners in 'Responsible' column

* remove unused python class import

* bump API version number

* fix handling of invalid IDs

* refactor filter options as a callback function

* fix JS styling
This commit is contained in:
simonkuehling
2023-02-25 03:52:12 +01:00
committed by GitHub
parent c46f153449
commit f523fb44f6
5 changed files with 54 additions and 4 deletions

View File

@ -2695,11 +2695,19 @@ function loadBuildTable(table, options) {
title: '{% trans "Responsible" %}',
sortable: true,
formatter: function(value, row) {
if (value) {
return row.responsible_detail.name;
} else {
if (!row.responsible_detail) {
return '-';
}
var html = row.responsible_detail.name;
if (row.responsible_detail.label == 'group') {
html += `<span class='float-right fas fa-users'></span>`;
} else {
html += `<span class='float-right fas fa-user'></span>`;
}
return html;
}
},
{

View File

@ -241,6 +241,11 @@ function generateFilterInput(tableKey, filterKey) {
// Return a 'select' input with the available values
html = `<select class='form-control filter-input' id='${id}' name='value'>`;
// options can be an object or a function, in which case we need to run
// this callback first
if (options instanceof Function) {
options = options();
}
for (var key in options) {
var option = options[key];
html += `<option value='${key}'>${option.value}</option>`;

View File

@ -359,6 +359,25 @@ function getAvailableTableFilters(tableKey) {
type: 'bool',
title: '{% trans "Assigned to me" %}',
},
assigned_to: {
title: '{% trans "Responsible" %}',
options: function() {
var ownersList = {};
inventreeGet(`/api/user/owner/`, {}, {
async: false,
success: function(response) {
for (key in response) {
var owner = response[key];
ownersList[owner.pk] = {
key: owner.pk,
value: `${owner.name} (${owner.label})`,
};
}
}
});
return ownersList;
},
},
};
}