2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 13:56:30 +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

@ -19,6 +19,36 @@
{% block js_ready %}
{{ block.super }}
loadAttachmentTable(
'{% url "api-part-attachment-list" %}',
{
filters: {
part: {{ part.pk }},
},
onEdit: function(pk) {
var url = `/api/part/attachment/${pk}/`;
constructForm(url, {
fields: {
comment: {},
},
title: '{% trans "Edit Attachment" %}',
onSuccess: reloadAttachmentTable,
});
},
onDelete: function(pk) {
var url = `/api/part/attachment/${pk}/`;
constructForm(url, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
}
}
);
enableDragAndDrop(
'#attachment-dropzone',
'{% url "api-part-attachment-list" %}',
@ -28,7 +58,7 @@
},
label: 'attachment',
success: function(data, status, xhr) {
location.reload();
reloadAttachmentTable();
}
}
);
@ -47,43 +77,10 @@
hidden: true,
}
},
reload: true,
onSuccess: reloadAttachmentTable,
title: '{% trans "Add Attachment" %}',
}
)
});
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var button = $(this);
var pk = button.attr('pk');
var url = `/api/part/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/part/attachment/${pk}/`;
constructForm(url, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
reload: true,
});
});
$("#attachment-table").inventreeTable({
});
{% endblock %}