A free open source IT asset/license management system
fix 2d barcode and logo swapping, remove unnecessary code
Godfrey M02443d6f1862
diff --git a/app/Http/Requests/CustomLabelRequest.php b/app/Http/Requests/CustomLabelRequest.phpindex 1bfbf344fc..20bca3e4a4 100644--- a/app/Http/Requests/CustomLabelRequest.php+++ b/app/Http/Requests/CustomLabelRequest.php@@ -2,7 +2,6 @@namespace App\Http\Requests;-use App\Models\Labels\CustomLabelFonts;use App\Rules\LabelGeometryRules;use App\Rules\CustomLabelContentRules;use Illuminate\Foundation\Http\FormRequest;diff --git a/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelContentProperties.php b/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelContentProperties.phpindex 098ce157ae..7f4e8ef394 100644--- a/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelContentProperties.php+++ b/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelContentProperties.php@@ -222,11 +222,6 @@ trait HasCustomLabelContentProperties$this->hydrateNumericContent($content);$this->hydrateStringContent($content);- if (array_key_exists('barcode2D_h_align', $content)) {- $this->syncLogoAnd2DBarcodeHAlign('barcode2D_h_align');- } elseif (array_key_exists('logo_h_align', $content)) {- $this->syncLogoAnd2DBarcodeHAlign('logo_h_align');- }}protected function hydrateNumericContent(array $content): voiddiff --git a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.phpindex 1dc77cdfc9..f8e1c2ad6c 100644--- a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php+++ b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php@@ -378,31 +378,13 @@ trait RenderCustomLabelContent$size = $this->calculate2DBarcodeSize($record, $body);$size = min($size, $body['w'], $body['h']);- $box = $this->anchorBox(+ return $this->anchorBox($body,$size,$size,$this->getBarcode2DHAlign(),$this->getBarcode2DVAlign());-- if ($this->boxesOverlap($box, $logoBox)) {- $altHAlign = strtoupper($this->getBarcode2DHAlign()) === 'R' ? 'L' : 'R';-- $altBox = $this->anchorBox(- $body,- $size,- $size,- $altHAlign,- $this->getBarcode2DVAlign()- );-- if (!$this->boxesOverlap($altBox, $logoBox)) {- $box = $altBox;- }- }-- return $box;}protected function resolveTagBox($record, array $body, ?array $barcode2dBox = null, ?array $logoBox = null): ?array@@ -470,29 +452,4 @@ trait RenderCustomLabelContentreturn min($body['w'] * 0.35, $body['w']);}-- protected function oppositeHAlign(string $align): string- {- return strtoupper($align) === 'L' ? 'R' : 'L';- }-- protected function syncLogoAnd2DBarcodeHAlign(?string $changedKey = null): void- {- if (method_exists($this, 'getLogoPlacement') && $this->getLogoPlacement() === 'text_column') {- return;- }-- if (!$this->getSupportLogo() || !$this->getSupport2DBarcode()) {- return;- }-- if ($changedKey === 'barcode2D_h_align') {- $this->logoHAlign = $this->oppositeHAlign($this->barcode2DHAlign);- return;- }-- if ($changedKey === 'logo_h_align') {- $this->barcode2DHAlign = $this->oppositeHAlign($this->logoHAlign);- }- }}\ No newline at end of filediff --git a/app/Rules/CustomLabelContentRules.php b/app/Rules/CustomLabelContentRules.phpindex 1b6eaa0caa..17b8cccd27 100644--- a/app/Rules/CustomLabelContentRules.php+++ b/app/Rules/CustomLabelContentRules.php@@ -30,6 +30,7 @@ class CustomLabelContentRules'content.title_font_size' => ['required', 'numeric'],'content.title_margin' => ['required', 'numeric'],+ 'content.title_offset_x' => ['required', 'numeric'],'content.field_label_font_size' => ['required', 'numeric'],'content.field_label_margin' => ['required', 'numeric'],diff --git a/resources/views/settings/label-edit.blade.php b/resources/views/settings/label-edit.blade.phpindex c09d2910aa..a3b10336fd 100644--- a/resources/views/settings/label-edit.blade.php+++ b/resources/views/settings/label-edit.blade.php@@ -212,20 +212,32 @@@stop@push('js')<script>- $(document).on('change', '.align-sync', function () {- const key = $(this).data('key');- const value = $(this).val();+ $(document).on(+ 'change',+ 'select[name="content[logo_h_align]"], select[name="content[barcode2D_h_align]"]',+ function () {+ const value = $(this).val();- if (key === 'logo_h_align') {- $('select[name="content[barcode2D_h_align]"]')- .val(value === 'L' ? 'R' : 'L');- }+ if (!['L', 'R'].includes(value)) {+ return;+ }++ const opposite = value === 'L' ? 'R' : 'L';- if (key === 'barcode2D_h_align') {- $('select[name="content[logo_h_align]"]')- .val(value === 'L' ? 'R' : 'L');+ const isLogo = this.name === 'content[logo_h_align]';++ const $other = isLogo+ ? $('select[name="content[barcode2D_h_align]"]')+ : $('select[name="content[logo_h_align]"]');++ if ($other.val() === value) {+ $other.val(opposite).trigger('change.select2');++ // Refresh the preview after both alignments are updated.+ this.form.dispatchEvent(new Event('change'));+ }}- });+ );function syncContentSupportGroups() {$('.label-editor-group[data-support-toggle]').each(function () {