mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
visual improvements for table filter elements
This commit is contained in:
parent
d5ebdd035e
commit
f3782ae8bc
@ -281,23 +281,24 @@ function setupFilterList(tableKey, table, target) {
|
|||||||
// One blank slate, please
|
// One blank slate, please
|
||||||
element.empty();
|
element.empty();
|
||||||
|
|
||||||
element.append(`<button id='reload-${tableKey}' title='{% trans "Reload data" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-redo-alt'></span></button>`);
|
var buttons = '';
|
||||||
|
|
||||||
// Callback for reloading the table
|
buttons += `<button id='reload-${tableKey}' title='{% trans "Reload data" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-redo-alt'></span></button>`;
|
||||||
element.find(`#reload-${tableKey}`).click(function() {
|
|
||||||
$(table).bootstrapTable('refresh');
|
|
||||||
});
|
|
||||||
|
|
||||||
// If there are no filters defined for this table, exit now
|
// If there are filters defined for this table, add more buttons
|
||||||
if (jQuery.isEmptyObject(getAvailableTableFilters(tableKey))) {
|
if (!jQuery.isEmptyObject(getAvailableTableFilters(tableKey))) {
|
||||||
return;
|
buttons += `<button id='${add}' title='{% trans "Add new filter" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-filter'></span></button>`;
|
||||||
|
|
||||||
|
if (Object.keys(filters).length > 0) {
|
||||||
|
buttons += `<button id='${clear}' title='{% trans "Clear all filters" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-backspace icon-red'></span></button>`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
element.append(`<button id='${add}' title='{% trans "Add new filter" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-filter'></span></button>`);
|
element.html(`
|
||||||
|
<div class='btn-group' role='group'>
|
||||||
if (Object.keys(filters).length > 0) {
|
${buttons}
|
||||||
element.append(`<button id='${clear}' title='{% trans "Clear all filters" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-backspace icon-red'></span></button>`);
|
</div>
|
||||||
}
|
`);
|
||||||
|
|
||||||
for (var key in filters) {
|
for (var key in filters) {
|
||||||
var value = getFilterOptionValue(tableKey, key, filters[key]);
|
var value = getFilterOptionValue(tableKey, key, filters[key]);
|
||||||
@ -307,6 +308,11 @@ function setupFilterList(tableKey, table, target) {
|
|||||||
element.append(`<div title='${description}' class='filter-tag'>${title} = ${value}<span ${tag}='${key}' class='close'>x</span></div>`);
|
element.append(`<div title='${description}' class='filter-tag'>${title} = ${value}<span ${tag}='${key}' class='close'>x</span></div>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback for reloading the table
|
||||||
|
element.find(`#reload-${tableKey}`).click(function() {
|
||||||
|
$(table).bootstrapTable('refresh');
|
||||||
|
});
|
||||||
|
|
||||||
// Add a callback for adding a new filter
|
// Add a callback for adding a new filter
|
||||||
element.find(`#${add}`).click(function clicked() {
|
element.find(`#${add}`).click(function clicked() {
|
||||||
|
|
||||||
@ -316,10 +322,12 @@ function setupFilterList(tableKey, table, target) {
|
|||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
|
html += `<div class='input-group'>`;
|
||||||
html += generateAvailableFilterList(tableKey);
|
html += generateAvailableFilterList(tableKey);
|
||||||
html += generateFilterInput(tableKey);
|
html += generateFilterInput(tableKey);
|
||||||
|
|
||||||
html += `<button title='{% trans "Create filter" %}' class='btn btn-outline-secondary filter-button' id='${make}'><span class='fas fa-plus'></span></button>`;
|
html += `<button title='{% trans "Create filter" %}' class='btn btn-outline-secondary filter-button' id='${make}'><span class='fas fa-plus'></span></button>`;
|
||||||
|
html += `</div>`;
|
||||||
|
|
||||||
element.append(html);
|
element.append(html);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user