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:
@ -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 %}
|
Reference in New Issue
Block a user