diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 61815f0587..ac7cf1f4e1 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -837,6 +837,12 @@ input[type="submit"] { pointer-events: none; /* Prevent this div from blocking links underneath */ } +.notes { + border-radius: 5px; + background-color: #fafafa; + padding: 5px; +} + .alert { display: none; border-radius: 5px; @@ -853,6 +859,11 @@ input[type="submit"] { margin-right: 2px; } +.btn-small { + padding: 3px; + padding-left: 5px; +} + .btn-remove { padding: 3px; padding-left: 5px; diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 5132721fec..8a78eb85a5 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -1,6 +1,7 @@ {% extends "part/part_base.html" %} {% load static %} {% load i18n %} +{% load markdownify %} {% block menubar %} @@ -135,11 +136,38 @@ {% endif %} {% if part.responsible %} - d + {% trans "Responsible User" %} {{ part.responsible }} {% endif %} + + + + + + + {% trans "Notes" %} + + +
+ +
+ + + + + {% if part.notes %} +
+ {{ part.notes | markdownify }} +
+ {% endif %} + + +
@@ -240,23 +268,35 @@ {% block post_content_panel %} -
-
-

- {% trans "Part Parameters" %} -

-
-
-
-
- {% if roles.part.add %} - - {% endif %} +
+
+
+
+

{% trans "Parameters" %}

+
+
+
+
+ {% if roles.part.add %} + + {% endif %} +
+
+
+
+
+
+
+
+
+

{% trans "Attachments" %}

+
+
+ {% include "attachment_table.html" %}
-
@@ -269,6 +309,18 @@ {% block js_ready %} {{ block.super }} + $('#edit-notes').click(function() { + constructForm('{% url "api-part-detail" part.pk %}', { + fields: { + notes: { + multiline: true, + } + }, + title: '{% trans "Edit Part Notes" %}', + reload: true, + }); + }); + $(".slidey").change(function() { var field = $(this).attr('fieldname'); @@ -337,4 +389,68 @@ }); }); + 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" %}', + { + data: { + part: {{ part.id }}, + }, + label: 'attachment', + success: function(data, status, xhr) { + reloadAttachmentTable(); + } + } + ); + + $("#new-attachment").click(function() { + + constructForm( + '{% url "api-part-attachment-list" %}', + { + method: 'POST', + fields: { + attachment: {}, + comment: {}, + part: { + value: {{ part.pk }}, + hidden: true, + } + }, + onSuccess: reloadAttachmentTable, + title: '{% trans "Add Attachment" %}', + } + ) + }); + {% endblock %} diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index b71551747c..6dd7dbd968 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -353,12 +353,16 @@ function constructFormBody(fields, options) { // Override existing query filters (if provided!) fields[field].filters = Object.assign(fields[field].filters || {}, field_options.filters); + // TODO: Refactor the following code with Object.assign (see above) + // Secondary modal options fields[field].secondary = field_options.secondary; // Edit callback fields[field].onEdit = field_options.onEdit; + fields[field].multiline = field_options.multiline; + // Custom help_text if (field_options.help_text) { fields[field].help_text = field_options.help_text; @@ -1483,7 +1487,11 @@ function constructInputOptions(name, classes, type, parameters) { opts.push(`placeholder='${parameters.placeholder}'`); } - return ``; + if (parameters.multiline) { + return ``; + } else { + return ``; + } }