Merge pull request #2475 from SchrodingersGat/table-filternig

Table filtering
This commit is contained in:
Oliver 2021-12-21 17:17:18 +11:00 committed by GitHub
commit f0c41b3b70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 42 additions and 10 deletions

View File

@ -45,8 +45,8 @@
{% endif %}
</ul>
</div>
{% include "filter_list.html" with id="supplier-part" %}
</div>
{% include "filter_list.html" with id="supplier-part" %}
</div>
</div>
{% endif %}
@ -92,8 +92,8 @@
{% endif %}
</ul>
</div>
{% include "filter_list.html" with id="manufacturer-part" %}
</div>
{% include "filter_list.html" with id="supplier-part" %}
</div>
</div>
{% endif %}
@ -169,10 +169,10 @@
</div>
<div class='panel-content'>
<div id='assigned-stock-button-toolbar'>
{% include "filter_list.html" with id="stock" %}
{% include "filter_list.html" with id="customerstock" %}
</div>
<table class='table table-striped table-condensed' id='assigned-stock-table' data-toolbar='#bassigned-stock-utton-toolbar'></table>
<table class='table table-striped table-condensed' id='assigned-stock-table' data-toolbar='#assigned-stock-button-toolbar'></table>
</div>
</div>
@ -225,6 +225,7 @@
},
url: "{% url 'api-stock-list' %}",
filterKey: "customerstock",
filterTarget: '#filter-list-customerstock',
});
{% if company.is_customer %}

View File

@ -25,6 +25,7 @@
<div class='panel-content'>
<div id='button-toolbar'>
{% include "filter_list.html" with id='company' %}
</div>
<table class='table table-striped table-condensed' id='company-table' data-toolbar='#button-toolbar'>

View File

@ -181,6 +181,9 @@
<div class='panel-content'>
<div id='param-button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right;'>
<div class='btn-group' role='group'>
{% include "filter_list.html" with id="parameters" %}
</div>
</div>
</div>
<table id='parameter-table' class='table table-condensed table-striped' data-toolbar="#param-button-toolbar"></table>
@ -217,7 +220,7 @@
</div>
</div>
<div class='panel-content'>
<div id='related-button-bar'>
<div id='related-button-toolbar'>
<div class='btn-group' role='group'>
{% include "filter_list.html" with id="related" %}
</div>
@ -344,6 +347,7 @@
<li><a class='dropdown-item' href='#' id='supplier-part-delete' title='{% trans "Delete supplier parts" %}'>{% trans "Delete" %}</a></li>
</ul>
</div>
{% include "filter_list.html" with id="supplier-part" %}
</div>
</div>
@ -371,6 +375,7 @@
<ul class="dropdown-menu">
<li><a class='dropdown-item' href='#' id='manufacturer-part-delete' title='{% trans "Delete manufacturer parts" %}'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete" %}</a></li>
</ul>
{% include "filter_list.html" with id="manufacturer-part" %}
</div>
</div>
</div>

View File

@ -2,7 +2,7 @@
<div id='attachment-buttons'>
<div class='btn-group' role='group'>
{% include "filter_list.html" with id="related" %}
{% include "filter_list.html" with id="attachments" %}
</div>
</div>

View File

@ -67,6 +67,8 @@ function loadAttachmentTable(url, options) {
var table = options.table || '#attachment-table';
setupFilterList('attachments', $(table), '#filter-list-attachments');
addAttachmentButtonCallbacks(url, options.fields || {});
$(table).inventreeTable({

View File

@ -380,6 +380,7 @@ function loadCompanyTable(table, url, options={}) {
url: url,
method: 'get',
queryParams: filters,
original: params,
groupBy: false,
sidePagination: 'server',
formatNoMatches: function() {
@ -463,7 +464,9 @@ function loadManufacturerPartTable(table, url, options) {
filters[key] = params[key];
}
setupFilterList('manufacturer-part', $(table));
var filterTarget = options.filterTarget || '#filter-list-manufacturer-part';
setupFilterList('manufacturer-part', $(table), filterTarget);
$(table).inventreeTable({
url: url,

View File

@ -621,7 +621,9 @@ function loadPartParameterTable(table, url, options) {
filters[key] = params[key];
}
// setupFilterList("#part-parameters", $(table));
var filterTarget = options.filterTarget || '#filter-list-parameters';
setupFilterList('part-parameters', $(table), filterTarget);
$(table).inventreeTable({
url: url,

View File

@ -1468,7 +1468,7 @@ function loadStockTable(table, options) {
var params = options.params || {};
var filterListElement = options.filterList || '#filter-list-stock';
var filterTarget = options.filterTarget || '#filter-list-stock';
var filters = {};
@ -1484,7 +1484,7 @@ function loadStockTable(table, options) {
original[k] = params[k];
}
setupFilterList(filterKey, table, filterListElement);
setupFilterList(filterKey, table, filterTarget);
// Override the default values, or add new ones
for (var key in params) {

View File

@ -381,6 +381,24 @@ function getAvailableTableFilters(tableKey) {
};
}
// Filters for "company" table
if (tableKey == 'company') {
return {
is_manufacturer: {
type: 'bool',
title: '{% trans "Manufacturer" %}',
},
is_supplier: {
type: 'bool',
title: '{% trans "Supplier" %}',
},
is_customer: {
type: 'bool',
title: '{% trans "Customer" %}',
},
};
}
// Filters for the "Parts" table
if (tableKey == 'parts') {
return {