mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Merge pull request #2055 from SchrodingersGat/test-template-table-fix
Fix callback for test template table
This commit is contained in:
		| @@ -667,6 +667,8 @@ | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     onPanelLoad("test-templates", function() { |     onPanelLoad("test-templates", function() { | ||||||
|  |  | ||||||
|  |         // Load test template table | ||||||
|         loadPartTestTemplateTable( |         loadPartTestTemplateTable( | ||||||
|             $("#test-template-table"), |             $("#test-template-table"), | ||||||
|             { |             { | ||||||
| @@ -677,12 +679,9 @@ | |||||||
|             } |             } | ||||||
|         );  |         );  | ||||||
|  |  | ||||||
|  |         // Callback for "add test template" button | ||||||
|         $("#add-test-template").click(function() { |         $("#add-test-template").click(function() { | ||||||
|  |  | ||||||
|             function reloadTestTemplateTable() { |  | ||||||
|                 $("#test-template-table").bootstrapTable("refresh"); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             constructForm('{% url "api-part-test-template-list" %}', { |             constructForm('{% url "api-part-test-template-list" %}', { | ||||||
|                 method: 'POST', |                 method: 'POST', | ||||||
|                 fields: { |                 fields: { | ||||||
| @@ -697,39 +696,10 @@ | |||||||
|                     } |                     } | ||||||
|                 }, |                 }, | ||||||
|                 title: '{% trans "Add Test Result Template" %}', |                 title: '{% trans "Add Test Result Template" %}', | ||||||
|                 onSuccess: reloadTestTemplateTable |                 onSuccess: function() { | ||||||
|  |                     $("#test-template-table").bootstrapTable("refresh"); | ||||||
|  |                 } | ||||||
|             }); |             }); | ||||||
|  |  | ||||||
|             $("#test-template-table").on('click', '.button-test-edit', function() { |  | ||||||
|                 var pk = $(this).attr('pk'); |  | ||||||
|              |  | ||||||
|                 var url = `/api/part/test-template/${pk}/`; |  | ||||||
|              |  | ||||||
|                 constructForm(url, { |  | ||||||
|                     fields: { |  | ||||||
|                         test_name: {}, |  | ||||||
|                         description: {}, |  | ||||||
|                         required: {}, |  | ||||||
|                         requires_value: {}, |  | ||||||
|                         requires_attachment: {}, |  | ||||||
|                     }, |  | ||||||
|                     title: '{% trans "Edit Test Result Template" %}', |  | ||||||
|                     onSuccess: reloadTestTemplateTable, |  | ||||||
|                 }); |  | ||||||
|             }); |  | ||||||
|  |  | ||||||
|             $("#test-template-table").on('click', '.button-test-delete', function() { |  | ||||||
|                 var pk = $(this).attr('pk'); |  | ||||||
|              |  | ||||||
|                 var url = `/api/part/test-template/${pk}/`; |  | ||||||
|              |  | ||||||
|                 constructForm(url, { |  | ||||||
|                     method: 'DELETE', |  | ||||||
|                     title: '{% trans "Delete Test Result Template" %}', |  | ||||||
|                     onSuccess: reloadTestTemplateTable, |  | ||||||
|                 }); |  | ||||||
|             }); |  | ||||||
|  |  | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1252,7 +1252,43 @@ function loadPartTestTemplateTable(table, options) { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         ] |         ], | ||||||
|  |         onPostBody: function() { | ||||||
|  |  | ||||||
|  |             table.find('.button-test-edit').click(function() { | ||||||
|  |                 var pk = $(this).attr('pk'); | ||||||
|  |              | ||||||
|  |                 var url = `/api/part/test-template/${pk}/`; | ||||||
|  |              | ||||||
|  |                 constructForm(url, { | ||||||
|  |                     fields: { | ||||||
|  |                         test_name: {}, | ||||||
|  |                         description: {}, | ||||||
|  |                         required: {}, | ||||||
|  |                         requires_value: {}, | ||||||
|  |                         requires_attachment: {}, | ||||||
|  |                     }, | ||||||
|  |                     title: '{% trans "Edit Test Result Template" %}', | ||||||
|  |                     onSuccess: function() { | ||||||
|  |                         table.bootstrapTable('refresh'); | ||||||
|  |                     }, | ||||||
|  |                 }); | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |             table.find('.button-test-delete').click(function() { | ||||||
|  |                 var pk = $(this).attr('pk'); | ||||||
|  |              | ||||||
|  |                 var url = `/api/part/test-template/${pk}/`; | ||||||
|  |              | ||||||
|  |                 constructForm(url, { | ||||||
|  |                     method: 'DELETE', | ||||||
|  |                     title: '{% trans "Delete Test Result Template" %}', | ||||||
|  |                     onSuccess: function() { | ||||||
|  |                         table.bootstrapTable('refresh'); | ||||||
|  |                     }, | ||||||
|  |                 }); | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user