mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add ability to delete multiple selected manufacturer part parameters
This commit is contained in:
parent
8a29a3de0f
commit
225162ab8e
@ -42,8 +42,11 @@
|
|||||||
<button class='btn btn-success' id='parameter-create'>
|
<button class='btn btn-success' id='parameter-create'>
|
||||||
<span class='fas fa-plus-circle'></span> {% trans "New Parameter" %}
|
<span class='fas fa-plus-circle'></span> {% trans "New Parameter" %}
|
||||||
</button>
|
</button>
|
||||||
<div id='param-dropdown' class='btn-group'>
|
<div id='opt-dropdown' class="btn-group">
|
||||||
<!-- TODO -->
|
<button id='parameter-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href='#' id='multi-parameter-delete' title='{% trans "Delete parameters" %}'>{% trans "Delete" %}</a></li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -115,6 +118,46 @@ $("#supplier-part-delete").click(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#multi-parameter-delete").click(function() {
|
||||||
|
|
||||||
|
var selections = $("#parameter-table").bootstrapTable("getSelections");
|
||||||
|
|
||||||
|
var text = `
|
||||||
|
<div class ='alert alert-block alert-danger'>
|
||||||
|
<p>{% trans "Selected parameters will be deleted" %}:</p>
|
||||||
|
<ul>`;
|
||||||
|
|
||||||
|
selections.forEach(function(item) {
|
||||||
|
text += `<li>${item.name} - <i>${item.value}</i></li>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
text += `
|
||||||
|
</ul>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
showQuestionDialog(
|
||||||
|
'{% trans "Delete Parameters" %}',
|
||||||
|
text,
|
||||||
|
{
|
||||||
|
accept_text: '{% trans "Delete" %}',
|
||||||
|
accept: function() {
|
||||||
|
// Delete each parameter via the API
|
||||||
|
var requests = [];
|
||||||
|
|
||||||
|
selections.forEach(function(item) {
|
||||||
|
var url = `/api/company/part/manufacturer/parameter/${item.pk}/`;
|
||||||
|
|
||||||
|
requests.push(inventreeDelete(url));
|
||||||
|
});
|
||||||
|
|
||||||
|
$.when.apply($, requests).then(function() {
|
||||||
|
$('#parameter-table').bootstrapTable('refresh');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
loadSupplierPartTable(
|
loadSupplierPartTable(
|
||||||
"#supplier-table",
|
"#supplier-table",
|
||||||
"{% url 'api-supplier-part-list' %}",
|
"{% url 'api-supplier-part-list' %}",
|
||||||
@ -140,5 +183,5 @@ loadManufacturerPartParameterTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
linkButtonsToSelection($("#supplier-table"), ['#supplier-part-options'])
|
linkButtonsToSelection($("#supplier-table"), ['#supplier-part-options'])
|
||||||
|
linkButtonsToSelection($("#parameter-table"), ['#parameter-options'])
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -123,7 +123,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Wait for *all* the requests to complete
|
// Wait for *all* the requests to complete
|
||||||
$.when(requests).then(function() {
|
$.when.apply($, requests).then(function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ function deleteManufacturerParts(selections, options={}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Wait for all the requests to complete
|
// Wait for all the requests to complete
|
||||||
$.when(requests).then(function() {
|
$.when.apply($, requests).then(function() {
|
||||||
|
|
||||||
if (options.onSuccess) {
|
if (options.onSuccess) {
|
||||||
options.onSuccess();
|
options.onSuccess();
|
||||||
@ -352,7 +352,7 @@ function loadManufacturerPartParameterTable(table, url, options) {
|
|||||||
{
|
{
|
||||||
checkbox: true,
|
checkbox: true,
|
||||||
switchable: false,
|
switchable: false,
|
||||||
visible: false,
|
visible: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
|
@ -906,7 +906,7 @@ function loadStockTable(table, options) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$.when(requests).then(function() {
|
$.when.apply($, requests).then(function() {
|
||||||
$("#stock-table").bootstrapTable('refresh');
|
$("#stock-table").bootstrapTable('refresh');
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user