mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add edit and delete buttons for supplier-part table
This commit is contained in:
parent
56fa6c512b
commit
29d7cb40e1
@ -58,6 +58,26 @@ function createSupplierPart(options={}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function editSupplierPart(part, options={}) {
|
||||||
|
|
||||||
|
constructForm(`/api/company/part/${part}/`, {
|
||||||
|
fields: supplierPartFields(),
|
||||||
|
title: '{% trans "Edit Supplier Part" %}',
|
||||||
|
onSuccess: options.onSuccess
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function deleteSupplierPart(part, options={}) {
|
||||||
|
|
||||||
|
constructForm(`/api/company/part/${part}/`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
title: '{% trans "Delete Supplier Part" %}',
|
||||||
|
onSuccess: options.onSuccess,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns a default form-set for creating / editing a Company object
|
// Returns a default form-set for creating / editing a Company object
|
||||||
function companyFormFields(options={}) {
|
function companyFormFields(options={}) {
|
||||||
|
|
||||||
@ -627,7 +647,51 @@ function loadSupplierPartTable(table, url, options) {
|
|||||||
field: 'packaging',
|
field: 'packaging',
|
||||||
title: '{% trans "Packaging" %}',
|
title: '{% trans "Packaging" %}',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'actions',
|
||||||
|
title: '',
|
||||||
|
sortable: false,
|
||||||
|
switchable: false,
|
||||||
|
formatter: function(value, row) {
|
||||||
|
var pk = row.pk;
|
||||||
|
|
||||||
|
var html = `<div class='btn-group float-right' role='group'>`;
|
||||||
|
|
||||||
|
html += makeIconButton('fa-edit icon-blue', 'button-supplier-part-edit', pk, '{% trans "Edit supplier part" %}');
|
||||||
|
html += makeIconButton('fa-trash-alt icon-red', 'button-supplier-part-delete', pk, '{% trans "Delete manufacturer part" %}');
|
||||||
|
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
onPostBody: function() {
|
||||||
|
// Callbacks
|
||||||
|
$(table).find('.button-supplier-part-edit').click(function() {
|
||||||
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
|
editSupplierPart(
|
||||||
|
pk,
|
||||||
|
{
|
||||||
|
onSuccess: function() {
|
||||||
|
$(table).bootstrapTable('refresh');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(table).find('.button-supplier-part-delete').click(function() {
|
||||||
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
|
deleteSupplierPart(
|
||||||
|
pk,
|
||||||
|
{
|
||||||
|
onSuccess: function() {
|
||||||
|
$(table).bootstrapTable('refresh');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user