diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 7564e7864e..8a00c1c5e6 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -3,44 +3,360 @@ {% load static %} {% load inventree_extras %} {% load i18n %} +{% load markdownify %} {% block menubar %} -{% include "stock/navbar.html" with tab="tracking" %} +{% include "stock/navbar.html" %} {% endblock %} -{% block heading %} -{% trans "Stock Tracking Information" %} -{% endblock %} +{% block page_content %} -{% block details %} +
+
+

{% trans "Stock Tracking Information" %}

+
+
+ {% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} + {% if owner_control.value == "True" %} + {% authorized_owners item.owner as owners %} + {% endif %} + + {% if owner_control.value == "False" or owner_control.value == "True" and user in owners %} + {% if roles.stock.change and not item.is_building %} +
+
+ +
+
+ {% endif %} + {% endif %} + +
+
+
-{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} -{% if owner_control.value == "True" %} - {% authorized_owners item.owner as owners %} -{% endif %} +
+
+

{% trans "Child Stock Items" %}

+
+
+ {% if item.child_count > 0 %} + {% include "stock_table.html" with prefix="childs-" %} + {% else %} +
+ {% trans "This stock item does not have any child items" %} +
+ {% endif %} +
+
-
+
+
+

{% trans "Test Data" %}

+
+
+
+
+
+ {% if user.is_staff %} + + {% endif %} + + +
+
+ +
+
+
+ +
+
+
- -{% if owner_control.value == "False" or owner_control.value == "True" and user in owners %} - {% if roles.stock.change and not item.is_building %} -
-
- +
+
+

{% trans "Attachments" %}

+
+
+ {% include "attachment_table.html" %} +
+
+ +
+
+
+
+

{% trans "Stock Item Notes" %}

+
+
+
+ +
+
- {% endif %} -{% endif %} - -
+
+ {% if item.notes %} + {{ item.notes | markdownify }} + {% endif %} +
+
+ +
+
+

{% trans "Installed Stock Items" %}

