mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Display part notes inline, and allow updating via API
This commit is contained in:
		| @@ -140,15 +140,15 @@ | |||||||
|             </div> |             </div> | ||||||
|             <div class='col-sm-6'> |             <div class='col-sm-6'> | ||||||
|                 <div class='btn-group float-right'> |                 <div class='btn-group float-right'> | ||||||
|                     <button type='button' id='edit-notes' title='{% trans "Edit Notes" %}' class='btn btn-outline-secondary'> |                     <button type='button' id='save-notes' title='{% trans "Save" %}' class='btn btn-success'> | ||||||
|                         <span class='fas fa-edit'>       |                         <span class='fas fa-save'></span> {% trans "Save Changes" %} | ||||||
|                         </span> |  | ||||||
|                     </button> |                     </button> | ||||||
|                 </div> |                 </div> | ||||||
|             </div> |             </div> | ||||||
|         </div> |         </div> | ||||||
|     </div> |     </div> | ||||||
|     <div class='panel-content'> |     <div class='panel-content'> | ||||||
|  |         <textarea id='part-notes'></textarea> | ||||||
|         {% if part.notes %} |         {% if part.notes %} | ||||||
|         {{ part.notes | markdownify }} |         {{ part.notes | markdownify }} | ||||||
|         {% endif %} |         {% endif %} | ||||||
| @@ -419,6 +419,47 @@ | |||||||
| {% block js_ready %} | {% block js_ready %} | ||||||
|     {{ block.super }} |     {{ 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 |     // Load the "scheduling" tab | ||||||
|     onPanelLoad('scheduling', function() { |     onPanelLoad('scheduling', function() { | ||||||
|         loadPartSchedulingChart('part-schedule-chart', {{ part.pk }}); |         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() { |     onPanelLoad("part-parameters", function() { | ||||||
|         loadPartParameterTable( |         loadPartParameterTable( | ||||||
|             '#parameter-table',  |             '#parameter-table',  | ||||||
|   | |||||||
| @@ -89,7 +89,7 @@ $('table').find('.boolean-setting').change(function() { | |||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             method: 'PATCH', |             method: 'PATCH', | ||||||
|             onSuccess: function(data) { |             success: function(data) { | ||||||
|             }, |             }, | ||||||
|             error: function(xhr) { |             error: function(xhr) { | ||||||
|                 showApiError(xhr, url); |                 showApiError(xhr, url); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user