mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-12 07:54:14 +00:00
Converting more forms to the API (#3181)
* Delete category via the API * Delete StockLocation via the API * Delete StockItem via the API - Removes the final instance of AjaxDelete * Remove URL path * Add missing code
This commit is contained in:
@ -39,6 +39,8 @@
|
||||
assignStockToCustomer,
|
||||
createNewStockItem,
|
||||
createStockLocation,
|
||||
deleteStockItem,
|
||||
deleteStockLocation,
|
||||
duplicateStockItem,
|
||||
editStockItem,
|
||||
editStockLocation,
|
||||
@ -156,6 +158,34 @@ function createStockLocation(options={}) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Launch an API form to delete a StockLocation
|
||||
*/
|
||||
function deleteStockLocation(pk, options={}) {
|
||||
var url = `/api/stock/location/${pk}/`;
|
||||
|
||||
var html = `
|
||||
<div class='alert alert-block alert-danger'>
|
||||
{% trans "Are you sure you want to delete this stock location?" %}
|
||||
<ul>
|
||||
<li>{% trans "Any child locations will be moved to the parent of this location" %}</li>
|
||||
<li>{% trans "Any stock items in this location will be moved to the parent of this location" %}</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
||||
constructForm(url, {
|
||||
title: '{% trans "Delete Stock Location" %}',
|
||||
method: 'DELETE',
|
||||
preFormContent: html,
|
||||
onSuccess: function(response) {
|
||||
handleFormSuccess(response, options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function stockItemFields(options={}) {
|
||||
var fields = {
|
||||
part: {
|
||||
@ -328,6 +358,28 @@ function duplicateStockItem(pk, options) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Launch a modal form to delete a given StockItem
|
||||
*/
|
||||
function deleteStockItem(pk, options={}) {
|
||||
var url = `/api/stock/${pk}/`;
|
||||
|
||||
var html = `
|
||||
<div class='alert alert-block alert-danger'>
|
||||
{% trans "Are you sure you want to delete this stock item?" %}
|
||||
</div>`;
|
||||
|
||||
constructForm(url, {
|
||||
method: 'DELETE',
|
||||
title: '{% trans "Delete Stock Item" %}',
|
||||
preFormContent: html,
|
||||
onSuccess: function(response) {
|
||||
handleFormSuccess(response, options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Launch a modal form to edit a given StockItem
|
||||
*/
|
||||
|
Reference in New Issue
Block a user