Add action buttons to the sales order page

This commit is contained in:
Oliver Walters 2020-04-21 22:02:17 +10:00
parent 15166c7797
commit b75c343236
3 changed files with 42 additions and 1 deletions

View File

@ -78,6 +78,22 @@ function getImageUrlFromTransfer(transfer) {
return url;
}
function makeIconButton(icon, id, opts) {
// Construct an 'icon button' using the fontawesome set
var options = opts || {};
var title = options.title || '';
var html = '';
html += `<button id='${id}' class='btn btn-default btn-glyph' title='${title}'>`;
html += `<span class='fas ${icon}'></span>`;
html += `</button>`;
return html;
}
function makeProgressBar(value, maximum, opts) {
/*
* Render a progessbar!

View File

@ -156,7 +156,30 @@ $("#so-lines-table").inventreeTable({
{
field: 'buttons',
formatter: function(value, row, index, field) {
return '-';
var html = '';
var pk = row.pk;
if (row.part) {
var part = row.part_detail;
html = `<div class='btn-group float-right' role='group'>`;
html += makeIconButton('fa-plus', `button-add-${pk}`);
if (part.purchaseable) {
html += makeIconButton('fa-shopping-cart', `button-buy-${pk}`);
}
if (part.assembly) {
html += makeIconButton('fa-tools', `button-build-${pk}`);
}
html += `</div>`;
}
return html;
}
},
],

View File

@ -65,6 +65,8 @@ class PartBriefSerializer(InvenTreeModelSerializer):
'thumbnail',
'active',
'assembly',
'purchaseable',
'salable',
'virtual',
]