Display proper printing target name in the label printing modal dialog (#4727)

Fix #4717
This commit is contained in:
Miklós Márton 2023-05-01 23:59:54 +02:00 committed by GitHub
parent e5e1a09b45
commit 0b8feb2c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 7 deletions

View File

@ -471,6 +471,7 @@
printLabels({ printLabels({
items: [{{ part.pk }}], items: [{{ part.pk }}],
key: 'part', key: 'part',
singular_name: '{% trans "part" %}',
url: '{% url "api-part-label-list" %}', url: '{% url "api-part-label-list" %}',
}); });
}); });

View File

@ -496,6 +496,7 @@ $("#stock-test-report").click(function() {
$("#print-label").click(function() { $("#print-label").click(function() {
printLabels({ printLabels({
items: [{{ item.pk }}], items: [{{ item.pk }}],
singular_name: '{% trans "stock item" %}',
url: '{% url "api-stockitem-label-list" %}', url: '{% url "api-stockitem-label-list" %}',
key: 'item', key: 'item',
}); });

View File

@ -284,6 +284,7 @@
printLabels({ printLabels({
items: locs, items: locs,
singular_name: '{% trans "stock location" %}',
key: 'location', key: 'location',
url: '{% url "api-stocklocation-label-list" %}', url: '{% url "api-stocklocation-label-list" %}',
}); });

View File

@ -889,7 +889,9 @@ function loadBuildOutputTable(build_info, options={}) {
labels: { labels: {
url: '{% url "api-stockitem-label-list" %}', url: '{% url "api-stockitem-label-list" %}',
key: 'item', key: 'item',
} },
singular_name: '{% trans "build output" %}',
plural_name: '{% trans "build outputs" %}',
}); });
function setupBuildOutputButtonCallbacks() { function setupBuildOutputButtonCallbacks() {

View File

@ -419,6 +419,8 @@ function setupFilterList(tableKey, table, target, options={}) {
printLabels({ printLabels({
items: items, items: items,
singular_name: options.singular_name,
plural_name: options.plural_name,
url: options.labels.url, url: options.labels.url,
key: options.labels.key, key: options.labels.key,
}); });

View File

@ -96,10 +96,10 @@ function selectLabel(labels, items, options={}) {
var html = ''; var html = '';
if (items.length > 0) { if (items.length > 0) {
name = items.length == 1 ? options.singular_name : options.plural_name;
html += ` html += `
<div class='alert alert-block alert-info'> <div class='alert alert-block alert-info'>
${items.length} {% trans "stock items selected" %} ${items.length} ${name} {% trans "selected" %}
</div>`; </div>`;
} }
@ -208,7 +208,9 @@ function printLabels(options) {
} else { } else {
window.open(href); window.open(href);
} }
} },
plural_name: options.plural_name,
singular_name: options.singular_name,
}); });
} }
}); });

View File

@ -1834,7 +1834,9 @@ function loadPartTable(table, url, options={}) {
labels: { labels: {
url: '{% url "api-part-label-list" %}', url: '{% url "api-part-label-list" %}',
key: 'part', key: 'part',
} },
singular_name: '{% trans "part" %}',
plural_name: '{% trans "parts" %}',
}); });
var columns = [ var columns = [

View File

@ -1724,7 +1724,9 @@ function loadStockTable(table, options) {
labels: { labels: {
url: '{% url "api-stockitem-label-list" %}', url: '{% url "api-stockitem-label-list" %}',
key: 'item', key: 'item',
} },
singular_name: '{% trans "stock item" %}',
plural_name: '{% trans "stock items" %}'
}); });
// Override the default values, or add new ones // Override the default values, or add new ones
@ -2378,7 +2380,9 @@ function loadStockLocationTable(table, options) {
labels: { labels: {
url: '{% url "api-stocklocation-label-list" %}', url: '{% url "api-stocklocation-label-list" %}',
key: 'location' key: 'location'
} },
singular_name: '{% trans "stock location" %}',
plural_name: '{% trans "stock locations" %}',
}); });
for (var key in params) { for (var key in params) {