2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-09 07:00:56 +00:00

Table custom buttons (#5075)

* Add generic implementation for barcode actions

- Commonize code against tables
- Cleaner UI
- Better code
- Will make future react refactor easier

* Add permissions.js

- Separate .js file for dynamically checking permissions

* Update stock table to use client-side actions

* API endpoint for bulk category adjustment

* Bug fix for purchase_order.js

- Prevent some really strange API calls

* Refactor actions for part table

- Now done dynamically

* Refactor actions for the attachment tables

* Refactor actions for build output table

* Increment API version

* Cleanup janky button

* Refactor supplier part table

* Refactor manufacturer part table

* Remove linkButtonsToSelection

- no longer needed
- Cleanup, yay!

* Cleanup purchase order line table

* Refactor BOM table buttons

* JS linting

* Further cleanup

* Template cleanup

- remove extra div elements

* js linting

* js fix
This commit is contained in:
Oliver
2023-06-20 07:45:35 +10:00
committed by GitHub
parent 13389845b1
commit 4c9d4add2c
43 changed files with 837 additions and 905 deletions

View File

@ -18,6 +18,7 @@
makeDeleteButton,
makeEditButton,
makeIconBadge,
orderParts,
renderClipboard,
renderDate,
renderLink,
@ -1213,6 +1214,43 @@ function deleteManufacturerPartParameters(selections, options={}) {
}
// Construct a set of actions for the manufacturer part table
function makeManufacturerPartActions(options={}) {
return [
{
label: 'order',
title: '{% trans "Order parts" %}',
icon: 'fa-shopping-cart',
permission: 'purchase_order.add',
callback: function(data) {
let parts = [];
data.forEach(function(item) {
let part = item.part_detail;
part.manufacturer_part = item.pk;
parts.push(part);
});
orderParts(parts);
},
},
{
label: 'delete',
title: '{% trans "Delete manufacturer parts" %}',
icon: 'fa-trash-alt icon-red',
permission: 'purchase_order.delete',
callback: function(data) {
deleteManufacturerParts(data, {
success: function() {
$('#manufacturer-part-table').bootstrapTable('refresh');
}
});
},
}
];
}
/*
* Load manufacturer part table
*/
@ -1226,7 +1264,18 @@ function loadManufacturerPartTable(table, url, options) {
var filterTarget = options.filterTarget || '#filter-list-manufacturer-part';
setupFilterList('manufacturer-part', $(table), filterTarget);
setupFilterList('manufacturer-part', $(table), filterTarget, {
custom_actions: [
{
label: 'manufacturer-part',
title: '{% trans "Manufacturer part actions" %}',
icon: 'fa-tools',
actions: makeManufacturerPartActions({
manufacturer_id: options.params.manufacturer,
})
}
]
});
$(table).inventreeTable({
url: url,
@ -1453,6 +1502,43 @@ function loadManufacturerPartParameterTable(table, url, options) {
}
// Construct a set of actions for the supplier part table
function makeSupplierPartActions(options={}) {
return [
{
label: 'order',
title: '{% trans "Order parts" %}',
icon: 'fa-shopping-cart',
permission: 'purchase_order.add',
callback: function(data) {
let parts = []
data.forEach(function(entry) {
parts.push(entry.part_detail);
});
orderParts(parts, {
supplier: options.supplier_id,
});
},
},
{
label: 'delete',
title: '{% trans "Delete supplier parts" %}',
icon: 'fa-trash-alt icon-red',
permission: 'purchase_order.delete',
callback: function(data) {
deleteSupplierParts(data, {
success: function() {
$('#supplier-part-table').bootstrapTable('refresh');
}
});
},
}
];
}
/*
* Load supplier part table
*/
@ -1464,7 +1550,18 @@ function loadSupplierPartTable(table, url, options) {
// Load filters
var filters = loadTableFilters('supplierpart', params);
setupFilterList('supplierpart', $(table));
setupFilterList('supplierpart', $(table), '#filter-list-supplier-part', {
custom_actions: [
{
label: 'supplier-part',
title: '{% trans "Supplier part actions" %}',
icon: 'fa-tools',
actions: makeSupplierPartActions({
supplier_id: options.params.supplier,
}),
}
]
});
$(table).inventreeTable({
url: url,