mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 21:16:46 +00:00
Add action buttons to order or build stock
This commit is contained in:
parent
bfbcbe252b
commit
0c053c6339
@ -870,6 +870,44 @@ function loadBuildPartsTable(table, options={}) {
|
|||||||
filters[key] = params[key];
|
filters[key] = params[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupTableCallbacks() {
|
||||||
|
// Register button callbacks once the table data are loaded
|
||||||
|
|
||||||
|
// Callback for 'buy' button
|
||||||
|
$(table).find('.button-buy').click(function() {
|
||||||
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
|
var idx = $(this).closest('tr').attr('data-index');
|
||||||
|
var row = $(table).bootstrapTable('getData')[idx];
|
||||||
|
|
||||||
|
launchModalForm('{% url "order-parts" %}', {
|
||||||
|
data: {
|
||||||
|
parts: [
|
||||||
|
pk,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Callback for 'build' button
|
||||||
|
$(table).find('.button-build').click(function() {
|
||||||
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
|
// Extract row data from the table
|
||||||
|
var idx = $(this).closest('tr').attr('data-index');
|
||||||
|
var row = $(table).bootstrapTable('getData')[idx];
|
||||||
|
|
||||||
|
// Launch form to create a new build order
|
||||||
|
launchModalForm('{% url "build-create" %}', {
|
||||||
|
follow: true,
|
||||||
|
data: {
|
||||||
|
part: pk,
|
||||||
|
parent: options.build,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var columns = [
|
var columns = [
|
||||||
{
|
{
|
||||||
field: 'sub_part',
|
field: 'sub_part',
|
||||||
@ -939,7 +977,21 @@ function loadBuildPartsTable(table, options={}) {
|
|||||||
title: '{% trans "Actions" %}',
|
title: '{% trans "Actions" %}',
|
||||||
switchable: false,
|
switchable: false,
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
// TODO - Add actions to build / order stock
|
|
||||||
|
// Generate action buttons against the part
|
||||||
|
var html = `<div class='btn-group float-right' role='group'>`;
|
||||||
|
|
||||||
|
if (row.sub_part_detail.assembly) {
|
||||||
|
html += makeIconButton('fa-tools icon-blue', 'button-build', row.sub_part, '{% trans "Build stock" %}');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row.sub_part_detail.purchaseable) {
|
||||||
|
html += makeIconButton('fa-shopping-cart icon-blue', 'button-buy', row.sub_part, '{% trans "Order stock" %}');
|
||||||
|
}
|
||||||
|
|
||||||
|
html += `</div>`;
|
||||||
|
|
||||||
|
return html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -950,6 +1002,7 @@ function loadBuildPartsTable(table, options={}) {
|
|||||||
name: 'build-parts',
|
name: 'build-parts',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
search: true,
|
search: true,
|
||||||
|
onPostBody: setupTableCallbacks,
|
||||||
rowStyle: function(row, index) {
|
rowStyle: function(row, index) {
|
||||||
var classes = [];
|
var classes = [];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user