2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 04:25:42 +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

@ -47,37 +47,38 @@ $('#new-attachment').click(function() {
}
},
method: 'POST',
reload: true,
onSuccess: reloadAttachmentTable,
title: '{% trans "Add Attachment" %}',
});
});
// Callback for editing an attachment
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var pk = $(this).attr('pk');
constructForm(`/api/build/attachment/${pk}/`, {
fields: {
attachment: {},
comment: {},
loadAttachmentTable(
'{% url "api-build-attachment-list" %}',
{
filters: {
build: {{ build.pk }},
},
reload: true,
title: '{% trans "Edit Attachment" %}',
});
});
onEdit: function(pk) {
var url = `/api/build/attachment/${pk}/`;
// Callback for deleting an attachment
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var pk = $(this).attr('pk');
constructForm(url, {
fields: {
comment: {},
},
onSuccess: reloadAttachmentTable,
title: '{% trans "Edit Attachment" %}',
});
},
onDelete: function(pk) {
constructForm(`/api/build/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
reload: true,
});
});
$("#attachment-table").inventreeTable({});
constructForm(`/api/build/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
}
}
);
{% endblock %}