diff --git a/InvenTree/order/templates/order/order_notes.html b/InvenTree/order/templates/order/order_notes.html deleted file mode 100644 index cdd121c412..0000000000 --- a/InvenTree/order/templates/order/order_notes.html +++ /dev/null @@ -1,54 +0,0 @@ -{% extends "order/order_base.html" %} - -{% load inventree_extras %} -{% load i18n %} -{% load static %} -{% load markdownify %} - -{% block menubar %} -{% include 'order/po_navbar.html' with tab='notes' %} -{% endblock %} - -{% block heading %} -{% trans "Order Notes" %} -{% if roles.purchase_order.change and not editing %} - -{% endif %} -{% endblock %} - -{% block details %} - -{% if editing %} -
- {% csrf_token %} - - {{ form }} -
- -
- -{{ form.media }} - -{% else %} - -
-
- {{ order.notes | markdownify }} -
-
-{% endif %} - -{% endblock %} - -{% block js_ready %} - -{{ block.super }} - -{% if editing %} -{% else %} -$("#edit-notes").click(function() { - location.href = "{% url 'po-notes' order.id %}?edit=1"; -}); -{% endif %} - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/po_attachments.html b/InvenTree/order/templates/order/po_attachments.html deleted file mode 100644 index 07e425016b..0000000000 --- a/InvenTree/order/templates/order/po_attachments.html +++ /dev/null @@ -1,83 +0,0 @@ -{% extends "order/order_base.html" %} - -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block menubar %} -{% include 'order/po_navbar.html' with tab='attachments' %} -{% endblock %} - -{% block heading %} -{% trans "Purchase Order Attachments" %} -{% endblock %} - -{% block details %} -{% include "attachment_table.html" with attachments=order.attachments.all %} - -{% endblock %} - -{% block js_ready %} -{{ block.super }} - -enableDragAndDrop( - '#attachment-dropzone', - '{% url "api-po-attachment-list" %}', - { - data: { - order: {{ order.id }}, - }, - label: 'attachment', - success: function(data, status, xhr) { - location.reload(); - } - } -); - -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" %}', { - method: 'POST', - fields: { - attachment: {}, - comment: {}, - order: { - value: {{ order.pk }}, - hidden: true, - }, - }, - reload: true, - title: '{% trans "Add Attachment" %}', - }); -}); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/po_navbar.html b/InvenTree/order/templates/order/po_navbar.html index 4dc501a8d6..9f7967810d 100644 --- a/InvenTree/order/templates/order/po_navbar.html +++ b/InvenTree/order/templates/order/po_navbar.html @@ -9,34 +9,34 @@ -
  • - - - {% trans "Details" %} +
  • + + + {% trans "Order Items" %}
  • {% if order.status == PurchaseOrderStatus.PENDING and roles.purchase_order.change %} -
  • +
  • {% trans "Upload File" %}
  • {% endif %} -
  • - +
  • + {% trans "Received Items" %}
  • -
  • - +
  • + {% trans "Attachments" %}
  • -
  • - +
  • + {% trans "Notes" %} diff --git a/InvenTree/order/templates/order/po_received_items.html b/InvenTree/order/templates/order/po_received_items.html deleted file mode 100644 index 487dbd1284..0000000000 --- a/InvenTree/order/templates/order/po_received_items.html +++ /dev/null @@ -1,37 +0,0 @@ -{% extends "order/order_base.html" %} - -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block menubar %} -{% include 'order/po_navbar.html' with tab='received' %} -{% endblock %} - -{% block heading %} -{% trans "Received Items" %} -{% endblock %} - -{% block details %} - -{% include "stock_table.html" with read_only=True %} - -{% endblock %} - -{% block js_ready %} -{{ block.super }} - -loadStockTable($("#stock-table"), { - params: { - purchase_order: {{ order.id }}, - part_detail: true, - supplier_part_detail: true, - location_detail: true, - }, - buttons: [ - '#stock-options', - ], - filterkey: "postock" -}); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 2e1ec0c39c..8832974510 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -4,31 +4,71 @@ {% load status_codes %} {% load i18n %} {% load static %} +{% load markdownify %} {% block menubar %} {% include 'order/po_navbar.html' with tab='details' %} {% endblock %} -{% block heading %} -{% trans "Purchase Order Items" %} -{% endblock %} +{% block page_content %} - -{% block details %} - - -
    - {% if order.status == PurchaseOrderStatus.PENDING and roles.purchase_order.change %} - - {% endif %} +
    +
    +

    {% trans "Purchase Order Items" %}

    +
    +
    +
    + {% if order.status == PurchaseOrderStatus.PENDING and roles.purchase_order.change %} + + {% endif %} +
    + + +
    +
    +
    +
    +

    {% trans "Received Items" %}

    +
    +
    + {% include "stock_table.html" with read_only=True %} +
    +
    - -
    +
    +
    +

    {% trans "Purchase Order Attachments" %}

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

    {% trans "Order Notes" %}

    +
    +
    +
    + +
    +
    +
    +
    +
    + {{ order.notes | markdownify }} +
    +
    {% endblock %} @@ -36,6 +76,91 @@ {{ block.super }} + $('#edit-notes').click(function() { + constructForm('{% url "api-po-detail" order.pk %}', { + fields: { + notes: { + multiline: true, + } + }, + title: '{% trans "Edit Notes" %}', + reload: true, + }); + }); + + enableDragAndDrop( + '#attachment-dropzone', + '{% url "api-po-attachment-list" %}', + { + data: { + order: {{ order.id }}, + }, + label: 'attachment', + success: function(data, status, xhr) { + location.reload(); + } + } + ); + + 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" %}', { + method: 'POST', + fields: { + attachment: {}, + comment: {}, + order: { + value: {{ order.pk }}, + hidden: true, + }, + }, + reload: true, + title: '{% trans "Add Attachment" %}', + }); + }); + + loadStockTable($("#stock-table"), { + params: { + purchase_order: {{ order.id }}, + part_detail: true, + supplier_part_detail: true, + location_detail: true, + }, + buttons: [ + '#stock-options', + ], + filterkey: "postock" + }); + {% if order.status == PurchaseOrderStatus.PENDING %} $('#new-po-line').click(function() { @@ -301,4 +426,9 @@ $("#po-table").inventreeTable({ ] }); + attachNavCallbacks({ + name: 'purchase-order', + default: 'order-items' + }); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index 8ba91ee0ab..a61f6a11ce 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -51,7 +51,7 @@
    -

    {% trans "Notes" %}

    +

    {% trans "Order Notes" %}

    diff --git a/InvenTree/order/templates/order/so_navbar.html b/InvenTree/order/templates/order/so_navbar.html index d7571ab691..710976ed3f 100644 --- a/InvenTree/order/templates/order/so_navbar.html +++ b/InvenTree/order/templates/order/so_navbar.html @@ -9,28 +9,28 @@
  • -
  • {% trans "Order Items" %}
  • -
  • {% trans "Build Orders" %}
  • -
  • {% trans "Attachments" %}
  • -
  • {% trans "Notes" %} diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py index 768607a93b..2ce90f1f81 100644 --- a/InvenTree/order/urls.py +++ b/InvenTree/order/urls.py @@ -19,10 +19,6 @@ purchase_order_detail_urls = [ url(r'^upload/', views.PurchaseOrderUpload.as_view(), name='po-upload'), url(r'^export/', views.PurchaseOrderExport.as_view(), name='po-export'), - url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='po-notes'), - - url(r'^received/', views.PurchaseOrderDetail.as_view(template_name='order/po_received_items.html'), name='po-received'), - url(r'^attachments/', views.PurchaseOrderDetail.as_view(template_name='order/po_attachments.html'), name='po-attachments'), url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='po-detail'), ] diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index 7267df1094..be1107f17b 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -13,7 +13,7 @@ from django.core.exceptions import ValidationError from django.urls import reverse from django.http import HttpResponseRedirect from django.utils.translation import ugettext_lazy as _ -from django.views.generic import DetailView, ListView, UpdateView +from django.views.generic import DetailView, ListView from django.views.generic.edit import FormMixin from django.forms import HiddenInput, IntegerField @@ -97,31 +97,6 @@ class SalesOrderDetail(InvenTreeRoleMixin, DetailView): template_name = 'order/sales_order_detail.html' -class PurchaseOrderNotes(InvenTreeRoleMixin, UpdateView): - """ View for updating the 'notes' field of a PurchaseOrder """ - - context_object_name = 'order' - template_name = 'order/order_notes.html' - model = PurchaseOrder - - # Override the default permission roles - role_required = 'purchase_order.view' - - fields = ['notes'] - - def get_success_url(self): - - return reverse('po-notes', kwargs={'pk': self.get_object().id}) - - def get_context_data(self, **kwargs): - - ctx = super().get_context_data(**kwargs) - - ctx['editing'] = str2bool(self.request.GET.get('edit', False)) - - return ctx - - class PurchaseOrderCancel(AjaxUpdateView): """ View for cancelling a purchase order """ diff --git a/InvenTree/templates/js/nav.js b/InvenTree/templates/js/nav.js index a7f4ac8555..ed0e1dcc31 100644 --- a/InvenTree/templates/js/nav.js +++ b/InvenTree/templates/js/nav.js @@ -24,7 +24,7 @@ function attachNavCallbacks(options={}) { var panelClass = options.name || 'unknown'; // Look for a default panel to initialize - var defaultPanel = localStorage.getItem(`selected-panel-${panelClass}`) || options.default; + var defaultPanel = localStorage.getItem(`inventree-selected-panel-${panelClass}`) || options.default; if (defaultPanel) { activatePanel(defaultPanel); @@ -37,7 +37,7 @@ function activatePanel(panelName, options={}) { var panelClass = options.name || 'unknown'; // Save the selected panel - localStorage.setItem(`selected-panel-${panelClass}`, panelName); + localStorage.setItem(`inventree-selected-panel-${panelClass}`, panelName); // First, cause any other panels to "fade out" $('.panel-visible').hide(); @@ -48,13 +48,13 @@ function activatePanel(panelName, options={}) { // Display the panel $(panel).addClass('panel-visible'); - $(panel).fadeIn(50); + $(panel).fadeIn(100); // Un-select all selectors - $('.nav-item').removeClass('active'); + $('.list-group-item').removeClass('active'); // Find the associated selector var select = `#select-${panelName}`; - $(select).parent('.nav-item').addClass('active'); + $(select).parent('.list-group-item').addClass('active'); } \ No newline at end of file