From 0b8feb2c4a92287cb2620d1a5028b709917e54e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20M=C3=A1rton?= Date: Mon, 1 May 2023 23:59:54 +0200 Subject: [PATCH] Display proper printing target name in the label printing modal dialog (#4727) Fix #4717 --- InvenTree/part/templates/part/part_base.html | 1 + InvenTree/stock/templates/stock/item_base.html | 1 + InvenTree/stock/templates/stock/location.html | 1 + InvenTree/templates/js/translated/build.js | 4 +++- InvenTree/templates/js/translated/filters.js | 2 ++ InvenTree/templates/js/translated/label.js | 8 +++++--- InvenTree/templates/js/translated/part.js | 4 +++- InvenTree/templates/js/translated/stock.js | 8 ++++++-- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 0cfd50a115..7f89f87cd3 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -471,6 +471,7 @@ printLabels({ items: [{{ part.pk }}], key: 'part', + singular_name: '{% trans "part" %}', url: '{% url "api-part-label-list" %}', }); }); diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 322ee56235..959b0d7457 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -496,6 +496,7 @@ $("#stock-test-report").click(function() { $("#print-label").click(function() { printLabels({ items: [{{ item.pk }}], + singular_name: '{% trans "stock item" %}', url: '{% url "api-stockitem-label-list" %}', key: 'item', }); diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index f1820f08d3..b97194899e 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -284,6 +284,7 @@ printLabels({ items: locs, + singular_name: '{% trans "stock location" %}', key: 'location', url: '{% url "api-stocklocation-label-list" %}', }); diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index c9184e22fe..f22eec19a4 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -889,7 +889,9 @@ function loadBuildOutputTable(build_info, options={}) { labels: { url: '{% url "api-stockitem-label-list" %}', key: 'item', - } + }, + singular_name: '{% trans "build output" %}', + plural_name: '{% trans "build outputs" %}', }); function setupBuildOutputButtonCallbacks() { diff --git a/InvenTree/templates/js/translated/filters.js b/InvenTree/templates/js/translated/filters.js index 965717daff..bc352edf33 100644 --- a/InvenTree/templates/js/translated/filters.js +++ b/InvenTree/templates/js/translated/filters.js @@ -419,6 +419,8 @@ function setupFilterList(tableKey, table, target, options={}) { printLabels({ items: items, + singular_name: options.singular_name, + plural_name: options.plural_name, url: options.labels.url, key: options.labels.key, }); diff --git a/InvenTree/templates/js/translated/label.js b/InvenTree/templates/js/translated/label.js index f714e0f861..1c8543c22d 100644 --- a/InvenTree/templates/js/translated/label.js +++ b/InvenTree/templates/js/translated/label.js @@ -96,10 +96,10 @@ function selectLabel(labels, items, options={}) { var html = ''; if (items.length > 0) { - + name = items.length == 1 ? options.singular_name : options.plural_name; html += `
- ${items.length} {% trans "stock items selected" %} + ${items.length} ${name} {% trans "selected" %}
`; } @@ -208,7 +208,9 @@ function printLabels(options) { } else { window.open(href); } - } + }, + plural_name: options.plural_name, + singular_name: options.singular_name, }); } }); diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index 6e8ef038e6..0209120219 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -1834,7 +1834,9 @@ function loadPartTable(table, url, options={}) { labels: { url: '{% url "api-part-label-list" %}', key: 'part', - } + }, + singular_name: '{% trans "part" %}', + plural_name: '{% trans "parts" %}', }); var columns = [ diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index 765a18f67c..7d4979d129 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1724,7 +1724,9 @@ function loadStockTable(table, options) { labels: { url: '{% url "api-stockitem-label-list" %}', key: 'item', - } + }, + singular_name: '{% trans "stock item" %}', + plural_name: '{% trans "stock items" %}' }); // Override the default values, or add new ones @@ -2378,7 +2380,9 @@ function loadStockLocationTable(table, options) { labels: { url: '{% url "api-stocklocation-label-list" %}', key: 'location' - } + }, + singular_name: '{% trans "stock location" %}', + plural_name: '{% trans "stock locations" %}', }); for (var key in params) {