From 241e2e35c09e71efb07909d5dc2b50f1267aaf7d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 10 Apr 2022 15:58:36 +1000 Subject: [PATCH] Display part notes inline, and allow updating via API --- InvenTree/part/templates/part/detail.html | 59 ++++++++++++++----- .../InvenTree/settings/settings.html | 2 +- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index b1cd832a03..d08297dc83 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -140,15 +140,15 @@
-
+ {% if part.notes %} {{ part.notes | markdownify }} {% endif %} @@ -419,6 +419,47 @@ {% block js_ready %} {{ block.super }} + // Load the "notes" tab + onPanelLoad('part-notes', function() { + + var notes = null; + + inventreeGet( + '{% url "api-part-detail" part.pk %}', + {}, + { + async: false, + success: function(response) { + notes = response.notes; + }, + } + ); + + const mde = new EasyMDE({ + element: document.getElementById('part-notes'), + initialValue: notes, + }); + + $('#save-notes').click(function() { + + inventreePut( + '{% url "api-part-detail" part.pk %}', + { + notes: mde.value(), + }, + { + method: 'PATCH', + success: function(response) { + showMessage('{% trans "Notes updated" %}', {style: 'success'}); + }, + error: function(xhr) { + showApiError(xhr, url); + } + } + ) + }); + }); + // Load the "scheduling" tab onPanelLoad('scheduling', function() { loadPartSchedulingChart('part-schedule-chart', {{ part.pk }}); @@ -832,18 +873,6 @@ }); }); - $('#edit-notes').click(function() { - constructForm('{% url "api-part-detail" part.pk %}', { - fields: { - notes: { - multiline: true, - } - }, - title: '{% trans "Edit Part Notes" %}', - reload: true, - }); - }); - onPanelLoad("part-parameters", function() { loadPartParameterTable( '#parameter-table', diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index dbb526cfd3..0039e8ee1a 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -89,7 +89,7 @@ $('table').find('.boolean-setting').change(function() { }, { method: 'PATCH', - onSuccess: function(data) { + success: function(data) { }, error: function(xhr) { showApiError(xhr, url);