mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Refactor "uninstall stock item" form to use the API
This commit is contained in:
@ -81,7 +81,7 @@ function renderStockItem(name, data, parameters={}, options={}) {
|
||||
|
||||
var part_detail = '';
|
||||
|
||||
if (render_part_detail) {
|
||||
if (render_part_detail && data.part_detail) {
|
||||
part_detail = `<img src='${image}' class='select2-thumbnail'><span>${data.part_detail.full_name}</span> - `;
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
stockItemFields,
|
||||
stockLocationFields,
|
||||
stockStatusCodes,
|
||||
uninstallStockItem,
|
||||
*/
|
||||
|
||||
|
||||
@ -2630,13 +2631,10 @@ function loadInstalledInTable(table, options) {
|
||||
table.find('.button-uninstall').click(function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
launchModalForm(
|
||||
'{% url "stock-item-uninstall" %}',
|
||||
uninstallStockItem(
|
||||
pk,
|
||||
{
|
||||
data: {
|
||||
'items[]': pk,
|
||||
},
|
||||
success: function() {
|
||||
onSuccess: function(response) {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
}
|
||||
@ -2647,6 +2645,43 @@ function loadInstalledInTable(table, options) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Launch a dialog to uninstall a stock item from another stock item
|
||||
*/
|
||||
function uninstallStockItem(installed_item_id, options={}) {
|
||||
|
||||
constructForm(
|
||||
`/api/stock/${installed_item_id}/uninstall/`,
|
||||
{
|
||||
confirm: true,
|
||||
method: 'POST',
|
||||
title: '{% trans "Uninstall Stock Item" %}',
|
||||
fields: {
|
||||
location: {
|
||||
icon: 'fa-sitemap',
|
||||
},
|
||||
note: {},
|
||||
},
|
||||
preFormContent: function(opts) {
|
||||
var html = '';
|
||||
|
||||
if (installed_item_id == null) {
|
||||
html += `
|
||||
<div class='alert alert-block alert-info'>
|
||||
{% trans "Select stock item to uninstall" %}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
onSuccess: function(response) {
|
||||
handleFormSuccess(response, options);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Launch a dialog to install a stock item into another stock item
|
||||
*/
|
||||
|
Reference in New Issue
Block a user