- {% if roles.part.add %}
-
- {% endif %}
+
+
+
+
+
{% trans "Parameters" %}
+
+
+
+
+
+
+
+
{% 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 `
`;
+ }
}