2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Refactoring "attachment" tables to use the API

- Part attachments
- StockItem attachments
- PurchaseOrder attachments
- SalesOrder attachments
- BuildOrder attachments
This commit is contained in:
Oliver
2021-06-30 17:40:44 +10:00
parent 682b2b4b2f
commit 9b4db43232
9 changed files with 234 additions and 193 deletions

View File

@ -28,11 +28,41 @@ enableDragAndDrop(
},
label: 'attachment',
success: function(data, status, xhr) {
location.reload();
reloadAttachmentTable();
}
}
);
loadAttachmentTable(
'{% url "api-stock-attachment-list" %}',
{
filters: {
item: {{ item.pk }},
},
onEdit: function(pk) {
var url = `/api/stock/attachment/${pk}/`;
constructForm(url, {
fields: {
comment: {},
},
title: '{% trans "Edit Attachment" %}',
onSuccess: reloadAttachmentTable
});
},
onDelete: function(pk) {
var url = `/api/stock/attachment/${pk}/`;
constructForm(url, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
}
}
);
$("#new-attachment").click(function() {
constructForm(
@ -53,39 +83,4 @@ $("#new-attachment").click(function() {
);
});
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var button = $(this);
var pk = button.attr('pk');
var url = `/api/stock/attachment/${pk}/`;
constructForm(url, {
fields: {
attachment: {},
comment: {},
},
title: '{% trans "Edit Attachment" %}',
reload: true
});
});
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var button = $(this);
var pk = button.attr('pk');
var url = `/api/stock/attachment/${pk}/`;
constructForm(url, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
reload: true,
});
});
$("#attachment-table").inventreeTable({
});
{% endblock %}