mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Label plugin refactor (#5251)
* Add skeleton for builtin label printing plugin * Force selection of plugin when printing labels * Enhance LabelPrintingMixin class - Add render_to_pdf method - Add render_to_html method * Enhance plugin mixin - Add class attribute to select blocking or non-blocking printing - Add render_to_png method - Add default method for printing multiple labels - Add method for offloding print job * Simplify print_label background function - All arguments now handled by specific plugin * Simplify label printing API - Simply pass data to the particular plugin - Check result type - Return result * Updated sample plugin * Working on client side code * Cleanup * Update sample plugin * Add new model type - LabelOutput model - Stores generated label file to the database - Makes available for download * Update label printing plugin mixin * Add background task to remove any old label outputs * Open file if response contains filename * Remove "default printer" option which does not specify a plugin * Delete old labels after 5 days * Remove debug statements * Update API version * Changed default behaviour to background printing * Update label plugin mixin docs * Provide default printer if none provided (legacy) * Update unit test * unit test updates * Further fixes for unit tests * unit test updates
This commit is contained in:
@ -62,12 +62,12 @@ function inventreeGet(url, filters={}, options={}) {
|
||||
url: url,
|
||||
type: 'GET',
|
||||
data: filters,
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
dataType: options.dataType || 'json',
|
||||
contentType: options.contentType || 'application/json',
|
||||
async: (options.async == false) ? false : true,
|
||||
success: function(response) {
|
||||
success: function(response, status, xhr) {
|
||||
if (options.success) {
|
||||
options.success(response);
|
||||
options.success(response, status, xhr);
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
|
@ -59,7 +59,6 @@ function selectLabel(labels, items, options={}) {
|
||||
</label>
|
||||
<div class='controls'>
|
||||
<select id='id_plugin' class='select form-control' name='plugin'>
|
||||
<option value='' title='{% trans "Export to PDF" %}'>{% trans "Export to PDF" %}</option>
|
||||
`;
|
||||
|
||||
plugins.forEach(function(plugin) {
|
||||
@ -207,19 +206,20 @@ function printLabels(options) {
|
||||
href += `${options.key}=${item}&`;
|
||||
});
|
||||
|
||||
if (data.plugin) {
|
||||
href += `plugin=${data.plugin}`;
|
||||
href += `plugin=${data.plugin}`;
|
||||
|
||||
inventreeGet(href, {}, {
|
||||
success: function(response) {
|
||||
inventreeGet(href, {}, {
|
||||
success: function(response) {
|
||||
if (response.file) {
|
||||
// Download the generated file
|
||||
window.open(response.file);
|
||||
} else {
|
||||
showMessage('{% trans "Labels sent to printer" %}', {
|
||||
style: 'success',
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.open(href);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
plural_name: options.plural_name,
|
||||
singular_name: options.singular_name,
|
||||
|
Reference in New Issue
Block a user