2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +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:
Oliver
2022-06-11 21:53:26 +10:00
committed by GitHub
parent 63f1e58ca9
commit 090f4f4387
14 changed files with 100 additions and 249 deletions

View File

@ -21,6 +21,7 @@
/* exported
deletePart,
deletePartCategory,
duplicateBom,
duplicatePart,
editCategory,
@ -317,7 +318,31 @@ function editCategory(pk) {
title: '{% trans "Edit Part Category" %}',
reload: true,
});
}
/*
* Delete a PartCategory via the API
*/
function deletePartCategory(pk, options={}) {
var url = `/api/part/category/${pk}/`;
var html = `
<div class='alert alert-block alert-danger'>
{% trans "Are you sure you want to delete this part category?" %}
<ul>
<li>{% trans "Any child categories will be moved to the parent of this category" %}</li>
<li>{% trans "Any parts in this category will be moved to the parent of this category" %}</li>
</ul>
</div>`;
constructForm(url, {
title: '{% trans "Delete Part Category" %}',
method: 'DELETE',
preFormContent: html,
onSuccess: function(response) {
handleFormSuccess(response, options);
}
});
}

View File

@ -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
*/