+
+
+
+
+
{% endblock %} {% block js_ready %} {{ block.super }} + loadInstalledInTable( + $('#installed-table'), + { + stock_item: {{ item.pk }}, + part: {{ item.part.pk }}, + quantity: {{ item.quantity }}, + } + ); + + $('#multi-item-uninstall').click(function() { + + var selections = $('#installed-table').bootstrapTable('getSelections'); + + var items = []; + + selections.forEach(function(item) { + items.push(item.pk); + }); + + launchModalForm( + "{% url 'stock-item-uninstall' %}", + { + data: { + 'items[]': items, + }, + reload: true, + } + ); + }); + + $('#edit-notes').click(function() { + constructForm('{% url "api-stock-detail" item.pk %}', { + fields: { + notes: { + multiline: true, + } + }, + title: '{% trans "Edit Notes" %}', + reload: true, + }); + }); + + enableDragAndDrop( + '#attachment-dropzone', + "{% url 'api-stock-attachment-list' %}", + { + data: { + stock_item: {{ item.id }}, + }, + label: 'attachment', + success: function(data, status, xhr) { + reloadAttachmentTable(); + } + } + ); + + loadAttachmentTable( + '{% url "api-stock-attachment-list" %}', + { + filters: { + stock_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( + '{% url "api-stock-attachment-list" %}', + { + method: 'POST', + fields: { + attachment: {}, + comment: {}, + stock_item: { + value: {{ item.pk }}, + hidden: true, + }, + }, + reload: true, + title: '{% trans "Add Attachment" %}', + } + ); + }); + + loadStockTestResultsTable( + $("#test-result-table"), { + part: {{ item.part.id }}, + stock_item: {{ item.id }}, + } + ); + + function reloadTable() { + $("#test-result-table").bootstrapTable("refresh"); + } + + {% if item.has_test_reports %} + $("#test-report").click(function() { + printTestReports([{{ item.pk }}]); + }); + {% endif %} + + {% if user.is_staff %} + $("#delete-test-results").click(function() { + launchModalForm( + "{% url 'stock-item-delete-test-data' item.id %}", + { + success: reloadTable, + } + ); + }); + {% endif %} + + $("#add-test-result").click(function() { + + constructForm('{% url "api-stock-test-result-list" %}', { + method: 'POST', + fields: { + test: {}, + result: {}, + value: {}, + attachment: {}, + notes: {}, + stock_item: { + value: {{ item.pk }}, + hidden: true, + } + }, + title: '{% trans "Add Test Result" %}', + onSuccess: reloadTable, + }); + }); + + $("#test-result-table").on('click', '.button-test-add', function() { + var button = $(this); + + var test_name = button.attr('pk'); + + constructForm('{% url "api-stock-test-result-list" %}', { + method: 'POST', + fields: { + test: { + value: test_name, + }, + result: {}, + value: {}, + attachment: {}, + notes: {}, + stock_item: { + value: {{ item.pk }}, + hidden: true, + } + }, + title: '{% trans "Add Test Result" %}', + onSuccess: reloadTable, + }); + }); + + $("#test-result-table").on('click', '.button-test-edit', function() { + var button = $(this); + + var pk = button.attr('pk'); + + var url = `/api/stock/test/${pk}/`; + + constructForm(url, { + fields: { + test: {}, + result: {}, + value: {}, + attachment: {}, + notes: {}, + }, + title: '{% trans "Edit Test Result" %}', + onSuccess: reloadTable, + }); + }); + + $("#test-result-table").on('click', '.button-test-delete', function() { + var button = $(this); + + var pk = button.attr('pk'); + + var url = `/api/stock/test/${pk}/`; + + constructForm(url, { + method: 'DELETE', + title: '{% trans "Delete Test Result" %}', + onSuccess: reloadTable, + }); + }); + + {% if item.child_count > 0 %} + loadStockTable($("#childs-stock-table"), { + params: { + location_detail: true, + part_detail: false, + ancestor: {{ item.id }}, + }, + name: 'item-childs', + groupByField: 'location', + buttons: [ + '#stock-options', + ], + url: "{% url 'api-stock-list' %}", + }); + {% endif %} + $("#new-entry").click(function() { launchModalForm( "{% url 'stock-tracking-create' item.id %}", diff --git a/InvenTree/stock/templates/stock/item_attachments.html b/InvenTree/stock/templates/stock/item_attachments.html deleted file mode 100644 index 5f9cfdee19..0000000000 --- a/InvenTree/stock/templates/stock/item_attachments.html +++ /dev/null @@ -1,86 +0,0 @@ -{% extends "stock/item_base.html" %} - -{% load static %} -{% load i18n %} - -{% block menubar %} -{% include "stock/navbar.html" with tab='attachments' %} -{% endblock %} - -{% block heading %} -{% trans "Stock Item Attachments" %} -{% endblock %} - -{% block details %} -{% include "attachment_table.html" with attachments=item.attachments.all %} - -{% endblock %} - -{% block js_ready %} -{{ block.super }} - -enableDragAndDrop( - '#attachment-dropzone', - "{% url 'api-stock-attachment-list' %}", - { - data: { - stock_item: {{ item.id }}, - }, - label: 'attachment', - success: function(data, status, xhr) { - reloadAttachmentTable(); - } - } - ); - -loadAttachmentTable( - '{% url "api-stock-attachment-list" %}', - { - filters: { - stock_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( - '{% url "api-stock-attachment-list" %}', - { - method: 'POST', - fields: { - attachment: {}, - comment: {}, - stock_item: { - value: {{ item.pk }}, - hidden: true, - }, - }, - reload: true, - title: '{% trans "Add Attachment" %}', - } - ); -}); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index ea57b981d8..547806e256 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -428,6 +428,7 @@ {% endif %} + {% endblock %} {% block js_ready %} @@ -610,4 +611,9 @@ $("#stock-return-from-customer").click(function() { {% endif %} +attachNavCallbacks({ + name: 'stockitem', + default: 'history' +}); + {% endblock %} diff --git a/InvenTree/stock/templates/stock/item_childs.html b/InvenTree/stock/templates/stock/item_childs.html deleted file mode 100644 index f5d80e5ad1..0000000000 --- a/InvenTree/stock/templates/stock/item_childs.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "stock/item_base.html" %} - -{% load static %} -{% load i18n %} - - -{% block menubar %} -{% include "stock/navbar.html" with tab='children' %} -{% endblock %} - -{% block heading %} -{% trans "Child Stock Items" %} -{% endblock %} - -{% block details %} -{% if item.child_count > 0 %} -{% include "stock_table.html" %} -{% else %} -
- {% trans "This stock item does not have any child items" %} -
-{% endif %} - -{% endblock %} - -{% block js_ready %} -{{ block.super }} - -{% if item.child_count > 0 %} -loadStockTable($("#stock-table"), { - params: { - location_detail: true, - part_detail: false, - ancestor: {{ item.id }}, - }, - name: 'item-childs', - groupByField: 'location', - buttons: [ - '#stock-options', - ], - url: "{% url 'api-stock-list' %}", -}); -{% endif %} - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item_installed.html b/InvenTree/stock/templates/stock/item_installed.html deleted file mode 100644 index 8902fe00ef..0000000000 --- a/InvenTree/stock/templates/stock/item_installed.html +++ /dev/null @@ -1,53 +0,0 @@ -{% extends "stock/item_base.html" %} - -{% load static %} -{% load i18n %} - -{% block menubar %} -{% include "stock/navbar.html" with tab='installed' %} -{% endblock %} - -{% block heading %} -{% trans "Installed Stock Items" %} -{% endblock %} - -{% block details %} -
- -{% endblock %} - -{% block js_ready %} - -{{ block.super }} - -loadInstalledInTable( - $('#installed-table'), - { - stock_item: {{ item.pk }}, - part: {{ item.part.pk }}, - quantity: {{ item.quantity }}, - } -); - -$('#multi-item-uninstall').click(function() { - - var selections = $('#installed-table').bootstrapTable('getSelections'); - - var items = []; - - selections.forEach(function(item) { - items.push(item.pk); - }); - - launchModalForm( - "{% url 'stock-item-uninstall' %}", - { - data: { - 'items[]': items, - }, - reload: true, - } - ); -}); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item_notes.html b/InvenTree/stock/templates/stock/item_notes.html deleted file mode 100644 index 788f7fb3bd..0000000000 --- a/InvenTree/stock/templates/stock/item_notes.html +++ /dev/null @@ -1,51 +0,0 @@ -{% extends "stock/item_base.html" %} - -{% load static %} -{% load inventree_extras %} -{% load i18n %} -{% load markdownify %} - -{% block menubar %} -{% include "stock/navbar.html" with tab="notes" %} -{% endblock %} - -{% block heading %} -{% trans "Stock Item Notes" %} -{% if roles.stock.change and not editing %} - -{% endif %} -{% endblock %} - -{% block details %} -{% if editing %} -
- {% csrf_token %} - - {{ form }} -
- -
- -{{ form.media }} - -{% else %} -{% if item.notes %} -{{ item.notes | markdownify }} -{% endif %} - -{% endif %} - -{% endblock %} - -{% block js_ready %} - -{{ block.super }} - -{% if editing %} -{% else %} -$("#edit-notes").click(function() { - location.href = "{% url 'stock-item-notes' item.id %}?edit=1"; -}); -{% endif %} - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item_tests.html b/InvenTree/stock/templates/stock/item_tests.html deleted file mode 100644 index d7d26fcbba..0000000000 --- a/InvenTree/stock/templates/stock/item_tests.html +++ /dev/null @@ -1,150 +0,0 @@ -{% extends "stock/item_base.html" %} - -{% load static %} -{% load i18n %} - -{% block menubar %} -{% include "stock/navbar.html" with tab='tests' %} -{% endblock %} - -{% block heading %} -{% trans "Test Data" %} -{% endblock %} - -{% block details %} -
-
-
- {% if user.is_staff %} - - {% endif %} - - -
-
- -
-
-
- -
- -{% endblock %} - -{% block js_ready %} -{{ block.super }} - -loadStockTestResultsTable( - $("#test-result-table"), { - part: {{ item.part.id }}, - stock_item: {{ item.id }}, - } -); - -function reloadTable() { - $("#test-result-table").bootstrapTable("refresh"); -} - -{% if item.has_test_reports %} -$("#test-report").click(function() { - printTestReports([{{ item.pk }}]); -}); -{% endif %} - -{% if user.is_staff %} -$("#delete-test-results").click(function() { - launchModalForm( - "{% url 'stock-item-delete-test-data' item.id %}", - { - success: reloadTable, - } - ); -}); -{% endif %} - -$("#add-test-result").click(function() { - - constructForm('{% url "api-stock-test-result-list" %}', { - method: 'POST', - fields: { - test: {}, - result: {}, - value: {}, - attachment: {}, - notes: {}, - stock_item: { - value: {{ item.pk }}, - hidden: true, - } - }, - title: '{% trans "Add Test Result" %}', - onSuccess: reloadTable, - }); -}); - -$("#test-result-table").on('click', '.button-test-add', function() { - var button = $(this); - - var test_name = button.attr('pk'); - - constructForm('{% url "api-stock-test-result-list" %}', { - method: 'POST', - fields: { - test: { - value: test_name, - }, - result: {}, - value: {}, - attachment: {}, - notes: {}, - stock_item: { - value: {{ item.pk }}, - hidden: true, - } - }, - title: '{% trans "Add Test Result" %}', - onSuccess: reloadTable, - }); -}); - -$("#test-result-table").on('click', '.button-test-edit', function() { - var button = $(this); - - var pk = button.attr('pk'); - - var url = `/api/stock/test/${pk}/`; - - constructForm(url, { - fields: { - test: {}, - result: {}, - value: {}, - attachment: {}, - notes: {}, - }, - title: '{% trans "Edit Test Result" %}', - onSuccess: reloadTable, - }); -}); - -$("#test-result-table").on('click', '.button-test-delete', function() { - var button = $(this); - - var pk = button.attr('pk'); - - var url = `/api/stock/test/${pk}/`; - - constructForm(url, { - method: 'DELETE', - title: '{% trans "Delete Test Result" %}', - onSuccess: reloadTable, - }); -}); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/navbar.html b/InvenTree/stock/templates/stock/navbar.html index 7c7d197a1a..90c0075ba0 100644 --- a/InvenTree/stock/templates/stock/navbar.html +++ b/InvenTree/stock/templates/stock/navbar.html @@ -8,24 +8,24 @@ -
  • - +
  • + {% trans "History" %}
  • {% if item.part.trackable %} -
  • - +
  • + {% trans "Test Data" %}
  • {% if item.part.assembly %} -
  • - +
  • + {% trans "Installed Items" %} @@ -35,8 +35,8 @@ {% endif %} {% if item.child_count > 0 %} -
  • - +
  • + {% trans "Children" %} @@ -44,15 +44,15 @@ {% endif %} -
  • - +
  • + {% trans "Attachments" %}
  • -
  • - +
  • + {% trans "Notes" %} diff --git a/InvenTree/stock/urls.py b/InvenTree/stock/urls.py index adae836d92..bcf180b700 100644 --- a/InvenTree/stock/urls.py +++ b/InvenTree/stock/urls.py @@ -34,12 +34,6 @@ stock_item_detail_urls = [ url(r'^add_tracking/', views.StockItemTrackingCreate.as_view(), name='stock-tracking-create'), - url(r'^test/', views.StockItemDetail.as_view(template_name='stock/item_tests.html'), name='stock-item-test-results'), - url(r'^children/', views.StockItemDetail.as_view(template_name='stock/item_childs.html'), name='stock-item-children'), - url(r'^attachments/', views.StockItemDetail.as_view(template_name='stock/item_attachments.html'), name='stock-item-attachments'), - url(r'^installed/', views.StockItemDetail.as_view(template_name='stock/item_installed.html'), name='stock-item-installed'), - url(r'^notes/', views.StockItemNotes.as_view(), name='stock-item-notes'), - url('^.*$', views.StockItemDetail.as_view(), name='stock-item-detail'), ] diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index d917bac72a..583f4db893 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -8,7 +8,7 @@ {% authorized_owners location.owner as owners %} {% endif %} -
    +
    - +