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

@ -34,6 +34,35 @@ enableDragAndDrop(
}
);
loadAttachmentTable(
'{% url "api-po-attachment-list" %}',
{
filters: {
order: {{ order.pk }},
},
onEdit: function(pk) {
var url = `/api/order/po/attachment/${pk}/`;
constructForm(url, {
fields: {
comment: {},
},
onSuccess: reloadAttachmentTable,
title: '{% trans "Edit Attachment" %}',
});
},
onDelete: function(pk) {
constructForm(`/api/order/po/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
}
}
);
$("#new-attachment").click(function() {
constructForm('{% url "api-po-attachment-list" %}', {
@ -51,37 +80,4 @@ $("#new-attachment").click(function() {
});
});
$("#attachment-table").on('click', '.attachment-edit-button', function() {
var button = $(this);
var pk = button.attr('pk');
var url = `/api/order/po/attachment/${pk}/`;
constructForm(url, {
fields: {
attachment: {},
comment: {},
},
reload: true,
title: '{% trans "Edit Attachment" %}',
});
});
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var button = $(this);
var pk = button.attr('pk');
constructForm(`/api/order/po/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
reload: true,
});
});
$("#attachment-table").inventreeTable({
});
{% endblock %}

View File

@ -35,6 +35,36 @@ enableDragAndDrop(
}
);
loadAttachmentTable(
'{% url "api-so-attachment-list" %}',
{
filters: {
order: {{ order.pk }},
},
onEdit: function(pk) {
var url = `/api/order/so/attachment/${pk}/`;
constructForm(url, {
fields: {
comment: {},
},
onSuccess: reloadAttachmentTable,
title: '{% trans "Edit Attachment" %}',
});
},
onDelete: function(pk) {
var pk = button.attr('pk');
constructForm(`/api/order/so/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
}
}
);
$("#new-attachment").click(function() {
constructForm('{% url "api-so-attachment-list" %}', {
@ -47,42 +77,9 @@ $("#new-attachment").click(function() {
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/order/so/attachment/${pk}/`;
constructForm(url, {
fields: {
attachment: {},
comment: {},
},
reload: true,
title: '{% trans "Edit Attachment" %}',
});
});
$("#attachment-table").on('click', '.attachment-delete-button', function() {
var button = $(this);
var pk = button.attr('pk');
constructForm(`/api/order/so/attachment/${pk}/`, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
reload: true,
});
});
$("#attachment-table").inventreeTable({
});
{% endblock %}