mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 20:46:47 +00:00
Refactorin'
- Add the "download" button into the "filters" list - Cuts down on boilerplate code
This commit is contained in:
parent
85e9c4d3ca
commit
ba406a4da9
@ -170,9 +170,6 @@
|
|||||||
<div class='panel-content'>
|
<div class='panel-content'>
|
||||||
<div id='assigned-stock-button-toolbar'>
|
<div id='assigned-stock-button-toolbar'>
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
<button class='btn btn-outline-secondary filter-button' id='assigned-stock-export' title='{% trans "Export Stock Information" %}'>
|
|
||||||
<span class='fas fa-download'></span>
|
|
||||||
</button>
|
|
||||||
{% include "filter_list.html" with id="customerstock" %}
|
{% include "filter_list.html" with id="customerstock" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -233,10 +230,6 @@
|
|||||||
filterTarget: '#filter-list-customerstock',
|
filterTarget: '#filter-list-customerstock',
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#assigned-stock-export').click(function() {
|
|
||||||
downloadTableData($('#assigned-stock-table'));
|
|
||||||
});
|
|
||||||
|
|
||||||
{% if company.is_customer %}
|
{% if company.is_customer %}
|
||||||
loadSalesOrderTable("#sales-order-table", {
|
loadSalesOrderTable("#sales-order-table", {
|
||||||
url: "{% url 'api-so-list' %}",
|
url: "{% url 'api-so-list' %}",
|
||||||
@ -291,10 +284,6 @@
|
|||||||
filterKey: "companystock",
|
filterKey: "companystock",
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#stock-export").click(function() {
|
|
||||||
downloadTableData($("#stock-table"));
|
|
||||||
});
|
|
||||||
|
|
||||||
{% if company.is_manufacturer %}
|
{% if company.is_manufacturer %}
|
||||||
|
|
||||||
function reloadManufacturerPartTable() {
|
function reloadManufacturerPartTable() {
|
||||||
|
@ -308,10 +308,6 @@ loadStockTable($("#stock-table"), {
|
|||||||
url: "{% url 'api-stock-list' %}",
|
url: "{% url 'api-stock-list' %}",
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#stock-export").click(function() {
|
|
||||||
downloadTableData($("#stock-table"));
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#item-create").click(function() {
|
$("#item-create").click(function() {
|
||||||
createNewStockItem({
|
createNewStockItem({
|
||||||
data: {
|
data: {
|
||||||
|
@ -164,9 +164,6 @@
|
|||||||
<div id='part-button-toolbar'>
|
<div id='part-button-toolbar'>
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
<button id='part-export' class='btn btn-outline-secondary' type='button' title='{% trans "Export part data" %}'>
|
|
||||||
<span class='fas fa-file-download'></span>
|
|
||||||
</button>
|
|
||||||
<button id='part-options' class='btn btn-primary dropdown-toggle' type='button' data-bs-toggle="dropdown">
|
<button id='part-options' class='btn btn-primary dropdown-toggle' type='button' data-bs-toggle="dropdown">
|
||||||
{% trans "Options" %}
|
{% trans "Options" %}
|
||||||
</button>
|
</button>
|
||||||
@ -290,10 +287,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#part-export").click(function() {
|
|
||||||
downloadTableData($('#part-table'));
|
|
||||||
});
|
|
||||||
|
|
||||||
{% if roles.part.add %}
|
{% if roles.part.add %}
|
||||||
$("#part-create").click(function() {
|
$("#part-create").click(function() {
|
||||||
|
|
||||||
|
@ -832,11 +832,6 @@
|
|||||||
url: "{% url 'api-stock-list' %}",
|
url: "{% url 'api-stock-list' %}",
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#stock-export").click(function() {
|
|
||||||
|
|
||||||
downloadTableData($("#stock-table"));
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#item-create').click(function () {
|
$('#item-create').click(function () {
|
||||||
createNewStockItem({
|
createNewStockItem({
|
||||||
data: {
|
data: {
|
||||||
|
@ -239,10 +239,6 @@
|
|||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
$("#stock-export").click(function() {
|
|
||||||
downloadTableData($('#stock-table'));
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#location-create').click(function () {
|
$('#location-create').click(function () {
|
||||||
|
|
||||||
createStockLocation({
|
createStockLocation({
|
||||||
|
@ -256,7 +256,7 @@ function generateFilterInput(tableKey, filterKey) {
|
|||||||
* @param {*} table - bootstrapTable element to update
|
* @param {*} table - bootstrapTable element to update
|
||||||
* @param {*} target - name of target element on page
|
* @param {*} target - name of target element on page
|
||||||
*/
|
*/
|
||||||
function setupFilterList(tableKey, table, target) {
|
function setupFilterList(tableKey, table, target, options={}) {
|
||||||
|
|
||||||
var addClicked = false;
|
var addClicked = false;
|
||||||
|
|
||||||
@ -283,6 +283,11 @@ function setupFilterList(tableKey, table, target) {
|
|||||||
|
|
||||||
var buttons = '';
|
var buttons = '';
|
||||||
|
|
||||||
|
// Add download button
|
||||||
|
if (options.download) {
|
||||||
|
buttons += `<button id='download-${tableKey}' title='{% trans "Download data" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-download'></span></button>`;
|
||||||
|
}
|
||||||
|
|
||||||
buttons += `<button id='reload-${tableKey}' title='{% trans "Reload data" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-redo-alt'></span></button>`;
|
buttons += `<button id='reload-${tableKey}' title='{% trans "Reload data" %}' class='btn btn-outline-secondary filter-button'><span class='fas fa-redo-alt'></span></button>`;
|
||||||
|
|
||||||
// If there are filters defined for this table, add more buttons
|
// If there are filters defined for this table, add more buttons
|
||||||
@ -295,7 +300,7 @@ function setupFilterList(tableKey, table, target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
element.html(`
|
element.html(`
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group filter-group' role='group'>
|
||||||
${buttons}
|
${buttons}
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
@ -322,6 +327,13 @@ function setupFilterList(tableKey, table, target) {
|
|||||||
$(table).bootstrapTable('refresh');
|
$(table).bootstrapTable('refresh');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add a callback for downloading table data
|
||||||
|
if (options.download) {
|
||||||
|
element.find(`#download-${tableKey}`).click(function() {
|
||||||
|
downloadTableData($(table));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 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() {
|
||||||
|
|
||||||
|
@ -1218,7 +1218,7 @@ function loadPartTable(table, url, options={}) {
|
|||||||
filters[key] = params[key];
|
filters[key] = params[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFilterList('parts', $(table), options.filterTarget || null);
|
setupFilterList('parts', $(table), options.filterTarget, {download: true});
|
||||||
|
|
||||||
var columns = [
|
var columns = [
|
||||||
{
|
{
|
||||||
|
@ -1571,7 +1571,7 @@ function loadStockTable(table, options) {
|
|||||||
original[k] = params[k];
|
original[k] = params[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFilterList(filterKey, table, filterTarget);
|
setupFilterList(filterKey, table, filterTarget, {download: true});
|
||||||
|
|
||||||
// Override the default values, or add new ones
|
// Override the default values, or add new ones
|
||||||
for (var key in params) {
|
for (var key in params) {
|
||||||
|
@ -11,9 +11,6 @@
|
|||||||
<div id='{{ prefix }}button-toolbar'>
|
<div id='{{ prefix }}button-toolbar'>
|
||||||
<div class='button-toolbar container-fluid' style='float: right;'>
|
<div class='button-toolbar container-fluid' style='float: right;'>
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
<button class='btn btn-outline-secondary' id='stock-export' title='{% trans "Export Stock Information" %}'>
|
|
||||||
<span class='fas fa-download'></span>
|
|
||||||
</button>
|
|
||||||
{% if barcodes %}
|
{% if barcodes %}
|
||||||
<!-- Barcode actions menu -->
|
<!-- Barcode actions menu -->
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user