Skip to content

A free open source IT asset/license management system

fix width and height not saving for tapes

Godfrey Meb4372fdb715
diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.php
index 0df6979045..739aa65fc2 100755
--- a/app/Http/Controllers/LabelsController.php
+++ b/app/Http/Controllers/LabelsController.php
@@ -173,15 +173,26 @@ class LabelsController extends Controller
})->toArray();
};
- $baseLabel = CustomUserLabel::makeBaseLabel($label->base_label);
+ if ($isTape && $label->base_label === 'StandardTape') {
+ $baseLabel = new PreviewTapeLabel;
+ } else {
+ $baseLabel = CustomUserLabel::makeBaseLabel(
+ $label->base_label
+ );
+ }
if (!$baseLabel) {
return redirect()->back()
- ->with('error', trans('admin/labels/labels.base_label_missing'));
+ ->with(
+ 'error',
+ trans('admin/labels/labels.base_label_missing')
+ );
}
$makePreviewLabel = function () use ($isTape) {
- return $isTape ? new PreviewTapeLabel : new PreviewSheetLabel;
+ return $isTape
+ ? new PreviewTapeLabel
+ : new PreviewSheetLabel;
};
$baseWorkingLabel = $makePreviewLabel();
@@ -330,6 +341,9 @@ class LabelsController extends Controller
'name' => $validated['name'],
...$finalConfig,
];
+ if ($type === 'tape') {
+ $configSnapshot['dimensions'] = $submittedConfig['dimensions'];
+ }
$overrides = CustomUserLabel::diffEditorConfig($finalConfig, $baseConfig);
diff --git a/app/Http/Transformers/LabelsTransformer.php b/app/Http/Transformers/LabelsTransformer.php
index 10efa266bd..ead00bc84e 100644
--- a/app/Http/Transformers/LabelsTransformer.php
+++ b/app/Http/Transformers/LabelsTransformer.php
@@ -80,6 +80,12 @@ class LabelsTransformer
protected function transformCustomLabel(CustomUserLabel $label): array
{
$snapshot = $label->config_snapshot ?? [];
+ $dimensionPath = $label->type === 'tape'
+ ? 'dimensions'
+ : 'label';
+
+ $width = (float)data_get($snapshot, "{$dimensionPath}.width", 0);
+ $height = (float)data_get($snapshot, "{$dimensionPath}.height", 0);
return [
'custom_label_id' => $label->id,
@@ -93,8 +99,8 @@ class LabelsTransformer
'unit' => 'mm',
- 'width' => number_format((float) data_get($snapshot, 'label.width', 0), 2),
- 'height' => number_format((float) data_get($snapshot, 'label.height', 0), 2),
+ 'width' => number_format($width, 2),
+ 'height' => number_format($height, 2),
'margin_top' => data_get($snapshot, 'label.margin_top'),
'margin_bottom' => data_get($snapshot, 'label.margin_bottom'),
@@ -109,8 +115,8 @@ class LabelsTransformer
'support_title' => data_get($snapshot, 'supports.title'),
'sheet_info' => [
- 'label_width' => data_get($snapshot, 'label.width'),
- 'label_height' => data_get($snapshot, 'label.height'),
+ 'label_width' => $width,
+ 'label_height' => $height,
'label_margin_top' => data_get($snapshot, 'label.margin_top'),
'label_margin_bottom' => data_get($snapshot, 'label.margin_bottom'),
'label_margin_left' => data_get($snapshot, 'label.margin_left'),