mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	Allow offloading of label printing to the configured plugin
This commit is contained in:
		| @@ -14,11 +14,41 @@ | ||||
| */ | ||||
|  | ||||
| /* exported | ||||
|     printLabels, | ||||
|     printPartLabels, | ||||
|     printStockItemLabels, | ||||
|     printStockLocationLabels, | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Perform the "print" action. | ||||
|  */ | ||||
| function printLabels(url, plugin=null) { | ||||
|  | ||||
|     if (plugin) { | ||||
|         // If a plugin is provided, do not redirect the browser. | ||||
|         // Instead, perform an API request and display a message | ||||
|  | ||||
|         url = url + `plugin=${plugin}`; | ||||
|  | ||||
|         inventreeGet(url, {}, { | ||||
|             success: function(response) { | ||||
|                 showMessage( | ||||
|                     '{% trans "Labels sent to printer" %}', | ||||
|                     { | ||||
|                         style: 'success', | ||||
|                     } | ||||
|                 ); | ||||
|             } | ||||
|         }); | ||||
|     } else { | ||||
|         window.location.href = url; | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| function printStockItemLabels(items) { | ||||
|     /** | ||||
|      * Print stock item labels for the given stock items | ||||
| @@ -67,11 +97,7 @@ function printStockItemLabels(items) { | ||||
|                                 href += `items[]=${item}&`; | ||||
|                             }); | ||||
|  | ||||
|                             if (data.plugin) { | ||||
|                                 href += `plugin=${data.plugin}`; | ||||
|                             } | ||||
|  | ||||
|                             window.location.href = href; | ||||
|                             printLabels(href, data.plugin); | ||||
|                         } | ||||
|                     } | ||||
|                 ); | ||||
| @@ -80,6 +106,7 @@ function printStockItemLabels(items) { | ||||
|     ); | ||||
| } | ||||
|  | ||||
|  | ||||
| function printStockLocationLabels(locations) { | ||||
|  | ||||
|     if (locations.length == 0) { | ||||
| @@ -124,11 +151,7 @@ function printStockLocationLabels(locations) { | ||||
|                                 href += `locations[]=${location}&`; | ||||
|                             }); | ||||
|  | ||||
|                             if (data.plugin) { | ||||
|                                 href += `plugin=${data.plugin}`; | ||||
|                             } | ||||
|  | ||||
|                             window.location.href = href; | ||||
|                             printLabels(href, data.plugin); | ||||
|                         } | ||||
|                     } | ||||
|                 ); | ||||
| @@ -186,11 +209,7 @@ function printPartLabels(parts) { | ||||
|                                 url += `parts[]=${part}&`; | ||||
|                             }); | ||||
|  | ||||
|                             if (data.plugin) { | ||||
|                                 href += `plugin=${data.plugin}`; | ||||
|                             } | ||||
|  | ||||
|                             window.location.href = url; | ||||
|                             printLabels(href, data.plugin); | ||||
|                         } | ||||
|                     } | ||||
|                 ); | ||||
| @@ -234,7 +253,6 @@ function selectLabel(labels, items, options={}) { | ||||
|  | ||||
|     var plugin_selection = ''; | ||||
|      | ||||
|      | ||||
|     if (plugins.length > 0) { | ||||
|         plugin_selection =` | ||||
|         <div class='form-group'> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user